Skip to content

Commit cb4d6a0

Browse files
feat: expose clearHistory() method on MindElixir instance
Adds a clearHistory() method to the operationHistory plugin that resets the undo/redo stack to an empty state with a fresh baseline snapshot. This is needed by hosts that load new data into an existing MindElixir instance (e.g. via refresh()) and want to prevent users from undoing back into the previous diagram's state.
1 parent 9f7e8a6 commit cb4d6a0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/plugin/operationHistory.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ export default function (mei: MindElixirInstance) {
8888
}
8989
}
9090
}
91+
mei.clearHistory = function () {
92+
history = []
93+
currentIndex = -1
94+
current = mei.getData()
95+
}
9196
const handleOperation = function (operation: Operation) {
9297
if (operation.name === 'beginEdit') return
9398
history = history.slice(0, currentIndex + 1)

0 commit comments

Comments
 (0)