64 Commits

Author SHA1 Message Date
Joost de Valk
12d73ff456 Add OG Image field to content editor (#328)
* Add OG Image field to content editor

The `_emdash_seo` table and content API already support `seo_image`, but
the admin UI had no way to set it. This adds:

- `SeoImageField` component using the existing `MediaPickerModal`
- 2-column grid layout placing the OG Image next to the Featured Image
- `description` prop on `ImageFieldRenderer` for helper text below images
- Preserve `seo.image` in `SeoPanel.emitChange` so sidebar edits don't
  clear the image

Closes #327

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: format

* Add changeset and fix stale seo.image in SeoPanel

- Add changeset for @emdash-cms/admin patch release
- Remove image from SeoPanel.emitChange to avoid overwriting
  a freshly-selected OG image with a stale prop value

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Address review feedback on OG Image field

- Fix #1: Use @phosphor-icons/react instead of lucide-react
- Fix #2: Send minimal patch { image } instead of spreading stale seo props
- Fix #3: Only show OG Image next to the featured_image field, not all image fields
- Fix #4: Only add description text for the featured_image field
- Fix #5: Add responsive breakpoint (grid-cols-1 md:grid-cols-2)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: format

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-07 23:14:54 +01:00
Matt Kane
d6cfc437f2 fix: migration 033 idempotency & smoke test cleanup (#365)
* fix(core): add IF NOT EXISTS to migration 033 index creation

The schema registry's createContentTable() creates composite indexes
on content tables at creation time. When migration 033 runs on a
database where tables were created after the registry added these
indexes, it fails with "index already exists". Adding IF NOT EXISTS
makes the migration idempotent.

* refactor(smoke): trim site matrix to templates + playground, remove typechecks

The smoke test matrix included every demo and template, plus typecheck
cases. This was slow and redundant — typechecks are already covered by
pnpm typecheck, and demos are dev targets not release artifacts.

Trim to templates + playground only, and replace the sequential per-site
astro build with a single recursive pnpm build. Remove the TypecheckSiteCase
type and handling since smoke tests should only verify runtime behavior.

* Update env

* chore: add changeset for migration 033 fix
2026-04-07 22:00:54 +00:00
Benjamin Price
f112ac4819 fix: use stable site hash for install telemetry deduplication (#298)
* fix: use stable site hash for install telemetry deduplication (#297)

generateSiteHash() used Date.now() as the hash seed, producing a different
hash on every call. Since the installs table uses PRIMARY KEY (plugin_id,
site_hash), the same site could insert unlimited rows, inflating install
counts and making "Most Popular" sorting meaningless.

Fix: use the site's request origin as a stable hash seed. The same origin
always produces the same hash, so the marketplace deduplicates correctly.

Also denormalizes install_count on the plugins table to avoid a COUNT(*)
subquery per row in searchPlugins(). The count is recalculated atomically
on each upsertInstall() call.

Fixes #297

* chore: add changeset for install telemetry fix

* fix: address review feedback on install telemetry

- Replace crypto.subtle fallback with FNV-1a hash to avoid origin
  leakage and collisions from truncated seed strings
- Remove duplicate p.install_count from SELECT (p.* already includes it)
- Use explicit p.install_count in ORDER BY clause
- Use db.batch() for atomic upsert + count recomputation instead of
  separate statements with misleading meta.changes check
2026-04-07 22:37:00 +01:00
Matt Kane
91e31fb2ca fix: validate sandbox plugin exports and fix plugin packaging (#363)
* fix(webhook-notifier): add build step and export built files

The webhook-notifier plugin exported raw TypeScript source from its
package.json exports (./sandbox pointed to src/sandbox-entry.ts).
When the Vite plugin resolved this at site build time, it embedded
unbuilt TypeScript into the sandbox module, causing "Unexpected token
'{'" errors at runtime.

Add a tsdown build step (matching sandboxed-test's pattern) and update
the exports map to point to dist/*.mjs.

Fixes #150

* fix(core): reject unbuilt source in sandbox module generator and bundle validator

Add two validation checks to prevent plugins with misconfigured exports
from silently breaking site builds:

1. generateSandboxedPluginsModule() now throws a clear error if a
   sandbox entrypoint resolves to a TypeScript/JSX source file instead
   of pre-built JavaScript. This catches the problem at site build time
   with an actionable message.

2. The `emdash bundle` command now validates that all package.json
   exports point to built files (.js/.mjs), not source (.ts/.tsx/.jsx).
   This catches the misconfiguration at plugin publish time, before
   consumers are affected.

Fixes #150

* chore: add changeset for sandbox source validation

* fix: use slash syntax for e18e rule override in oxlintrc

The test file override for e18e/prefer-static-regex used parenthesis
syntax ("e18e(prefer-static-regex)") which is the diagnostic display
format, not the config format. Changed to slash syntax to match the
top-level rule declarations so the override actually takes effect.

* test: add tests for sandbox source validation

Add tests for both validation checks:

- generateSandboxedPluginsModule: verifies it embeds pre-built JS,
  rejects .ts/.tsx/.mts source files, and includes the plugin ID in
  error messages.

- findSourceExports: verifies it flags .ts/.tsx/.mts/.cts/.jsx exports,
  accepts .mjs/.js exports, and handles conditional export maps.

Also extracts findSourceExports() from the inline bundle.ts validation
into bundle-utils.ts so it can be tested without the CLI harness.

* fix(atproto, audit-log): add build step and export built files

Same issue as webhook-notifier — both plugins exported raw TypeScript
source from their package.json sandbox exports. Add tsdown build steps
and update exports to point to dist/*.mjs.

* refactor(smoke): replace sequential per-site astro builds with recursive pnpm build

The build verification section was running `astro build` individually
and sequentially for every demo and template (~12 sites). Replace with
a single `pnpm run --recursive --filter {./demos/*} --filter
{./templates/*} build` which pnpm parallelizes automatically.
2026-04-07 22:34:35 +01:00
Matt Kane
885df3b3a8 test(smoke): add astro build verification for all demos and templates (#361)
Smoke tests only ran astro dev, which uses Vite's on-demand compilation
and never invokes the adapter build pipeline. Build failures in
cloudflare/playground demos (or any adapter-dependent site) passed CI
undetected. Add a build verification suite that runs astro build for
every site in the matrix before the existing runtime tests.

Bumps smoke test CI timeout from 15 to 30 minutes to accommodate.
2026-04-07 19:07:07 +00:00
Matt ‘TK’ Taylor
5b3e33c26b fix: adds optimize indexes (33) to migration runner (#330)
* fix: adds optimize indexes (33) to migration runner

* chore: add changeset for migration 033 runner registration fix

* test: update migration count assertions for 033_optimize_content_indexes
2026-04-07 11:52:55 +01:00
James Garbutt
a996387de4 test(gutenberg-to-portable-text): add transform tests (#332)
* test(gutenberg-to-portable-text): add transform tests

This adds a bunch of tests, mostly for the transformers but also some
minor edge cases in the inline parser, too.

It also enables `noUnusedLocals` in `tsconfig.json` which caught a
couple of unused things.

* chore: add domain to each

* style: format

* chore: remove some figures

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
2026-04-07 07:36:14 +01:00
Hasan Smadi
dbaf8c6f85 fix(visual-editing): don’t open admin for portableText; simplify starter PT markup (#40)
* fix(visual-editing): PT inline editing; align starter templates

* chore(admin): format router.tsx

---------

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-06 20:10:09 +00:00
Sarah Dayan
ec1e71ec2f fix: adjust user menu button height for avatar content (#77)
Override the fixed h-6.5 from Kumo's sm size with h-auto and py-1 so
the button sizes naturally around the avatar. The sm size is still used
for text size, gap, and border-radius — only the height is overridden,
since this is a usage-specific concern (tall content inside a small
button) rather than a design system issue.

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-06 21:09:12 +01:00
Delowar Hossain
fe74f8a33e Hide preview button unless collection supports preview and content is published (#70)
* Hide preview button unless collection supports preview and content is published

* Remove isPublished check

---------

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-06 21:07:50 +01:00
Doğu Abaris
ab21f29f71 fix(admin): avoid locally caught exception in PasskeyLogin (#268)
* fix(admin): avoid locally caught exception in PasskeyLogin

Why:

The passkey login flow threw an error when navigator.credentials.get()
returned no credential, but that exception was immediately caught by the
local catch block in the same function. This triggered a
"throw of exception caught locally" warning and made the failure path
less direct.

What:

- Handle the missing credential case inline instead of throwing locally
- Preserve the existing error message shown to the user
- Keep the onError callback behavior unchanged

* Add changeset

---------

Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-06 20:05:16 +00:00
Matt Van Horn
b297fdd88d fix: allow public access to search API for frontend LiveSearch (#107)
* fix: allow public access to search and suggest API endpoints

The search and suggest endpoints required search:read permission,
blocking unauthenticated visitors from using the LiveSearch component.
This is safe because the search query layer defaults to status=published,
so public users only see published content.

Fixes #104

* fix: add changeset for public search API access

Patch bump for emdash - allows public access to search API endpoints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Matt Kane <mkane@cloudflare.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 20:01:28 +00:00
jul
71744fb8b2 align back button position in API Tokens section (#306)
* replace link with button for back navigation

* changeset
2026-04-06 20:43:38 +01:00
Flynsarmy
5f448d1035 Add Back navigation to Security and Domain settings pages (#45)
* Add Back navigation to Security and Domain settings pages

* changeset

---------

Co-authored-by: Matt Kane <mkane@cloudflare.com>
Co-authored-by: Matt Kane <m@mk.gg>
2026-04-06 10:46:22 +00:00
Jonah Foster
de251fc039 Fix drag-and-drop reordering for custom fields in content type editor (#108)
Wire up @dnd-kit sortable integration in ContentTypeEditor and connect the existing reorderFields API. The grab handle icon was visual-only with no drag functionality attached.

Closes #43

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-06 07:26:41 +00:00
Benjamin Price
8c693b582d fix: prevent media upload OOM on Workers for large images (#262)
* fix: prevent media upload OOM on Workers via client thumbnails + server safety net

Large image uploads (5MB+) crash Cloudflare Workers (128MB limit) because
generatePlaceholder() decodes entire images to raw RGBA pixels. A 4000x3000
JPEG becomes ~48MB RGBA, exceeding the isolate memory budget.

Two-layer fix:
- Client-side: browser generates a 64px canvas thumbnail for oversized images
  and sends it alongside the upload. Server generates blurhash from the
  thumbnail (~16KB RGBA) instead of decoding the full image.
- Server-side: reads dimensions from image headers via image-size and skips
  placeholder generation when estimated decoded size exceeds 32MB. This covers
  API/CLI uploads that don't provide thumbnails.

* chore: add changeset for media upload OOM fix

* fix: clamp upload thumbnail to 64x64 box for extreme aspect ratios

Naive sizing (thumbW=64, thumbH=(h/w)*64) could produce an enormous canvas
for very tall or very wide images — e.g. a 100x840000 image would allocate
a 64x537600 canvas client-side, reintroducing the memory blowup this feature
exists to prevent.

Extract computeThumbnailSize() that fits the image within a 64x64 box by
scaling against max(width, height), wrap canvas allocation and drawImage
in try/catch with a no-thumbnail fallback, and add unit tests covering
extreme aspect ratios.

---------

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-06 07:14:39 +00:00
all3f0r1
73b71b4e59 fix(admin): apply data-mode attribute for system theme preference (#97)
When theme is "system", ThemeProvider removed the data-mode attribute
from <html>, expecting color-scheme: light dark to handle dark mode.
However, Tailwind dark: utilities are mapped to [data-mode="dark"] via
@custom-variant and do not respond to color-scheme, so dark mode never
activated for system preference users.

Decouple DOM synchronization from the theme preference by syncing
data-mode with resolvedTheme instead. This ensures data-mode is always
set to "light" or "dark" regardless of whether the user chose explicitly
or follows system preference.

Fixes #96

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-06 06:54:37 +00:00
seslly
d2114523a5 fix: passkeys behind TLS reverse proxy (#225)
* fix: passkeys behind TLS reverse proxy

Add passkeyPublicOrigin and wire it through passkey routes so origin/rpId match
the browser when dev runs behind nginx. Expose dev-only /_emdash/api/dev/passkey-url,
add admin messaging for insecure WebAuthn contexts, nginx repro under demos/simple,
and direct kysely dependency for the simple demo Node adapter bundle.

Made-with: Cursor

* docs: add passkeyPublicOrigin to configuration reference

Adds the new passkeyPublicOrigin option and reverse proxy guidance
to the public-facing configuration docs as requested in PR review.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* update tests and more docs

* fix: add missing refresh-server-pat fixture and restore docs heading

---------

Co-authored-by: Joseph Eftekhari <jdeftekhari@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 07:41:07 +01:00
Sarah Dayan
28f98fda4f Fix header user menu button shifting on open (#74)
Base UI's PopoverTrigger injects invisible focus guard <span> elements
as siblings when the popover opens. The space-x-2 utility (which uses
> * + *) applied margin to these spans, causing the button to shift.

Replace space-x-2 with gap-2 which is unaffected by DOM changes.

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-06 07:32:33 +01:00
Matt Kane
5beb0ddc33 refactor: split smoke and integration test configs into separate CI jobs (#264)
* refactor: split smoke and integration test configs into separate CI jobs

* fix: move CLA labeling from triage to CLA workflow

* fix: install formatters in temp dir to avoid catalog: protocol error

* fix: handle 404 when removing labels that don't exist on the PR
2026-04-05 08:22:17 +01:00
Filip Ilić
9d10d2791f fix(admin): use collection urlPattern for preview button fallback URL (#181)
* fix(admin): use collection urlPattern for preview button fallback URL

The preview button hardcoded fallback URLs as /${collection}/${slug},
ignoring the collection's urlPattern setting. Collections with custom
URL patterns (e.g. urlPattern: "/biljke/{slug}" on a "biljka" collection)
would open a 404 instead of the correct page.

Thread urlPattern through the manifest and use it in the ContentEditor
preview fallback.

Fixes #167

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>

* chore: add changeset for preview URL pattern fix

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>

---------

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>
Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-04 19:00:28 +00:00
Justin White
9269759674 fix: magic links missing root prefix (#133)
* Fix magic links

* Include changeset

---------

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-04 19:47:05 +01:00
Matt Kane
8fb4173036 fix: format router.tsx to pass oxfmt check 2026-04-04 16:00:27 +01:00
jul
66beb4da1f fix DOM XSS via unvalidated form redirects (#120)
* implement safe url validation for redirects

added validation for safe redirect urls to prevent xss attacks

* add changeset: fix dom xss in form redirects
(marked as patch version bump for @emdash-cms/plugin-forms)

---------

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-04 15:51:36 +01:00
Mason Hall
036e0fc23a fix(x402): add tsdown config to build middleware entry point (#48)
* fix(x402): add tsdown config to build middleware entry point

* adds optimizeDeps.exclude and ssr.optimizeDeps.exclude for @emdash-cms/x402 in the integration's Vite config

* fix CI typecheck

---------

Co-authored-by: Matt Kane <mkane@cloudflare.com>
2026-04-04 09:03:41 +01:00
Foysal Zihak
018be7f1c3 fix(admin): use infinite scroll for content list to support large dat… (#135)
* fix(admin): use infinite scroll for content list to support large datasets

* chore: apply copilot review suggestions and add changeset
2026-04-04 09:02:57 +01:00
saram ali
e9a6f7ac3c perf(db): optimize D1 indexes to eliminate full table scans (#214)
* perf(db): optimize D1 indexes to eliminate full table scans

- Add composite indexes to ec_* tables for common query patterns
- Replace single-column indexes with (deleted_at, updated_at, id) composite
- Add (deleted_at, status) index for count queries
- Add (deleted_at, created_at, id) index for chronological ordering
- Optimize comment counting with partial indexes per status
- Rewrite countByStatus() to use parallel WHERE queries instead of GROUP BY

Fixes #131

* chore: add changeset for D1 index optimization

* style: wrap changeset description for formatting compliance
2026-04-04 08:17:56 +01:00
Matt Kane
12e0aa71bc feat(cloudflare): add logo branding to playground and preview pages (#202)
- Playground loading: replace "Em<span>Dash</span>" text with inline
  SVG icon mark + "EmDash" wordmark, add favicon
- Preview loading: add favicon
2026-04-03 21:48:13 +00:00
Matt Kane
422018aeb2 feat(admin): add proper EmDash logo branding to admin UI (#200)
Replace placeholder text branding ("— EmDash") with actual logo SVGs
from the brand assets. Adds Logo.tsx with LogoIcon (icon mark) and
LogoLockup (icon + wordmark) components.

- Sidebar: gradient icon mark replaces em dash text character
- Login, Signup, Setup: full lockup SVG with currentColor wordmark
- Welcome modal: logo icon replaces Sparkle placeholder
- Favicon: real gradient icon SVG replaces emoji
2026-04-03 22:23:02 +01:00
Cotton Hou
4f92c63702 fix(auth): secureCompare to reuse constantTimeEqual from @oslojs/crypto (#180) 2026-04-03 20:00:51 +01:00
Matt Kane
953815969a fix(tests): use global hookTimeout for integration test beforeAll hooks (#125)
* fix(tests): remove explicit beforeAll timeouts that override global hookTimeout

Integration tests passed 60s timeouts to beforeAll, overriding the
120s hookTimeout in vitest.smoke.config.ts. On CI the dev server
startup can consume the full 60s, leaving no time for setup + seeding.

Also bumps createTestServer's default waitForServer timeout from 60s
to 90s, leaving 30s margin within the 120s hook budget.

* fix(tests): don't remove shared node_modules symlink during cleanup

Multiple integration test suites run concurrently and share the
fixture/node_modules symlink. When the suite that created it finishes
first, its cleanup deletes the symlink, causing other suites to fail
with MODULE_NOT_FOUND when their server process tries to resolve astro.

The symlink is gitignored so it's safe to leave in place.
2026-04-02 20:33:07 +01:00
Matt Kane
7924d54072 Playground interstitial (#16) 2026-04-02 18:32:52 +01:00
Matt Kane
25a327baf2 fix: set hookTimeout for smoke tests to prevent beforeAll timeouts 2026-04-02 16:30:43 +01:00
Matt Kane
8e28cfc5d6 fix: resolve smoke test failures -- CLI JSON output, port collision, stale DBs 2026-04-02 15:30:36 +01:00
Matt Kane
53329df155 Format 2026-04-01 16:16:45 +01:00
Matt Kane
78019103e0 Fix wrangler.jsonc 2026-04-01 16:12:02 +01:00
Matt Kane
de70c72aa8 fix: set all plugin versions to 0.1.0 (not 1.0.0)
Changesets treats minor on 0.0.x as a major bump per semver convention.
All packages should be 0.1.0 for the first beta release.
2026-04-01 16:10:06 +01:00
github-actions[bot]
2463da9556 ci: release 2026-04-01 15:02:06 +00:00
Matt Kane
c7d2401b8b fix: resolve all lint warnings and fix failing playground toolbar test
- Fix playground-toolbar test: URL changed to github.com but test still expected docs.emdashcms.com
- create-emdash: extract selectTemplate() to eliminate unsafe/unnecessary type assertions
- create-emdash: use type-safe Object.keys filter instead of bare cast
- cloudflare/cache: use Reflect.get with typeof guard instead of double type assertion
- x402/enforcer: replace unsafe request cast with Reflect.get type guards for CF bot management
- x402/middleware: suppress unavoidable virtual module any-cast with eslint comment
2026-04-01 15:35:06 +01:00
Matt Kane
ca398cc3f8 format 2026-04-01 15:25:41 +01:00
Matt Kane
9db4c2cba2 fix(create-emdash): remove manual bootstrap step from CLI output 2026-04-01 15:23:54 +01:00
Matt Kane
bc81ad2280 fix: update database_id in wrangler.jsonc and add README.md 2026-04-01 15:05:11 +01:00
github-actions[bot]
144d7e488a ci: release 2026-04-01 13:28:55 +00:00
Matt Kane
0c6c66fe44 Merge pull request #7 from emdash-cms/fix/create-emdash-spinner
fix(create-emdash): fix spinner hanging during dep install
2026-04-01 14:24:28 +01:00
Matt Kane
025a8973e6 Merge pull request #8 from emdash-cms/fix/fresh-deploy-setup-redirect
fix: redirect to setup wizard on fresh deployments
2026-04-01 14:24:11 +01:00
Matt Kane
3c319ed641 fix: redirect to setup wizard on fresh deployments when public page is first request
On a fresh CF deployment, if the first request hits a public page, the
middleware fast-path skips runtime init. Template helpers like
getSiteSettings() then query an empty database and crash with
'no such table: options'.

Add a one-time setup probe in the middleware fast-path: check if the
migrations table exists, and redirect to the setup wizard if not.
The check is cached for the worker lifetime after first success.

Also includes release workflow update to use GitHub App token and
admin branding changeset.
2026-04-01 14:14:05 +01:00
Matt 'TK' Taylor
0553848b66 Fix playground toolbar link to point to repo 2026-04-01 14:10:30 +01:00
Matt Kane
2022b77341 fix(create-emdash): use async exec so spinner animates during install 2026-04-01 13:45:04 +01:00
github-actions[bot]
90e31e8e43 ci: release 2026-04-01 12:35:38 +00:00
Matt Kane
7877db5032 Format 2026-04-01 13:29:26 +01:00