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

[Mentions Plugin]: add triggerPreviousCharPattern option #2542

Conversation

cacosandon
Copy link
Contributor

@cacosandon cacosandon commented Jul 27, 2023

Description

See changesets.

Before this PR, if you wanted to create a mention, it had to be either at the beginning of the line or after a space. The option triggerPreviousCharPattern allows users to create mentions after custom characters.

For instance, if you want to create a tag between parenthesis, or between quotes.

Using:

createMentionPlugin({
  enabled: !!enabled.mention,
  options: {
    triggerPreviousCharPattern: /^$|^[\s"']$/,
  },
}),
Screen.Recording.2023-07-27.at.09.48.33.mov

@changeset-bot
Copy link

changeset-bot bot commented Jul 27, 2023

🦋 Changeset detected

Latest commit: c6f5967

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@udecode/plate-mention Minor
@udecode/plate Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jul 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2023 2:09pm

@reviewpad
Copy link
Contributor

reviewpad bot commented Jul 27, 2023

AI-Generated Summary: This pull request includes two patches related to improvements to the mention functionality in a text editor package. The first patch introduces a new triggerPreviousCharPattern parameter in the mention feature. This pattern is applied to the character previous to the mention trigger. This allows for more complex triggering conditions for mentions, such as triggering only after certain characters. The change is reflected in the documentation, test files, and type definitions. The second patch adds a changeset reflecting the update. This update is considered a minor change according to the changeset. Overall, this pull request enhances the flexibility of the mention feature in the text editor package.

@reviewpad
Copy link
Contributor

reviewpad bot commented Jul 27, 2023

Thank you @cacosandon for this first contribution!

@reviewpad reviewpad bot added small Pull request is small waiting-for-review labels Jul 27, 2023
@ghost
Copy link

ghost commented Jul 27, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@cacosandon cacosandon changed the title feat(mentions): add triggerPreviousCharPattern parameter [Mentions Plugin]: add triggerPreviousCharPattern option Jul 27, 2023
packages/mention/src/withMention.ts Outdated Show resolved Hide resolved
apps/www/src/registry/default/example/playground-demo.tsx Outdated Show resolved Hide resolved
@cacosandon
Copy link
Contributor Author

Updated the PR description and video example. You can test in the Vercel deployment that you can tag after quotes (" or '), spaces and beginning of line.

packages/mention/src/withMention.ts Outdated Show resolved Hide resolved
@zbeyens zbeyens enabled auto-merge July 27, 2023 15:17
@zbeyens zbeyens disabled auto-merge July 27, 2023 15:44
@zbeyens zbeyens merged commit 6a2f4c0 into udecode:main Jul 27, 2023
5 of 7 checks passed
@zbeyens zbeyens mentioned this pull request Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small Pull request is small waiting-for-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants