Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate input rules and paste rules into the core #1997

Merged
merged 48 commits into from
Oct 8, 2021

Conversation

philippkuehn
Copy link
Contributor

@philippkuehn philippkuehn commented Oct 8, 2021

With this PR we are removing the prosemirror-inputrules dependency and adding a custom implementation into the core.

Features

  • instead of a regex, we can now add a custom handler to find a match. This is useful for using complex libraries like linkified for link detection where a simple regex is not enough (fixes Pasting links with comma / Use real link parser #1872)
  • paste rules are applied after the content is pasted instead of before. This has the advantage that you have access to the state instead of just a slice. Also, it is possible that input rules and paste rules share logic.
  • input rules are not executed within code marks (fixes Don't apply typography when inside the Code mark #1889)
  • input rules can now also be executed after enter. This is useful for creating code blocks with ```{enter}. For using that you have to put [\s\n]$ at the end of your input rule regex.
  • all input rules of prosemirror-inputrules are exported by @tiptap/core now. There are also some custom input rules and paste rules. You can use:
    • markInputRule
    • nodeInputRule
    • textblockTypeInputRule
    • textInputRule
    • wrappingInputRule
    • markPasteRule
    • textPasteRule

Breaking changes

  • New syntax. Instead of multiple parameters all input rules and paste rules expects an object for better readability:
    // old
    markInputRule(/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/gm, this.type)
    
    // new
    markInputRule({
      find: /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/gm,
      type: this.type,
    })
  • incompatibility to prosemirror-inputrules. Because we provide these new feature, you can’t put input rules of prosemirror-inputrules into addInputRules() in your extensions. If you still want to use these input rules you have to add them via the inputRules plugin exported by prosemirror-inputrules.

@wengtytt
Copy link

wengtytt commented Feb 2, 2022

  • If you still want to use these input rules you have to add them via the inputRules plugin exported by prosemirror-inputrules

Hi there, is there any example how can we add old prosemirror-inputrules via the inputRules plugin exported by prosemirror-inputrules to the custom extension?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't apply typography when inside the Code mark Pasting links with comma / Use real link parser
2 participants