mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
fix editor undo
This commit is contained in:
1 parent
25504e8cb1
commit
73339d8cd9
7 files changed
+212
-64
No files matched your search
@@ -5,7 +5,6 @@ import { Decoration, DecorationSet } from '@tiptap/pm/view'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Text from '@tiptap/extension-text'
|
||||
import HardBreak from '@tiptap/extension-hard-break'
|
||||
import History from '@tiptap/extension-history'
|
||||
import Gapcursor from '@tiptap/extension-gapcursor'
|
||||
import Dropcursor from '@tiptap/extension-dropcursor'
|
||||
import { createApp, reactive } from 'vue'
|
||||
@@ -1475,7 +1474,7 @@ const VariableHighlight = Extension.create({
|
||||
}
|
||||
})
|
||||
|
||||
export function buildEditor ({ dynamicAreaProps, getAttachmentsIndex, renderHtmlForSaveRef, onFieldDrop, onFieldDestroy, editorOptions }) {
|
||||
export function buildEditor ({ dynamicAreaProps, getAttachmentsIndex, renderHtmlForSaveRef, onFieldDrop, onFieldDestroy, onUndo, onRedo, editorOptions }) {
|
||||
const FieldNode = Node.create({
|
||||
name: 'fieldNode',
|
||||
inline: true,
|
||||
@@ -1598,6 +1597,51 @@ export function buildEditor ({ dynamicAreaProps, getAttachmentsIndex, renderHtml
|
||||
}
|
||||
})
|
||||
|
||||
const undo = () => {
|
||||
onUndo()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const redo = () => {
|
||||
onRedo()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const BuilderHistory = Extension.create({
|
||||
name: 'builderHistory',
|
||||
addKeyboardShortcuts () {
|
||||
return {
|
||||
'Mod-z': undo,
|
||||
'Shift-Mod-z': redo,
|
||||
'Mod-y': redo,
|
||||
'Mod-я': undo,
|
||||
'Shift-Mod-я': redo
|
||||
}
|
||||
},
|
||||
addProseMirrorPlugins () {
|
||||
return [
|
||||
new Plugin({
|
||||
key: new PluginKey('builderHistory'),
|
||||
props: {
|
||||
handleDOMEvents: {
|
||||
beforeinput (_view, event) {
|
||||
const command = { historyUndo: undo, historyRedo: redo }[event.inputType]
|
||||
|
||||
if (!command) return false
|
||||
|
||||
event.preventDefault()
|
||||
|
||||
return command()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const RESIZE_HANDLE_PX = 4
|
||||
const MIN_SIZE_PX = 16
|
||||
|
||||
@@ -1818,7 +1862,7 @@ export function buildEditor ({ dynamicAreaProps, getAttachmentsIndex, renderHtml
|
||||
Document,
|
||||
Text,
|
||||
HardBreak,
|
||||
History,
|
||||
BuilderHistory,
|
||||
Gapcursor,
|
||||
Dropcursor,
|
||||
CustomParagraph,
|
||||
|
||||
Reference in new issue
Block a user