feat(tiptap): add undo and redo (#944)

This commit is contained in:
Piotrek Tomczewski 2023-01-10 22:16:56 +01:00 committed by GitHub
parent 62b6020895
commit 7c651d450d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 26 deletions

View file

@ -8,6 +8,7 @@ import HardBreak from '@tiptap/extension-hard-break'
import Bold from '@tiptap/extension-bold' import Bold from '@tiptap/extension-bold'
import Italic from '@tiptap/extension-italic' import Italic from '@tiptap/extension-italic'
import Code from '@tiptap/extension-code' import Code from '@tiptap/extension-code'
import History from '@tiptap/extension-history'
import { Plugin } from 'prosemirror-state' import { Plugin } from 'prosemirror-state'
import type { Ref } from 'vue' import type { Ref } from 'vue'
@ -61,6 +62,9 @@ export function useTiptap(options: UseTiptapOptions) {
placeholder: () => placeholder.value!, placeholder: () => placeholder.value!,
}), }),
CodeBlockShiki, CodeBlockShiki,
History.configure({
depth: 10,
}),
Extension.create({ Extension.create({
name: 'api', name: 'api',
addKeyboardShortcuts() { addKeyboardShortcuts() {

View file

@ -31,6 +31,7 @@
"@iconify/utils": "^2.0.11", "@iconify/utils": "^2.0.11",
"@tiptap/extension-character-count": "2.0.0-beta.204", "@tiptap/extension-character-count": "2.0.0-beta.204",
"@tiptap/extension-code-block": "2.0.0-beta.204", "@tiptap/extension-code-block": "2.0.0-beta.204",
"@tiptap/extension-history": "2.0.0-beta.204",
"@tiptap/extension-mention": "2.0.0-beta.204", "@tiptap/extension-mention": "2.0.0-beta.204",
"@tiptap/extension-paragraph": "2.0.0-beta.204", "@tiptap/extension-paragraph": "2.0.0-beta.204",
"@tiptap/extension-placeholder": "2.0.0-beta.204", "@tiptap/extension-placeholder": "2.0.0-beta.204",

View file

@ -53,6 +53,7 @@ importers:
'@pinia/nuxt': ^0.4.6 '@pinia/nuxt': ^0.4.6
'@tiptap/extension-character-count': 2.0.0-beta.204 '@tiptap/extension-character-count': 2.0.0-beta.204
'@tiptap/extension-code-block': 2.0.0-beta.204 '@tiptap/extension-code-block': 2.0.0-beta.204
'@tiptap/extension-history': 2.0.0-beta.204
'@tiptap/extension-mention': 2.0.0-beta.204 '@tiptap/extension-mention': 2.0.0-beta.204
'@tiptap/extension-paragraph': 2.0.0-beta.204 '@tiptap/extension-paragraph': 2.0.0-beta.204
'@tiptap/extension-placeholder': 2.0.0-beta.204 '@tiptap/extension-placeholder': 2.0.0-beta.204
@ -128,6 +129,7 @@ importers:
'@iconify/utils': 2.0.11 '@iconify/utils': 2.0.11
'@tiptap/extension-character-count': 2.0.0-beta.204 '@tiptap/extension-character-count': 2.0.0-beta.204
'@tiptap/extension-code-block': 2.0.0-beta.204 '@tiptap/extension-code-block': 2.0.0-beta.204
'@tiptap/extension-history': 2.0.0-beta.204
'@tiptap/extension-mention': 2.0.0-beta.204_ggkstofzpnfxkp3gzsos4mewvi '@tiptap/extension-mention': 2.0.0-beta.204_ggkstofzpnfxkp3gzsos4mewvi
'@tiptap/extension-paragraph': 2.0.0-beta.204 '@tiptap/extension-paragraph': 2.0.0-beta.204
'@tiptap/extension-placeholder': 2.0.0-beta.204 '@tiptap/extension-placeholder': 2.0.0-beta.204
@ -205,7 +207,7 @@ importers:
typescript: 4.9.4 typescript: 4.9.4
unplugin-auto-import: 0.12.1_@vueuse+core@9.10.0 unplugin-auto-import: 0.12.1_@vueuse+core@9.10.0
vite-plugin-inspect: 0.7.14 vite-plugin-inspect: 0.7.14
vite-plugin-pwa: 0.14.1 vite-plugin-pwa: 0.14.1_tz3vz2xt4jvid2diblkpydcyn4
vitest: 0.27.0_jsdom@21.0.0 vitest: 0.27.0_jsdom@21.0.0
vue-tsc: 1.0.24_typescript@4.9.4 vue-tsc: 1.0.24_typescript@4.9.4
workbox-build: 6.5.4 workbox-build: 6.5.4
@ -2649,20 +2651,6 @@ packages:
rollup: 2.79.1 rollup: 2.79.1
dev: true dev: true
/@rollup/plugin-replace/5.0.1_rollup@3.9.1:
resolution: {integrity: sha512-Z3MfsJ4CK17BfGrZgvrcp/l6WXoKb0kokULO+zt/7bmcyayokDaQ2K3eDJcRLCTAlp5FPI4/gz9MHAsosz4Rag==}
engines: {node: '>=14.0.0'}
peerDependencies:
rollup: ^1.20.0||^2.0.0||^3.0.0
peerDependenciesMeta:
rollup:
optional: true
dependencies:
'@rollup/pluginutils': 5.0.2_rollup@3.9.1
magic-string: 0.26.7
rollup: 3.9.1
dev: true
/@rollup/plugin-replace/5.0.2_rollup@2.79.1: /@rollup/plugin-replace/5.0.2_rollup@2.79.1:
resolution: {integrity: sha512-M9YXNekv/C/iHHK+cvORzfRYfPbq0RDD8r0G+bMiTXjNGKulPnCT9O3Ss46WfhI6ZOCgApOP7xAdmCQJ+U2LAA==} resolution: {integrity: sha512-M9YXNekv/C/iHHK+cvORzfRYfPbq0RDD8r0G+bMiTXjNGKulPnCT9O3Ss46WfhI6ZOCgApOP7xAdmCQJ+U2LAA==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
@ -2917,6 +2905,14 @@ packages:
'@tiptap/core': 2.0.0-beta.204 '@tiptap/core': 2.0.0-beta.204
dev: false dev: false
/@tiptap/extension-history/2.0.0-beta.204:
resolution: {integrity: sha512-Dk64Nu2bnPutLV0Fd2H1c5ffGE+bQ2eVyWUrAGodAhZJINouN8EF7T0pZLSo0YaIlLMWsl23fImGtBEyVYQUKw==}
peerDependencies:
'@tiptap/core': ^2.0.0-beta.193
dependencies:
prosemirror-history: 1.3.0
dev: false
/@tiptap/extension-history/2.0.0-beta.204_bv566pzu4gfcw3675d5jwhi56i: /@tiptap/extension-history/2.0.0-beta.204_bv566pzu4gfcw3675d5jwhi56i:
resolution: {integrity: sha512-Dk64Nu2bnPutLV0Fd2H1c5ffGE+bQ2eVyWUrAGodAhZJINouN8EF7T0pZLSo0YaIlLMWsl23fImGtBEyVYQUKw==} resolution: {integrity: sha512-Dk64Nu2bnPutLV0Fd2H1c5ffGE+bQ2eVyWUrAGodAhZJINouN8EF7T0pZLSo0YaIlLMWsl23fImGtBEyVYQUKw==}
peerDependencies: peerDependencies:
@ -3661,7 +3657,7 @@ packages:
'@vue/compiler-sfc': 3.2.45 '@vue/compiler-sfc': 3.2.45
'@vue/reactivity': 3.2.45 '@vue/reactivity': 3.2.45
'@vue/shared': 3.2.45 '@vue/shared': 3.2.45
minimatch: 5.1.1 minimatch: 5.1.2
vue-template-compiler: 2.7.14 vue-template-compiler: 2.7.14
dev: true dev: true
@ -8539,13 +8535,6 @@ packages:
brace-expansion: 1.1.11 brace-expansion: 1.1.11
dev: true dev: true
/minimatch/5.1.1:
resolution: {integrity: sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g==}
engines: {node: '>=10'}
dependencies:
brace-expansion: 2.0.1
dev: true
/minimatch/5.1.2: /minimatch/5.1.2:
resolution: {integrity: sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==} resolution: {integrity: sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -11314,7 +11303,7 @@ packages:
'@rollup/plugin-commonjs': 23.0.3_rollup@3.9.1 '@rollup/plugin-commonjs': 23.0.3_rollup@3.9.1
'@rollup/plugin-json': 5.0.2_rollup@3.9.1 '@rollup/plugin-json': 5.0.2_rollup@3.9.1
'@rollup/plugin-node-resolve': 15.0.1_rollup@3.9.1 '@rollup/plugin-node-resolve': 15.0.1_rollup@3.9.1
'@rollup/plugin-replace': 5.0.1_rollup@3.9.1 '@rollup/plugin-replace': 5.0.2_rollup@3.9.1
'@rollup/pluginutils': 5.0.2_rollup@3.9.1 '@rollup/pluginutils': 5.0.2_rollup@3.9.1
chalk: 5.1.2 chalk: 5.1.2
consola: 2.15.3 consola: 2.15.3
@ -11948,10 +11937,12 @@ packages:
- supports-color - supports-color
dev: true dev: true
/vite-plugin-pwa/0.14.1: /vite-plugin-pwa/0.14.1_tz3vz2xt4jvid2diblkpydcyn4:
resolution: {integrity: sha512-5zx7yhQ8RTLwV71+GA9YsQQ63ALKG8XXIMqRJDdZkR8ZYftFcRgnzM7wOWmQZ/DATspyhPih5wCdcZnAIsM+mA==} resolution: {integrity: sha512-5zx7yhQ8RTLwV71+GA9YsQQ63ALKG8XXIMqRJDdZkR8ZYftFcRgnzM7wOWmQZ/DATspyhPih5wCdcZnAIsM+mA==}
peerDependencies: peerDependencies:
vite: ^3.1.0 || ^4.0.0 vite: ^3.1.0 || ^4.0.0
workbox-build: ^6.5.4
workbox-window: ^6.5.4
dependencies: dependencies:
'@rollup/plugin-replace': 5.0.2_rollup@3.9.1 '@rollup/plugin-replace': 5.0.2_rollup@3.9.1
debug: 4.3.4 debug: 4.3.4
@ -11961,7 +11952,6 @@ packages:
workbox-build: 6.5.4 workbox-build: 6.5.4
workbox-window: 6.5.4 workbox-window: 6.5.4
transitivePeerDependencies: transitivePeerDependencies:
- '@types/babel__core'
- supports-color - supports-color
dev: true dev: true