Description As an Author, I want to add a caption to an image so I can give Readers more context.
Acceptance Criteria
Image captions do not show the Insert Block button.
The slash menu is disabled inside image captions.
Image captions only allow inline rich text only and not blocks.
Recap
Implemented the image-caption restriction so captions remain inline rich text only and no longer expose block-insertion UI or slash commands.
Files touched
frontend/packages/editor/src/inline-add-block-button.tsxfrontend/packages/editor/src/blocknote/core/extensions/SlashMenu/SlashMenuPlugin.tsfrontend/packages/editor/src/blocknote/core/shared/plugins/suggestion/SuggestionPlugin.tsfrontend/packages/editor/src/inline-add-block-button.test.tsxfrontend/packages/editor/src/blocknote/core/__tests__/slash-menu-caption-guards.test.ts
Main objects changed
InlineAddBlockButtonAdded a guard so the floating Insert Block button does not render when selection is inside an image caption.
isSlashMenuEnabledAdded as a shared helper in
SlashMenuPlugin.tsto centralize whether slash commands are allowed in the current selection context.
SlashMenuProsemirrorPluginWired the new guard into slash-menu activation so
/does not open the menu inside image captions.
setupSuggestionsMenuExtended with an optional
isEnabledcontext guard.Prevents activation in blocked contexts and closes the menu if selection moves into one.
Behavior delivered
Image captions do not show the Insert Block button.
The slash menu is disabled inside image captions.
Captions stay inline rich text only; no schema rewrite was introduced.
Tests added
inline-add-block-button.test.tsxVerifies the button appears in a normal empty paragraph.
Verifies the button is hidden inside an image caption.
slash-menu-caption-guards.test.tsVerifies slash menu works in normal paragraphs.
Verifies slash menu is blocked inside image captions.
Verifies an active slash menu closes when selection moves into a caption.
Notes
No schema/content-model change was made.
Existing plain-text caption behavior was preserved.
Full local validation was blocked in this environment because frontend dependencies were not installed.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime