diff --git a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx index b6179a4a0..413dcb6e2 100644 --- a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx @@ -16,6 +16,7 @@ export default function IMSSTextbox(props: ITextboxProps) { isFirefox: boolean, fontSize, miniAvatar, + isHasName, showName, font, textDuration, @@ -39,8 +40,68 @@ export default function IMSSTextbox(props: ITextboxProps) { WebGAL.events.textSettle.off(settleText); }; }, []); - let allTextIndex = 0; + const nameElementList = showName.map((line, index) => { + const textline = line.map((en, index) => { + const e = en.reactNode; + let style = ''; + let tips = ''; + let style_alltext = ''; + let isEnhanced = false; + if (en.enhancedValue) { + isEnhanced = true; + const data = en.enhancedValue; + for (const dataElem of data) { + const { key, value } = dataElem; + switch (key) { + case 'style': + style = value; + break; + case 'tips': + tips = value; + break; + case 'style-alltext': + style_alltext = value; + break; + } + } + } + const styleClassName = ' ' + css(style, { label: 'showname' }); + const styleAllText = ' ' + css(style_alltext, { label: 'showname' }); + if (isEnhanced) { + return ( + + + {e} + {e} + {isUseStroke && {e}} + + + ); + } + return ( + + + {e} + {e} + {isUseStroke && {e}} + + + ); + }); + return ( +
+ {textline} +
+ ); + }); const textElementList = textArray.map((line, index) => { const textLine = line.map((en, index) => { const e = en.reactNode; @@ -49,7 +110,6 @@ export default function IMSSTextbox(props: ITextboxProps) { let style_alltext = ''; if (en.enhancedValue) { const data = en.enhancedValue; - console.log(data); for (const dataElem of data) { const { key, value } = dataElem; switch (key) { @@ -159,7 +219,7 @@ export default function IMSSTextbox(props: ITextboxProps) { miniAvatar )} - {showName !== '' && ( + {isHasName && ( <>
-
- {showName.split('').map((e, i) => { - return ( - - - {e} - {e} - {isUseStroke && {e}} - - - ); - })} -
+ {nameElementList}
- {showName.split('').map((e, i) => { - return ( - - - {e} - {e} - {isUseStroke && {e}} - - - ); - })} + {nameElementList}
)} diff --git a/packages/webgal/src/Stage/TextBox/TextBox.tsx b/packages/webgal/src/Stage/TextBox/TextBox.tsx index fb349516d..7e6edcb88 100644 --- a/packages/webgal/src/Stage/TextBox/TextBox.tsx +++ b/packages/webgal/src/Stage/TextBox/TextBox.tsx @@ -67,7 +67,8 @@ export const TextBox = () => { .default(() => 2); // 拆字 const textArray = compileSentence(stageState.showText, lineLimit); - const showName = stageState.showName; + const isHasName = stageState.showName !== ''; + const showName = compileSentence(stageState.showName, lineLimit); const currentConcatDialogPrev = stageState.currentConcatDialogPrev; const currentDialogKey = stageState.currentDialogKey; const miniAvatar = stageState.miniAvatar; @@ -79,6 +80,7 @@ export const TextBox = () => { isText={isText} textDelay={textDelay} showName={showName} + isHasName={isHasName} currentConcatDialogPrev={currentConcatDialogPrev} fontSize={size} currentDialogKey={currentDialogKey} @@ -135,7 +137,7 @@ export function compileSentence(sentence: string, lineLimit: number, ignoreLineL * @param sentence */ export function splitChars(sentence: string) { - if (!sentence) return []; + if (!sentence) return ['']; const words: string[] = []; let word = ''; let cjkFlag = isCJK(sentence[0]); @@ -248,6 +250,9 @@ function parseString(input: string): Segment[] { } } + // 我也不知道为什么,不加这个就会导致在 Enhanced Value 处于行首时故障 + // 你可以认为这个代码不明所以,但是不要删除 + result.unshift({ type: SegmentType.String, value: '' }); return result; } @@ -264,7 +269,7 @@ function parseEnhancedString(enhanced: string): KeyValuePair[] { while ((match = regex.exec(enhanced)) !== null) { result.push({ key: match[1], - value: match[2].trim(), + value: match[2].replace(/~/g, ':').trim(), }); } diff --git a/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx b/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx index 33ca4f88b..465b918bb 100644 --- a/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx @@ -15,6 +15,7 @@ export default function StandardTextbox(props: ITextboxProps) { isFirefox, fontSize, miniAvatar, + isHasName, showName, font, textDuration, @@ -38,7 +39,25 @@ export default function StandardTextbox(props: ITextboxProps) { WebGAL.events.textSettle.off(settleText); }; }, []); - + const nameElementList = showName.map((e,index)=>{ + let prevLength = currentConcatDialogPrev.length; + if (index < prevLength) { + return ( + + {e} + {e} + {isUseStroke && {e}} + + ); + } + return ( + + {e} + {e} + {isUseStroke && {e}} + + ); + }); const textElementList = textArray.map((e, index) => { // if (e === '
') { // return
; @@ -83,7 +102,6 @@ export default function StandardTextbox(props: ITextboxProps) { }); const padding = isHasMiniAvatar ? 500 : undefined; - const isHasName = showName !== ''; let paddingTop = isHasName ? undefined : 15; if (textSizeState === textSize.small && !isHasName) { paddingTop = 35; @@ -114,19 +132,9 @@ export default function StandardTextbox(props: ITextboxProps) {
{miniAvatar !== '' && miniAvatar}
- {showName !== '' && ( -
- {showName.split('').map((e, i) => { - return ( - - - {e} - {e} - {isUseStroke && {e}} - - - ); - })} + {isHasName && ( +
+ {nameElementList}
)}
{
); }); + const showNameArray = compileSentence(backlogItem.currentStageState.showName, 3, true); + const showNameArray2 = showNameArray.map((line)=>{ + return line.map((c) => { + return c.reactNode; + }); + }); + const showNameArrayReduced = mergeStringsAndKeepObjects(showNameArray2); + const nameElementList = showNameArrayReduced.map((line,index)=>{ + return ( +
+ {line.map((e, index) => { + if (e === '
') { + return
; + } else { + return e; + } + })} +
+ ); + }); const singleBacklogView = (
{
) : null}
-
{backlogItem.currentStageState.showName}
+
{nameElementList}
{showTextElementList} diff --git a/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx b/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx index d6d9e0459..4e8bbc4d3 100644 --- a/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx +++ b/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx @@ -23,6 +23,9 @@ export const TextPreview = (props: any) => { const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent); const previewText = t('textPreview.text'); const previewTextArray = compileSentence(previewText, 3); + const showNameText = t('textPreview.title'); + const showNameArray = compileSentence(showNameText, 3); + const isHasName = showNameText !== ''; const Textbox = IMSSTextbox; @@ -30,7 +33,8 @@ export const TextPreview = (props: any) => { textArray: previewTextArray, isText: true, textDelay: textDelay, - showName: t('textPreview.title'), + isHasName: isHasName, + showName: showNameArray, currentConcatDialogPrev: '', fontSize: size, currentDialogKey: '',