Skip to content

Commit

Permalink
undo manager only tracks user actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Jan 27, 2020
1 parent 3213706 commit fd505bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/plugins/sync-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class ProsemirrorBinding {
}).filter(n => n !== null)
const tr = this.prosemirrorView.state.tr.replace(0, this.prosemirrorView.state.doc.content.size, new PModel.Slice(new PModel.Fragment(fragmentContent), 0, 0))
this.prosemirrorView.dispatch(tr)
})
}, ySyncPluginKey)
})
}
/**
Expand Down Expand Up @@ -318,7 +318,7 @@ export class ProsemirrorBinding {
this.doc.transact(() => {
updateYFragment(this.doc, this.type, doc, this.mapping)
this.beforeTransactionSelection = getRelativeSelection(this, this.prosemirrorView.state)
})
}, ySyncPluginKey)
})
}
destroy () {
Expand Down Expand Up @@ -398,7 +398,7 @@ export const createNodeFromYElement = (el, schema, mapping, snapshot, prevSnapsh
// an error occured while creating the node. This is probably a result of a concurrent action.
/** @type {Y.Doc} */ (el.doc).transact(transaction => {
/** @type {Y.Item} */ (el._item).delete(transaction)
})
}, ySyncPluginKey)
mapping.delete(el)
return null
}
Expand Down Expand Up @@ -430,7 +430,7 @@ export const createTextNodesFromYText = (text, schema, mapping, snapshot, prevSn
// an error occured while creating the node. This is probably a result of a concurrent action.
/** @type {Y.Doc} */ (text.doc).transact(transaction => {
/** @type {Y.Item} */ (text._item).delete(transaction)
})
}, ySyncPluginKey)
return null
}
// @ts-ignore
Expand Down Expand Up @@ -756,7 +756,7 @@ const updateYFragment = (y, yDomFragment, pNode, mapping) => {
}
yDomFragment.insert(left, ins)
}
})
}, ySyncPluginKey)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/undo-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const yUndoPlugin = ({ protectedNodes = new Set(['paragraph']), trackedOr
// TODO: check if plugin order matches and fix
const ystate = ySyncPluginKey.getState(state)
const undoManager = new UndoManager(ystate.type, {
trackedOrigins: new Set([null, ySyncPluginKey].concat(trackedOrigins)),
trackedOrigins: new Set([ySyncPluginKey].concat(trackedOrigins)),
deleteFilter: item => !(item instanceof Item) ||
!(item.content instanceof ContentType) ||
!(item.content.type instanceof Text ||
Expand Down

0 comments on commit fd505bb

Please sign in to comment.