tiptap/docs/src/docPages/api/extensions/history.md

58 lines
1.1 KiB
Markdown
Raw Normal View History

2020-08-19 03:39:41 +08:00
# History
Enables history support.
2020-08-20 21:33:16 +08:00
## Commands
| Command | Options | Description |
2020-08-19 03:39:41 +08:00
| ------ | ---- | ---------------- |
| undo | — | Undo the latest change. |
| redo | — | Redo the latest change. |
2020-08-19 03:39:41 +08:00
2020-08-20 21:33:16 +08:00
## Keybindings
2020-08-19 03:39:41 +08:00
* Windows & Linux: `Control` + `Z` → Undo
* Windows & Linux: `Shift` + `Control` + `Z` → Redo
* macOS: `Command` + `Z` → Undo
* macOS: `Shift` + `Command` + `Z` → Redo
2020-08-20 21:33:16 +08:00
## Usage
2020-08-19 03:39:41 +08:00
```markup
<template>
<div>
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">
<div>
<button type="button" @click="commands.undo">
Undo
</button>
<button type="button" @click="commands.redo">
Redo
</button>
</div>
</editor-menu-bar>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import { History } from 'tiptap-extensions'
export default {
components: {
EditorMenuBar,
EditorContent,
},
data() {
return {
editor: new Editor({
extensions: [
new History(),
],
}),
}
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>
```