Skip to content

feat(toolbars): support presets for selection and slash menus - #1224

Open
makhnatkin wants to merge 2 commits into
mainfrom
feat/selection-toolbar-config
Open

feat(toolbars): support presets for selection and slash menus#1224
makhnatkin wants to merge 2 commits into
mainfrom
feat/selection-toolbar-config

Conversation

@makhnatkin

@makhnatkin makhnatkin commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Shared configuration for all toolbars (Closes #1226)

  • Added shared preset configuration for selection and slash toolbars.
  • Deprecated legacy contextual configuration while preserving compatible fallbacks.
  • Preserved command selection and updated open menus when configurations change.
  • Updated customization examples, migration documentation, and regression coverage.

Summary by Sourcery

Configure selection and slash menus through shared toolbar presets while preserving legacy compatibility and reliable dynamic updates.

New Features:

  • Add shared toolbar presets for configuring selection and slash toolbars alongside the main toolbars.
  • Support slash-command aliases and contextual toolbar actions derived from shared preset items.

Bug Fixes:

  • Update open contextual menus when toolbar presets change while preserving the selected command and editor history behavior.
  • Hide contextual menus when configurations are empty, filtered out, unavailable, or otherwise produce no usable actions.

Enhancements:

  • Retain legacy selection and slash configuration options as deprecated fallbacks while giving explicit contextual preset orders precedence.
  • Keep contextual toolbars disabled on mobile and support dynamic preset changes without recreating the editor.

Documentation:

  • Document shared configuration for all six toolbars and provide migration guidance from legacy contextual options.

Tests:

  • Add unit and visual regression coverage for contextual presets, aliases, dynamic updates, fallbacks, conditions, mode switching, and mobile behavior.

@makhnatkin
makhnatkin requested a review from d3m1d0v as a code owner September 10, 2026 12:27
@sourcery-ai

sourcery-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR unifies selection and slash menus with the shared toolbar preset model, deriving contextual configurations from preset items and orders and propagating them through ProseMirror state so open menus update live. It retains legacy extension-option fallbacks, adds slash aliases and filtering behavior, updates built-in presets and documentation, and provides unit and visual regression coverage.

File-Level Changes

Change Details Files
Introduces shared preset-driven configuration for selection and slash contextual toolbars.
  • Adds contextual toolbar items and orders to built-in and demo presets.
  • Converts slash orders into executable, searchable commands and preserves grouped selection toolbar data.
  • Supports aliases, previews, conditions, nested list actions, and contextual component portal defaults.
packages/editor/src/modules/toolbars/presets.ts
packages/editor/src/modules/toolbars/items.tsx
packages/editor/src/modules/toolbars/types.ts
packages/editor/src/bundle/toolbar/utils/toolbarsConfigs.ts
demo/src/stories/presets/presets.ts
Adds runtime contextual toolbar state so view-level preset changes update existing menus without recreating the editor.
  • Stores selection and slash overrides in a ProseMirror plugin state keyed by contextual toolbar configuration.
  • Dispatches preset changes from MarkdownEditorView and clears state during mode/editor teardown.
  • Updates open selection and slash menus, hides them for empty orders, and retains extension-option fallback when orders are omitted.
packages/editor/src/modules/toolbars/contextual.ts
packages/editor/src/bundle/MarkdownEditorView.tsx
packages/editor/src/bundle/wysiwyg-preset.ts
packages/editor/src/extensions/behavior/SelectionContext/index.ts
packages/editor/src/extensions/behavior/SelectionContext/tooltip.tsx
packages/editor/src/extensions/behavior/SelectionContext/TextSelectionTooltip.tsx
packages/editor/src/extensions/behavior/CommandMenu/index.ts
packages/editor/src/extensions/behavior/CommandMenu/handler.ts
Preserves compatibility and documents migration to shared contextual presets.
  • Keeps legacy selectionContext and commandMenu extension options as fallbacks.
  • Adds action names and contextual configuration guidance, including empty orders, aliases, mobile behavior, and required extensions.
  • Updates customization examples to define contextual items and orders through toolbarsPreset.
packages/editor/src/bundle/config/action-names.ts
docs/how-to-customize-toolbars.md
demo/src/stories/presets/Presets.stories.tsx
Adds regression and visual coverage for contextual preset behavior.
  • Verifies built-in parity, slash flattening and filtering, aliases, conditions, and explicit empty orders.
  • Covers live updates, legacy fallback, zero presets, mode switching, mobile disabling, action execution, and popup closure.
packages/editor/src/bundle/toolbar/utils/toolbarsConfigs.test.ts
demo/tests/visual-tests/ContextualToolbars.helpers.tsx
demo/tests/visual-tests/ContextualToolbars.visual.test.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@gravity-ui

gravity-ui Bot commented Sep 10, 2026

Copy link
Copy Markdown

Storybook Deployed

@gravity-ui

gravity-ui Bot commented Sep 10, 2026

Copy link
Copy Markdown

🎭 Playwright Report

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.

Complete toolbar preset migration

1 participant