-
-
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
How to create editor without replacing an existing element #2882
Comments
RFC for how to shape the API of the base class(es) and the concrete editor classes so they are clean and easily usable in as many scenarios as possible. |
It would be great to have It is as well ok to have |
OK, so let's do it. I've just had to change a couple of tests all across our code base because |
It is closed by ckeditor/ckeditor5-core#116. Now, base We can still consider changes in |
I'm unsure about closing this ticket. It's not only about the I'll reopen this ticket because the core of this issue is still pending and I'd like to track it in one place. But it's not iteration 14 anymore. |
Unfortunately, we need to do bigger changes here (see the PRs linked above to understand "bigger than what"). Current state
What the PRs changeIf, suddenly, the The conclusion is simple – we cannot use one property (
SolutionsNow, the problem is that we called the first one
But this means a breaking change. So, the alternative is this:
I strongly prefer the first option because it seems cleaner. WDYT? |
Well the tl;dr: first option 👍. |
Option number 1. Seems more reasonable. |
I'm for option 1. I remember I had a problem to understand what |
Perfect, thanks. That's the feeling I had too but it's hard to break legacy :) |
I’m very interested in this because I understand it to be important for the React bindings. I’m curious; what is the current status? I see a bunch of in-flight PRs in this repo and the build repos that have been around for 2-4 weeks. It seems close yes? |
Hi! The first attempt at making this change was pretty close to be merged 2 weeks ago, but then I realised that the resulting API will be confusing. We decided to make broader changes (rename BTW, we also work on https://github.com/ckeditor/ckeditor5-react and will release it in ~3 weeks (once we'll unblock it by releasing the changes from this ticket). |
Feature: Introduced the `#element` property to the `EditorWithUI` interface. The `#element` property from the `ElementApi` interface has been renamed to `#sourceElement`. Most editors implement both interfaces, which ultimately means that the old `editor.element` property is now called `editor.sourceElement` and there's a new `editor.element` property with a new meaning. Closes #64. BREAKING CHANGE: The `editor.element` property was renamed to `editor.sourceElement`. BREAKING CHANGE: The `editor.updateElement()` method was renamed to `editor.updateSourceElement()`.
Feature: Editor can now be created with initial data passed to the `create()` method. Closes #72. BREAKING CHANGE: The `ClassicEditor#element` property was renamed to `ClassicEditor#sourceElement`. See ckeditor/ckeditor5-core#64.
Feature: Editor can now be created with initial data passed to the constructor. Closes #37. BREAKING CHANGE: The `InlineEditor#element` property was renamed to `InlineEditor#sourceElement`. See ckeditor/ckeditor5-core#64.
Other: Aligned `DecoupledEditor` to changes in the `EditorWithUI` and `ElementApi` interfaces. BREAKING CHANGE: `DecoupledEditor#element` was renamed to `DecoupledEditor#sourceElement`. See ckeditor/ckeditor5-core#64.
@oskarwrobel asked me today how to create the classic editor with data which he stores in JS. Well, turns out that you need to create a fork of the
ClassicEditor
.We've never thought about this enough I think. The assumption that the editor is replacing an existing element can't be generalised. It may be true in sth like 75%, making the editor hard to use in 25% cases.
We need to design the creators in a way that you'll be able to either replace an existing element or create the editor with your own data.
First of all, this means that the concept of "editor element" needs to be revisited. An editor may not have an element if it didn't replace any. So the
StandardEditor#element
property andupdateEditorElement/loadDataFromEditorElement()
methods will be optional and perhaps should be removed totally.Second, we need to define a more general
create()
method. The first idea which came to my mind was that create() could have two modes – if called with an element it would replace it, if called with a string, it would create an editor with that data.HOWEVER, I'm a bit worried that we cannot allow creating an editor detached from the DOM. I'm not entirely sure that it's going to work correctly. From my past experience, it may through weird errors.
The text was updated successfully, but these errors were encountered: