Repository navigation
@emdash-cms/cloudflare@1.7.0
Minor Changes
-
#5109
8a9e11dThanks @ascorbic! - Adds amatchGroupsByoption to the Cloudflare Access adapter soroleMappingcan be keyed by IdP group ID instead of group display name. Some identity providers allow several groups with the same name and let members create groups, so with name matching a group named like a mapped key receives that key's role.Name matching stays the default. If members of your directory can create or rename groups, set
matchGroupsBy: "id"and replace each group-name key with the group'sidas reported by Access:auth: access({ teamDomain: "myteam.cloudflareaccess.com", matchGroupsBy: "id", roleMapping: { "0b5c8e2a-3f1d-4c7e-9a61-2d4f8b7c1e90": 50, }, }),
The
[cf-access] Identity from Accesslog line now includes each group'sidas well as its name. Matching by ID only helps when those differ: some generic SAML and OIDC providers report the group name as itsid, and in that case you should restrict who can create groups in your identity provider instead. GitHub team keys keep the"organization-name/team-name"form with either setting. -
#5152
17401f3Thanks @emdash-autofix! - Fixes scheduled Workers Cache purges by adding the namedEmDashWorkerentrypoint for sites that re-export it as their default Worker export.To enable the fix on an existing site, replace the object-style default export in
src/worker.tswith this re-export:export { EmDashWorker as default, EmDashRoom, EmDashRoomSite, PluginBridge, } from "@emdash-cms/cloudflare/worker";
Sites with custom fetch or scheduled handling should extend
EmDashWorker; see the Cloudflare deployment documentation for thehandleRoomUpgradeandcreateScheduledHandler()delegation points. Custom scheduled handlers must passinvalidateViaDefaultEntrypoint: trueto opt into RPC invalidation. The legacy object default export and directcreateScheduledHandler()usage remain compatible, but scheduled Workers Cache purges requireEmDashWorkeras the site's default.emdash doctorrecognizes the subclass form and adds a migration hint for legacy object-style entrypoints while continuing to accept their scheduler wiring. Cache invalidation from co-editing rooms and the plugin bridge is unchanged. -
#4686
91dfa31Thanks @ascorbic! - Adds editorial comments: threads that staff leave on an entry while reviewing it, separate from the public comments visitors post.A thread points at the whole entry, a field, a Portable Text block, or a range of text in a block, and holds a conversation that can be resolved and reopened. Threads are private to staff and never appear on the site.
In the entry editor, select text in any Portable Text field and choose Comment in the formatting toolbar, or press ⌘⌥M (Ctrl+Alt+M), to start a thread beside it. To comment on an image, embed, divider or other non-text block, choose Comment in its block menu (or, without edit access, select the block and choose Comment in the toolbar above it), and to comment on a whole field, use the comment button at the end of the field's label row. The comment button in the editor bar, just before the settings panel toggle, shows or hides the margin and shows how many threads are open. Commenting needs no edit access: Contributors who can't edit an entry, and anyone viewing an entry while someone else holds its edit lock, can still select text and comment. Commented text stays highlighted as you edit, and a thread whose text was deleted is listed as detached with the text it referred to. Links of the form
?thread=<id>open the editor with that thread selected and its text in view, and Go to text on an open thread selects the text it refers to.The API lives under each entry, at
/_emdash/api/content/{collection}/{id}/threads, with routes to list and start threads, reply, edit and delete comments, resolve and reopen threads, and store anchors after the entry's content changes. Each thread and comment in a response carriescanflags that say what the caller may do with it.Mentions and email
Type
@in a comment to mention someone who can take part in threads. A comment body stores each mention as<@USER_ID>, and every thread in a response lists the users it mentions undermentions, with their current names, so a renamed user shows the new name.GET …/threads/mentionable?q=returns up to 10 people to mention, matched by display name, without email addresses. A new comment, or an edit that adds a mention, fails withVALIDATION_ERRORwhen it mentions a user who doesn't exist or can't take part. Mentions already in a comment don't stop it being edited.When the site has an email provider, a new comment emails the people it mentions, the thread's creator and the authors of its earlier comments that weren't deleted, except its own author, anyone who can no longer take part, and users whose email address isn't verified. Editing a comment to mention someone new emails only that person. The email has the entry's title, an excerpt of the comment and a link to the thread. Without an email provider, nothing is sent, and the comment is still saved. See Comment on an entry for mentions and comment emails.
MCP tools
AI agents can review entries through five MCP tools:
editorial_thread_list,editorial_mentionable_list,editorial_thread_create,editorial_comment_createandeditorial_thread_resolve. A token needs thecontent:readscope foreditorial_thread_listandeditorial_mentionable_list, and thecontent:writescope for the other three.editorial_mentionable_listfinds the user IDs that comment bodies mention as<@USER_ID>. The user behind the token needs theeditorial:commentandcontent:read_draftspermissions for every tool.editorial_thread_createstarts a thread on the whole entry, or on one field when you passfield. To comment on specific text, passfieldand the exactquote, with optionalprefixandsuffixto tell repeated text apart. The tool finds the quote in the entry's current draft. Passingprefixorsuffixwithoutquotefails withVALIDATION_ERROR.Visual editing
Editors can review threads on the site itself. In edit mode, each element bound with
{...entry.edit}or{...entry.edit.field}shows a badge with the number of its open threads; threads on text and blocks in a field count toward that field's badge, and threads on a field the page doesn't show count toward the entry's badge. Hover over or tab to a bound element to show its comment button, which opens a popover where you can reply, resolve a thread you're allowed to resolve, follow Open in admin, and start a new thread on the entry or field.A Portable Text field rendered with
<PortableText>in edit mode gets a badge of its own even when no element around it is bound with{...entry.edit.field}. Its text and block threads are highlighted in the page editor, and clicking a highlight opens a popover next to it with just the threads on that text while the cursor stays in the text, and the field's badge still lists all of them; press ⌘⌥M (Ctrl+Alt+M) in a highlight to move to its reply box instead. To start a thread on text, select it and choose Comment in the formatting toolbar, or press ⌘⌥M (Ctrl+Alt+M). When you edit text that a thread points at, the thread moves with it on the next save. The page editor now keeps each block's_keywhen it saves, instead of giving every block a new one, so links to a block from comments and other content survive edits made on the page.The toolbar loads threads with one request per entry on the page, at most four at a time, and only for signed-in users in edit mode who can take part in threads. The popover's code loads the first time someone opens it, from the editor-only
/_emdash/visual-editing/commentspage, which the site's Astro build bundles with@astrojs/react, as it does the inline editor. Pages for logged-out visitors don't change.Permissions
Two permissions are new in
@emdash-cms/auth. Every editorial route also needscontent:read_drafts.editorial:comment(Contributor and above): read threads, start them, and reply.editorial:manage(Editor and above): resolve, reopen and delete any thread, and delete anyone's comment.
A thread's creator may also resolve and reopen it, and so may the entry's author when they hold
content:edit_own. A creator may delete their own thread until someone else replies, and only a comment's author may edit it. Storing recomputed anchors needs edit access to the entry and its current_rev.New playground sessions open with example threads on the "Building for the Long Term" post, from a demo reviewer, so visitors can reply, resolve and add their own.
Upgrading
A migration adds two tables,
_emdash_editorial_threadsand_emdash_editorial_comments. Threads stay while an entry is in the trash, where their comments and threads can still be deleted but not added, edited, resolved or moved, and are deleted with the entry or its collection. Site transfer leaves them out.
Patch Changes
-
822ac68Thanks @ascorbic! - On sites with an Astrobase, admin and API requests under the base path, such as/blog/_emdash/api/..., now get the same authentication and request checks as the unprefixed paths. This includes the external auth provider, theX-EmDash-Requestheader, the admin Content-Security-Policy, the setup redirect and the write checks that run during a site transfer. Redirect rules, 404 logging and the visual editing toolbar no longer apply to these paths. This also covers a base with spaces or non-ASCII characters, such as/my blogor/über, whose requests arrive percent-encoded.API tokens sent to paths under the base were previously ignored. They are now accepted and scope-checked as on the unprefixed paths.
In
@emdash-cms/cloudflare, preview mode and playground mode now apply their route restrictions to paths under the base, and Hyperdrive no longer serves_emdashreads under the base from the cached binding. -
#5106
db3aa05Thanks @ascorbic! - Fixes the D1 and Durable Object read-replica bookmark cookies (__em_d1_bookmark,__em_do_bookmark) being set on requests that carry anAuthorization: Bearerheader the site never verified. The cookie is now set only for a signed-in session or a token the site has accepted, so a valid token sent to a public page no longer receives one. Requests with a Bearer header are still routed to the primary database. -
#5027
dfe35e4Thanks @emdash-autofix! - Fixes Cloudflare AccessroleMappingignoring GitHub teams and assigningdefaultRoleto new users. Use organization-qualified team names as mapping keys, such as"my-org/Web Admins": 50; bare team names are not matched because users can create identically named teams in other organizations. Teams are matched in the order returned by Access, after any IdP groups. Existing users keep their assigned roles unlesssyncRolesis enabled. -
#5143
628ea8dThanks @Yusaku01! - Fixes the visual editing toolbar and Cloudflare preview toolbar overflowing on narrow screens. Both toolbars now wrap to fit the viewport, keeping the visual editing toolbar's Publish button, close buttons, and long status or error messages visible on mobile and in languages with longer labels. -
#4701
1981c17Thanks @swissky! - Fixes media served through EmDash's media route (R2 or local storage without a public bucket URL) being served as full-size originals in production whensiteUrlisn't set inastro.config.mjsand neitherEMDASH_SITE_URLnorSITE_URLis set at build time, as in the Cloudflare templates. On pages rendered on demand, theImageandGallerycomponents fromemdash/uinow get resized WebP renditions and a responsivesrcsetwithout extra configuration, through the Cloudflare Images binding with the Cloudflare adapter's default image service, or through sharp on Node. Prerendered pages still needsiteUrl,EMDASH_SITE_URLorSITE_URLwhenastro buildruns. These images are served as the original file instead of failing when the Cloudflare Images binding returns an error, for example after the plan's monthly transformations run out, or on Node withoutsharpinstalled. -
#5164
54ee891Thanks @emdash-autofix! - Makesemdash media repair-usagestop safely before exhausting D1's per-request query allowance on Workers Paid, leaving queries available to release write leases and save status. Repair returnsCONTENT_USAGE_QUERY_LIMITand preserves its indexed-source count instead of returning a generic failure. This does not enable large collections to finish: resumable batches are not yet supported, and repeated runs restart at the first entry. Use--jsonand check the returned status rather than treating exit code0as complete coverage. The lower query allowance on Workers Free is not covered by this safeguard. -
770d9c8Thanks @ascorbic! - Updates the plugin bridge for sandboxed plugins on Cloudflare to declare its internal helper methods as JavaScript private (#) members instead of TypeScriptprivate. The bridge methods that plugins call are unchanged. -
Updated dependencies [
7ed8e09,db3aa05,db3aa05,723784e,db3aa05,822ac68,db3aa05,5c9b00d,4dd5dba,69a77ad,8092274,7b97204,ba1eb52,5030c20,17401f3,7e693aa,a853fe3,a0fe5c9,00367c1,a895695,e574cae,c94f442,16cb80f,060e7e7,91dfa31,35d40a3,7ed8e09,0917f1b,628ea8d,3c64f9b,405dbef,5684ca8,4874deb,9369192,a0fe5c9,0c9dd87,736af38,736af38,0f67ed9,1705671,1981c17,ef0e581,246eacf,3f9d7fd,285c949,5e24aa2,31bc35b,a397efc,e2bbd0d,af2abf7,46f8a08,afdf4c3,c5877be,29caf9c,13bedc5,52d7880,54ee891,801bdac,7ed8e09,31625c7,a14daef,83bb981,fe7c634,ff2a923,e4c9baa,4301fcd,302f950,fe34a65,35d40a3,c78cc4b,c78cc4b,390f8b1]:- emdash@1.7.0