diff --git a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx index f603f2792..b7648309a 100644 --- a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx @@ -1,5 +1,5 @@ import styles from './textbox.module.scss'; -import { useEffect } from 'react'; +import { useEffect, useMemo } from 'react'; import { WebGAL } from '@/Core/WebGAL'; import { ITextboxProps } from './types'; import useApplyStyle from '@/hooks/useApplyStyle'; @@ -8,6 +8,11 @@ import { textSize } from '@/store/userDataInterface'; import { useSelector } from 'react-redux'; import { RootState } from '@/store/store'; +const hasEmoji = (text: any): boolean => { + if (typeof text !== 'string') return false; + return /\p{Emoji}/u.test(text); +}; + export default function IMSSTextbox(props: ITextboxProps) { const { textArray, @@ -72,24 +77,18 @@ export default function IMSSTextbox(props: ITextboxProps) { } const styleClassName = ' ' + css(style, { label: 'showname' }); const styleAllText = ' ' + css(style_alltext, { label: 'showname' }); - if (isEnhanced) { - return ( - + const skipEffect = hasEmoji(e); + return ( + + {skipEffect ? ( + {e} + ) : ( {e} {e} {isUseStroke && {e}} - - ); - } - return ( - - - {e} - {e} - {isUseStroke && {e}} - + )} ); }); @@ -140,36 +139,44 @@ export default function IMSSTextbox(props: ITextboxProps) { } const styleClassName = ' ' + css(style); const styleAllText = ' ' + css(style_alltext); + const skipEffect = hasEmoji(e); + if (allTextIndex < prevLength) { return ( - - {e} - {e} - {isUseStroke && {e}} - + {skipEffect ? ( + {e} + ) : ( + + {e} + {e} + {isUseStroke && {e}} + + )} ); } return ( - - {e} - {e} - {isUseStroke && {e}} - + {skipEffect ? ( + {e} + ) : ( + + {e} + {e} + {isUseStroke && {e}} + + )} ); });