mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-11 17:53:59 +02:00
Extracts history push to own function (#5382)
This commit is contained in:
committed by
GitHub
parent
b52e08b0ea
commit
42b60fb0eb
@@ -17,6 +17,7 @@ export interface HistoryEditor extends BaseEditor {
|
|||||||
history: History
|
history: History
|
||||||
undo: () => void
|
undo: () => void
|
||||||
redo: () => void
|
redo: () => void
|
||||||
|
writeHistory: (stack: 'undos' | 'redos', batch: any) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-redeclare
|
// eslint-disable-next-line no-redeclare
|
||||||
|
@@ -37,7 +37,7 @@ export const withHistory = <T extends Editor>(editor: T) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
history.redos.pop()
|
history.redos.pop()
|
||||||
history.undos.push(batch)
|
e.writeHistory('undos', batch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ export const withHistory = <T extends Editor>(editor: T) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
history.redos.push(batch)
|
e.writeHistory('redos', batch)
|
||||||
history.undos.pop()
|
history.undos.pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ export const withHistory = <T extends Editor>(editor: T) => {
|
|||||||
operations: [op],
|
operations: [op],
|
||||||
selectionBefore: e.selection,
|
selectionBefore: e.selection,
|
||||||
}
|
}
|
||||||
undos.push(batch)
|
e.writeHistory('undos', batch)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (undos.length > 100) {
|
while (undos.length > 100) {
|
||||||
@@ -110,6 +110,10 @@ export const withHistory = <T extends Editor>(editor: T) => {
|
|||||||
apply(op)
|
apply(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.writeHistory = (stack: 'undos' | 'redos', batch: any) => {
|
||||||
|
e.history[stack].push(batch)
|
||||||
|
}
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user