Merge pull request #7554 from penpot/azazeln28-fix-text-editor-v2-issues

🐛 Fix text editor v2 render integration issues
This commit is contained in:
Elena Torró 2025-10-23 15:55:54 +02:00 committed by GitHub
commit 89763d7c5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 1 deletions

View File

@ -1047,6 +1047,17 @@ export class SelectionController extends EventTarget {
return isParagraphEnd(this.focusNode, this.focusOffset);
}
#getFragmentInlineTextNode(fragment) {
if (isInline(fragment.firstElementChild.lastChild)) {
return fragment.firstElementChild.firstElementChild.lastChild;
}
return fragment.firstElementChild.lastChild;
}
#getFragmentParagraphTextNode(fragment) {
return fragment.lastElementChild.lastElementChild.lastChild;
}
/**
* Insert pasted fragment.
*
@ -1071,7 +1082,7 @@ export class SelectionController extends EventTarget {
}
return this.collapse(collapseNode, collapseNode.nodeValue.length);
}
const collapseNode = fragment.lastElementChild.lastElementChild.firstChild;
const collapseNode = this.#getFragmentParagraphTextNode(fragment);
if (this.isParagraphStart) {
const a = fragment.lastElementChild;
const b = this.focusParagraph;
@ -1090,6 +1101,9 @@ export class SelectionController extends EventTarget {
);
this.focusParagraph.after(fragment, newParagraph);
}
if (isLineBreak(collapseNode)) {
return this.collapse(collapseNode, 0);
}
return this.collapse(collapseNode, collapseNode.nodeValue.length);
}