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:
when updates should happen automatically?
possible answers:
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:
should this be a default feature of editors which replace textarea?
possible answers:
anything more?
My initial answers are:
LOL, I tried to make a nested list for 3 minutes and I failed. Markdown, I hate you!
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.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
That's a separate issue, so better to not mix it here.
Another question - do we want to override form.submit() method to update editor element? This does not fire submit event and should be handled separately (similar to what is done in CKE4). It's not a big deal but after f2f talk with @Reinmar we have doubts. If someone uses JavaScript API to submit the form it can manually call updateEditorElement(). On the other hand someone might just replace text areas with CKE5 in some existing system and it will work out of the box without additional changes to JS code.
I think that if editor replaced <textarea> it might have been wise to update <textarea> after each changesDone or - if that's too often - make a debounced event that does that.
do we want to override form.submit() method to update editor element?
Yes, I would say. Parts of the code that are related to form submit may not be aware at all about the existence of CKEditor. I would go with the CKE4 way on this.
I think that if editor replaced
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.
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.
Just got this crazy idea... is it possible for us to proxy textarea.value::get() so we produce the most up-to-date value "on demand". Questions:
Haha :D Crazy indeed. I'm curious if it would work. The property seems to be proxable:

(if it wasn't configurable you wouldn't be able to add a proxy which changes the return value – see https://twitter.com/wookiebpl/status/905135304616574976)
But will it affect the POST done by the browser? Peeerhaps.
Whether people want that? I think they would rather like a custom element which behaves properly. Whether they'd like us to modify native elements on the fly... I'm not sure. Besides, such a feature requires Proxy so it's not polyfiable. Therefore, I'd rather see this as an extension, not a core behaviour on which we heavily depend.
Although it is possible to override the value property with Object.defineProperty( textarea, 'value', { ... } ), it is not used to retrieve the post data. It seems that the inner HTML of the element is used by the browser instead. So, there is no way to make much magic here, unfortunately, but I've dreamed for a short while :)
Most helpful comment
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.