There are 3 comments.
 
 
XWiki Platform / cid:jira-generated-image-avatar-a50cc53b-18f4-4793-ac45-4fc1b53be91b XWIKI-20191 Open

Add the Source button for the Realtime editor

 
View issue   ยท   Add comment
 

3 comments

 
cid:jira-generated-image-avatar-ce754387-b38f-4c61-bed5-b02cab3998ef Dorian Ouakli on 22/Jul/24 07:20
 

We tried the approach of making the source view read-only when realtime is enabled, but we discovered it was difficult and hackish to implement in practise. The iframed WYSIWYG  editor, which is still assumed to be widely used, for instance when creating new pages, destroys the document to which the patches are applied when switching to source mode. To work around this we would have to keep a fake document in memory and temporarily apply the patches to that fake document while in source mode.

 
cid:jira-generated-image-avatar-ce754387-b38f-4c61-bed5-b02cab3998ef Dorian Ouakli on 22/Jul/24 07:28
 

Given these difficulties, we also thought of using a modal, or a ckeditor source dialog, see https://ckeditor.com/cke4/addon/sourcedialog
The benefits of a source dialog is that it would be clear that it is simply a view of the realtime session rather than the realtime session itself, but also that it would not destroy the iframe and prevent the realtime extension from receiving patches from other users.

To keep things simple because of our running late on the schedule, we decided to bring the Source button back by temporarily leaving the realtime session. If no unsaved changes were made or if the user is alone in the realtime session, switching back to the wysiwyg brings the user back in the realtime session.
If the user has unsaved changes and is not alone in the realtime session when switching back to wysiwyg, the editor permanently leaves the realtime session, until the user decides to manually join the session.

 

With this last solution, the source button would have the same behavior in a realtime session alone, as outside of a realtime session.

 
cid:jira-generated-image-avatar-ce754387-b38f-4c61-bed5-b02cab3998ef Dorian Ouakli on 22/Jul/24 07:28
 

I will open a PR this morning.