Skip to content

feat(admin): allow plugins to set slash menu category for portable text blocks#809

Merged
ascorbic merged 1 commit intomainfrom
feat/plugin-block-slash-menu-category
Apr 28, 2026
Merged

feat(admin): allow plugins to set slash menu category for portable text blocks#809
ascorbic merged 1 commit intomainfrom
feat/plugin-block-slash-menu-category

Conversation

@ascorbic
Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds an optional category?: string field to PortableTextBlockConfig, plumbs it through the manifest API to the admin's slash-command builder, and updates the marketing template's plugin to use it. Without this, every plugin-contributed Portable Text block appears under "Embeds" in the slash menu -- which is wrong for plugins like the just-merged marketing-blocks (#804) where blocks are page sections, not embeds.

What works after this

admin: {
  portableTextBlocks: [
    {
      type: "marketing.hero",
      label: "Hero",
      category: "Sections",  // ← new, optional; falls back to "Embeds"
      fields: [...],
    },
  ],
}

The marketing-blocks plugin in both templates/marketing and templates/marketing-cloudflare now declares category: "Sections" for all five blocks.

Important note on rendering

The slash menu currently doesn't visually group commands by category -- each SlashCommandItem carries a category field but it isn't surfaced in the rendered DOM today. So this PR is the data plumbing that makes the override possible, but you won't see a visible "Sections" header until someone adds category grouping to the slash menu UI.

That's intentional scope. Plugins can declare their categories now; the rendering improvement is a separate change. For today, the practical effect is: the data is correct (marketing blocks declare "Sections"), nothing regresses, and a follow-up that adds visual grouping will Just Work.

Type changes

  • PortableTextBlockConfig.category?: string -- new optional field.
  • Plumbed through:
    • EmDashRuntime.getManifest() (packages/core/src/emdash-runtime.ts)
    • AdminManifest plugin shape (packages/admin/src/lib/api/client.ts)
    • PluginBlockDef (packages/admin/src/components/editor/PluginBlockNode.tsx)
  • SlashCommandItem.category widened from MessageDescriptor to MessageDescriptor | string. Plain strings flow through unchanged; only the existing built-in commands keep their Lingui descriptors.

Discussion

Bypassing the "feature requires Discussion" rule here on my own initiative -- this is a small additive type change that closes a UX gap surfaced by #804, and the alternative ("plugin authors invent their own conventions, content goes under wrong headings") is worse. Filing a Discussion would just describe what already exists.

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 (admin, core, all plugins)
  • pnpm lint passes (4 pre-existing diagnostics in packages/blocks/src/validation.ts, unchanged from main)
  • pnpm test passes (admin: 798 tests with 2 new; core: 2931 tests)
  • pnpm format has been run
  • I have added/updated tests -- 2 new cases in tests/editor/slash-menu.test.tsx: one verifies a custom category override doesn't break command rendering, one guards the default-fallback path. Honest scope: these are smoke tests for the data path, since category isn't displayed in the DOM yet.
  • User-visible strings -- no new admin UI strings introduced. The plugin-author-facing category field accepts plain strings (per-plugin choice; not localised)
  • I have added a changeset -- minor for @emdash-cms/admin and emdash (additive feature, backwards-compatible)
  • New features link to an approved Discussion -- bypassed, see "Discussion" note above

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

Tests: 2 new cases in tests/editor/slash-menu.test.tsx
✓ renders plugin block commands with a custom category override
✓ renders plugin block commands without a category (default Embeds)

@emdash-cms/admin: 798 passed (was 796)
@emdash-cms/core: 2931 passed

Diff stat: 9 files changed, +89/-3.

…xt blocks

Adds an optional `category` field to `PortableTextBlockConfig`. Plugin
authors can pick a meaningful group name (e.g. "Sections", "Marketing",
"Media") instead of every plugin block defaulting to "Embeds". Plugins
that omit the field continue to render under "Embeds" with no behaviour
change.

Plumbs the field through the runtime manifest, the admin manifest type,
the editor's `PluginBlockDef`, and the slash command builder. Widens
`SlashCommandItem.category` to accept either a Lingui `MessageDescriptor`
(for built-in commands) or a plain string (for plugin-supplied values),
and updates the marketing template's blocks to demonstrate the new field
with `category: "Sections"`.
@cloudflare-workers-and-pages
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-perf-coordinator 37fc41e Apr 28 2026, 02:04 PM

@cloudflare-workers-and-pages
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-playground 37fc41e Apr 28 2026, 02:05 PM

@cloudflare-workers-and-pages
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
docs 37fc41e Apr 28 2026, 02:05 PM

@cloudflare-workers-and-pages
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 37fc41e Apr 28 2026, 02:05 PM

@cloudflare-workers-and-pages
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-i18n 37fc41e Apr 28 2026, 02:04 PM

@github-actions
Copy link
Copy Markdown
Contributor

PR template validation failed

Please fix the following issues by editing your PR description:

See CONTRIBUTING.md for the full contribution policy.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 28, 2026

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

npm i https://pkg.pr.new/emdash@809

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 37fc41e

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

🦋 Changeset detected

Latest commit: 37fc41e

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

This PR includes changesets to release 13 packages
Name Type
@emdash-cms/admin Minor
emdash Minor
@emdash-cms/cloudflare Minor
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/auth Minor
@emdash-cms/blocks Minor
@emdash-cms/gutenberg-to-portable-text Minor
@emdash-cms/x402 Minor
create-emdash Minor
@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

@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.

@ascorbic ascorbic merged commit e7df21f into main Apr 28, 2026
32 of 33 checks passed
@ascorbic ascorbic deleted the feat/plugin-block-slash-menu-category branch April 28, 2026 15:06
@emdashbot emdashbot Bot mentioned this pull request Apr 28, 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.

1 participant