Add glossary hover presentation
This commit is contained in:
@@ -58,6 +58,7 @@ class SocketClientModule extends BaseModule {
|
||||
'normalizeHistoryBlock',
|
||||
'dispatchTurnTags',
|
||||
'isTimedCueTag',
|
||||
'isRenderMetadataTag',
|
||||
'cueMarkersFromTags',
|
||||
'dispatchChoices',
|
||||
'dispatchInputMode',
|
||||
@@ -360,12 +361,22 @@ class SocketClientModule extends BaseModule {
|
||||
: { role: pendingParagraph || null, cueTags: [] };
|
||||
const tags = Array.isArray(paragraph?.tags) ? paragraph.tags : [];
|
||||
const { blocks, paragraphRole } = this.blocksFromTags(tags, turnId);
|
||||
const text = String(paragraph?.text || '').trim();
|
||||
const rawText = String(paragraph?.text || '').trim();
|
||||
const markupParser = this.getModule('markup-parser');
|
||||
const parsedParagraph = rawText && markupParser && typeof markupParser.parseParagraph === 'function'
|
||||
? markupParser.parseParagraph(rawText)
|
||||
: null;
|
||||
const text = String(parsedParagraph?.text || rawText).trim();
|
||||
const layoutText = parsedParagraph?.layoutText || paragraph.layoutText || text;
|
||||
const glossaryEntries = markupParser && typeof markupParser.extractGlossaryTags === 'function'
|
||||
? markupParser.extractGlossaryTags(tags)
|
||||
: [];
|
||||
const cueTags = tags.filter(tag => this.isTimedCueTag(tag));
|
||||
const deferredTags = tags.filter(tag => this.isDeferredPopupTag(tag));
|
||||
const immediateTags = tags.filter(tag =>
|
||||
!this.isStructuralTag(tag) &&
|
||||
!this.isTimedCueTag(tag) &&
|
||||
!this.isRenderMetadataTag(tag) &&
|
||||
!this.isDeferredPopupTag(tag)
|
||||
);
|
||||
|
||||
@@ -390,6 +401,7 @@ class SocketClientModule extends BaseModule {
|
||||
const role = pending.role || paragraphRole || 'body';
|
||||
const cueMarkers = [
|
||||
...(Array.isArray(paragraph.cueMarkers) ? paragraph.cueMarkers : []),
|
||||
...(Array.isArray(parsedParagraph?.cueMarkers) ? parsedParagraph.cueMarkers : []),
|
||||
...this.cueMarkersFromTags([
|
||||
...(Array.isArray(pending.cueTags) ? pending.cueTags : []),
|
||||
...cueTags
|
||||
@@ -398,7 +410,8 @@ class SocketClientModule extends BaseModule {
|
||||
blocks.push({
|
||||
type: 'paragraph',
|
||||
text,
|
||||
layoutText: paragraph.layoutText || text,
|
||||
layoutText,
|
||||
glossaryEntries,
|
||||
cueMarkers,
|
||||
deferredTags: [
|
||||
...(Array.isArray(pending.deferredTags) ? pending.deferredTags : []),
|
||||
@@ -467,6 +480,11 @@ class SocketClientModule extends BaseModule {
|
||||
return ['sfx', 'sound', 'audio'].includes(key);
|
||||
}
|
||||
|
||||
isRenderMetadataTag(tag) {
|
||||
const key = String(tag?.key || '').toLowerCase();
|
||||
return ['gloss'].includes(key);
|
||||
}
|
||||
|
||||
isDeferredPopupTag(tag) {
|
||||
const key = String(tag?.key || '').toLowerCase();
|
||||
return ['alert', 'achievement', 'score', 'error'].includes(key);
|
||||
|
||||
Reference in New Issue
Block a user