fix: text content with tab characters act different in view/edit (#8336)

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Clarence Chan
2024-08-09 20:20:36 +00:00
committed by GitHub
co-authored by dwelle
parent 7b2bee9746
commit f7b3befd0a
2 changed files with 12 additions and 2 deletions
+10 -1
View File
@@ -357,7 +357,16 @@ export const textWysiwyg = ({
};
editable.oninput = () => {
onChange(normalizeText(editable.value));
const normalized = normalizeText(editable.value);
if (editable.value !== normalized) {
const selectionStart = editable.selectionStart;
editable.value = normalized;
// put the cursor at some position close to where it was before
// normalization (otherwise it'll end up at the end of the text)
editable.selectionStart = selectionStart;
editable.selectionEnd = selectionStart;
}
onChange(editable.value);
};
}