Merge branch 'main' of github.com:ueberdosis/tiptap-next into main

This commit is contained in:
Hans Pagel 2020-12-02 12:35:29 +01:00
commit 141a4215f1
2 changed files with 8 additions and 4 deletions

View File

@ -53,7 +53,7 @@ export default class CommandManager {
const method = (...args: any) => {
const callback = command(...args)(props)
if (tr.steps.length) {
if (!tr.getMeta('preventDispatch')) {
view.dispatch(tr)
}
@ -74,7 +74,7 @@ export default class CommandManager {
return new Proxy({}, {
get: (_, name: string, proxy) => {
if (name === 'run') {
if (!hasStartTransaction && shouldDispatch && tr.steps.length) {
if (!hasStartTransaction && shouldDispatch && !tr.getMeta('preventDispatch')) {
view.dispatch(tr)
}

View File

@ -22,13 +22,17 @@ const Collaboration = Extension.create({
/**
* Undo recent changes
*/
undo: (): Command => ({ state }) => {
undo: (): Command => ({ tr, state }) => {
tr.setMeta('preventDispatch', true)
return undo(state)
},
/**
* Reapply reverted changes
*/
redo: (): Command => ({ state }) => {
redo: (): Command => ({ tr, state }) => {
tr.setMeta('preventDispatch', true)
return redo(state)
},
}