CKEditor autosave alerts about saved text for ckeditor other than the one that originated the autosave
Description
relates to
Activity

Andrea Schmidt December 18, 2021 at 4:16 PMEdited
Verified on 22x: https://qa22-mysql.nightly.sakaiproject.org/, build: 3e861ec7 that announcement2 is not overwritten by announcement1’s auto-saved text, but there is an issue with the pop-up which allows you to compare the content. Will add comments to
I will set this one to verified because the auto-saved content from the first one is no longer showing the pop-up when editing the second one and when editing the first one, the pop-up does display and correctly updates that one.

Sean Horner September 30, 2021 at 1:33 PMEdited
, any tool outside core that loads the CKEditor will likely need to inject two hidden input fields:
<input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="insert_here_a_context_identifier_for_debugging">
<input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="insert_here_relevant_entity_id">
The value attribute for the latter would need to be dynamically set, using syntax specific to that tool's Java framework (e.g., JSF, RSF, Wicket, etc.).
With that said, there are some exceptions where the above are not required. Two that come to mind include the Site Info > Edit Site Information page, where the content being edited is already unique per the location URL (presented in the browser). This also seems to hold with Dashboard when editing the Site Description (which is also editable from Overview and Site Info > Edit Site Information).
Depending on the contrib tool in question and how it behaves, more might be needed. For instance, problems with the comments tool in Lessons () are not resolved with this patch. Furthermore, I added some Javascript logic in ckeditor.launch.js to handle some cases specific to Overview and Tests & Quizzes.
I hope that helps.

Austin September 30, 2021 at 1:17 PM
, Thanks for fixing this! Quick question... Will contrib tools (any that use ckeditor) need to be patched? If they aren't patched will ckeditor still work?

Sean Horner September 27, 2021 at 11:28 AM
In case it doesn't show up in the "Git commits" section of this issue, I've submitted a PR for this issue.

Sean Horner July 19, 2021 at 11:35 AM
, thanks for clarifying the scenario in T&Q you were referring to. That particular case in T&Q is also another incident affected by AutoSave plugin issue 133 that had reported (in addition to needing an entity ID somewhere in the DOM for the T&Q item currently being edited).
create an announcement
create another announcement
go back an edit the first announcement
add some additionl text to the ckeditor
wait a few (2) minutes for the autosave to save the ckeditor content
refresh the announcement tool (to view the list of announcements)
edit the 2nd announcement
the ckeditor (intermittently) pops up an alert indicating that there is saved content
if you say 'yes', it will completely overwrite the 2nd announcement's content with what was autosaved from the first one.
or sometimes, if it doesn't happen right away, try opening a different tool, then going back to the 2nd announcement
or try opening a ckeditor (or already having one open) in another tool like forums. Sometimes, the forums ckeditor will pop up the alert.