- Home
- Forum
- JavaScript - EJ 2
- Paste Event problem.
Paste Event problem.
Hi,
I'm using iframe and also having trouble with PasteCleanup. It doesn't seem to simply clean up within the 'paste' area; I have a feeling it's cleaning up the entire document.
When I paste a line of formatted text,
The DOM outside the pasted content becomes corrupted. Many DOM elements are removed, and nodes marked with contenteditable="false" also have their structure altered after the paste. Additionally, the undo functionality no longer works. In some cases, after each paste, the cursor automatically jumps back to the top of the page.
Let's review some of these functions:
updateValue: function() {
e.parent.updateValue()
},
processHtmlPaste
handleHtmlValuePaste
These are the functions that change the content in front:
e.cursorPos = function(...) {
e.classList.add("lastNode"),
r.innerHTML = jy(r.innerHTML, this.isBlazor),
...
}
The cursor position is lost after pasting:
e.pasteInsertHTML= function(...) {
this.positionCursorAfterPaste(...);
..
}
Additionally, I've noticed an issue with executeCommand("insertHTML", ...). It can cause the undo functionality to stop working and may also break the layout. I suspect it triggers a DOM cleanup process.
Thanks you.
Jamin.
contenteditable="false" also have their structure altered after the paste. Additionally, the undo functionality no longer works. In some cases, after each paste, the cursor automatically jumps back to the top of the page."- The exact steps to reproduce the issue.
- The complete Rich Text Editor code snippet/configuration being used.
- A video recording or screenshots demonstrating the issue.
- The current package version of the Rich Text Editor in your application.
executeCommand method in the Rich Text Editor, the changes made through the API are not automatically added to the undo/redo stack. To enable undo and redo functionality for content modified using executeCommand, you need to explicitly call the saveData method and enableUndo function after the command execution. function onclick = (): void => { editor.executeCommand('insertHTML', 'inserted an html'); editor.formatter.saveData(); editor.formatter.enableUndo(editor); }; |