Skip to content

feat(EditorSuggestionMenu): expose suggestion matching options#6234

Merged
benjamincanac merged 10 commits intonuxt:v4from
Archetipo95:feat/editor-suggestion-menu-suggestion-options
Apr 11, 2026
Merged

feat(EditorSuggestionMenu): expose suggestion matching options#6234
benjamincanac merged 10 commits intonuxt:v4from
Archetipo95:feat/editor-suggestion-menu-suggestion-options

Conversation

@Archetipo95
Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #6233

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR exposes TipTap suggestion matching options on UEditorSuggestionMenu so users can customize how trigger characters are matched.

The main change is adding a new optional suggestion?: Partial<SuggestionOptions> prop to UEditorSuggestionMenu and threading it through EditorMenuOptions into the internal TipTap Suggestion(...) configuration.

This allows opt-in use cases such as setting allowedPrefixes: null so a : trigger can open directly after / or letters, instead of only after whitespace.

The implementation preserves existing behavior.

This PR also includes:

  • unit tests for forwarded suggestion options
  • regression coverage for default behavior when suggestion is omitted
  • documentation for the new prop on the EditorSuggestionMenu page
  • a changelog entry

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new optional suggestion prop to suggestion menu components (EditorSuggestionMenu, EditorEmojiMenu, EditorMentionMenu) and to the EditorMenuOptions type, typed as Omit<Partial<SuggestionOptions>, 'pluginKey'|'editor'|'char'|'items'|'command'|'render'>. The composable useEditorMenu merges options.suggestion into the TipTap Suggestion(...) plugin initialization while preserving composable-controlled fields. Documentation pages were updated with examples, and a new Vitest suite verifies option forwarding, precedence rules, and related typings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(EditorSuggestionMenu): expose suggestion matching options' clearly and specifically describes the main change—exposing suggestion matching options on the EditorSuggestionMenu component.
Description check ✅ Passed The description is directly related to the changeset, explaining the new suggestion prop, its purpose, the implementation approach, and additional materials included (tests, documentation, changelog).
Linked Issues check ✅ Passed The PR fully addresses issue #6233 by implementing Option A: adding the suggestion?: Partial prop to expose TipTap matching options, with comprehensive tests and documentation coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue's objectives: adding the suggestion prop to editor menus, documentation updates, and comprehensive test coverage for the new feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/runtime/composables/useEditorMenu.ts`:
- Around line 68-71: The suggestion spread currently allows options.suggestion
to override core fields (pluginKey, editor, char) which can break plugin state;
update the construction around options.suggestion (where suggestion?:
Partial<SuggestionOptions> is used and options.suggestion is spread) so that
pluginKey, editor and char are applied after spreading user options OR
explicitly omit those keys from the spread (i.e., create a sanitizedSuggestion =
{ ...options.suggestion } without pluginKey/editor/char) and then build the
final suggestion object using pluginKeyInstance/pluginKey/editor/char last to
ensure the core values always take precedence.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 709ec4e6-dd63-4a8c-bfb2-910d23119493

📥 Commits

Reviewing files that changed from the base of the PR and between 90a94fb and 5537ad8.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • docs/content/docs/2.components/editor-suggestion-menu.md
  • src/runtime/components/EditorSuggestionMenu.vue
  • src/runtime/composables/useEditorMenu.ts
  • test/composables/useEditorMenu.spec.ts

Comment thread src/runtime/composables/useEditorMenu.ts Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 24, 2026

npm i https://pkg.pr.new/@nuxt/ui@6234

commit: 0105940

Copy link
Copy Markdown
Contributor

@howwohmm howwohmm left a comment

Choose a reason for hiding this comment

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

nice addition — exposing TipTap's suggestion matching options is useful for custom slash commands.

one thing worth watching: the spread order in the suggestion config means options.suggestion could accidentally override pluginKey or editor since it's spread after those positional keys. a consumer passing suggestion: { pluginKey: ... } would silently replace the internal plugin key.

safest fix would be to destructure and omit the dangerous keys before spreading:

const { pluginKey: _pk, editor: _ed, char: _ch, ...safeSuggestion } = options.suggestion || {}

or move pluginKey, editor, and char after the spread so they always win. either way it's a one-line guard against a subtle footgun.

@Archetipo95
Copy link
Copy Markdown
Contributor Author

I pushed the fix!

User provided suggestion options are now applied first, and internal plugin fields are set after, cannot be overridden.
The type is narrowed to exclude internal keys: pluginKey, editor, char, items, command, and render.
Added regression coverage to verify internal key override attempts are ignored.

@benjamincanac benjamincanac changed the title feat(EditorSuggestionMenu): expose TipTap suggestion matching options feat(EditorSuggestionMenu): expose suggestion matching options Apr 11, 2026
Copy link
Copy Markdown
Member

@benjamincanac benjamincanac left a comment

Choose a reason for hiding this comment

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

Thanks! 😊 I've made a few changes to clean the code a bit and allow this suggestion in the two other menus.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/composables/useEditorMenu.spec.ts`:
- Around line 62-69: The helper getSuggestionConfig currently only checks that
suggestionMock.mock.calls has at least one entry; change it to enforce exactly
one call by validating suggestionMock.mock.calls.length === 1 (throw an Error if
length !== 1) before extracting the config, so getSuggestionConfig reliably
fails when Suggestion is called zero or multiple times; keep references to
suggestionMock.mock.calls and the getSuggestionConfig function when making the
change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c84e9a0e-9826-49fe-8376-f22be811c0c2

📥 Commits

Reviewing files that changed from the base of the PR and between 784650f and daff3e7.

📒 Files selected for processing (3)
  • docs/content/docs/2.components/editor-emoji-menu.md
  • docs/content/docs/2.components/editor-mention-menu.md
  • test/composables/useEditorMenu.spec.ts
✅ Files skipped from review due to trivial changes (2)
  • docs/content/docs/2.components/editor-emoji-menu.md
  • docs/content/docs/2.components/editor-mention-menu.md

Comment thread test/composables/useEditorMenu.spec.ts Outdated
@benjamincanac benjamincanac merged commit 4427824 into nuxt:v4 Apr 11, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose TipTap suggestion matching options in UEditorSuggestionMenu (allowedPrefixes, startOfLine, etc.)

3 participants