#2600 - Support smart tags in Custom JSON-LD string values - #489
Conversation
This reverts merge commit 5e8cd34 (-m 1) so the upcoming EditorInput release ships without the breaking Tailwind v4 changes. Re-apply after release by reverting this commit.
Adds an optional triggerRegex prop that overrides the built-in mention-suggestion matcher so consumers can allow the trigger without a leading space (e.g. inside quoted JSON-LD string values). When omitted, the existing trigger-based matcher is used - zero behavior change. Related to brainstormforce/surerank#2600
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
The storybook test-runner's axe pass runs on the final story state. The open combobox popup has pre-existing aria-required-parent/children and aria-valid-attr-value violations unrelated to the triggerRegex feature, so the new interaction stories now dismiss the menu after asserting.
mohitsbsftester
left a comment
There was a problem hiding this comment.
Extensive review findings:
1. Blocker: unrelated dependency and tooling changes are mixed into this component change
This PR includes a broad Tailwind and dependency rollback alongside the EditorInput / mention trigger work. That makes the feature difficult to validate safely and significantly increases the regression surface.
Please rebase this after the dependency rollback is handled separately, then keep this PR limited to the EditorInput implementation, mention plugin, relevant tests, and stories. Please also verify that the final lockfile contains only dependency changes required for this feature.
2. Major: stateful custom regular expressions can fail intermittently
The custom matcher directly calls triggerRegex.exec( text ). A caller can pass a regex with the g or y flag, making lastIndex stateful. Repeated calls using identical input can then alternate between matching and failing.
Please reset triggerRegex.lastIndex = 0 before execution, or clone the expression without stateful flags. Add a test that invokes the matcher repeatedly with a global custom regular expression and confirms stable results.
3. Test coverage requested
Please add coverage for:
- Global and sticky custom regex flags.
- Shadow DOM menu behavior with a custom trigger regex.
- Repeated focus, blur, and reopening of the mention menu.
- Invalid custom regex capture groups, since the implementation expects groups 1, 2, and 3.
The implementation direction is useful, but the unrelated scope and stateful regex behavior should be addressed before this is consumed by SureRank.
What
Adds an optional
triggerRegexprop toEditorInputthat overrides the built-in mention-suggestion matcher.mention-plugin.tsx: whentriggerRegexis set, it replaces the built-in matcher entirely; when omitted, the existing trigger-based matcher runs unchanged (zero behavior change for current consumers).CustomTriggerRegex- proves a custom regex switches the trigger ({{opens the menu, default@does not).MentionWithoutLeadingSpace- proves the trigger works without a preceding blank space.Why
SureRank's Custom JSON-LD editor needs smart tags insertable inside quoted JSON string values without a leading space (e.g.
"name": "@site_name"). The built-in matcher requires(^|\s|\()before the trigger. See brainstormforce/surerank#2600 and the review discussion on brainstormforce/surerank#2776.SureRank will consume this via:
Verified end-to-end on a local SureRank build: menu opens after
"and space, stays closed mid-word.Note
This branch also carries f76013a (revert of the TailwindCSS v4 migration, PR #470) so the upcoming EditorInput release ships without the v4 breaking changes. Once that revert lands on staging via its own PR, this PR reduces to the EditorInput commit only.
Testing
npx vitest run --project=storybook- 82 files / 250 tests greenCloses brainstormforce/surerank#2600