Skip to content
Snippets Groups Projects
Commit fa1c0bb3 authored by Marius Dumitru Florea's avatar Marius Dumitru Florea
Browse files

XWIKI-22034: Realtime WYSIWYG editor is very slow even on medium size content

* Properly initialize the new nested editables after a remote change is applied in order to prevent adding them multiple times.
* Re-render the macros when a new nested editable is added for a macro widget.
parent d933cd41
No related branches found
No related tags found
No related merge requests found
...@@ -280,13 +280,20 @@ define('xwiki-ckeditor-realtime-adapter', [ ...@@ -280,13 +280,20 @@ define('xwiki-ckeditor-realtime-adapter', [
// We need create the editables ourselves under the widget element so that they get submitted to the // We need create the editables ourselves under the widget element so that they get submitted to the
// server when the content is refreshed (in order to be taken into account when rendering the macros). // server when the content is refreshed (in order to be taken into account when rendering the macros).
editable = widgetPlaceholder.ownerDocument.createElement('div'); editable = widgetPlaceholder.ownerDocument.createElement('div');
editable.setAttribute('contenteditable', 'true');
editable.classList.add('xwiki-metadata-container'); editable.classList.add('xwiki-metadata-container');
editable.dataset.xwikiNonGeneratedContent = editablePlaceholder.dataset.contentType; editable.dataset.xwikiNonGeneratedContent = editablePlaceholder.dataset.contentType;
editable.dataset.xwikiParameterName = editableName; editable.dataset.xwikiParameterName = editableName;
widget.element.$.append(editable); widget.element.$.append(editable);
widget.initEditable(editableName, {
selector: `[data-xwiki-parameter-name="${CSS.escape(editableName)}"]`
});
}
if (editable) {
// The editable should be empty, unless it was just initialized above in which case it may contain an
// empty paragraph that we want to get rid of (we want only the content from the editable placeholder).
editable.innerHTML = '';
editable.append(...editablePlaceholder.childNodes);
} }
editable?.append(...editablePlaceholder.childNodes);
}); });
} }
}); });
...@@ -338,9 +345,13 @@ define('xwiki-ckeditor-realtime-adapter', [ ...@@ -338,9 +345,13 @@ define('xwiki-ckeditor-realtime-adapter', [
} }
}); });
} }
// The macro parametes are kept on the macro wrapper, so if the macro wrapper was updated then it's very likely // Most of the macro parametes are kept on the macro wrapper, so if the macro wrapper was updated then it's very
// that the macro parameters were also updated. // likely that the macro parameters were also updated. Some macro parameters are edited in-place using nested
shouldRefreshContent = shouldRefreshContent || updatedNode.tagName.toLowerCase() === 'xwiki-widget-xwiki-macro'; // editables. We need to re-render the macro if a new nested editable is added.
shouldRefreshContent = shouldRefreshContent ||
updatedNode.tagName.toLowerCase() === 'xwiki-widget-xwiki-macro' ||
(updatedNode.tagName.toLowerCase() === 'xwiki-editable' && widget?.name === 'xwiki-macro' &&
!widget.editables[updatedNode.getAttribute('name')]);
}); });
// Delete the updated widgets so that we can reinitialize them. // Delete the updated widgets so that we can reinitialize them.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment