Skip to content

fix(editor): polish code block controls - #2603

Merged
khoinguyenpham04 merged 23 commits into
codex/issue-2361-code-block-specfrom
codex/issue-2361-code-block-polish
Aug 27, 2026
Merged

fix(editor): polish code block controls#2603
khoinguyenpham04 merged 23 commits into
codex/issue-2361-code-block-specfrom
codex/issue-2361-code-block-polish

Conversation

@khoinguyenpham04

@khoinguyenpham04 khoinguyenpham04 commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds matching language selection and one-click copy actions to code blocks in the admin and inline visual editors. The controls stay compact on narrow screens and in right-to-left layouts. Copy feedback is smoother, and the inline language picker reports the selected language correctly.

This is the top pull request in native stack #2607, stacked on #2606.

Relates to #2361

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes — verified for the affected admin and core packages
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). No new strings are introduced.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package) — .changeset/quiet-code-block-actions.md; the stacked base's .changeset/bright-code-blocks.md covers syntax highlighting only
  • New features link to an approved Discussion: N/A — this is a bug-fix follow-up

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: OpenAI GPT-5.6 Codex, reviewed with GPT-5.6 Terra xhigh

Screenshots / test output

  • Type-aware lint passed.
  • Admin and core typechecks and builds passed.
  • Admin editor tests: 86 passed.
  • Core inline code-block tests: 5 passed.
  • Focused Playwright coverage: 8 passed.
  • Changeset validation passed.
  • Browser-verified both editors at desktop and narrow widths in left-to-right and right-to-left layouts.

@changeset-bot

changeset-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f78bc1b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 22, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-do 0155696 Aug 26 2026, 02:00 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 22, 2026

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://codex-issue-2361-code-block-polish.try.emdashcms.com, https://codex-issue-2361-code-block-polish-emdash-playground.emdash-cms.workers.dev (commit f78bc1b)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://350b3a02.try.emdashcms.com, https://350b3a02-emdash-playground.emdash-cms.workers.dev f78bc1b 2026-08-27T16:53:09.512Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ea8a02a9.try.emdashcms.com, https://ea8a02a9-emdash-playground.emdash-cms.workers.dev 8e76ead 2026-08-27T15:23:24.847Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ef025616.try.emdashcms.com, https://ef025616-emdash-playground.emdash-cms.workers.dev 0155696 2026-08-26T14:12:55.583Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://d614e140.try.emdashcms.com, https://d614e140-emdash-playground.emdash-cms.workers.dev 685ca9d 2026-08-26T10:54:25.983Z Visit the dashboard ↗
  • Build: Failed ❌

View logs ↗
302dc32 2026-08-26T10:12:20.579Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://1244249d.try.emdashcms.com, https://1244249d-emdash-playground.emdash-cms.workers.dev cc22676 2026-08-25T15:57:32.527Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://333c0ee9.try.emdashcms.com, https://333c0ee9-emdash-playground.emdash-cms.workers.dev 72cd8df 2026-08-24T09:22:28.457Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://8a165ac4.try.emdashcms.com, https://8a165ac4-emdash-playground.emdash-cms.workers.dev 02d2b64 2026-08-23T21:47:42.247Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://18164d69.try.emdashcms.com, https://18164d69-emdash-playground.emdash-cms.workers.dev 0ec09c7 2026-08-23T21:15:52.950Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ecbd768e.try.emdashcms.com, https://ecbd768e-emdash-playground.emdash-cms.workers.dev b340a7b 2026-08-23T08:41:11.383Z Visit the dashboard ↗

View all previews: View all previews ↗

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 22, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 0155696 Aug 26 2026, 02:00 PM

@khoinguyenpham04
khoinguyenpham04 changed the base branch from codex/issue-2361-code-block-controls to codex/issue-2361-code-block-spec August 22, 2026 22:51
@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@github-actions github-actions Bot added size/XL and removed size/M labels Aug 23, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/admin@2603

@emdash-cms/auth

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/auth@2603

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/auth-atproto@2603

@emdash-cms/blocks

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/blocks@2603

@emdash-cms/cloudflare

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/cloudflare@2603

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/contentful-to-portable-text@2603

emdash

npm i https://pkg.pr.new/emdash-cms/emdash@2603

create-emdash

npm i https://pkg.pr.new/emdash-cms/emdash/create-emdash@2603

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/gutenberg-to-portable-text@2603

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-cli@2603

@emdash-cms/plugin-types

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-types@2603

@emdash-cms/registry-client

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-client@2603

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-lexicons@2603

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-moderation@2603

@emdash-cms/registry-verification

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-verification@2603

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/sandbox-workerd@2603

@emdash-cms/x402

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/x402@2603

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-ai-moderation@2603

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-atproto@2603

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-audit-log@2603

@emdash-cms/plugin-color

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-color@2603

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-embeds@2603

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-field-kit@2603

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-forms@2603

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-webhook-notifier@2603

commit: f78bc1b

@khoinguyenpham04
khoinguyenpham04 marked this pull request as ready for review August 23, 2026 10:19
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Aug 23, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a sensible polish follow-up: it unifies language + copy controls across the admin and inline visual editors, smooths the copied feedback, and adds focused regression coverage for aliases, free-form languages, cancel behavior, and the RTL/narrow-viewport layout. The implementation is mostly aligned with EmDash conventions (Lingui in admin, RTL-safe logical CSS in both surfaces, clipboard-fallback guard for the inline blur-save path).

I did not run tests or lint; this is a static read of the diff and changed files.

Two items should be addressed before merge:

  1. Accessibility regression: the new CSS-only show/hide for code-block controls only uses opacity: 0 and pointer-events: none. Unlike the previous implementation, which removed hidden chips from the tab order with tabIndex={chipVisible ? 0 : -1} / tabIndex={chipPersistent ? 0 : -1}, the new toolbar buttons remain focusable while completely invisible. Keyboard users can tab into controls they cannot see. Add visibility: hidden in the hidden state and visibility: visible in the shown state (with a delayed visibility transition so the opacity fade-out finishes first).

  2. Changeset duplication with the stacked base: the PR description says this change is already covered by .changeset/gentle-code-block-controls.md in the stacked base, but the diff adds a new .changeset/quiet-code-block-actions.md whose prose also describes adding language/copy controls. If both land, the CHANGELOG will contain two nearly identical entries. Remove the new changeset or rewrite it to describe the specific polish/fix (compact responsive layout, copied feedback, inline language-picker semantics, RTL/narrow-viewport fixes) rather than the feature addition itself.

Comment thread packages/admin/src/styles.css
Comment thread packages/core/src/components/InlinePortableTextEditor.tsx
Comment thread .changeset/quiet-code-block-actions.md Outdated
@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond review/needs-rereview Author pushed changes since the last review and removed review/needs-review No maintainer or bot review yet review/awaiting-author Reviewed; waiting on the author to respond labels Aug 23, 2026
@khoinguyenpham04 khoinguyenpham04 added the bot:review Trigger an emdashbot code review on this PR label Aug 23, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the right polish follow-up to the stacked code-block work. It unifies the language picker and copy action across the admin and inline visual editors, tightens the responsive layout, smooths the copied-feedback lifecycle, and adds focused regression coverage for aliases, free-form languages, cancel behavior, and the no-save-on-copy path. It stays aligned with EmDash conventions: admin strings go through Lingui, both surfaces use RTL-safe logical properties, and the inline clipboard fallback is guarded so it does not trigger a blur-save.

This is a re-review of #2603. My previous review raised two items:

  1. Accessibility of hidden controls: I previously asked for visibility: hidden to remove hidden toolbar buttons from the tab order. The author did not add it, and the new E2E specs instead verify that keyboard focus reveals the toolbar via :focus-within. That makes the hidden-but-focusable state an intentional “show on focus” pattern rather than a clear regression, and using visibility: hidden on the container would actually prevent :focus-within from matching. I am not treating this as a blocker again.

  2. Changeset duplication: Still unresolved — the new .changeset/quiet-code-block-actions.md duplicates the capability described in the stacked base changeset, which the PR description says already covers this work. See the file comment below.

I did not run tests, lint, or typecheck; this is a static read of the diff and changed files. One documentation issue remains.

Comment thread .changeset/quiet-code-block-actions.md Outdated
@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Aug 23, 2026
@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond review/needs-rereview Author pushed changes since the last review and removed review/needs-rereview Author pushed changes since the last review review/awaiting-author Reviewed; waiting on the author to respond labels Aug 23, 2026
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/approved Approved; no new commits since labels Aug 27, 2026
@khoinguyenpham04
khoinguyenpham04 force-pushed the codex/issue-2361-code-block-polish branch from 8e76ead to f78bc1b Compare August 27, 2026 16:46
@khoinguyenpham04
khoinguyenpham04 merged commit f5e18d8 into main Aug 27, 2026
60 of 87 checks passed
@khoinguyenpham04
khoinguyenpham04 deleted the codex/issue-2361-code-block-polish branch August 27, 2026 20:12
@emdashbot emdashbot Bot mentioned this pull request Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants