diff --git a/src/core/render/components/textbox.tsx b/src/core/render/components/textbox.tsx index dfc421a..95d6596 100644 --- a/src/core/render/components/textbox.tsx +++ b/src/core/render/components/textbox.tsx @@ -130,7 +130,7 @@ const textContentOptions = { 'x', 'y' ], - emits: ['typeEnd'] + emits: ['typeEnd', 'typeStart'] } satisfies SetupComponentOptions; export const TextContent = defineComponent( @@ -168,7 +168,7 @@ export const TextContent = defineComponent( if (key in renderData && !isNil(value)) { if (key === 'width') { if (value && value <= 0) { - logger.warn(41); + logger.warn(41, String(props.width)); renderData.width = 200; } else { renderData.width = value; @@ -238,11 +238,12 @@ export const TextContent = defineComponent( const line = dirtyIndex[linePointer]; const data = renderable[line]; const pointer = char - data.from; - if (pointer >= data.to) { + if (char >= data.to) { data.pointer = data.text.length; linePointer++; } else { data.pointer = pointer; + break; } } if (linePointer >= dirtyIndex.length) { @@ -255,6 +256,7 @@ export const TextContent = defineComponent( onTick(tick); onMounted(() => { data.value = makeSplitData(); + lineData.value = splitLines(data.value); }); const renderContent = ( @@ -343,6 +345,7 @@ export const TextContent = defineComponent( * 从头开始渲染 */ const rawRender = (text: string, lines: number[]) => { + console.trace(); makeRenderable(text, lines, 0, 0); spriteElement.value?.update(); }; @@ -419,7 +422,6 @@ export const TextContent = defineComponent( rawRender(data.value.text, value); } }); - lineData.value = splitLines(data.value); return () => { return (