BoldDesk®Customer service software with ticketing, live chat & omnichannel support, starting at $99/mo for unlimited agents. Try for free!
Hello,
On the 27.1.58 version of the DocumentEditor, we have discovered a scenario where the editor will crash when manipulating the bookmarks.
I have created a demo that reproduces this behavior:
https://stackblitz.com/edit/7xxc69-r5ecqe?file=index.html
This demo does the following:
While this may seem a very specific scenario, it has affected several of our users, so any help would be largely appreciated. Please let me know if there is anything else I can do to help with this issue.
Best regards,
Daniel Souz
Daniel Souza,
We can reproduce the reported issue. Currently, we are validating the issue and get back to you with more details by November 22, 2024.
Regards,
Aravind D
We are glad to announce that our patch release (v28.1.35) has been rolled out successfully. In this release, we have added the fix for the reported issue "Bookmark manipulation causes editor crash".
If you’re experiencing editor crashes due to bookmark manipulation in JavaScript, it likely stems from improper handling of DOM elements or an issue with how the editor processes its internal state when bookmarks are altered. Here's a breakdown of how to address this issue:
Verify Bookmark Creation and Removal:
Ensure bookmarks are created and removed using the editor's API. For example, if you are using a rich text editor like TinyMCE or Quill, follow their specific bookmark handling methods to avoid tampering directly with the DOM.
// Example: Removing a bookmark safely
const bookmark = editor.selection.getBookmark();
editor.selection.moveToBookmark(bookmark);
editor.execCommand('RemoveFormat'); // Clean up bookmark formatting
Monitor DOM Changes:
If bookmarks are tied to specific nodes, use MutationObserver
to monitor DOM changes and handle unexpected deletions or modifications.
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.removedNodes) {
// Check if a bookmark node was removed
}
});
});
observer.observe(document.body, { childList: true, subtree: true });
Use Proper Editor APIs:
Avoid direct DOM manipulation for bookmarks. Use APIs provided by your editor to ensure its internal state remains consistent.
Error Handling:
Add error handling to gracefully manage unexpected crashes during bookmark manipulation.
try {
// Bookmark manipulation code
} catch (error) {
console.error("An error occurred during bookmark manipulation:", error);
}
Update or Patch the Editor:
If the issue is caused by a bug in the editor itself, check the documentation or community forums for updates or patches that address bookmark-related crashes.
By following these practices, you can resolve or mitigate the crashes caused by bookmark manipulation and ensure a more stable editor experience.
Hi Adrian Scott,
We have included the fix for the reported issue in the latest patch release (v28.1.35). Please upgrade to the latest version to resolve this issue.
https://www.npmjs.com/package/@syncfusion/ej2-documenteditor
Please let us know if you need any further assistance.
Regards,
Mohammed Affan C