-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple editable roots #2247
Comments
PoCI have added a One thing to consider is if it should be separate editor type or if we could just extend decoupled one. The changes in a away how Focus indicationWhen any editable is focused all editables gets blue focus indicator: this is caused by the fact that focus is listened on document and the view element when receives focus from the document doesn't check (or rather have no way to check) which editable was focused. It looks it shouldn't be too much work to fix this. Make some editables readonlyJust to mention for future reference, ATM, there is no reliable mechanism to make only some of the editables readonly, so one can make whole editor readonly (all editables). To sum, everything seems to be working quite nice and haven't noticed any issues which would make editor unusable or unstable. And the changes required to provide such editor are just changes in the flow how editor is initialized so no Anyway, if possible I would like to ask @Mgsy to also take a look and do some quick testing (no more than 30 mins) to see if something obvious is not failing and I have missed it somehow (to test, switch to |
That's great news! :)
I think that since multiroot editor is be able to handle all cases of the decoupled editor there is no point to keep both. It should be enough to make this editor accepts single or multiple roots in the constructor/configuration and it will be able to handle all cases.
This is not that bad. At the end of the day, it is a single editor, so it makes some sense that all its editables show that the editor is focused.
I think this is more like a feature request than a bug. |
I've tested this editor and haven't spotted any unexpected behaviour 👍 |
Makes sense to improve the decoupled editor, especially that from the perspective of API the changes are minimal. However, I have one doubt about API consistency. We have agreed that What about Always return an object
The issue here is that this is not backward compatible (breaking change) and also Return type depends on how editor was created
Backward compatible and consistency across editor types is preserved. However, Return type depends on number of roots
Very similar issues to previous one - backward compatible and consistent across editor types. However, TBH, I'm the fan of consistent results so the 1st seems reasonable to me (consistency of the return types). However, it introduces backward incompatibility and incompatibility across editor types which makes me 😢 WDYT? Btw. The very similar issue is with |
I think that getData(); // return data of the main root, same as `getData( { rootName: 'main' } );`
getData( { rootName: 'root2' } ); // return data of the "root2" root We may also introduce a method to get all root names, but I think it is not needed. It is the developer who set these roots, so he should know names, and he can always call
WDYT? |
@pjasiun I was thinking about that too, but what if there is no I would go with a method signature like Now if we go with all 3
it's again inconsistent with
or if we need to have |
If there is no
I was thinking about it, but we may have more option for
I believe that |
As I'm preparing the PR with the above changes, here is a quick summary of what has been changed: 1. I have decided to move creating a docs sample to a separate branch/PR ( 2. As we concluded in the discussion above about
3. Since 4. There is a change in how 5. One breaking change was introduced. Before, one could use |
More I think about it, more I realise we could skip:
This is an edge case that one will try to overwrite a single root which is not a main root. And one can always do:
|
One problem that I see with this is compatibility with #401. We'll have |
It the other hand, it would be nice to make it symmetrical with
Same for |
We have decided to start with docs sample for multiple root editor - see #1447 and if there will be a high demand for multiple root editor it can be turned into separate editor build/type. |
Would it be possible also to allow dynamic loading of roots, if we don't know the number of roots in advance? The MultirootEditor requires that we know the number of elements in advance as we're supplying it as an object to Editor.create() with known keys. I was looking at the MultirootEditor source code, but I only manage to dynamically load the root (using |
After separating some functionality in the multi root example, I was able to create and destroy roots dynamically. One problem over here (and when I have a lot of spare time I will create an actual bug report): the current selection / focus is lost as soon as a new root is added and Proposal: don't remove the selection during |
I'm a little confused, this ticket is still open, but the documentation seems to imply that this feature is fully supported already. What's the current status? On a side note, considering the various separated source files in the documentation, it would be great to be able to download a working demo in a zip file. Now I have to manually set up a project, create several demo files and copy paste everything. |
I am also trying to create and destroy roots dynamically, could you please share what you had to change to do this? Thanks:) |
Hi! The multi-root editor is officially supported in CKEditor 5, it seems that this issue has slipped our attention, that's why it's still open. Thanks for bringing it to our attention! For everyone interested in using the multi-root editor, see the guide.
Adding and removing roots dynamically is not supported yet. You can find more information about it here. |
Hi, I know this is an old post but, I think this post here solved your setData issues (#8915 (comment)) |
CKEditor 5 engine support multiple roots in the editor.
The user should be able in the constructor of the decoupled editor to use an object where keys are editable names and walues are (
HTMLElements
or string data). AlsogetData( rootName )
andsetData( rootName )
should be provided there.Then, in the documentation, we should add a sample in https://ckeditor.com/docs/ckeditor5/latest/examples/builds/document-editor.html (in the framework section?) with the editor with multiple (two?) editable areas.
Also, decoupled editor samples need to be updated.
The text was updated successfully, but these errors were encountered: