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

fix (mention/heading): clashing heading markdown command and mention/suggestion with # #4954

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VV-EE
Copy link

@VV-EE VV-EE commented Mar 7, 2024

Please describe your changes

Fixes #2570
Now mention nodes with # will preempt the heading markdown input rule

How did you accomplish your changes

Instead of using addInputRules I've added the heading input rule as a separate ProseMirror plugin. After this higher priority extensions will be ahead of this input rule. For the same reason I set the Mention node's priority to 101.

How have you tested your changes

Added 3 E2E tests, one checks if there's no heading created is something is selected from the mention lis, one checks that we can still use the heading shortcut if we don't select anything, one checks if two mention plugins with '@' and '#' can work together.

How can we verify your changes

Run the E2E test, or visit preview/Examples/HeadingMultipleMention

Remarks

Added some documentation to Mention about higher priority.

Checklist

  • [ x] The changes are not breaking the editor
  • [ x] Added tests where possible
  • [ x] Followed the guidelines
  • [ x] Fixed linting issues

Copy link

netlify bot commented Mar 7, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 248cdfd
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/660e0703ac13fd00081b19f8
😎 Deploy Preview https://deploy-preview-4954--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@VV-EE VV-EE force-pushed the heading-with-mention branch 2 times, most recently from 327928e to 27ddfbd Compare March 10, 2024 01:11
Copy link
Contributor

@svenadlung svenadlung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool! Thank you so much 🙌

@@ -16,7 +16,7 @@ export const MentionPluginKey = new PluginKey('mention')

export const Mention = Node.create<MentionOptions>({
name: 'mention',

priority: 101, // Fixes collision with Heading '#' input rule
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be so nit-picky, but can you please insert breaks before and after?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put the comment on a separate line, I hope that's what you meant.

docs/api/nodes/mention.md Outdated Show resolved Hide resolved
@svenadlung
Copy link
Contributor

@bdbch what do you think? What do you think of this solution?

@svenadlung
Copy link
Contributor

@VV-EE we are still in internal discussion to find a better way to respect the priority of the input rules in the ExtensionManager.

@VV-EE VV-EE force-pushed the heading-with-mention branch 2 times, most recently from 13ae879 to 73c16f8 Compare April 4, 2024 01:37
@VV-EE
Copy link
Author

VV-EE commented Apr 4, 2024

I get it, this is a workaround, not a solution to the underlying problem. I thought about adding an extra forcePriority prop to ExtensionManager and order all plugins with that too, but I don't know how often this problem happens. If it's a one-off then a workaround is better IMO.

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

Successfully merging this pull request may close these issues.

Hash character with the suggestion utility conflicts with heading Markdown shortcut
2 participants