tiptap
tiptap copied to clipboard
Can't cancel node input rule
What’s the bug you are facing?
I can't cancel node input rule by returning false
.
Here are my rules:
addInputRules() {
return [
nodeInputRule({
find: /({{([^}{]+)}})$/,
type: this.type,
getAttributes: match => {
const type = match[2];
if (type !== 'demo') {
return null;
}
return { type };
},
}),
];
},
addPasteRules() {
return [
nodePasteRule({
find: /({{([^}{]+)}})/g,
type: this.type,
getAttributes: match => {
const type = match[2];
if (type !== 'demo') {
return null;
}
return { type };
},
}),
];
},
Cancelling paste rule works fine, but cancelling input rule doesn't work for me.
I believe this PR (https://github.com/ueberdosis/tiptap/pull/2368) has implemented such ability, but either I'm doing something wrong or there is a bug in the core.
Which browser was this experienced in? Are any special extensions installed?
Chrome Version 105.0.5195.102
How can we reproduce the bug on our side?
By creating a node with the rules mentioned above and trying to write {{demo}}
which should not be cancelled (works fine), then to write {{foo}}
that should be cancelled (because I return null
in the rule) but it doesn't get cancelled.
Can you provide a CodeSandbox?
https://codesandbox.io/s/strange-snow-sp7p04?file=/src/MergeTags.js
What did you expect to happen?
I expected the rule to be cancelled and the {{foo}}
text not to be converted to node.
Anything to add? (optional)
No response
Did you update your dependencies?
- [X] Yes, I’ve updated my dependencies to use the latest version of all packages.
Are you sponsoring us?
- [ ] Yes, I’m a sponsor. 💖