Add Insert HTML toolbar button to PortableTextEditor - #1440
Conversation
🦋 Changeset detectedLatest commit: 543a3c3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
All contributors have signed the CLA ✍️ ✅ |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
Approach judgment: This is the right change. The PR exposes the existing htmlBlock insertion capability (previously only discoverable via the /html slash command) through a visible toolbar button. This directly addresses issue #1341, follows the established pattern of other insertion buttons (Image, Horizontal Rule), and is purely additive with no breaking changes.
Implementation: The button reuses the exact same insertContent call as the slash command, uses the already-imported BracketsAngle icon, and wraps the label with Lingui's t macro. The title prop feeds the required aria-label, and onMouseDown prevents focus theft from the editor — all consistent with sibling buttons.
What I checked:
- Logic and edge cases: no off-by-one, null, or state issues. The insertion chain matches the existing slash-command path.
- Accessibility: the button carries a proper
aria-labeland is discoverable viagetByRole("button", { name: "Insert HTML" }). - AGENTS.md conventions: Lingui wrapping is present, no raw directional Tailwind classes, no SQL/API/cache concerns (this is a UI-only change), and a changeset is included.
- Tests: a functional test is added, but it is misplaced in the test file (see finding below).
The author left the pnpm typecheck checkbox unchecked; they note running the filtered admin-package typecheck locally. I did not verify this statically.
|
I have read the CLA Document and I hereby sign the CLA |
37f335b to
543a3c3
Compare
What does this PR do?
Adds a visible
Insert HTMLtoolbar button to the WYSIWYG Portable Text editor. This exposes the existinghtmlBlockinsertion path that was previously only discoverable through the/htmlslash command.Closes #1341
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output
Verified locally:
pnpm lint:json | jq '.diagnostics | length'->0pnpm lint:quickpnpm --filter @emdash-cms/admin typecheckpnpm exec vitest run tests/editor/toolbar.test.tsx->47 passedpnpm exec vitest runinpackages/admin->79 files passed,997 tests passedFormatting was run on touched files:
pnpm exec oxfmt --ignore-path .gitignore packages/admin/src/components/PortableTextEditor.tsx packages/admin/tests/editor/toolbar.test.tsxpnpm exec prettier --write .changeset/html-block-toolbar.md