Skip to content

#2600 - Support smart tags in Custom JSON-LD string values - #489

Open
jaieds wants to merge 4 commits into
stagingfrom
component-improvements/editor-input
Open

#2600 - Support smart tags in Custom JSON-LD string values#489
jaieds wants to merge 4 commits into
stagingfrom
component-improvements/editor-input

Conversation

@jaieds

@jaieds jaieds commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What

Adds an optional triggerRegex prop to EditorInput that overrides the built-in mention-suggestion matcher.

  • mention-plugin.tsx: when triggerRegex is set, it replaces the built-in matcher entirely; when omitted, the existing trigger-based matcher runs unchanged (zero behavior change for current consumers).
  • Custom regex contract (same capture groups as the built-in matcher): 1 = leading boundary, 2 = replaceable string (trigger + query), 3 = query string used to filter options.
  • New stories with interaction tests:
    • 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:

<EditorInput triggerRegex={ /(^|[\s("])(@(\w{0,75}))$/ } ... />

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 green
  • Build + lint green

Closes brainstormforce/surerank#2600

jaieds added 2 commits August 3, 2026 13:04
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
@socket-security

socket-security Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedpostcss@​8.5.16 ⏵ 8.5.810078 -782 +295100
Updatedtailwind-merge@​3.6.0 ⏵ 2.6.1100 +11008695100
Added@​tailwindcss/​container-queries@​0.1.11001009986100
Updatedtailwindcss@​4.3.2 ⏵ 3.4.1998 -210087 +498100
Addedautoprefixer@​10.4.271001008992100
Addedtailwindcss-scoped-preflight@​3.5.79910010089100

View full report

Comment thread package-lock.json
Comment thread package-lock.json
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 mohitsbsftester left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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.

3 participants