Skip to content

Commit 4d17134

Browse files
[6.x] Only remove Bard set when backspace key is hit (#14189)
1 parent 2a49c00 commit 4d17134

File tree

1 file changed

+16
-1
lines changed
  • resources/js/components/fieldtypes/bard

1 file changed

+16
-1
lines changed

resources/js/components/fieldtypes/bard/Set.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Node } from '@tiptap/core';
2-
import { Plugin, PluginKey } from '@tiptap/pm/state';
2+
import { Plugin, PluginKey, NodeSelection } from '@tiptap/pm/state';
33
import { Slice, Fragment } from '@tiptap/pm/model';
44
import { Decoration, DecorationSet } from '@tiptap/pm/view';
55
import { VueNodeViewRenderer } from '@tiptap/vue-3';
@@ -86,6 +86,21 @@ export const Set = Node.create({
8686
return found;
8787
};
8888
return [
89+
new Plugin({
90+
key: new PluginKey('setBlockCharacterInput'),
91+
props: {
92+
handleKeyDown(view, event) {
93+
const { selection } = view.state;
94+
if (!(selection instanceof NodeSelection) || selection.node.type !== type) return false;
95+
96+
const key = event.key;
97+
if (['Backspace', 'Delete', 'Enter', 'Escape', 'Tab'].includes(key)) return false;
98+
if (key.length === 1) return true;
99+
100+
return false;
101+
},
102+
},
103+
}),
89104
new Plugin({
90105
key: new PluginKey('setSelectionDecorator'),
91106
props: {

0 commit comments

Comments
 (0)