diff --git a/packages/editor/src/lib/app/shapeutils/shared/useEditableText.ts b/packages/editor/src/lib/app/shapeutils/shared/useEditableText.ts index 4c649137f..667e12b90 100644 --- a/packages/editor/src/lib/app/shapeutils/shared/useEditableText.ts +++ b/packages/editor/src/lib/app/shapeutils/shared/useEditableText.ts @@ -131,7 +131,20 @@ export function useEditableText) => { - const text = TextHelpers.normalizeText(e.currentTarget.value) + let text = TextHelpers.normalizeText(e.currentTarget.value) + + // ------- Bug fix ------------ + // Replace tabs with spaces when pasting + const untabbedText = text.replace(/\t/g, ' ') + if (untabbedText !== text) { + const selectionStart = e.currentTarget.selectionStart + e.currentTarget.value = untabbedText + e.currentTarget.selectionStart = selectionStart + (untabbedText.length - text.length) + e.currentTarget.selectionEnd = selectionStart + (untabbedText.length - text.length) + text = untabbedText + } + // ---------------------------- + app.updateShapes([{ id, type, props: { text } }]) }, [app, id, type]