aguingand/tiptap-markdown

Custom input/paste rules not working on initial content

Closed this issue · 2 comments

benank commented

Describe the bug
I would like to accept both one or two tildes for strikethrough marks. (and also change the characters needed for bold and italic, but it's all the same issue)

Eg. ~strike and ~~strike~~ should both produce strike.

I have created a custom strike extension that you can see here. It works great when inputting text manually or pasting text in, but it doesn't work when adding content programmatically, either through the initial editor content or adding it through editor commands.

To Reproduce

  1. Add the custom strike extension linked above to tiptap.
  2. Set the initial content to: ~strike~ ~~strike~~
  3. Observe that only the second strike works - the first one still has tildes, and if you check the markdown output, the tildes are escaped.

Expected behavior
I would like both strikes, single and double, to work properly. Are there more places in the custom strike extension that I need to modify to get this to work?

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Chrome
  • Version: 115

Markdown-it does not support single tilde. You will have to add a custom plugin like this one.

Example of how to add a markdown-it plugin: https://github.com/aguingand/tiptap-markdown/blob/main/example/src/extensions/highlight.js#L15

benank commented

Thanks for your response! I'll do that.