Hey folks, another question for people who’ve worked with the prosemirror-collab module before:
Has anyone found a good method, within the context of a view plugin, for determining if a state change was caused by a remote transaction?
The scenario is that I have a menu plugin that needs to close if the user changes their selection or updates the document, but it needs to stay open if the document is updated by a different user.
The idea I have for now is to use the Plugin.state
fields to look for transactions with collab$
metadata and change plugin state based on that. Something like:
new Plugin({
key: new PluginKey('LAST_TR'),
state: {
init () {
return false
},
apply (tr, prev, oldState, newState) {
if (tr.getMeta('collab$')) return true
return false
}
}
})
To clarify further, I need to be able to tell within the scope of the update
function returned by Plugin.view
if the last update was caused by the collab module.
I’m thinking I’d be able to use the value set above in the update
function by checking state of editorView.state[LAST_TR]
, LAST_TR being the plugin key.
Anyone have a better idea?