fix: call selectAll on 'cmd+a', set a TextSelection instead of AllSelection, fix #1908

This commit is contained in:
Philipp Kühn
2021-09-22 00:03:32 +02:00
parent 31b269dd5a
commit bad16d9f3a
2 changed files with 6 additions and 5 deletions

View File

@@ -1,4 +1,3 @@
import { selectAll as originalSelectAll } from 'prosemirror-commands'
import { RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
@@ -12,6 +11,9 @@ declare module '@tiptap/core' {
} }
} }
export const selectAll: RawCommands['selectAll'] = () => ({ state, dispatch }) => { export const selectAll: RawCommands['selectAll'] = () => ({ tr, commands }) => {
return originalSelectAll(state, dispatch) return commands.setTextSelection({
from: 0,
to: tr.doc.content.size,
})
} }

View File

@@ -29,8 +29,7 @@ export const Keymap = Extension.create({
'Mod-Backspace': () => handleBackspace(), 'Mod-Backspace': () => handleBackspace(),
Delete: () => handleDelete(), Delete: () => handleDelete(),
'Mod-Delete': () => handleDelete(), 'Mod-Delete': () => handleDelete(),
// we dont need a custom `selectAll` for now 'Mod-a': () => this.editor.commands.selectAll(),
// 'Mod-a': () => this.editor.commands.selectAll(),
} }
}, },
}) })