lib/ckeditor5/rails/assets/webcomponent.mjs in ckeditor5-1.1.1 vs lib/ckeditor5/rails/assets/webcomponent.mjs in ckeditor5-1.1.2
- old
+ new
@@ -49,16 +49,21 @@
instance = null;
/** @type {Record<string, HTMLElement>} Map of editable elements by name */
editables = {};
+ /** @type {String} Initial HTML passed to component */
+ #initialHTML = '';
+
/**
* Lifecycle callback when element is connected to DOM
* Initializes the editor when DOM is ready
* @protected
*/
connectedCallback() {
+ this.#initialHTML = this.innerHTML;
+
try {
execIfDOMReady(() => this.#reinitializeEditor());
} catch (error) {
console.error('Failed to initialize editor:', error);
this.dispatchEvent(new CustomEvent('editor-error', { detail: error }));
@@ -177,10 +182,10 @@
}
this.style.display = 'block';
if (!this.isMultiroot() && !this.isDecoupled()) {
- this.innerHTML = `<${this.#editorElementTag}></${this.#editorElementTag}>`;
+ this.innerHTML = `<${this.#editorElementTag}>${this.#initialHTML}</${this.#editorElementTag}>`;
this.#assignInputAttributes();
}
// Let's track changes in editables if it's a multiroot editor.
if(this.isMultiroot()) {