The BlockNote metadata store (the data kept about blocks and links outside of the BlockNote content, keyed by block id or link id) was local to each realtime collaborator. A user who joined the session didn't have the metadata matching the ids of the shared content, so saving lost what BlockNote can't represent (block parameters, link and image references, verbatim code blocks, etc.).
Changes:
The metadata store now has private and shared entries. Each entry is identified by a BlockMetadataKey ({{{ name, shared? }}}), defined by the editing feature that owns it, so the editor doesn't hard-code what is shared. Entries are private by default, because some metadata must stay local (e.g. the macro output, rendered with the rights of the current user, see XWIKI-24374). A block can have both shared and private entries; get(id) returns them merged.
When editing in realtime, the shared entries are kept in the Y.Doc of the session (a <name>:metadata map, next to the content): the user who initializes the session copies their shared entries there, the users who join drop theirs and use those of the session. Leaving the session keeps a copy of the shared entries.
The XWiki rendering metadata (parameters, references, freestanding, generated label, leading / trailing new line, verbatim) is shared; the macro call and macro output stay private.
Added CollaborationIT#saveSourceInformationFromJoinedSession: John edits a paragraph with parameters, Alice joins, edits and saves, and the saved source keeps the parameters, the link reference and the verbatim block.
Known limitations: the metadata of deleted blocks stays in the shared map, and two users creating the metadata of the same new block at the same time can lose one entry.
The BlockNote metadata store (the data kept about blocks and links outside of the BlockNote content, keyed by block id or link id) was local to each realtime collaborator. A user who joined the session didn't have the metadata matching the ids of the shared content, so saving lost what BlockNote can't represent (block parameters, link and image references, verbatim code blocks, etc.).
Changes: * The metadata store now has *private* and *shared* entries. Each entry is identified by a {{BlockMetadataKey}} (a{{\{ name, shared? \}} and an optional {{shared}} flag), defined by the editing feature that owns it, so the editor doesn't hard-code what is shared. Entries are private by default, because some metadata must stay local (e.g. the macro output, rendered with the rights of the current user, see XWIKI-24374). A block can have both shared and private entries; {{get(id)}} returns them merged. * When editing in realtime, the shared entries are kept in the {{Y.Doc}} of the session (a {{<name>:metadata}} map, next to the content): the user who initializes the session copies their shared entries there, the users who join drop theirs and use those of the session. Leaving the session keeps a copy of the shared entries. * The XWiki rendering metadata (parameters, references, freestanding, generated label, leading / trailing new line, verbatim) is shared; the macro call and macro output stay private. * Added {{CollaborationIT#saveSourceInformationFromJoinedSession}}: John edits a paragraph with parameters, Alice joins, edits and saves, and the saved source keeps the parameters, the link reference and the verbatim block.
Known limitations: the metadata of deleted blocks stays in the shared map, and two users creating the metadata of the same new block at the same time can lose one entry.
Nikita Petrenko The link attributes (link parameters, e.g. rel="__blank" to open the link in a new tab) are kept with the other link metadata (the link reference), which wasn't shared with the users who joined the realtime session. That's what this issue fixes: the link parameters are preserved now when a user who joined the session saves. Note that this can happen even if you are the only one editing, when a previous realtime session for the same page is still open.
I extended CollaborationIT#saveSourceInformationFromJoinedSession to check it: