Hello there
We are having an issue with the built-in input rules in Tiptap when used with the macOS text replacement feature. Tiptap input rules use handleTextInput
and I’ve recreated the most simple CodeSandbox I could without using Tiptap to demonstrate the issue:
As a baseline example, the CodeSandbox above does this:
When the Markdown syntax for bold is typed, the handleTextInput
handler will take care of deleting the starting and ending **
, and apply the strong
mark to the remaining text. This is all working fine, but the problem exists when using macOS text replacements where the replacement includes Markdown bold syntax:
In this case, this is what happens:
Because we are suppressing the handleTextInput
default behaviour, the replacement text is not actually being inserted into the editor, and both the range
and the textContent
state reflect that (the current content is [crd]
- see the logs), while the delete
and addMark
calls are being called with the expectation that the editor state contains **[CARD]**
, and boom!
Preventing the error can be achieved with:
if (text === textBefore) {
return;
}
And from my testing, this doesn’t cause additional issues. However, the **[CARD]**
text will remain in the editor, but it will not be handled as expected (i.e. remove **
, and add the strong
mark to the rest of the text).
Not sure I’m seeing how this can be fixed, any suggestions?