Skip to content

Feat/002 markdown toolbar actions - #6

Merged
hendrikebbers merged 8 commits into
mainfrom
feat/002-markdown-toolbar-actions
Aug 16, 2026
Merged

Feat/002 markdown toolbar actions#6
hendrikebbers merged 8 commits into
mainfrom
feat/002-markdown-toolbar-actions

Conversation

@hendrikebbers

Copy link
Copy Markdown
Contributor

This pull request implements a breaking change to the MarkdownEditor component: the toolbar is now configurable per usage via a new toolbar prop, and its default set of buttons is reduced to only Bold and Italic. The change is fully documented, covered by tests, and reflected in the specs and README. Existing content is unaffected; only the authoring UI changes.

The most important changes are:

Breaking change: MarkdownEditor toolbar configuration

  • The MarkdownEditor component now accepts a toolbar prop, an ordered allowlist of actions that determines which formatting buttons are shown. The default is reduced to ["bold", "italic"], so Strikethrough and Link buttons are no longer present unless explicitly declared. This is a breaking change for authoring affordance, not for stored content. [1] [2]

Documentation and upgrade guidance

  • Added a comprehensive upgrade guide in docs/upgrade-to-0.11.md describing the breaking change, migration steps, and best practices for configuring the toolbar per field.
  • Updated the README.md to mention the new toolbar prop and its configurability.

Test and spec coverage

  • Extended and refactored tests for the MarkdownEditor to verify toolbar rendering, action execution, accessibility (aria-labels, aria-pressed), and that undeclared constructs still render. [1] [2]
  • Added implementation steps and behavior coverage in specs/002-markdown-toolbar-actions/steps.md, ensuring all scenarios are tested and documented.
  • Updated the spec index and drift log to reflect that the toolbar is now configurable and the spec is complete. [1] [2]

Accessibility improvements

  • Every toolbar button now includes an aria-label and aria-pressed attribute, ensuring full accessibility for screen readers. [1] [2]

Task list creation gating

  • Task-list creation (via shortcut or input rule) is now gated by the presence of "taskList" in the toolbar allowlist; other actions are only gated at the button level. Stored checklists still render and remain editable regardless of toolbar configuration. [1] [2]

These changes ensure that each usage of MarkdownEditor can tailor its toolbar to the needs of the field, improve accessibility, and provide clear upgrade guidance for consumers.

Add a MarkdownToolbarAction union and a toolbar prop (default
["bold", "italic"]) that declares, in order, which actions a usage
offers. The toolbar renders from a single ACTIONS record mapping each
action to icon/label/predicate/command, de-duplicated and order-preserving,
with an aria-label plus title on every icon button and no toolbar element
at all for an empty list. Link keeps its window.prompt flow and contextual
Unlink.

Gate task-list creation on the allowlist in createMarkdownExtensions: the
Mod-Shift-9 shortcut and [ ] input rule open only when "taskList" is
offered and are stripped otherwise. The tight attribute and in-list
editing shortcuts are kept unconditionally so stored lists always
round-trip and stay editable. No schema or MarkdownView changes.

BREAKING CHANGE: the default toolbar drops from Bold/Italic/Strike/Link
to ["bold", "italic"]; usages must declare Strike/Link explicitly.

Refs spec 002-markdown-toolbar-actions
Verify allowedActions drives the gate: creation stays closed (shortcut +
input rule) when taskList is absent, both open when it is present, and a
stored task list stays editable and round-trips regardless. Also fix the
Mod-Shift-9 dispatch (jsdom is non-Mac, so Mod=Ctrl; sending metaKey too
never matched the binding, making the existing 'shortcut does nothing'
test a false pass).

Refs spec 002-markdown-toolbar-actions
…ive toolbar updates

Add component tests for the toolbar: exact/ordered/default/empty/duplicate
rendering, block+list execution reporting Markdown, active-state, the
contextual Unlink appearing and disappearing with the cursor, accessible
names on all 14 buttons, and undeclared constructs still rendering. Add
extension-level tests that marks (Mod-b, **bold**) stay reachable when only
italic is offered, and type-level tests that 'unlink' is not a declarable
action and MarkdownViewProps is unchanged.

Two fixes surfaced by the tests:
- Set shouldRerenderOnTransaction: true so the toolbar's active states and
  contextual Unlink track the cursor; TipTap v3 defaults it to false, which
  would freeze the toolbar as the user moves the caret.
- Stub getClientRects/getBoundingClientRect on Node/Range in the test setup
  so ProseMirror's scrollIntoView does not crash under jsdom (which has no
  layout), plus aria-pressed on toggle buttons for an accessible active state.

Refs spec 002-markdown-toolbar-actions
Document the toolbar default change (Bold/Italic/Strike/Link -> [bold,
italic]) as an agent-executable upgrade prompt, note the taskList creation
gate and the new aria-labels, and mark all implementation steps complete.

Refs spec 002-markdown-toolbar-actions
@hendrikebbers
hendrikebbers merged commit df49aea into main Aug 16, 2026
1 check passed
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.

1 participant