Ckeditor5: CKEditor does not update replaced element (e.g. textarea) automatically

Created on 6 Sep 2017  Â·  14Comments  Â·  Source: ckeditor/ckeditor5

As in https://github.com/ckeditor/ckeditor5-build-classic/issues/21:

Not sure if it's a bug or by design. If by design then we need to document this.
I was expecting that if I instruct the classic editor to replace a textarea, it will do the magic like updating the "hidden" textarea in surrounding form with latest content automatically (on submit let's say). Unfortunately that does not happen.

To reproduce click here: https://jsfiddle.net/wutzo173/

I decided to hoist it to this repo to clarify first some general rules. Basically:

  1. when updates should happen automatically?

    possible answers:

    • before submit,
    • before editor is destroyed,
    • ...?
  2. if "before submit" is your answer, then how critical is this feature assuming that Editor#updateEditorElement() is already available (we may need a guide mentioning form integration)?

    possible answers:

    • before 1.0.0-alpha,
    • before 1.0.0,
    • one day.
  3. should this be a default feature of editors which replace textarea?

    possible answers:

    • yes, built into the editor class,
    • no, a plugin,
    • no, a plugin which will be included in builds like the classic one,
    • ...?
  4. anything more?


My initial answers are:

  1. Before submit and before editor is destroyed. Additionally, on demand, by an editor method (available already).
  2. Not for me to assess.
  3. I'd see it as a plugin. And by default in all builds which needs it.

LOL, I tried to make a nested list for 3 minutes and I failed. Markdown, I hate you!

core feature

Most helpful comment

Wouldn't this be too intensive, in term of processing? Remember that we need to build the HTML (or whichever target format) output of the editor when updating the textarea.

Yep, performance would suffer. Like GC kicking in every couple of seconds while you type – not really a thing you like. And you'd still need a listener for submit because you might type text, Tab,Enter to submit very quickly. We'd need a low timeout for the debouncer (and hence, affecting performance) or a listener for submit.

Besides, you may have a really long content, processing which might be noticeable.

Finally, this is just not a feature which should be on by default. Stuff like autosave should be opt in – so it should be a plugin.

All 14 comments

  1. Before submit and before editor is destroyed. Additionally, on demand, by an editor method (available already).
  2. Should be an easy one (copy from CK4) and updateEditorElement() is not a replacement for it. It is for now a missing feature. I would say that we should have it asap, but let's leave the last word to @wwalc.
  3. I think it is pretty safe to make it simple and have it inside the editor class.

I'd answer just the 2nd point:

before 1.0.0-alpha

Reasoning: the editor should be easy to use in the most basic scenarios. Even if with the new editor we have rights to do things that worked for years in some other way, we should not make developers life harder. Especially in case of simple enhancements like this one.

Should be an easy one (copy from CK4)

It's not a simple copy and paste because it's hard to figure out which tricks here are still necessary: https://github.com/ckeditor/ckeditor-dev/blob/master/core/editor.js#L759-L813

But if it turns out to be a short code after we get rid of tricks (which hopefully are unnecessary now), then I'm ok with adding it to the editor.

OK, so we go with this in 1.0.0-alpha. Ideally, loaded by the editor class by default (not necessarily implemented there). Thanks.

One more thing – do we also need to bring support for the <textarea required> attribute now?

It was a pretty tricky thing – see https://dev.ckeditor.com/ticket/8031#comment:13.

One more thing – do we also need to bring support for the