What is @ckeditor/ckeditor5-editor-multi-root?
@ckeditor/ckeditor5-editor-multi-root is a package that provides a multi-root editor implementation for CKEditor 5. This allows you to create an editor instance that can manage multiple editable areas (roots) within a single editor instance. This is particularly useful for complex applications where you need to manage multiple content areas simultaneously.
What are @ckeditor/ckeditor5-editor-multi-root's main functionalities?
Creating a Multi-Root Editor
This code demonstrates how to create a multi-root editor instance with two editable areas: 'header' and 'content'. The editor is initialized with these two roots, allowing you to manage both areas within a single editor instance.
const MultiRootEditor = require('@ckeditor/ckeditor5-editor-multi-root/src/multirooteditor');
const ClassicEditor = require('@ckeditor/ckeditor5-editor-classic/src/classiceditor');
MultiRootEditor.create({
header: document.querySelector('#header'),
content: document.querySelector('#content')
}).then(editor => {
console.log('Editor was initialized', editor);
}).catch(error => {
console.error(error.stack);
});
Adding Plugins to Multi-Root Editor
This code sample shows how to add plugins to the multi-root editor. In this example, the Essentials, Paragraph, and Bold plugins are added, and the toolbar is configured to include the 'bold' button.
const MultiRootEditor = require('@ckeditor/ckeditor5-editor-multi-root/src/multirooteditor');
const Essentials = require('@ckeditor/ckeditor5-essentials/src/essentials');
const Paragraph = require('@ckeditor/ckeditor5-paragraph/src/paragraph');
const Bold = require('@ckeditor/ckeditor5-basic-styles/src/bold');
MultiRootEditor.create({
header: document.querySelector('#header'),
content: document.querySelector('#content')
}, {
plugins: [ Essentials, Paragraph, Bold ],
toolbar: [ 'bold' ]
}).then(editor => {
console.log('Editor with plugins was initialized', editor);
}).catch(error => {
console.error(error.stack);
});
Accessing and Modifying Editor Data
This code demonstrates how to access and modify the data in different roots of the multi-root editor. You can get the data from a specific root and set new data for a specific root.
const MultiRootEditor = require('@ckeditor/ckeditor5-editor-multi-root/src/multirooteditor');
MultiRootEditor.create({
header: document.querySelector('#header'),
content: document.querySelector('#content')
}).then(editor => {
// Accessing data
const headerData = editor.getData({ rootName: 'header' });
const contentData = editor.getData({ rootName: 'content' });
console.log('Header Data:', headerData);
console.log('Content Data:', contentData);
// Modifying data
editor.setData('<p>New header content</p>', { rootName: 'header' });
editor.setData('<p>New content area</p>', { rootName: 'content' });
}).catch(error => {
console.error(error.stack);
});
Other packages similar to @ckeditor/ckeditor5-editor-multi-root
quill
Quill is a modern WYSIWYG editor built for compatibility and extensibility. While it does not natively support multi-root editing, it offers a highly customizable and extensible architecture that can be adapted for complex use cases. Compared to @ckeditor/ckeditor5-editor-multi-root, Quill is more lightweight but may require additional customization for multi-root functionality.
tinymce
TinyMCE is a popular rich text editor that provides a wide range of features and plugins. It supports multiple instances of editors on the same page but does not natively support a single editor instance managing multiple roots. TinyMCE is highly configurable and offers extensive documentation and community support, making it a robust alternative to @ckeditor/ckeditor5-editor-multi-root for many use cases.
draft-js
Draft.js is a JavaScript rich text editor framework, built for React. It provides a lot of flexibility and control over the editor's behavior and appearance. While it does not offer out-of-the-box multi-root editing, its modular architecture allows developers to implement custom solutions for managing multiple content areas. Draft.js is more of a framework than a ready-to-use editor, offering more control at the cost of requiring more development effort.
44.1.0 (December 16, 2024)
We are pleased to announce the latest CKEditor 5 release, focusing on performance enhancements and key bug fixes to improve your editing and collaboration experience.
Release Highlights
⚡ Performance enhancements: Part 3
This release introduces another set of performance related improvements, focused on faster editor initialization for huge documents. The initialization time was lowered by further 15% to 45%, depending on the tested sample.
The combined improvements introduced in recent releases amount to around 65%-80% lower loading time in total, which means the editor will load 3-5x faster. As the gain is not linear, bigger documents see even better improvement (more than 10x faster).
Moreover, all these improvements positively impact document save time (editor.getData()
), which should help with autosave issues, among others.
We still actively work in this area, so you may expect even more editor load and save efficiency improvements in the upcoming releases.
🔨 Bug Fixes and improvements
- Comments enhancements:
- Data export options: We introduced the
showCommentHighlights
option in editor.getData()
, that changes the comment marker conversion, allowing for styling comments in the output. Perfect for showing what was commented in Export to PDF, for example. - Inline mode improvements: We addressed a problem where comment annotations in inline mode did not close properly when clicking elsewhere in the content.
- Thread management: We resolved an issue where creating a new thread was not interrupted when the corresponding marker was removed from the content, ensuring better stability during collaborative editing.
- Revision History update:
- Restore functionality: We disabled the ability to restore the current (edited, not saved) revision, as it represents current content, so there is nothing to restore. At the same time, using it led to some non-obvious behaviors.
- Image handling: We resolved an issue where images in the uploading state could be deleted when dragged and dropped within the editor. Keep dragging, even when it is not there 🙈.
🎄 Happy holidays!
As the holiday season approaches, we extend our warmest wishes to our community and users. Thank you for your continued support, and we look forward to bringing you further enhancements and exciting features in the coming year.