/** * The visual-editing toolbar for hosts that serve the public site from * somewhere EmDash's middleware never runs (a static build behind a proxy). * Such a host decides who is an editor and splices the toolbar into the HTML * itself; the pieces are the same ones the middleware uses. */ export { EDIT_PARAM, renderToolbarBootstrap } from "./toolbar-bootstrap.js"; export { renderToolbar, type ToolbarConfig } from "./toolbar.js"; /** Cookie the toolbar's own toggle sets to request an edit-mode render. */ export const EDIT_MODE_COOKIE = "emdash-edit-mode"; /** Users at or above this role see the toolbar (author). */ export const TOOLBAR_MIN_ROLE = 30; /** * Splice `toolbarHtml` in front of ``. Returns the input unchanged when * the document has no body end tag (fragments, non-HTML bodies). */ export function injectToolbarHtml(html: string, toolbarHtml: string): string { const at = html.lastIndexOf(""); return at === -1 ? html : `${html.slice(0, at)}${toolbarHtml}${html.slice(at)}`; } /** Whether a Cookie header carries `name` with the given value. */ export function cookieHas(cookieHeader: string | null, name: string, value: string): boolean { if (!cookieHeader) return false; return cookieHeader.split(";").some((part) => part.trim() === `${name}=${value}`); }