Skip to content

Commit

Permalink
Added an option to override the decorator generator
Browse files Browse the repository at this point in the history
  • Loading branch information
EricRabil committed Apr 5, 2020
1 parent f975837 commit 5f17f92
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/plugins/cursor-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ export const createDecorations = (state, awareness) => {
* @param {Awareness} awareness
* @return {any}
*/
export const yCursorPlugin = awareness => new Plugin({
export const yCursorPlugin = (awareness, decorator = createDecorations) => new Plugin({
key: yCursorPluginKey,
state: {
init (_, state) {
return createDecorations(state, awareness)
return decorator(state, awareness)
},
apply (tr, prevState, oldState, newState) {
const ystate = ySyncPluginKey.getState(newState)
const yCursorState = tr.getMeta(yCursorPluginKey)
if ((ystate && ystate.isChangeOrigin) || (yCursorState && yCursorState.awarenessUpdated)) {
return createDecorations(newState, awareness)
return decorator(newState, awareness)
}
return prevState.map(tr.mapping, tr.doc)
}
Expand Down

0 comments on commit 5f17f92

Please sign in to comment.