Skip to content
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

Introduce config.initialData #1619

Closed
pjasiun opened this issue Mar 12, 2019 · 1 comment
Closed

Introduce config.initialData #1619

pjasiun opened this issue Mar 12, 2019 · 1 comment
Assignees
Labels
type:improvement This issue reports a possible enhancement of an existing feature.
Milestone

Comments

@pjasiun
Copy link

pjasiun commented Mar 12, 2019

Right now, in all editors, you can use element or data as the first parameter. The problem is, that, in many cases, you want to use the element for your existing DOM, but use data from the database. The problem is even bigger when you use for instance React integration where we have no good way to inject HTML data to DOM.

Because if it many integrations uses:

InlineEditor.create( element, {
    // ...
} ).then( editor => {
    editor.setData( '<p>foo</p>' );
} );

but this is wrong, because:

  1. it will create an undo step during the initialization,
  2. it will break the collaboration if the collaboration plugin is used because you need to have initial data available in the collaborative editor during the editor initialization (this is the moment when the editor decides if local or server data should be used).

This is why we decided that initialData configuration should be introduced.

InlineEditor.create( element, {
    initialData: '<p>foo</p>'
} );

initialData will be used instead of elements HTML.

InlineEditor.create( '<p>bar</p>', {
    initialData: '<p>foo</p>'
} );

Exception will be thrown, such configuration does not make sense.

In the future we plan to move also source element to the configuration:

InlineEditor.create( {
    sourceElement: element,
    initialData: '<p>foo</p>'
} );

But since this is a bigger (and breaking) change, we agreed to pospond it and do it later.

@pjasiun pjasiun added this to the iteration 23 milestone Mar 12, 2019
@pjasiun pjasiun added the type:improvement This issue reports a possible enhancement of an existing feature. label Mar 12, 2019
@pjasiun
Copy link
Author

pjasiun commented Mar 18, 2019

Make sure to carefully update documentation of all editor.create methods to keep the documentation consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

No branches or pull requests

2 participants