There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-8a1abab0-877e-409f-92ea-c8b66673be3c XWIKI-23262 Open

The WYSIWYG editor is disconnected from the realtime session after changing the syntax of the edited content

 
View issue   ยท   Add comment
 

1 comment

 
cid:jira-generated-image-avatar-7b36ebd1-5677-4260-9113-50197248c357 Marius Dumitru Florea on 03/Jun/25 13:43
 

I can fix the disconnection easily with:

... 	... 	@@ -120,17 +120,6 @@
120 	120 	   }
121 	121 	 
122 	122 	   function createEditors(ckeditor, container, config) {
123 		-    if (config.editorName) {
124 		-      // We cannot set the editor name through the editor configuration. The editor name is taken by default from the
125 		-      // container id or name. To overcome this we set the editor name just after the editor instance is created.
126 		-      const handler = ckeditor.on('instanceCreated', event => {
127 		-        if (event.editor.element.$ === container[0]) {
128 		-          event.editor.name = config.editorName;
129 		-          handler.removeListener();
130 		-        }
131 		-      });
132 		-    }
133 		-
134 	134 	     container.attr({
135 	135 	       'data-sourceDocumentReference': XWiki.Model.serialize(config.document.documentReference),
136 	136 	       'data-syntax': config.document.syntax
... 	... 	@@ -147,6 +147,17 @@
147 	147 	   }
148 	148 	 
149 	149 	   function createEditor(ckeditor, element, config, instanceConfig) {
	139 	+    if (config.editorName) {
	140 	+      // We cannot set the editor name through the editor configuration. The editor name is taken by default from the
	141 	+      // element id or name. To overcome this we set the editor name just after the editor instance is created.
	142 	+      const handler = ckeditor.on('instanceCreated', event => {
	143 	+        if (event.editor.element.$ === element) {
	144 	+          event.editor.name = config.editorName;
	145 	+          handler.removeListener();
	146 	+        }
	147 	+      });
	148 	+    }
	149 	+
150 	150 	     let stopAvoidingCKAndSaveBarOverlap = null;
151 	151 	     const fieldSet = createFieldSet(element.ownerDocument, config);
152 	152 	     const deferred = $.Deferred();

but this raises other issues:

  • [minor] The update of the document syntax field (from the Information tab) increments the document version but the in-place editor is not aware of it. You get a merge conflict as a result on the next (auto)save from the WYSIWYG editor. This can be fixed by modifying editableProperty.js to trigger the xwiki:document:changeVersion event, but we can't call meta's setVersion unless the edited property is from the current document, which might not be always the case (it's possible to edit on page X a property from page Y).
  • [major] The syntax change is not propagated by the realtime session. Currently, only the edited content is synchronized. This means the other users editing at the same time will get the new content resulted from the syntax conversion, but their edit form will still submit the old syntax, which can create a mess...