import { FrameGeometry, FrameGeometryError, FrameInset, Point, Rect, frameContentOrigin, pointToCanvas, pointToHost, rectToHost } from "./geometry.js"; import { a as BuilderOp, c as OpPosition, o as NodePatch, r as AppliedOp, s as OpError, u as applyOp } from "./prop-label-DvFnzMno.js"; import { A as readZoom, D as MAX_ZOOM, E as FIT_ZOOM, M as writeZoom, O as MIN_ZOOM, T as CanvasZoom, _ as browserStore, a as LEFT_PANELS, c as MIN_CANVAS_WIDTH, f as PANEL_BOUNDS, g as ShellPreferences, i as DEFAULT_PREFERENCES, j as steppedZoom, k as ZOOM_STEPS, l as MIN_SHELL_WIDTH, m as RAIL_WIDTH, o as LeftPanel, p as PreferenceStore } from "./shell-state-cTWI_x2H.js"; import { AnyBlockDefinition, Binding, BlockDocument, BlockNode, BreakpointId, BreakpointSet, ComponentDocument, ComponentLookup, DefinitionsById, DocumentLimits, ExposedPropertyType, ExposedValueSource, LocatedLockBreak, NamedClass, NestingSource, NestingVerdict, NodeStyles, OverrideValue, PlacedNode, PlacementRefusal, PlacementRefused, PlacementSources, PlacementTarget, PlacementTarget as PlacementTarget$1, PlacementVerdict, PlanProblem, PlanRefusal, PropSchema, RegionArea, SiteTokenSet, SlotDefaultSource, StyleLeaf, StyleOrigin, StyleProperty, StyleShape, StyleState, StyleSubject, StyleTraceEntry, StyleUnionVariantOptions, StyleValue, ValidationIssue, registryBlockSource } from "@nextlyhq/blocks-engine"; import { PageReadReport } from "@nextlyhq/blocks-react"; import * as React from "react"; /** * How far a frame's content viewport sits inside its border box. * * Border plus padding, in the frame's own untransformed CSS pixels — which is * what {@link FrameInset} means and what `frameContentOrigin` scales. * * `clientLeft`/`clientTop` report the border alone. Padding comes from the * computed style because there is no element property that carries it, and a * non-pixel value (a percentage, `auto`) resolves to pixels there too. */ export declare function frameInsetOf(frame: HTMLIFrameElement): FrameInset; /** * Whether a value is an HTML element, from any realm. * * By namespace, because that is what decides the interface: an element in the * HTML namespace is an `HTMLElement`, and an `` or MathML element is not, * however it is spelled. `focus`, `offsetWidth` and `isContentEditable` are on * this interface, so it is the question to ask before reaching for them. */ export declare function isHTMLElement(value: unknown): value is HTMLElement; /** * The element that has focus, looking inside a focused same-origin iframe. * * `document.activeElement` read from the host reports the IFRAME while focus * is on something inside it, so a question about what the author is typing in * — a field, a contenteditable passage — has to be asked of the frame's own * document. This follows focus down through each focused frame whose document * the host can read; a cross-origin frame has no readable document and is * where the walk stops. * * A frame whose document has nothing focused — its `activeElement` is its body * or nothing — answers with the iframe element itself. That is what holds focus * from the host's side, and it is the element focus can be put back on: a * frame's body takes no focus of its own. * * Not the answer to "is focus inside this container" for a container in the * host. The innermost element belongs to the frame's document, which no host * element contains, while the iframe the host reports is contained by the * region that renders it — so those checks read `activeElement` directly. */ export declare function deepActiveElement(doc: Document): Element | null; /** One thing that failed, in the words an author reads. */ interface BuilderNotice { /** Identity for the list, and what dismissing addresses. */ readonly id: string; /** The sentence shown. Already written for an author, not a log line. */ readonly message: string; } /** Raise a notice. Returns nothing: nobody waits on a report. */ type RaiseNotice = (message: string) => void; /** What the shell holds so a notice outlives the control that raised it. */ interface NoticeQueue { readonly notices: readonly BuilderNotice[]; readonly raise: RaiseNotice; readonly dismiss: (id: string) => void; } /** * Which part of a panel is showing, for a panel with parts — the Design * panel's tabs. The shell keeps it with the other preferences, so the tab an * author left open is the one they come back to; what the names mean is the * host's business. */ interface PanelView { /** The part last chosen, or null for the panel's own default. */ current: string | null; choose: (view: string) => void; } /** What the shell hands the host's Settings dialog. */ interface SettingsDialogState { open: boolean; onOpenChange: (open: boolean) => void; /** The control focus returns to when the dialog closes: the rail's item. */ returnFocus: () => HTMLElement | null; } interface BuilderShellProps { /** Rendered inside the switched left panel. Keyed by the panel that is open. */ renderPanel?: (panel: LeftPanel, view: PanelView) => React.ReactNode; /** * Settings, as a dialog the host draws and the rail's Settings item opens. * * A dialog rather than a panel: it holds the page's and the site's * configuration, which an author visits and leaves, and a panel would take * the canvas's room for it. The shell owns whether it is open, as it owns * Help's, so the rail shows it pressed and the editor giving way to the * narrow-window notice closes it. With this given, `settings` is never a * left panel. */ renderSettings?: (dialog: SettingsDialogState) => React.ReactNode; /** * Opens the host's Settings dialog from outside the rail, as * `openPanelRequest` opens a panel: a page's "Settings" in a list the host * draws, say. Applied once per `count`, so a host re-rendering with the same * request does not reopen a dialog the author has closed. Ignored without * `renderSettings`. */ openSettingsRequest?: { readonly count: number; }; /** * The host's notice queue, when the host raises notices of its own. * * The shell owns a queue and renders the region for it, and provides its * `raise` to everything it renders — but a host sits ABOVE the shell, and * an editor it builds there (the apply that refuses an edit for room, say) * has no way to reach that sink. Handed the host's queue, the shell renders * and provides THAT one, so a sentence raised above the shell and one raised * inside it land in the same region. Absent, the shell's own queue serves. */ notices?: NoticeQueue; /** * Which panels the host can actually fill. * * The rail offers only these. A panel outside the list has no item at all * rather than a disabled one: an item that does nothing teaches an author * that the rail is unreliable, and opening a panel nothing renders into would * reserve room and shrink the canvas to display nothing. Omit the prop * entirely and every panel is treated as available, which keeps a host that * fills all of them from having to enumerate them. * * Derived from what the host can render rather than declared twice: pass the * same set `renderPanel` returns content for, and the rail cannot disagree with * the panel body. */ availablePanels?: readonly LeftPanel[]; /** * Opens a panel from OUTSIDE the shell, once per distinct count. * * The rail is normally the only way to change which panel is open, and its * own click handler is a TOGGLE — pressing an already-open panel's item * closes it. A control drawn on the canvas itself (the empty-container * appender) needs the opposite contract: pressing it must show the insert * panel whether or not it is already open, and pressing it again for a * DIFFERENT empty container must show it again even if the author closed it * by hand in between. * * A plain boolean or a bare panel name cannot express "again" — the second * press would carry the same value as the first, and an effect keyed on it * would never re-run. A counter the caller bumps on every press is the same * shape {@link PreferencesLoad.count} below has: not the state itself, but a * count of how many times the thing behind it happened. * * The panel travels WITH the count rather than in a second prop. One caller * asking for Add and another for Design's variables are the same request * with a different subject, and two props would be two answers to one * question — free to disagree about which panel a given count refers to. * The view travels with them for the same reason; absent, the panel opens * on whichever part the author last chose. * * Left `undefined` this does nothing, which is what every host that has no * such control gets by default. */ openPanelRequest?: { readonly panel: LeftPanel; readonly view?: string; readonly count: number; /** * Asked by the editor rather than by the author: the Add panel an empty * page opens on. It shows in the left side, but a left side the author * hid themselves stays hidden. */ readonly unlessHidden?: boolean; }; /** * Reports the canvas zoom, and takes the change back. * * The shell owns it because the shell owns preferences, and a host owns what * to DO with it — the canvas is the host's to render, so only it can apply a * scale. Reported on every value, including the first, so a host never has * to assume the default. */ onZoomChange?: (zoom: CanvasZoom) => void; /** * Asks the shell to edit at a breakpoint: an id from the site's breakpoints, * or null for the base one. * * A count travels with it for the reason `openPanelRequest` carries one: the * same device asked for twice is two requests, and a value that repeated * itself would look unchanged. The shell stores the choice with the author's * other preferences and, when it is a different device from the one being * edited, puts the zoom back to fitting, since a zoom chosen for one width * rarely suits another. */ editingBreakpointRequest?: { readonly breakpoint: string | null; readonly count: number; }; /** * Reports the breakpoint being edited, including the one restored on load * and the base one (null) a new author starts on. * * The host draws the canvas at that breakpoint's width and sends edits to * it. It is the author's choice alone: nothing the shell does to the layout, * opening a panel or a narrower window, changes it. */ onEditingBreakpointChange?: (breakpoint: string | null) => void; /** * The scale the canvas is actually painting at, for the zoom control. * * Travels UP because only the canvas can know it — while fitting it is * derived from a region the canvas measures — and the canvas is the host's to * render. The zoom itself travels DOWN, because this shell owns preferences * and therefore owns the choice. * * One direction each is the whole design. Holding the zoom on both sides and * syncing them is what produced an oscillating write of `fit, 2, fit, 2` on * every open: two owners, each correcting the other. */ appliedScale?: number; /** The canvas. The shell never looks inside it. */ children?: React.ReactNode; /** The inspector's contents. */ inspector?: React.ReactNode; /** * The document's title, shown read-only at the start of the top bar and cut * short with its full text in a tooltip when the bar is narrow. */ title?: string; /** The top bar's start column, after the exit button and the title. */ topBar?: React.ReactNode; /** * The top bar's centre column, before the zoom: the device buttons. Centred * between two equal side columns, so it stays in the middle of the editor * whatever the sides hold. */ topBarCenter?: React.ReactNode; /** The top bar's end column, after the side-panel buttons: the actions. */ topBarEnd?: React.ReactNode; /** The ancestor breadcrumb, along the bottom bar. */ breadcrumb?: React.ReactNode; /** * A card floated over the canvas — the getting-started checklist today. * * Positioned by the shell rather than passed through `Canvas.overlay`, * because that overlay lives in the canvas's own content coordinates and * would scroll away with the page. This one belongs to the editor's chrome * and stays where it is put. */ checklist?: React.ReactNode; /** * A strip pinned along the top of the canvas, above the page and outside * the region that scrolls it, so it stays in view while the page scrolls * under it: what the canvas is drawn with, where that is the author's to * choose (the entry a template is previewed with). Absent, or a node that * draws nothing (`null`, `false`), the canvas keeps the whole region, so * conditional JSX never leaves an empty band. * * @experimental Settles when collection templates ship. */ canvasStrip?: React.ReactNode; /** * Leaving the editor. Explicit and LABELLED, never an unmarked X: the author * is one click from losing a canvas full of work, and an ambiguous glyph is * how that happens. * * **Optional, because not every host has a destination.** The editor mounts * both as a standalone view, where leaving means navigating away from unsaved * canvas state, and EMBEDDED as a field inside an entry form, where there is * nowhere to go — the form is already on screen around it. Omitting this * renders no exit affordance anywhere, including in the narrow-viewport * notice, whose escape sentence travels with the button. * * The handler IS the capability rather than a mode flag beside it, so the * control cannot exist without something to do. A `standalone` boolean would * be a second thing to keep in sync, and the state where the two disagree * would be representable. */ onExit?: () => void; /** * What the exit is called: its accessible name and tooltip, and the narrow * notice's button. "Exit editor" when absent, which is right where leaving * returns to the document that opened the editor. A host whose exit goes * somewhere else names that place ("Back to Pages"), so the arrow says where * it goes rather than claiming a return it doesn't make. Read only with * `onExit`. */ exitLabel?: string; /** * Where chrome preferences live. Defaults to `localStorage` in a browser and * to a store that remembers nothing anywhere else, so a server render is a * default rather than a crash. * * **Pass a NEW object whenever the data behind it changes** — a different * signed-in user, a different workspace. The shell reloads preferences when * this identity changes, and cannot see a store that quietly starts reading * somewhere else: it would go on showing the previous user's panel widths and * write their preferences into the new target. * * This is the same contract React puts on any value it compares by identity, * and it keeps the port at two methods. The alternative — a subscription or a * revision token — is a third method every host has to implement correctly * for a case that a new object already solves. */ store?: PreferenceStore; className?: string; } /** * What the panel needs to offer a block's custom CSS: given only to someone * who may change the site's settings, the permission site code is held to. * Without it the panel draws no Custom CSS section and never shows the CSS. * * @experimental Settles with custom CSS. */ interface BlockCustomCssAccess { /** * Checks a block's CSS as the server will: every line that can't be used, * each worded for the author with its line ("Line 3: …"), in line * order; none when it may be stored. */ readonly check: (css: string) => readonly string[]; } /** * One entry in the palette. * * `id` rather than the label as the identity, because labels are user-facing text that gets * reworded, and a React key that changes on a copy edit remounts the row and drops its state. * * @experimental */ interface BuilderCommand { /** * Stable across renames, and UNIQUE across the assembled list. * * Uniqueness is required rather than merely expected: it is the React key and cmdk's selection * identity, and two rows sharing it are both marked selected, with Enter running the first * whichever the user chose. A host that concatenates registries is where this happens. */ id: string; /** What the user reads. */ label: string; /** Heading this command is listed under. Ungrouped commands are listed first, without one. */ group?: string; /** * Extra words that should match this command. * * A palette is only as good as its synonyms: someone looking for "layers" should find "Outline" * without knowing what it was named. */ keywords?: readonly string[]; /** The shortcut to DISPLAY, if the host binds one elsewhere. Rendering it here binds nothing. */ shortcut?: string; /** Checked whenever the list is built; a command that returns false is not offered. */ when?: () => boolean; /** A small glyph before the label. Decorative: the label alone names the row. */ icon?: React.ReactNode; /** * Said after the label, more quietly: where a block will go, what a row is, the shortcut's * neighbour. Not searched — what the search matches is the label and `keywords`. */ detail?: React.ReactNode; /** * The footer's word for choosing this row while it is highlighted: "Add", "Select", "Open". * "Run" when absent, which is what a command does. */ verb?: string; /** Runs when the command is chosen. The palette closes first. */ run: () => void; } /** * How one named group behaves while the author searches. * * @experimental */ interface CommandGroupOptions { /** The group's heading, as the commands name it in `group`. */ name: string; /** At most this many matches, best first. Every match when absent. */ limit?: number; /** * The host has matched these already — a search made on the server — so each is shown as * given, in the host's order. Scoring them again here could drop a row the server matched on * something the label does not show. */ matched?: boolean; /** * Said in the group's place while its results are on their way, or could not be had * ("Searching pages…"). Shown even when the group has no rows yet, so the author can tell a * search still running from one that found nothing. */ status?: string; } /** * What the host gives the palette. * * @experimental */ interface CommandPaletteProps { /** * Everything the palette can run. * * Order within a group is preserved WHILE THE SEARCH IS EMPTY. * * Once the user types, the groups STAY, each under its heading and in the same order, and the * matches inside each are ranked best first by cmdk's scorer over the label and synonyms. The * groups are kinds of thing (blocks to add, blocks on the page, pages, commands), and an author * reads a result by its kind before its rank. cmdk keys SELECTION on an item's value, so the * value here is the `id` alone — anything richer is a concatenation of free-form fields and two * commands can collide, which makes the wrong one run. */ commands: readonly BuilderCommand[]; /** * Controls the dialog. Omit both to let the palette own its own open state, which is the usual * case; pass them when the host needs to open it from somewhere else as well. */ open?: boolean; onOpenChange?: (open: boolean) => void; /** * Named groups' order and their behaviour while searching. A group listed here comes in this * order; one that is not follows, in the order its commands first appear. */ groups?: readonly CommandGroupOptions[]; /** * Told the search as the author types it, trimmed, for a host that searches elsewhere too (the * site's pages, on the server). Its answers come back as commands in a `matched` group. */ onSearchChange?: (query: string) => void; /** Placeholder for the search field. */ placeholder?: string; /** Shown when nothing matches what was typed. Given the search, so it can quote it. */ emptyMessage?: React.ReactNode | ((query: string) => React.ReactNode); /** * Whether the palette may be opened at all. * * Defaults to whether the surrounding shell is interactive, and to `true` outside one. The * dialog PORTALS to the document body, so it escapes the `hidden`/`inert` wrapper the shell * puts its slots behind below its minimum width — without this it would float, fully * interactive, over the narrow-screen notice. * * NARROWS the shell's answer rather than replacing it: passing `false` disables the palette, * and passing `true` does NOT re-enable one inside a shell that has taken itself out of * service. A host condition of its own — `enabled={!readOnly}` — is therefore safe to pass * without also re-deriving the shell's minimum width, which would be a second implementation of * a question the shell already answers. */ enabled?: boolean; } /** * A stored pattern, as the palette needs to read it. * * The fields a pattern is STORED with that no palette reads — its slug, its * status, its granularity — are deliberately absent. A granularity decides * whether a pattern is offered as something to insert or as a way to start a * page, and that vocabulary belongs to the collection that declares it; a copy * of the four words here would be a second enumeration nothing keeps in step, * so the caller splits its own list and hands this the rows it means to offer. * * `keywords` arrives as ONE string because that is how it is stored — matched, * never enumerated — and {@link patternEntriesFrom} is where it becomes the * word list the palette searches. */ interface SavedPattern { /** The stored row's id, which the insert plans against. */ readonly id: string; readonly title: string; readonly description?: string; readonly category?: string; /** * The author's own search terms, however they separated them. * * `null` as well as absent, because that is what a stored row holds: the * field is not required, and Nextly writes an unset non-required field as SQL * `NULL` and reads it back with the KEY PRESENT. A pattern saved without * keywords — the ordinary case — arrives here as `null`, so an * undefined-only check would reach `null.split` and take catalog * construction down with it. */ readonly keywords?: string | null; /** * The pattern's document, carried whole — or absent, as a stored row's is. * * The collection does not mark its blocks field required and the field layer * persists an omitted document as SQL `NULL`, so a published row with a * title, a slug and a granularity but no content is a legal row. There is * nothing to offer for one, so it is skipped exactly as an empty pattern is; * reading `kind` off it took catalogue construction down. * * Held BY REFERENCE, and treated as immutable, which is how a stored row is * treated everywhere else it travels. Cloning each one instead would copy * every pattern's whole forest on each build of the catalogue, and the * catalogue is rebuilt whenever the palette opens — against a library the * design sizes at three thousand entries. * * What that costs is bounded, because the planner judges the forest AGAIN * before it plans: a row mutated between being offered and being clicked can * make the insert refuse, and cannot make it place something the nesting * rules forbid. And the value it would then place is the row as it stands * now, which for a live library is the better of the two answers. */ readonly document?: BlockDocument | null; } /** * A stored component definition, as the library hands it to the palette. * * The same shape and the same caveats as {@link SavedPattern}, because it is * the same kind of row from a sibling collection: `keywords` is one stored * string, and `document` may be `null` for a published row saved without * content. Carried separately rather than widened onto `SavedPattern` because * what the two are FOR differs — a pattern is copied in and forgets its source, * a component is placed as one node that keeps pointing back — and a reader * should be able to tell from the type which it holds. */ interface SavedComponent { /** The stored row's id, which an instance node points at. */ readonly id: string; readonly title: string; readonly description?: string; readonly category?: string; readonly keywords?: string | null; readonly document?: ComponentDocument | null; /** * How many pages currently place it, when the library can say. * * Optional because the count is a separate read the library may not have * made, and a tile that showed "used on 0 pages" for a count nobody took * would be stating a fact it does not hold. */ readonly usedOn?: number; } /** * How a caller answers for a block's declared child regions. * * Deliberately NOT a registry, matching `NestingSource`: resolving a type to * its definition differs per caller, and a one-method source lets each supply * its own resolution while sharing the rule applied to the result. * * The NODE cannot answer this. A container inserted from the palette carries no * `slots` key at all — `makeNode` writes one only when children are supplied — * so asking the node whether it is a container answers "no" for every empty * one, which is exactly the case that needs filling. */ interface SlotSource { /** The names of the child regions this block type declares, in order. */ slotsOf(type: string): readonly string[] | undefined; /** * The region the canvas draws for this block in place of its first, when * it draws another: a collection list whose empty state is shown. Adding * inside such a block adds to the region the author sees. */ shownSlotOf?(node: BlockNode): string | undefined; } /** * `slots`, naming the empty-state slot as the one drawn for each list the * canvas shows empty (see `EditorState.listsShowingEmpty`), so a block added * inside it, from the canvas or the Add panel, lands where it is seen. */ export declare function slotsShowingEmpty(slots: SlotSource, showingEmpty: ReadonlySet | undefined): SlotSource; /** * @deprecated Renamed to `PlacementTarget`, which is the engine's name for it * and now the only one. Kept as an alias for one release because this type is * published from the package entry; import `PlacementTarget` instead. * * Note the discriminant moved with the name: the member is `kind`, not `at`. * A value written as `{ at: "slot", ... }` no longer satisfies this type, and * that is deliberate — a silently accepted `at` would fall through every * `kind === "slot"` narrowing and be judged as a root placement. */ type InsertTarget = PlacementTarget$1; /** * The name an author reads. * * A declared `editor.label` wins. Without one, the namespaced identity is * humanised rather than shown raw: "core/collection-loop" reads as "Collection * loop". Showing the identity verbatim is honest and hostile — a palette is * read by whoever writes the page, not by whoever registered the block, and * every block that has simply not been labelled yet would present as an * internal name. * * Derived rather than stored, because a definition gaining a real label must * override this immediately, and a copy written into the entry at build time * would keep the guess alongside it. * * `lookup` is where the definition comes from, the process registry unless a * caller says otherwise. A surface outside the editor — the entry screen, which * deliberately registers nothing — resolves blocks through its own resolver, * and asking the empty registry there would humanise a block whose declared * label the editor shows, so the two screens would name one block twice. */ export declare function blockLabel(type: string, lookup?: (type: string) => AnyBlockDefinition | undefined): string; /** * Whether a block type may be placed at a target, by NAME. * * The same rule as {@link entryAllowedAt} and the same code, reached without a * palette entry. A drag moves a node that already exists, so the only thing it * has is a type name — and asking the question a second way is how the palette * and the canvas come to disagree about where a block may go, with the palette * offering what the drop refuses. * * Both halves are asked, because a placement needs both to agree and neither is * derivable from the other: `parent` is the child saying where it makes sense, * a slot's `allow` is the container saying what it holds. * * The child's half runs first so its reason survives when both would refuse. * "This block belongs inside a Columns" tells an author where to go; "this * region does not take that block" leaves them looking for a region, which is * the less actionable of the two sentences. */ export declare function blockAllowedAt(blockName: string, target: PlacementTarget$1, source: NestingSource): NestingVerdict; /** * The registry as a slot source. * * DERIVED from `registryBlockSource` rather than reading the registry again: * the names of a block's slots are a narrower view of its declaration, and two * readings of one registry would agree until one of them learned to filter. * * Here rather than beside either caller. The palette asks it where an insert * would land and the canvas asks it which regions a drag can aim at, and those * two have to agree: a container the palette will fill but the drag cannot see * is a block that behaves differently depending on how an author reached it. */ export declare function registrySlotSource(): SlotSource; /** * The direction a region lays its children out. * * `"y"` is an ordinary vertical stack; `"x"` is a row or a grid track running * across. It decides which coordinate separates two children and therefore * which way an insertion line is drawn. */ type DropAxis = "x" | "y"; /** The region id standing for the document's top level. */ export declare const ROOT_REGION = "root"; /** * Rectangles, measured from wherever they actually are. * * An interface rather than a DOM read so this module stays pure. The canvas * supplies one backed by `getBoundingClientRect`; a test supplies a literal. * * All rectangles must be in ONE coordinate space — the canvas's. Mixing spaces * produces an indicator drawn a constant distance from the gap it names, which * looks like a styling mistake rather than a measurement one. */ interface RectSource { /** Where a node's element sits, or `undefined` when it rendered nothing. */ rectOf(nodeId: string): Rect | undefined; /** The canvas's own extent, which is the root region's. */ rootRect(): Rect; } /** * One container's child list, as somewhere a block can be dropped. * * A region is addressed by a parent and a slot, never by position: the document * makes ids the only thing anything stores, and a positional region would name * a different container the moment a sibling is inserted above it. */ interface DropRegion { /** Stable identity: {@link ROOT_REGION}, or `"::"`. */ readonly id: string; /** * What this region is, as the nesting rule needs to see it. * * Named as {@link DropTarget.target} is, because it is the same thing: the * placement a block would be nested into. `at` is reserved for a POSITION * throughout this module, and a reader holding a region and a target should * not have to remember which of two meanings the one word carries. */ readonly target: PlacementTarget; /** The container node, absent for the root region. */ readonly parentId?: string; /** The slot within that container, absent for the root region. */ readonly slot?: string; /** How far inside the document this region sits; the root is 0. */ readonly depth: number; /** The container's measured extent, which decides what it contains. */ readonly rect: Rect; /** Which way its children run. */ readonly axis: DropAxis; /** Its children's ids, in document order. */ readonly childIds: readonly string[]; } /** * One place a block can land, and the line that says so. * * `at` is what the op needs and `line` is what the author sees, produced * together for the same reason the inserter produces a position and its target * together: computed apart, the indicator and the drop can be derived from * different readings and the block lands somewhere other than where the line * was drawn. */ interface DropTarget { /** * Stable identity across pointer moves. * * Required by the switch rule, which compares the committed target with a * rival — an identity derived from the rectangle would differ every time the * page reflowed, and every reflow would read as a crossing. */ readonly id: string; /** The region this target belongs to. */ readonly regionId: string; /** Where the block goes. */ readonly at: OpPosition; /** What that position is, for the nesting rule. */ readonly target: PlacementTarget; /** The axis children are separated along. */ readonly axis: DropAxis; /** * Where the line sits along {@link axis} — a `y` for a horizontal line, an * `x` for a vertical one. */ readonly line: number; /** Where the line starts, across the axis. */ readonly from: number; /** Where the line ends, across the axis. */ readonly to: number; } /** * Why a drop the author aimed at cannot happen. * * The engine's refusal CODE, not a sentence. Wording is a presentation * decision — it belongs where the words are drawn and where they can be * translated — and a code is what a caller can branch on. `permitted` travels * with it because naming what the region DOES take is the difference between * "no" and an instruction. */ interface DropRefusal { readonly regionId: string; /** * The container node the refusing region belongs to, absent at the root. * * Where an ancestor on the page refused for its content model, that ancestor * instead: a Button aimed at a Box inside a linked Card names the Card, which * is the block the refusal's words name and the one its notice sits over. * {@link DropRefusal.regionId} still names the region the pointer is in. * * Carried for the same reason `permitted` is: a surface explaining the * refusal needs it, and this is the only place it is still known. A region is * identified by `"::"`, so recovering the node from * {@link DropRefusal.regionId} means splitting a composite string — reading a * value back out of a spelling this module chose, which stops being correct * the moment the spelling does. * * Absent rather than a sentinel at the root, because "there is no container" * is the fact that separates a refusal an author can fix by aiming elsewhere * from one that needs a container to exist first. */ readonly parentId?: string; /** * Why the region refuses. Beside the name rules' reasons (`"wrong-parent"`, * `"restricted-at-root"`, `"not-allowed-in-slot"`) this carries the * placement rule's: `"undeclared-slot"`, `"holds-no-blocks"`, * `"phrasing-only"` and `"content-model"`. A `switch` over it needs a * `default`, or a case for each of those; {@link DropRefusal.verdict} * carries the facts each of them is explained by. */ readonly reason: PlacementRefusal; readonly permitted: readonly string[]; /** * The one placement rule's whole answer, when the drop was judged by it, so * its words can name a slot the container lacks or the linked block that * refuses what is being dropped. */ readonly verdict?: PlacementRefused; } /** * What the one placement rule needs to judge a drop: the document, the blocks * being placed with everything inside them, and where it reads its answers. */ interface DropPlacement { readonly nodes: readonly unknown[]; /** * The blocks being placed, read only when a region is judged: an insert has * no node until its palette builds one, and asking for it is what builds * it. An empty answer leaves the drop to the name rules. */ readonly placing: () => readonly PlacedNode[]; readonly sources: PlacementSources; /** * The answers already reached, kept for one gesture. The document, the * blocks being placed and the regions are fixed while a drag lasts, so a * region's answer is too, and every pointer move and autoscroll frame would * otherwise walk the same subtree again. */ readonly verdicts?: RegionVerdicts; } /** * Region answers keyed by the region's container, then its slot, with the * root region under `undefined` for both. * * Two keys rather than {@link DropRegion.id}: that id joins the two with `::`, * and a node id or a slot name may itself contain `::`, so container `a` with * slot `b::c` and container `a::b` with slot `c` spell the same id while * being different regions with different answers. */ type RegionVerdicts = Map>; /** * A region's answer: the rule's verdict, and for a refusal the container it is * drawn over, worked out with the verdict so a cached answer carries both. */ interface RegionVerdict { readonly verdict: PlacementVerdict; readonly parentId: string | undefined; } /** * What the pointer currently means. * * A refusal is a distinct answer rather than an absent target, and the * distinction is what the canvas needs to say why. An author who drags a * heading over an accordion has aimed at something; showing no indicator tells * them the editor did not notice, while showing a refusal tells them the region * does not take that block. */ type DropResolution = { readonly kind: "target"; readonly target: DropTarget; } | { readonly kind: "refused"; readonly refusal: DropRefusal; } | { readonly kind: "none"; }; /** * Which way a region's children run, read from where they actually landed. * * Measured rather than declared. A container's CSS is only half the story — a * `flex-direction: row` whose children wrapped runs down the page, and a block * that declares nothing still lays out somehow — so the rectangles are the * evidence and the declaration is a claim about them. Reading the result also * means grid, flex, inline and ordinary flow need no separate handling. * * The axis with the greater spread of leading edges wins. Children stacked * vertically share an `x` and differ in `y`, and a row is the reverse. * * **Vertical when there is no evidence** — fewer than two children, or children * that spread equally. A single child cannot indicate a direction, and page * content runs down the page far more often than across. * * **Known limit: a region that WRAPS is served on one axis only.** A grid of * three columns by two rows genuinely separates its children both ways, and a * single line cannot express "after the end of row one". Such a region gets its * dominant axis, which orders row-major grids correctly and leaves column-major * ones approximate. */ export declare function axisOfRects(rects: readonly Rect[]): DropAxis; /** * Every region in the document, deepest last. * * A container contributes a region for each slot its DEFINITION declares, not * for each slot its node happens to hold. An empty container carries no `slots` * key at all — `makeNode` writes one only when children are supplied — so * asking the node would produce no region for exactly the containers that most * need one, and an author could never fill anything they had just inserted. * * A container that rendered nothing measurable is skipped rather than given a * zero rectangle. A zero rectangle contains no point, so it would never be * resolved, but it WOULD sit in the list claiming to be droppable — an absence * that reads as a presence is the harder of the two to notice. */ export declare function collectRegions(document: BlockDocument, slots: SlotSource, rects: RectSource, slotsOfNode?: (node: BlockNode) => readonly string[] | undefined): DropRegion[]; /** * The insertion lines inside one region, in index order. * * A region with `n` children has `n + 1` of them. The first sits on the first * child's leading edge and the last on the final child's trailing edge; the * ones between sit in the middle of the gap separating two children, which is * where an author sees the boundary and where a margin puts it. * * Ranking by distance to these lines is what makes each child's CENTRE the * place the target changes: a pointer in a child's leading half is nearer the * line before it, and in its trailing half nearer the line after. That holds * for children of any size, which is precisely what a rule measuring to a zone's * middle gets wrong. * * **An empty region still has one**, drawn across its middle. It is the only * way to fill a container that has just been inserted, and a container that * cannot be filled is decorative. * * A child that rendered nothing measurable is skipped, but its INDEX is not: * the op addresses a position in the stored children, and quietly renumbering * around an unrendered node would drop the block at a different index from the * one the line was drawn for. */ export declare function targetsInRegion(region: DropRegion, rects: RectSource): DropTarget[]; /** * The node with this id, and everything inside it. * * A block cannot be dropped into itself or into anything it contains: the move * would detach a subtree and re-attach it beneath itself, which is not a page. * Collected as a set so the check below is a lookup rather than a walk per * candidate region. */ export declare function movingSubtree(document: BlockDocument, movingId: string | undefined): Set; /** What {@link resolveDrop} needs to answer a pointer. */ interface DropQuery { /** * The block types the placement is judged by. * * One for a block, its registered type name. Several for a component * instance: the ROOTS of the definition it draws, resolved as its tile was * (`placementTypesOf`), because the instance node's own type is not a * registered block and the nesting source answers "no restriction" for it. * Every type must be admitted, as every root of a pattern must be. */ readonly blockNames: readonly string[]; /** * Nodes the drop may not land inside: the dragged block and its descendants. * * Empty for a drag from the palette, where nothing is being detached. Passed * in already computed rather than derived here, because it cannot change * during a drag while this runs on every pointer move — and a walk of the * document per move is work whose answer is known before the drag starts. * * Build it with {@link movingSubtree}. */ readonly forbiddenParents: ReadonlySet; readonly regions: readonly DropRegion[]; readonly nesting: NestingSource; readonly rects: RectSource; /** * The blocks being placed, judged by the one placement rule. Absent, the * drop is judged by the name rules alone, as before the rule existed. */ readonly placement?: DropPlacement; } /** * Which region owns the pointer. * * The DEEPEST containing one, so a container nested inside another claims the * pointer over its own area rather than losing it to the ancestor it sits in. * Ties on depth go to the one declared later, which is document order — a * region overlapping a sibling is already a layout the author can see, and * taking the later one matches which of the two paints on top. * * `undefined` when the pointer is outside everything, INCLUDING outside the * root. Falling back to the root would let a drop resolve from a pointer that * had left the canvas, which is how a block lands on the page after a drag the * author abandoned by dragging away. */ export declare function regionAt(regions: readonly DropRegion[], pointer: Point, forbiddenParents?: ReadonlySet): DropRegion | undefined; /** * The target the pointer means right now. * * Region first, then the nearest line inside it — never a distance across the * two, for the reason in the module docblock. * * A region the block cannot go in produces a REFUSAL rather than deferring to * the container around it. Resolving to the ancestor would silently drop the * block somewhere the author was not aiming, which the nesting rule exists to * prevent; saying no is the honest answer and it carries the reason. */ export declare function resolveDrop(query: DropQuery, pointer: Point): DropResolution; /** * A drop target's identity, or `null` for "the pointer is over none". * * `null` is an ordinary value here rather than an absence: losing a target at a * boundary flickers exactly as gaining the wrong one does, so dropping the * committed target is held to the same threshold as replacing it. */ type TargetId = string | null; /** * A candidate that has appeared but not yet earned the switch. * * `anchor` is where the pointer was when this candidate FIRST differed from the * committed target, which is the subtlety the whole rule turns on. See * {@link nextTargetSwitchState}. */ interface PendingTarget { readonly target: TargetId; readonly anchor: Point; } /** What the rule remembers between pointer moves. */ interface TargetSwitchState { /** The target actually in effect — what the indicator draws and a drop uses. */ readonly committed: TargetId; /** A rival waiting to earn the switch, or `null` when none is waiting. */ readonly pending: PendingTarget | null; } /** A drag that has not yet resolved a target. */ export declare const NO_TARGET: TargetSwitchState; /** * Advances the rule by one pointer move. * * @param state - what the previous move left behind; {@link NO_TARGET} to begin * @param candidate - the target the collision engine resolves at `pointer` now * @param pointer - the pointer, in any one coordinate space used consistently * @param thresholdPx - how far the pointer must travel for a rival to win * @returns the next state; `committed` is what the editor should act on * * @throws RangeError if `thresholdPx` is negative or not finite. A threshold is * a contract rather than a hint, and a `NaN` arriving from an unparsed * configuration value would make every comparison false and silently disable the * rule — a flickering canvas with nothing to point at. * * @remarks * **The anchor is where the candidate CHANGED, not where the last switch * happened, and the difference is the whole mechanism.** * * Measuring from the last switch reads plausibly and gives no hysteresis at all * in the commonest case. An author dragging from the block library crosses most * of the page before reaching the seam between two blocks: by the time they * arrive, the distance since the last switch is already far past any threshold, * so the first pixel over the boundary switches immediately and the jitter that * follows switches back just as fast. The rule would be satisfied and absent * exactly where it is needed. * * Anchoring at the moment the candidate first differs makes the threshold * measure the crossing itself, so it costs the same and applies wherever the * crossing happens. * * **Displacement, not path length.** A pointer jittering back and forth across a * seam accumulates unbounded path length while never getting anywhere, so a path * measure would eventually grant the switch it exists to withhold. Distance from * the anchor cannot be accumulated by going nowhere. * * **The first target commits immediately.** There is nothing to flicker between * before a target exists, and withholding it would leave a drag with no * indicator until the pointer had travelled the threshold, which reads as the * canvas failing to respond. */ export declare function nextTargetSwitchState(state: TargetSwitchState, candidate: TargetId, pointer: Point, thresholdPx: number): TargetSwitchState; /** * A component's title, by the id a placement stores. * * A placement is one node of the engine's instance type, so its type says only * that it IS a placement; the document holds no title. The library is the one * holder of a component's title, and the host that read it hands this in. */ type ComponentTitleOf = (componentId: string) => string | undefined; /** * The title lookup for a library's rows, built once per list. * * A map rather than a search per row, since the tree asks once for every * placement on the page, on every render. */ export declare function componentTitles(components: readonly Pick[]): ComponentTitleOf; /** * One block, as a row in the tree. * * Badges are FACTS about the node rather than switches. `locked` is a boolean * the engine defines; the two visibility flags are not, and conflating them * into one "hidden" is the mistake this shape exists to prevent — see * {@link LayerNode.conditional}. */ interface LayerNode { readonly id: string; readonly type: string; /** The instance name if the author gave one, otherwise the block's name. */ readonly label: string; /** * The name the author gave, when they gave one: what a rename starts from. * The label falls back to the type or the component's title, which is not * a name the author wrote and must not be stored as one by a rename. */ readonly name?: string; /** * The block is a component placement, so its row is marked as one: its label * may be the component's title, which would otherwise read as a block's own * name. */ readonly component: boolean; /** The author has locked this block in Layers. */ readonly locked: boolean; /** * The name of the block locked in Layers that this one sits inside, when it * is not locked itself: a lock covers everything inside the block, so the * row says it is held and by which block, where the lock is lifted. */ readonly lockedBy?: string; /** * The block declares conditions, so whether it appears depends on the entry. * * NOT "hidden". Conditions are predicates over an entry's fields evaluated at * render time, so the editor cannot know the answer — showing an eye here * would state one. What is knowable, and worth showing, is that this block's * presence is conditional at all. */ readonly conditional: boolean; /** * The block is marked never to be quoted in search snippets, so its row * says so in words a screen reader reads. */ readonly notQuoted?: boolean; /** * The block holds custom CSS of its own, so its row is marked for everyone. * Only that it does: the CSS itself is never part of the tree. */ readonly customCss?: true; /** * The block is hidden at one or more breakpoints. * * Also not "hidden", for a different reason: visibility is per breakpoint, so * a block hidden on mobile is fully present on desktop. A single eye would * have to pick one of those to be true about. */ readonly breakpointHidden: boolean; /** * The block is hidden on the device being edited, which is the device the * canvas shows: the row is drawn dimmed with a "Hidden" badge. Only known * when the tree was asked for a device. */ readonly hiddenHere?: boolean; /** * The name of the block hidden on the device being edited that this one * sits inside, when it is not hidden itself: a visitor on that device sees * none of what the block holds, so the row says it is hidden with it, and * where it is shown again. */ readonly hiddenWith?: string; /** The region of its parent this block sits in. */ readonly slot?: string; /** * The regions an author tells apart in this block, in order, each with * what it is called: a collection list's "Each entry" and "When empty". * Absent for a block whose children read as one run. */ readonly slotRows?: readonly SlotRow[]; readonly children: readonly LayerNode[]; } /** * One region of a block, as Layers draws it between the block and its * children. `rowId` is the row's own identity in the tree, chosen so that no * block of the document has it: a stored id may be any non-empty string, so * no spelling alone could be kept apart from them. */ interface SlotRow { readonly slot: string; readonly label: string; readonly rowId: string; } /** * The device the tree is read for: the site's breakpoints and the one being * edited, which decides each row's {@link LayerNode.hiddenHere}. */ interface LayersDevice { readonly breakpoints: BreakpointSet | undefined; readonly id: string; } /** * The name an author reads for one block. * * An instance name wins, because it is the only part an author wrote. A * component placement is then named by its component's title: its type's * label, "Component instance", names the engine's mechanism rather than what * the author placed. With no title to read (none handed in, a component the * library no longer holds, a blank title) it is a "Component". */ export declare function layerLabel(node: BlockNode, lookup?: Parameters[1], componentTitle?: ComponentTitleOf): string; /** * The name of the block at an address anywhere in the document, as its Layers * row reads (see {@link layerLabel}), or `undefined` where the document holds * no such block. The canvas tags a selected placement with it, so the page and * the tree call one block by one name. */ export declare function blockNameOf(document: BlockDocument, id: string, componentTitle?: ComponentTitleOf): string | undefined; /** * The document as a tree of rows. * * `componentTitle` names component placements; see {@link layerLabel}. * * Without a device, the tree is built once per document, title lookup and set * of registered definitions and handed out again after that: the breadcrumb * and the selected block's toolbar and keyboard verbs each ask for the path to * the selection on every click, and each path was a whole tree. An edit makes * a new document, and a block registered or replaced changes the definitions, * so either is built afresh. What is handed out is shared, so no caller may * change it. */ export declare function layersOf(document: BlockDocument, componentTitle?: ComponentTitleOf, device?: LayersDevice): LayerNode[]; /** * The ancestors of a node, outermost first, ending with the node itself. * * Empty when nothing is selected or the id is not in the document — which the * breadcrumb draws as nothing rather than as a broken trail, and which happens * routinely: an undo can remove the selected node while the selection stands. */ export declare function pathTo(document: BlockDocument, id: string | null, componentTitle?: ComponentTitleOf): LayerNode[]; /** * Every ancestor id on the way to a node, excluding the node itself. * * What the panel must expand for a selection made elsewhere to be visible. A * block selected on the canvas inside three collapsed containers is otherwise * highlighted in a tree that shows none of it, which reads as the panel * ignoring the click. */ export declare function ancestorIds(document: BlockDocument, id: string | null): string[]; /** What a search left standing, and what has to open for it to be visible. */ interface LayerSearch { readonly roots: readonly LayerNode[]; /** Ids to expand so every match is on screen. */ readonly expand: readonly string[]; } /** * Narrow the tree to what matches, keeping the ancestors of every match. * * A match's ancestors are KEPT even when they do not match themselves, because * a tree that dropped them would present matches as top-level blocks and lose * the one thing this panel exists to show. A matching node keeps its whole * subtree, so searching for a container still shows what is inside it. * * An empty or whitespace-only query returns the tree unchanged rather than * nothing — the panel renders with no query, and treating that as "match * nothing" would show an empty panel on open. */ export declare function filterLayers(roots: readonly LayerNode[], query: string): LayerSearch; /** * Scroll the block `id` into view inside `root`. * * `nearest` on both axes, so a block already on screen does not move and one * off screen moves only as far as it must. Smooth, except where the reader * asked for less motion, where it jumps. * * @param root - the canvas: its root element, or the document of the frame it * draws in * @param id - the block's id, as the document stores it * @param options - `instant` jumps rather than scrolling smoothly * @returns whether the block was found; `false` scrolls nothing, which is what * an address naming a block the page no longer has should do */ export declare function revealNode(root: Document | HTMLElement, id: string, { instant }?: { readonly instant?: boolean; }): boolean; /** * One binding as a person would read it, or `null` when the spec cannot be read. * * `null` rather than a best guess: a hint is a promise that pressing something * does something, and a spec this cannot parse is one whose keystroke it does * not know. Showing a wrong one is worse than showing none, which is the same * judgement the toolbar made when it showed none at all. * * @experimental */ export declare function keyHint(spec: string, apple?: boolean): string | null; /** Whether this node itself carries the author's lock. */ export declare function isLocked(node: BlockNode): boolean; /** * The locked block that stops this one being MOVED, or `undefined`. * * The block itself or one inside it, outermost first, since the move would * carry it; else a locked block it sits inside, since the move would take it * out. The op layer refuses both, so offering either move would be offering a * refusal. */ export declare function lockBlockingMove(document: BlockDocument, id: string): BlockNode | undefined; /** * The locked node that stops this one being DELETED, or `undefined`. * * The node or anything inside it, else a locked block it sits inside: deleting * a block out of a locked one changes what that lock protects. Returns the * OUTERMOST locked node inside rather than merely reporting that one exists, * because the refusal has to name something an author can act on — "this * section holds a locked block" is followed by going and finding it, and the * deepest match is the least likely to be the one they meant. * * The same answer as {@link lockBlockingMove}, asked under its own name * because the verb reaches the author: callers word a refusal to delete and a * refusal to move differently. */ export declare function lockBlockingDelete(document: BlockDocument, id: string): BlockNode | undefined; /** The two lines a refusal draws. */ interface RefusalWording { /** Why the drop will not happen, in one sentence. */ readonly headline: string; /** * What the author can do about it, or null when the engine named nothing. * * Named for the job rather than for one of its sentences, because * `permitted` does NOT mean the same thing for every reason and the wording * has to follow that. A slot refusal names what the SLOT admits; the other * two name the containers the MOVING BLOCK is allowed to sit inside. Calling * both "This spot takes" asserts something about the region that the second * kind never said — it would read as the accordion accepting columns, which * is not what was measured; those say where the block goes instead. * * Null rather than an empty string: a caller rendering it unconditionally * would draw a sentence that was cut off rather than an absent fact. */ readonly remedy: string | null; } /** How a gesture changes the selection. */ type SelectionMode = "replace" | "toggle" | "extend"; /** The selection: what is in it, and which one the surfaces answer for. */ interface BlockSelection { /** Every selected id, in document order, outermost only. */ readonly ids: readonly string[]; /** * The block the inspector edits and a range extends from, or `null`. * * Always a member of `ids` when `ids` is non-empty, which callers may rely * on: a primary outside the set would make the inspector edit a block the * canvas does not show as selected. */ readonly primary: string | null; } /** Nothing selected. */ export declare const EMPTY_SELECTION: BlockSelection; /** * Every id in the document, in the order a reader meets them. * * Deliberately a walk of its own rather than a flatten of `layersOf`, which * would compute a label, a lock badge and two style predicates per node on * every click. `selection.test` asserts this agrees with `layersOf`'s order, so * there is one VERIFIED definition of document order rather than one shared * implementation of it. */ export declare function documentOrder(document: BlockDocument): string[]; /** * The set with anything that has an ancestor in it removed, in document order. * * Ids the document no longer holds are dropped too, which an undo produces * routinely — a selection outliving its blocks is the normal case, not an edge * one. */ export declare function normalizeSelection(document: BlockDocument, ids: readonly string[]): string[]; /** * The sibling run between two blocks, at the deepest level they share. * * Shift-clicking a block inside another section does NOT select across the two * containers, because there is no run of siblings spanning them. It selects the * run at the level where the two paths diverge — the sections themselves — so * the gesture always answers with something contiguous. * * `[]` when either id is absent, and the OUTER one alone when one contains the * other: a range from a container to something inside it is the container. */ export declare function rangeBetween(document: BlockDocument, anchorId: string, targetId: string): string[]; /** * The selection after a gesture on `targetId`. * * `null` clears it, whatever the mode: a click on canvas background has no * subject to toggle or extend to. A target the document does not hold is * IGNORED rather than treated as a deselect — a stale id is not an instruction * to clear, and treating it as one loses a selection for a reason the author * cannot see. * * A dispatcher and nothing else. Each mode is its own function above, because * the three were one body until a complexity gate objected — and it was right: * the shared shape between them is only "normalise, then pick a primary", which * {@link withPrimary} now owns for all three. */ export declare function applySelection(document: BlockDocument, current: BlockSelection, targetId: string | null, mode?: SelectionMode): BlockSelection; /** * The selection with anything the document has lost dropped. * * Called after an edit rather than on read, so a surface never renders against * ids that are gone. An undo removing selected blocks is routine. */ export declare function pruneSelection(document: BlockDocument, selection: BlockSelection): BlockSelection; /** * Every setting the panel offers for the selected block, as one list an author * can search by name and filter to what they changed. * * Built from what the panel already reads for the selection (the block's * inspection, the Style tab's sections, the built-in Advanced rows), so a * setting is found under the words it is drawn with. Pure: no document, no * DOM, so a tool reaches the same answers the panel does. * * - **Matching** goes by a setting's plain label, its section, its options' * labels, the CSS names it writes and a few other words for it * ({@link SYNONYMS}), ignoring case, accents, hyphens, underscores and camel * case: "zindex", "z-index" and "zIndex" are one word. * - **Order** stays the panel's: a match never moves a setting, so the panel * does not rearrange itself while the author types. * - **Only changed** keeps the settings holding a value of their own for what * is being edited. * * @module settings-index */ /** The panel's three tabs. */ type SettingTab = "content" | "style" | "advanced"; /** A setting of a block's panel: its tab, and its id in the settings index. */ interface AskedSetting { readonly tab: SettingTab; readonly id: string; } /** * The facts a slot-lock refusal is worded from: the rule, and the block whose * slot it holds. A break on the page itself and one in the composed page, * inside a component a placement reaches, both answer with these. */ type SlotLockRefusalFacts = Pick & { /** The placement a break inside a component is reached through. */ readonly instanceId?: string; }; /** What an action does to a block, as a refusal of it says. */ type LockedVerb = "move" | "delete" | "change" | "add"; /** * Where a locked block sits relative to the block an action is aimed at: * - `self`: it is that block; * - `inside`: it is inside that block; * - `around`: that block is inside it; * - `destination`: the action would put a block into it; * - `component`: the block is a component's, which locks it; `label` is then * the component's name, since the page cannot unlock it. */ type LockedRelation = "self" | "inside" | "around" | "destination" | "component"; /** * The facts a Layers-lock refusal is worded from: the locked block by the name * the author knows it by, where it sits, and what the action would do. * * `layers-locked-when-saved` is the lock the SAVED page still holds on a block * the author has unlocked since: a save refuses to delete it until the unlock * itself has been saved, so the editor refuses the delete before that. */ interface LayersLockRefusalFacts { readonly code: "layers-locked" | "layers-locked-when-saved"; readonly label: string; readonly relation: LockedRelation; readonly verb: LockedVerb; } /** * Why an edit is refused for a lock: a slot's lock a block declares, or a * block an author locked in Layers. */ type LockRefusalFacts = SlotLockRefusalFacts | LayersLockRefusalFacts; /** * What a block is, as distinct from what it holds. * * `name` and `locked` are fields on the NODE rather than entries in `props`, so * no `PropSchema` describes them and the prop loop below cannot reach them. * They are also the two the layers panel already displays — and until this * existed, nothing in the editor could set either, so the panel showed * information the editor had no way to produce. */ interface BlockIdentity { /** The author's own name for this instance, empty when they have not given one. */ readonly name: string; readonly locked: boolean; } /** * How a lock reads across a whole selection. * * `"mixed"` is a real third state, not a rounding of the other two: some * selected blocks are locked and some are not, and a checkbox showing either * on or off there would tell the author something false about half of what * they have selected. ARIA models it as `aria-checked="mixed"`, and the first * click from mixed LOCKS everything — the reading every file manager and design * tool gives it, because the alternative is a first click that appears to do * nothing to half the selection. */ type LockState = "locked" | "unlocked" | "mixed"; /** * The lock across a set. * * Ids the document no longer holds are skipped rather than counted as * unlocked. An undo removing a selected block is routine, and counting a * missing one as unlocked would report `mixed` for a set that is entirely * locked. */ export declare function lockStateOf(document: BlockDocument, ids: readonly string[]): LockState; /** * What the editor judges locks by, as the inspector reads it: the lock source * its edits are refused against, and the page with its placements composed in. * Absent, the live registry and the page alone. */ interface LockView { readonly definitions?: SlotDefaultSource; readonly composed?: BlockDocument; } /** * The exposed types this inspector can draw a control for. * * Named as a set rather than inferred from what the switch happens to handle, * for the reason `SUPPORTED_PROP_TYPES` is: an exposed type with no control is * a KNOWN gap the row states, never a silent fallthrough. A link is edited as * the address its prop holds, visibility as shown-or-hidden, and an image as * a file chosen from the host's media library, which the inspector hands the * panel. Rich text has no control here yet — a passage is edited on the * canvas — and its row still shows its value and its source, and still * offers a reset, because withholding the row would present a component as * exposing less than it does. */ export declare const EDITABLE_EXPOSED_TYPES: readonly ["text", "select", "link", "visibility", "image", "richText"]; /** One exposed property, with everything a row needs to draw itself. */ interface ExposedRow { /** The definition's stable id for the property, which the override is keyed by. */ readonly id: string; readonly label: string; readonly type: ExposedPropertyType; /** * The value in force, read back from the resolver's own result. * * `undefined` for a cleared row and for a definition that holds nothing * there; {@link cleared} separates the two. */ readonly value: OverrideValue; /** * Which layer supplied the value IN FORCE at this row's target: the * definition, a variant, or this instance. * * The target's, not the row's: two exposures aimed at one target share a * value, and the resolver reports the winning exposure's source on both. * What this row itself stores is {@link ownOverride}. */ readonly source: ExposedValueSource; /** True when the author cleared the property rather than inheriting or setting it. */ readonly cleared: boolean; /** * Whether THIS instance's record holds a value under this row's id — set * or cleared. What a reset would remove, and so whether one is offered: a * row shadowed by a neighbour that holds the override reads `instance` as * its source and has nothing of its own to reset. */ readonly ownOverride: boolean; /** Whether this inspector can draw a control for it. Carried, not recomputed. */ readonly supported: boolean; /** The choices, for `select` only; empty for every other type. */ readonly options: readonly { readonly value: string; readonly label: string; }[]; /** * The exposure actually in force at this row's target, when it is not this * one — carried with its label so the row can NAME what shadows it rather * than pointing at an id an author has never seen. */ readonly shadowedBy?: { readonly id: string; readonly label: string; }; /** * Why this row is read-only, when a `contentOnly` lock holds what it drives: * a value that is not content, inside an area locked to its content. The * same rule a save applies to the composed page, so the panel holds exactly * what the store would refuse. Absent where the row may change. */ readonly heldBy?: RefusalWording; /** * Where the setting may be bound to data: the schema of the component * block's prop it fills, named as the setting, which the binding picker * lists the fitting fields for. The placement's binding is written onto * that prop when the component is composed, so it is judged by that prop. * Absent for a setting no field fills. */ readonly bindable?: PropSchema; /** The placement's binding of this setting, where it has one. */ readonly binding?: Binding; } /** * A value this instance stores for a property the definition no longer * exposes. * * Surfaced rather than dropped, and separately from the rows: it is not a * property any more, so it has no label, no type and no control — only the * stored value and the offer to discard it. An author whose override * disappeared the moment somebody else edited the component is told, and * chooses. */ interface OrphanedOverride { readonly id: string; readonly value: OverrideValue; } /** The selected instance, as something to edit. */ interface InstanceInspection { readonly nodeId: string; readonly componentId: string; /** What the node IS, beside what it overrides: its own name and lock. */ readonly identity: BlockIdentity; /** * What to title the panel: the library's title for the definition, or the * id when the library has no row for it. */ readonly label: string; /** How many pages place this component, when the library can say. */ readonly usedOn?: number; /** * The variant this placement chose, by its stored key, with the label the * definition gives it; `label` is absent when the definition no longer * offers that variant. Absent when the placement chose none. */ readonly variant?: { readonly key: string; readonly label?: string; }; /** * Whether the lookup holds a definition for this instance. * * `false` is a state the panel has to draw rather than an error: the * canvas draws such an instance as could-not-be-loaded, and the panel says * the same thing in words. The rows are empty when this is false, and * empty when the definition exposes nothing — the flag is what tells the * two apart. */ readonly definitionFound: boolean; /** In the definition's own declared order, which is the order it designed. */ readonly rows: readonly ExposedRow[]; /** Overrides this instance holds for properties no longer exposed. */ readonly orphaned: readonly OrphanedOverride[]; } /** * Describe the selected instance for editing, or `null` when the selection is * not an instance — no selection, an id the document no longer holds, or an * ordinary block, which the block inspector answers for. * * `definitions` is the lookup the CANVAS resolves against, handed in rather * than fetched, so a row's value is read from the same document the page is * drawn from. `components` is the library's list, which is the only holder of * a definition's title and usage; the document itself carries neither. */ export declare function inspectInstance(document: BlockDocument, selectedId: string | null, definitions: ComponentLookup, components: readonly SavedComponent[], view?: LockView): InstanceInspection | null; /** * What an author is told after double-clicking text a component does not * expose: whose it is, with the variant the placement uses, and where its * editable fields are. The placement is selected, so the panel beside it is * the one this points to. */ export declare function partOfComponentSentence(inspection: Pick, heldExposureId?: string): string; /** * The patch that replaces the instance's override record. * * **The whole props object, not the one key**, for the reason `propPatch` * states: `updateNode` merges at the top level, so a patch carrying only * `{ props: { overrides } }` would drop `componentId` and the node would name * no component at all. And the KEY IS OMITTED when nothing remains: the * record is optional, so absent is what "no overrides" already means * everywhere else, and a stored empty record would be a second spelling of * the same state that every reader would have to know about. */ export declare function overridesPatch(node: BlockNode, overrides: Readonly>): NodePatch; /** * The op that sets one override — a value, or the `$unset` sentinel to clear * the property rather than inherit it. * * Read from the node at call time rather than from a row: a control committing * on blur can fire after another edit replaced the node, and a record rebuilt * from an older copy would resurrect overrides that edit removed. */ export declare function setOverrideOp(node: BlockNode, id: string, value: OverrideValue): BuilderOp; /** * The op that removes one override, so the property inherits again. * * Removal rather than writing the definition's value back: an override equal * to the definition's value is still an override, and would go on shadowing * the definition the next time somebody edits the component. */ export declare function resetOverrideOp(node: BlockNode, id: string): BuilderOp; /** The suffix that keeps two copies of a named block apart. */ export declare const COPY_SUFFIX = " copy"; /** A duplication, ready to apply. */ interface BlockDuplication { /** The re-id'd copy, with its name adjusted. */ readonly node: BlockNode; /** Immediately after the original, in the same parent and slot. */ readonly at: OpPosition; /** What to call the block in an announcement. */ readonly label: string; } /** * What duplicating the selected block would do, or `null` when it cannot. * * `null` for no selection and for an id the document no longer holds — which an * undo produces routinely — for a block holding an Entry content block, which * a template holds one of, and for a node whose parent has no named slot, * because that is a position the op vocabulary cannot express and therefore one * an insert could not be undone from. */ export declare function blockDuplication(document: BlockDocument, selectedId: string | null): BlockDuplication | null; /** A planned group, with what to say about it. */ interface SelectionEdit { /** The ops, in the order they must apply. */ readonly ops: readonly BuilderOp[]; /** How many blocks the author selected, for phrasing. */ readonly count: number; /** * How many blocks travel INSIDE the selected ones, across the whole group. * * Reported because a container takes its children with it and that is * invisible from the block an author had selected — a collapsed section looks * exactly like an empty one. Summed across the group rather than per block, * since the announcement describes one action. */ readonly descendants: number; /** * What to select once the group is gone, or `null` when nothing is left. * * A delete that left nothing selected would drop the author out of the * inspector and the toolbar for a reason they did not ask for. Taken from the * single-block rule's own `nextSelection`, skipping any candidate that is * itself being deleted — with a run of siblings removed together, most of * them name each other. */ readonly nextSelection: string | null; /** What to call the subject: the block's name, or "3 blocks". */ readonly subject: string; } /** What stopped an edit, phrased for an author. */ interface SelectionRefusal { readonly reason: string; } /** Either a plan or the reason there is none. */ type SelectionPlan = SelectionEdit | SelectionRefusal | null; /** * Whether a plan can be applied. * * Accepts any planned edit rather than only a {@link SelectionPlan}, because * every verb here answers with the same three-way shape and a caller should not * need a different guard per verb. The `reason` field is what separates a * refusal, and only a refusal carries one. */ export declare function isRefusal(plan: T | SelectionRefusal | null): plan is SelectionRefusal; /** * Removing every selected block. * * **One lock refuses the WHOLE group**, and that follows from the group being * atomic rather than being a separate policy: there is no half-done delete to * fall back to, so the choice is all or nothing, and silently skipping the * locked one would leave an author who selected six blocks looking at one they * did not notice surviving. */ export declare function selectionDeletion(document: BlockDocument, selectedIds: readonly string[]): SelectionPlan; /** A duplication, with the ids the copies will have. */ interface SelectionDuplication extends SelectionEdit { /** The copies, in document order, for selecting them afterwards. */ readonly newIds: readonly string[]; } /** * Copying every selected block, each beside its original. * * A lock does NOT refuse this: duplicating neither moves nor removes the * original, and refusing would mean an author could not copy the blocks they * had most deliberately protected. The copies carry the lock, as they do for a * single block. A lock AROUND the copy's place is another matter: putting a * block into a locked one is refused, as any insert there is. */ export declare function selectionDuplication(document: BlockDocument, selectedIds: readonly string[]): SelectionDuplication | null; /** * Locking or unlocking every selected block. * * Order-independent: each op addresses one node and changes only its own flag. */ export declare function selectionLock(document: BlockDocument, selectedIds: readonly string[], locked: boolean): SelectionEdit | null; /** A planned reorder, with what to say about it. */ interface SelectionMove { /** The moves, in the order they must apply. */ readonly ops: readonly BuilderOp[]; /** How many blocks the author selected, for phrasing. */ readonly count: number; /** What to call the subject: the block's name, or "3 blocks". */ readonly subject: string; } /** Either a reorder, the reason there is none, or `null` for nothing to say. */ type SelectionMovePlan = SelectionMove | SelectionRefusal | null; /** * Moving every selected block one step, keeping their order and their spacing. * * **A set moves only within one container.** Duplicate and delete are the * single-block verb repeated and need nothing of each other; a move is a step * through a list, so blocks in different lists are not doing the same thing. * That is a refusal an author is told about, because nothing on the page says * the selection straddles a boundary. * * **One block at the edge refuses the WHOLE group**, like a lock. Letting the * others move would close the gaps between them, and the set would come back * differently arranged than it went, so `up` would no longer be undone by * `down`. Preserving that inverse is what the two move axes exist to protect, * and a group edit is where it is easiest to lose. * * **Every position is the single-block rule's**, asked once per block. Nothing * here re-decides what one step means. */ export declare function selectionMove(document: BlockDocument, selectedIds: readonly string[], direction: "up" | "down"): SelectionMovePlan; /** * The device to edit at once the site's breakpoints change from `before` to * `after`, given the device the author had chosen. * * The chosen breakpoint while the site still offers it. Once it is removed, * the narrowest device that remains at least as wide as it was, so the author * stays as close as the site allows to the layout they were styling, without * moving to a narrower one whose styles reach fewer widths. A breakpoint left * at exactly the removed one's width is the same layout, and is kept: a set * may define two at one bound, where only the later one is offered until the * other is removed. The base when nothing as wide remains, which covers every * width above the remaining bounds. * * The removed breakpoint's width is read from `before`, since `after` no * longer has it. A chosen id `before` never offered as a device has no width * to compare, so it goes to the base, as {@link editingBreakpointOf} sends it. * * @experimental */ export declare function fallbackBreakpoint(before: BreakpointSet | undefined, after: BreakpointSet | undefined, chosen: string | null): BreakpointId; /** * The editor kind a leaf resolves to. * * Named separately from `StyleLeaf["kind"]` rather than reused, because the two * answer different questions and will not stay parallel: `dimension` and * `number` are distinct storage shapes that both draw a numeric field with a * scrub affordance, and a future leaf kind may reuse an existing control * outright. Collapsing them onto one name would make that a breaking rename. */ type StyleControlKind = "select" | "length" | "number" | "color" | "css" | "url"; /** * The leaf kinds this build can draw. * * DERIVED from the mapping rather than listed beside it. A second list agrees * with the mapping on the day it is written: adding a leaf kind and its * required map entry while forgetting the list still compiles, and * `controlForLeaf` then reports a kind it can perfectly well draw as * unsupported. * * Membership is still checked at runtime rather than trusted from the type, * because a catalog written by a NEWER engine can carry a kind absent from * both — and indexing a mapped type with it returns `undefined` while the type * says otherwise. Such a kind resolves to an unsupported descriptor rather * than to `undefined` flowing into a renderer, the same policy as * `inspector.ts`'s `SUPPORTED_PROP_TYPES`: the author is told the property * exists and is not editable here, because omitting it entirely would present * an incomplete property as a complete one. */ export declare const SUPPORTED_LEAF_KINDS: readonly StyleLeaf["kind"][]; /** * One editable position inside a property's value, with everything a control * needs to draw itself and nothing about how it is drawn. */ interface StyleControl { /** The catalog key this belongs to, as stored in a `StyleValues` record. */ readonly property: string; /** * Where inside the property's value this control writes, outermost first. * * Empty for a property stored as a scalar. `["blockEnd"]` for the bottom * margin, `["startStart"]` for the top-left corner radius. A control writes * by handing this path back to `style-values.ts`, which is what keeps the * addressing in one place rather than in every control. */ readonly path: readonly string[]; /** The leaf the catalog declares at this path, carrying units, bounds and token kinds. */ readonly leaf: StyleLeaf; /** * The control to draw, or `undefined` when this build has no control for the * leaf's kind. * * Carried rather than recomputed by the panel, for the reason `EditableProp` * carries `supported`: the panel would have to repeat the membership test, and * the two would disagree the first time the set gained a member. */ readonly kind: StyleControlKind | undefined; /** Whether {@link kind} is present. */ readonly supported: boolean; /** * Whether the value stored here is one the Baseline gate withholds: a value * of a withheld property, or a withheld keyword. Such a value is still on * the page, so it is shown and may be cleared, and nothing new is offered. */ readonly withheld: boolean; } /** * A union's variants, when the shape at a path accepts more than one form. * * `borderRadius` stores either one measurement or four corners, and an editor * offers a way to move between them. Recorded here so that affordance reads the * catalog's own list instead of re-deriving which forms exist. */ interface StyleControlVariants { /** * Where in the property's value the choice sits, empty at the root. * * Carried because a union is not only a top-level shape: `position.zIndex` is * a number OR the `auto` keyword, nested a level down. Reporting choices only * at the root would leave a renderer no way to offer `auto` at all. */ readonly path: readonly string[]; /** Which variant the returned controls describe, as an index into the union. */ readonly active: number; /** How many variants the catalog declares at this position. */ readonly count: number; /** * Each arm's own shape kind, in the catalog's order. * * Carried so an affordance offering the choice can NAME the forms from the * catalog rather than numbering them: `borderRadius` is a length or four * corners, and "Form 1 / Form 2" tells an author nothing about which is * which. The arms have no names of their own, so their shape kind is the * most specific thing the catalog actually says about them. */ readonly kinds: readonly StyleShape["kind"][]; /** * Each arm in plain words, in the catalog's order: what the toggle offering * the choice says. Derived from the arms here, once, so nothing else names * a form its own way. Optional, so a variant built to the earlier shape * stays valid; read it through {@link formNamesOf}. */ readonly names?: readonly string[]; } /** * What a caller can tell the resolver about the site. * * DERIVED from the engine's own option type rather than restated beside it. * Both this and `StylePolicy` in `style-values.ts` are the same contract — what * this site allows — read at two moments, and three structural copies of it * would all keep compiling while the next field was added to one: arm selection * and write validation would then disagree about a value, which is the failure * the module docblock above describes from the other direction. * * Kept as a NAME rather than making callers import the engine's, because it is * this package's public surface and a rename there should not be one here. */ type StyleControlOptions = StyleUnionVariantOptions; /** * Everything {@link styleControlsFor} accepts. * * The site policy, plus the one thing the engine has no opinion about: which * form an AUTHOR has chosen to write a value in. A union's arm is decided by * the stored value wherever there is one, so this is consulted only where the * position is unset — which is exactly when the engine has nothing to read and * answers with the catalog's first arm for every caller alike. */ interface StyleControlInput extends StyleControlOptions { /** * The arm an author picked at one position inside the value, if any. * * Addressed by the same path a control carries, so a union nested below the * property root is answerable too — `position.zIndex` is a number OR `auto`, * and a caller that could only speak about the root could never offer it. */ readonly variantAt?: (path: readonly string[]) => number | undefined; } /** A property's controls, and every choice of form its shape offers. */ interface StyleControlSet { readonly property: string; readonly controls: readonly StyleControl[]; /** Empty when the property's shape holds no union at any depth. */ readonly variants: readonly StyleControlVariants[]; } /** * The controls one catalog property offers. * * `value` is optional and affects exactly one thing: which arm of a union the * controls describe. Every other answer is a property of the catalog alone, * which is what lets a caller derive a panel before any value is loaded. */ export declare function styleControlsFor(property: StyleProperty, value?: StyleValue, options?: StyleControlInput): StyleControlSet; /** * The site policy a value is judged against. * * Carried rather than defaulted, because the engine ships no host list of its * own: which hosts a site will fetch from is the operator's decision. Omitting * it from a validation run does not mean "allow" — it means the question was * never asked — so a control that never forwarded it would accept a URL the * published compiler refuses, show it in the preview, fetch it from the editor, * and let the author save a value that then vanishes from the page. * * DERIVED rather than restated. This and `StyleControlOptions` are the same * contract read at two moments — choosing which arm to draw, and judging the * write — and they must never disagree about a field. Both trace to the * engine's own option type, so a field added there reaches all three at once. */ type StylePolicy = StyleControlOptions; /** Where a control reads and writes. */ interface StyleAddress { readonly state: StyleState; readonly breakpoint: BreakpointId; /** The catalog key, as stored in a `StyleValues` record. */ readonly property: string; /** * The position inside the property's value, from `StyleControl.path`. * * Empty addresses the property itself. A control never builds this by hand: * it carries the path the descriptor gave it, which is what keeps the two * from disagreeing about where a side or a corner lives. */ readonly path: readonly string[]; } /** * The outcome of asking for a write. * * A discriminated union rather than a thrown error, because a refused value is * an ordinary thing for a control to encounter — a half-typed length is invalid * for as long as it takes to type the unit — and an exception on every keystroke * is not a control flow anyone wants to write against. */ type StyleWrite = { readonly ok: true; /** * The op to apply, or `null` when the document already holds this value. * * `applyOp` REFUSES an update that changes nothing — "a history entry for * it would undo to no visible effect" — so an SDK that always handed back * an op would advertise one that throws on the ordinary cases: resetting * a control that was already unset, or retyping the value a node already * holds. Null says the ask was valid and there is nothing to do. */ readonly op: BuilderOp | null; /** * Findings the catalog reported that do not refuse the write. * * Carried rather than dropped: a warning is the validator explaining * something about a value it accepted, and a control that discarded them * would present an accepted-with-reservations value as an unremarkable * one. */ readonly warnings: readonly ValidationIssue[]; } | { readonly ok: false; readonly issues: readonly ValidationIssue[]; }; /** * A value wrapped in the containers its path names. * * A control holds a scalar and an address; both the validator and the compiler * take the property's WHOLE value. Building the containers in one place is what * lets the commit judge exactly the shape the preview compiled — two copies * would agree until either moved. */ export declare function styleValueAtPath(path: readonly string[], value: StyleValue): StyleValue; /** The value a control is currently showing, or `undefined` when nothing set it. */ export declare function readStyleValue(styles: NodeStyles | undefined, address: StyleAddress): StyleValue | undefined; /** The op that sets one control's value, or the reasons the value was refused. */ export declare function styleWriteOp(nodeId: string, styles: NodeStyles | undefined, address: StyleAddress, value: StyleValue, policy?: StylePolicy): StyleWrite; /** One address and the value to put there. */ interface StyleWriteRequest { readonly address: StyleAddress; readonly value: StyleValue; } /** * ONE op that sets several addresses on ONE node. * * ## Why this is not a list of `styleWriteOp` results * * A style op patches the WHOLE `styles` envelope. Four calls to `styleWriteOp` * built from the same node therefore produce four complete envelopes that each * know about one side, and whichever is applied last wins — the other three * sides are silently dropped. `batchStyleWriteOps` documents the same mechanism * from the other direction, where an op built from the primary carried the * primary's unrelated declarations to every block in the selection. * * Folding is what fixes it: each write is computed against the envelope the * previous one produced, so the last envelope carries all of them and is the * only op anyone needs. That it is ONE op rather than a group is also what * makes "one gesture, one undo entry" a property of the value layer instead of * something every caller has to remember to ask `applyAll` for. * * ## Judged per write, not on the merged result * * Every write is validated on its own leaf, exactly as the singular does. * Judging the folded envelope instead would look at the LAST value written to a * property and miss the other three — so a drag that set three legal sides and * one impossible one would commit all four. * * Atomic: the first refusal ends it and no op is returned. A gesture that * writes some of the sides it promised is not a smaller version of the edit the * author asked for. * * An empty list is not an error and produces `op: null` — the same answer as a * write that changes nothing, which is what it is. * * @param nodeId - the node being edited * @param styles - that node's own styles before the edit * @param writes - the addresses to set, applied in order * @param policy - the site policy every value is judged under * @returns one op for all of them, or the reasons the first refusal gives */ export declare function styleWriteOps(nodeId: string, styles: NodeStyles | undefined, writes: readonly StyleWriteRequest[], policy?: StylePolicy): StyleWrite; /** * The op that clears one control's value at this state × breakpoint. * * Clearing is not writing an empty string: a property with no entry falls back * through the cascade to whatever a class, a block default or a wider * breakpoint set, which is what an author asking to reset a control means. A * stored empty value would instead pin the property to nothing here and win * over the tier the author wanted back. */ export declare function styleClearOp(nodeId: string, styles: NodeStyles | undefined, address: StyleAddress, policy?: StylePolicy): StyleWrite; /** What the host knows about the site's shared styles and the author's right. */ interface SharedStyleOffer { /** The site's library, or `undefined` while it has not been read. */ readonly library: readonly NamedClass[] | undefined; /** Whether the author may change the site's design (`update-site-style`). */ readonly mayChange: boolean; /** * The editor's lock view (`lockViewOf`), so a block inside an area locked * to its content is refused here as the dialog refuses it. The registry's * locks alone when omitted. */ readonly view?: LockView; } /** The menu verbs, by the type each turns the block into. */ declare const TURN_INTO_TARGETS: { readonly "turn-into-text": "core/text"; readonly "turn-into-rich-text": "core/rich-text"; readonly "turn-into-heading": "core/heading"; }; /** One of the menu verbs. */ type TurnIntoActionId = keyof typeof TURN_INTO_TARGETS; /** The editor's own lock question, asked of the ops a verb would apply. */ type LockQuestion = (ops: readonly BuilderOp[]) => LockRefusalFacts | undefined; /** The verbs the bar offers, in the order it draws them. */ type ToolbarActionId = "select-parent" | "move-up" | "move-down" | "duplicate" | "copy" | "cut" | "paste" | "copy-style" | "paste-style" | TurnIntoActionId | "save-as-pattern" | "save-as-shared-style" | "edit-component" | "turn-into-component" | "detach-component" | "duplicate-component" | "update-pattern" | "wrap-in-box" | "unwrap" | "delete"; /** One button's worth of decision. */ interface ToolbarAction { readonly id: ToolbarActionId; /** * The accessible name, which is also the tooltip. * * Fixed per verb rather than naming the block: the bar is drawn against the * block it acts on, so "Duplicate" is unambiguous there, and a name that grew * with the block's would reflow the bar on every selection. */ readonly label: string; /** Whether pressing it would do anything. */ readonly enabled: boolean; /** * Why it is disabled, phrased for an author, or `undefined` when enabled. * * Set for every disabled item, so nothing is dimmed without a word: a lock, * which nothing on the canvas explains and whose remedy is one field away, * and the plain edges too ("Already the first block here"), since a dimmed * item with no reason reads as broken rather than as finished. */ readonly reason?: string; /** * Offered from a menu rather than as a button of its own: the block * toolbar keeps these behind its "More" button, and the context menu groups * them, so the bar stays one short row however many verbs the host adds. */ readonly inMenu?: true; /** * What the verb removes, said beside it before it is chosen: "Turn into * Heading" removes bold and links. Visible text under the label, as a * reason is. */ readonly note?: string; } /** * What the host offers for making components from a selection. * * Absent where the host has no component library to write to, and then * neither verb is offered at all. */ interface ComponentVerbsOffer { /** * Whether the author may create and publish components, which both verbs * need: the component is created published. `false` dims both, with * {@link MAKE_COMPONENT_GRANT_REFUSAL}. */ readonly mayCreate: boolean; /** * The component definitions the canvas draws, which a detach inlines. * Absent, Detach is not offered. */ readonly definitions?: DefinitionsById; /** * Whether the author may update and publish patterns. Absent, "Update * pattern" is not offered; `false` dims it with the reason. */ readonly mayUpdatePattern?: boolean; } /** * The toolbar's buttons for the current selection, or `[]` when there is none. * * `[]` also covers a selected id the document no longer holds, which an undo * produces routinely — the bar is drawn against an element, and there is no * element for a node that is gone. */ export declare function toolbarActions(document: BlockDocument, selectedId: string | null, selectedIds?: readonly string[], nesting?: NestingSource, mayCreatePattern?: boolean, lockRefusalFor?: LockQuestion, components?: ComponentVerbsOffer, offersEditComponent?: boolean, sharedStyles?: SharedStyleOffer, planned?: boolean, limits?: DocumentLimits): ToolbarAction[]; /** * The smallest rectangle containing all of them, or `undefined` for none. * * What a floating bar anchors to once a selection can hold several blocks. The * PRIMARY's rectangle would be the easy choice and is the wrong one: with two * blocks selected at opposite ends of a page, a bar drawn at one of them * describes an action that is about to happen to both, and the author cannot * see the other. The union is the shape the selection actually occupies. */ export declare function unionRect(rects: readonly Rect[]): Rect | undefined; /** How big the bar measured, in canvas content pixels. */ interface ToolbarSize { readonly width: number; readonly height: number; } /** Where the bar is drawn, and which side of the block it landed on. */ interface ToolbarPlacement { readonly x: number; readonly y: number; /** * Above the block; inside its top-left corner where there is no room above * it on screen; or pinned to the top of the screen over a tall block whose * own top is scrolled out of view. */ readonly side: "above" | "inside" | "pinned"; } /** * The part of the canvas on screen, in its coordinates: top and bottom, and * the left and right edges where the canvas scrolls sideways too. */ interface ToolbarScreen { readonly top: number; readonly bottom: number; readonly left?: number; readonly right?: number; } /** The gap between the bar and the block it names, in pixels. */ export declare const TOOLBAR_GAP_PX = 6; /** * Where to draw the bar for a block, in the canvas's own content coordinates. * * **Above by default, inside the block when there is no room.** Above keeps * the bar off the block's own content, which is what an author is looking at. * The first block on a page has nothing above it, and there the bar is drawn * just inside the block's top-left corner: over the block it names, and never * below it, where it would cover the next block. Whatever is drawn above the * block on the canvas counts as room, a Layout's header included, since the * bar may cover that but no other block of the page. * * **Left-aligned to the block, never centred.** A centred bar moves whenever * the block's width changes — which happens while an author is editing its * padding — so the button they are reaching for slides out from under the * pointer. The leading edge is the one part of a block that stays put. * * **Clamped horizontally, never vertically.** A bar pushed off the right edge * is unreachable, so it slides back in. Vertical overflow is handled by the * side chosen rather than by clamping. * * **Kept to what is on screen** (`screen`, the whole page when not given): * room above is room above on screen, so a block just below the screen's top * takes its bar inside; and a tall block whose top is scrolled away keeps its * bar pinned at the top of the screen, over the block, where an author * working in its middle can reach it. */ export declare function toolbarPlacement(block: Rect, toolbar: ToolbarSize, canvas: ToolbarSize, gap?: number, screen?: ToolbarScreen, parts?: readonly Rect[]): ToolbarPlacement; /** The verbs a palette command needs, as `BlockKeyboardActions` publishes them. */ interface CommandVerbs { readonly move: (direction: "up" | "down") => void; readonly delete: () => void; readonly duplicate: () => void; /** Copy, Cut and Paste of blocks, through the clipboard. */ readonly copy: () => void; readonly cut: () => void; readonly paste: () => void; /** * Copy one block's look, and give it to every selected block. Optional, * so a host built before them keeps compiling; absent, they do nothing. */ readonly copyStyle?: () => void; readonly pasteStyle?: () => void; readonly selectParent: () => void; /** * Begin storing the selection in the pattern library. * * REQUIRED, like the four above it, and that is a decision rather than an * oversight. Nothing else here is a capability a host may lack, and making * this one optional produces the shape the totalised runner map exists to * prevent: a verb the bar offers with nothing bound to it, which reaches an * author as a button that does nothing. Required, the compiler names every * host that has to wire it. * * A host with no library to save into is a real case and not one there is a * second example of yet. Designing an availability model against a guess is * how a surface ends up with a control that is dimmed for a reason nobody can * phrase; when there is a second host it can be designed against that. */ readonly saveAsPattern: () => void; /** * Open the selected placement's component in its own view. Silent when the * selection is not one placement or the host does not offer it, so it may * be pressed without asking first. Optional, so a host built before it * keeps compiling; absent, the verb does nothing. */ readonly editComponent?: () => void; /** * Begin turning the selection into a component, replacing it with a * placement or keeping it and saving a copy; the host owns the form. */ readonly turnIntoComponent?: () => void; /** Begin detaching the selected placement from its component. */ readonly detachComponent?: () => void; /** Begin duplicating the selected placement's component. */ readonly duplicateComponent?: () => void; /** Put the selected blocks in a new Box at their place. */ readonly wrapInBox?: () => void; /** Replace the selected container by its blocks. */ readonly unwrap?: () => void; /** Begin replacing a pattern's content with the selection. */ readonly updatePattern?: () => void; /** Begin saving the block's look as a shared style; the host owns the form. */ readonly saveAsSharedStyle?: () => void; /** * Turn the selected block into another type (`"core/heading"`), as one undo * step, saying what it removes. Optional, so a host built before it keeps * compiling; absent, the verb does nothing. */ readonly turnInto?: (to: string) => void; } /** Everything the command list is built from. */ interface BuilderCommandsInput { /** * What the bar would offer for this selection, from `toolbarActions`. * * Taken rather than derived, and that is what keeps availability DERIVED in * the sense that matters: the palette now shows exactly the list the toolbar * and the context menu are drawing, because it is the same array. Asked * separately it was a second call — one that could be given a narrower * question, which is how this surface came to offer a verb the bar refused — * and not a cheap one either, since deciding whether a selection can be saved * builds the document a save would store. */ readonly actions: readonly ToolbarAction[]; readonly verbs: CommandVerbs; readonly undo: () => void; readonly redo: () => void; readonly canUndo: boolean; readonly canRedo: boolean; /** * Leaving the editor, when the host has somewhere to go. * * Optional for the same reason the shell's exit affordance is: the editor * mounts both standalone and embedded in a form that is already on screen, * and a palette offering "Close the editor" where nothing closes is a command * that does nothing. */ readonly onExit?: () => void; } /** The group the block verbs are listed under. */ export declare const BLOCK_GROUP = "Block"; /** The group undo and redo are listed under. */ export declare const HISTORY_GROUP = "History"; /** The group leaving the editor is listed under. */ export declare const EDITOR_GROUP = "Editor"; /** * What each toolbar action id actually RUNS. * * Published rather than kept inside the palette because the palette is no * longer the only surface over these verbs: the right-click menu offers the * same list, and a second copy of this map is how one surface comes to move a * block while another duplicates it. The AVAILABILITY of an action is * `toolbarActions`'s answer and the LABEL is the surface's own; this is the * third and last thing a surface needs, and the only one they can all share. * * Total over {@link ToolbarActionId}, so a verb added to the bar cannot reach a * surface with nothing bound to it — the compiler names the omission here. */ export declare function blockActionRunners(verbs: CommandVerbs): Record void>; /** * The palette's commands for the current state. * * Unavailable commands are OMITTED rather than listed and disabled, which is * the opposite of what the toolbar does — and deliberately. A toolbar keeps one * shape so the control an author is aiming at does not move; a palette is * searched rather than aimed at, and a row that matches the search and then * refuses to run is worse there than one that was never offered. */ export declare function builderCommands({ actions, verbs, undo, redo, canUndo, canRedo, onExit }: BuilderCommandsInput): BuilderCommand[]; /** * What to tell an author about a refusal. * * The `permitted` set is spelled out where the planner supplies one, because * "this block only works inside another one" sends an author looking while * naming the containers tells them where. The refusal carries the set rather * than leaving it to be looked up again — `NestingVerdict` says why — so this * never asks the rule source a second question. * * **What the set MEANS depends on the cause**, which is the reading * `refusalWording` already takes of the same list. For `not-allowed-in-slot` * the planner answers with what the SLOT ACCEPTS — the children it will hold — * and for the other two with the CONTAINERS the refused block may sit in. * Read as containers either way, a narrowed slot produces "It belongs inside * Heading or Text" about blocks that are neither containers nor where anything * belongs. * * The joiner follows from that: containers are alternatives an author picks * between, and a slot's list is an enumeration of what it holds. * * Through the SAME prose the drag refusal uses. The set holds registry * specifiers, and a namespace wildcard is not a block name: read naively, * `core/*` announces that a block "belongs inside *". */ export declare function compositionRefusalReason(refusal: PlanRefusal): string; /** * Whether a string is a cause this vocabulary knows. * * Derived from the copy map, which is total over {@link PlanProblem}, so this * recognises exactly the causes a sentence exists for and cannot drift from * them. It exists because a cause can arrive from OUTSIDE the process: a save * refused by the server carries its `PlanProblem` on the wire, and the surface * that has to phrase it is holding a string rather than a typed union. */ export declare function isPlanProblem(value: unknown): value is PlanProblem; /** The priority that puts the editor's claim above a host page's bindings. */ export declare const CANVAS_ESCAPE_PRIORITY = 1; /** * Whether a modal is open, and therefore owns Escape. * * Read from the DOM rather than from editor state, because the components that * matter — the command palette today, whatever a host mounts tomorrow — portal * to the body and are outside every React tree this could subscribe to. The * attribute pair is what the dialog primitive already publishes, so this reads * a contract rather than a convention. */ export declare function modalIsOpen(root: Document | undefined): boolean; /** * Whether focus is somewhere that Escape means something else. * * A field's own dismissal — closing a combobox, abandoning an IME composition, * reverting an edit in progress — is what Escape means while typing, and * clearing the canvas selection out from under it would answer a question the * author did not ask. * * The claim is still made in that case, and that is the point: standing down * would let the keystroke fall through to the form's "cancel and go back", * which is the data loss this module exists to stop. So the answer here decides * what Escape DOES, never whether the editor consumes it. */ export declare function isTextEntry(element: Element | null): boolean; /** * Where an Escape press started, and the canvas it may have started on. * * Both halves come from outside the DOM's present state on purpose: the origin * from the keydown itself, and the frame from the editor's own record of the * canvas, so the answer cannot depend on what a closing layer did to focus * between the keystroke and the rule reading it. */ interface EscapePress { /** * The element the keydown was dispatched on, from {@link pressOrigin}; * `null` when it was dispatched on no element at all. */ readonly origin: Element | null; /** * The frame the canvas is drawn in, or `null` while the canvas shares the * editor's own document and there is no separate place to send focus. */ readonly canvasFrame: HTMLIFrameElement | null; } /** What pressing Escape over the editor should do. */ type EscapeOutcome = "defer-to-modal" | "leave-to-field" | "return-to-canvas" | "navigate-selection"; /** * The whole rule, as one decision a test can make without a keyboard. * * Everything but `"defer-to-modal"` is CONSUMED by the editor, and they differ * only in what happens afterwards: the focused field or floating layer keeps * the key's meaning, focus goes back to the canvas, or the selection moves. * Only `"defer-to-modal"` declines the key, and it declines to something that * is itself dismissing on Escape. * * **The selection is deliberately not an input.** This answers who OWNS the * key, and the editor owns it whether or not a block is selected — an editor * that released Escape once the canvas happened to have nothing selected would * lose the author's work in exactly the state a click on background produces. * What it does with the selection — up to the block holding it, or clear at * the top — and whether there is a selection at all are the caller's * questions, asked after this one. */ export declare function escapeOutcome(root: Document | undefined, press: EscapePress): EscapeOutcome; /** What a control's dot reports. */ type StyleProvenance = { readonly kind: "unset"; } | { readonly kind: "authored"; readonly entry: StyleTraceEntry; } | { readonly kind: "inherited"; readonly entry: StyleTraceEntry; readonly from: StyleOrigin; } | { readonly kind: "ambiguous"; readonly entry: StyleTraceEntry; /** Every catalog property that writes this declaration, this one included. */ readonly sharedWith: readonly string[]; }; /** Everything needed to place one control's dot. */ interface StyleProvenanceQuery { /** The declarations the compiler wrote, in emission order. */ readonly trace: readonly StyleTraceEntry[]; /** The node the control belongs to, and the ancestors whose rules reach it. */ readonly subject: StyleSubject; /** * The CSS property, as the trace records it. * * Taken from the control's own leaf (`StyleLeaf.cssProperty`) rather than from * the catalog key: two catalog keys can write one CSS property, and the trace * records what was written. */ readonly cssProperty: string; /** * The selector inside the block this control's declaration attaches to, from * the control's own leaf (`StyleLeaf.descendant`), and `undefined` for the * ordinary case of styling the block itself. * * Load-bearing, because a CSS property does not identify a control on its * own. The catalog writes `color` from THREE properties: `color` on the block, * `linkColor` on ` a`, and `linkColorHover` on ` a:hover`. `styleOrigin` reads * the descendant for SPECIFICITY and does not filter on it, so a query * carrying only the property lets a link rule win the plain text-colour * control — reporting an unset control as authored, and all three controls as * showing the same value. */ readonly descendant?: string; /** The state being edited. */ readonly state: StyleState; /** The breakpoint being edited, which is what "authored here" is measured against. */ readonly breakpoint: BreakpointId; /** * Every breakpoint live at the width being viewed. * * Distinct from {@link breakpoint}, and both are needed: the live set decides * which declarations are in play at all, while the edited one decides whether * the winner among them belongs to this control. An editor simulating a narrow * viewport inside a wide window is the ordinary case, so neither can be * derived from the other. */ readonly liveBreakpoints: readonly BreakpointId[]; /** * Every state whose rules are matching right now. * * A fact about the viewer, exactly as {@link liveBreakpoints} is: an element * under a pressed pointer matches `:active` AND `:hover`, and a focused one * being hovered matches two more. All of their rules apply at once, and * because each is wrapped in `:where()` none outranks another — so emission * order alone decides, and a winner can come from a state other than the one * being edited. * * Omitted means the state being edited plus base, which is right when the * canvas simulates exactly the state under the cursor. A canvas that * simulates several should say so, or a control will report a value the * browser is not showing. */ readonly liveStates?: readonly StyleState[]; } /** * Where the value a control is showing came from. * * Undefined from `styleOrigin` is a real answer rather than a failure — a * property no tier set is one the browser takes from its own defaults, and a * control over it is genuinely empty. */ export declare function styleProvenance(query: StyleProvenanceQuery): StyleProvenance; /** The node a scrub is previewing against. */ interface ScrubTarget { readonly nodeId: string; /** * The class the compiler emitted for this node. * * Supplied rather than derived from the id. `nodeClassName` cannot see a hash * collision — only `nodeClassNames`, which reads the whole document, can — so * a target that hashed the id itself would preview against the wrong node on * exactly the documents where the compiler had already disambiguated. */ readonly nodeClass: string; /** * The container a preview surface compiled this page's breakpoints against. * * Carried because the override must be wrapped in the SAME at-rule the rule * it outranks was emitted under. Compiled without it while the page was * compiled with it, a non-base override sits in `@media` while its target sits * in a container query — so in a narrow canvas inside a wide window the * override matches nothing, the drag looks frozen, and the value jumps into * place on commit. */ readonly previewContainer?: string; /** * The document's compile scope, when it has one. * * `compilePageCss` anchors every rule to `${PAGE_ROOT_SELECTOR}.${scope}`, so * a preview that spelled the unscoped root would sit one class BELOW the rule * it is previewing over — the stored value would win and the drag would show * nothing move. It would also reach a same-class node in another document * rendered beside this one. * * Escaped through the engine's own `escapeIdentifier`, so the preview and the * compiled sheet cannot disagree about a scope needing escapes. */ readonly scope?: string; /** * The site's breakpoint definitions, as the canvas compiles with. * * `compilePageCss` wraps a non-base breakpoint's rules in `@media` or * `@container` — measured, a `mobile` value comes out inside * `@media (max-width: 640px)`. A preview that ignored the address's * breakpoint would show the value at every width and lose it on release, and * for a breakpoint id this site does not define the compiler writes no rule * at all while an unconditional preview still showed one. * * Omitted means every value previews unconditionally, which is right only for * a site whose breakpoints are all unconditional. */ readonly breakpoints?: BreakpointSet; readonly address: StyleAddress; /** * The custom-property prefix this site emits tokens under. * * `compilePageCss` takes it from `StyleCompileContext.tokenPrefix`, so a site * that configured `--acme-` would have its published sheet read * `var(--acme-brand)` while a preview compiled with the default read * `var(--site-brand)` — a token that resolves to nothing, or to a different * value, for exactly as long as the drag lasts. Omitted means the engine's * own default, which is what the compiler falls back to. */ readonly tokenPrefix?: string; /** The site policy, forwarded to the compile so a refused URL never previews. */ readonly policy?: StylePolicy; /** * The node's own styles, so the preview can decline to outrank a state it * does not belong to. * * The compiler emits one rule per state at EQUAL specificity, in * `STYLE_STATES` order — measured: base, then hover, then focus, then active, * each constrained by a zero-specificity `:where()`. Later therefore beats * earlier on document ORDER alone, and a preview mounted after the whole * sheet is later than all of them. So a base-state preview silently outranks * an existing hover declaration: the block shows the scrubbed base value * while the pointer is over it, and reverts to hover on release. * * Given the styles, the rule excludes exactly the states that are emitted * AFTER this one and declare THIS address. The exclusion is written with * `:not(:where(...))`, whose specificity is that of its most specific * argument — and `:where()` is always zero — so the rule still ranks exactly * where the compiler put the one it is previewing over. Raising specificity * instead would win the hover case and lose the contract: the preview would * land somewhere the committed value cannot. * * Omitted, the preview outranks every later state, which is the behaviour * this field exists to correct. Supply it whenever a node may carry * interaction states — which is any node an editor can style. */ readonly styles?: NodeStyles; } /** Every state's fragment, for a caller that wants them warmed or asserted. */ export declare function scrubStateFragments(): ReadonlyMap; /** CSS for the value under the pointer, or the reasons it was refused. */ type ScrubPreview = { readonly ok: true; readonly css: string; /** * What the compiler remarked on while writing this declaration. * * Emitting and objecting are not the same outcome. A site whose * `tokenPrefix` is invalid gets its declarations written under the * engine's default prefix WITH a warning saying so — measured: a plain * `24px` compiles to one declaration and one `severity: "warning"` * issue. Treating that as a refusal would blank every preview on that * site, including values with no token in them, while the commit * succeeded and the published page rendered normally. */ readonly warnings: readonly ValidationIssue[]; } | { readonly ok: false; readonly issues: readonly ValidationIssue[]; }; /** * The stylesheet text that shows `value` without touching the document. * * Only the scrubbed property is compiled. Everything else the node carries * still comes from the sheet underneath, so a preview of one side of a margin * does not restate — and cannot accidentally drop — the other three. */ export declare function scrubPreviewCss(target: ScrubTarget, value: StyleValue): ScrubPreview; /** * The single op that ends a scrub. * * Separate from the preview and deliberately not derived from it: the preview * is CSS the canvas throws away, and the commit is a document edit. Passing one * through the other would make the stored value a function of a string that was * built for display. */ export declare function scrubCommitOp(target: ScrubTarget, styles: Parameters[1], value: StyleValue): StyleWrite; /** Behaviour a control cannot derive from its leaf. */ interface StyleControlBehaviour { /** * What a screen reader announces in place of the raw value. * * A slider's thumb reports its number, and a number is the wrong unit of * meaning for some properties. `aria-valuetext` is where a spoken form * belongs, and it is read from the THUMB rather than inherited from anything. */ readonly ariaValueText?: (value: StyleValue) => string; } /** Behaviour by key, as an editor is configured with it. */ type StyleControlBehaviours = ReadonlyMap; /** * The default: nothing registered. * * Exported as a value so a caller has something to pass rather than reaching * for `new Map()` and creating one per render. */ export declare const NO_STYLE_CONTROL_BEHAVIOUR: StyleControlBehaviours; /** * The key a control's behaviour is registered under. * * Derived from the catalog's own identity — the property key and the path * inside its value — so nothing has to be added to `catalog.ts` for a control * to be addressable. A dot separates the segments because a catalog key is a * JavaScript identifier and a path segment is a declared field name, so neither * can contain one and the join is unambiguous. */ export declare function styleControlBehaviourKey(property: string, path: readonly string[]): string; /** The behaviour registered for a control, when there is one. */ export declare function styleControlBehaviour(behaviours: StyleControlBehaviours, property: string, path: readonly string[]): StyleControlBehaviour | undefined; /** How a block's parent lays it out at the edited device. */ type ParentArrangement = "flow" | "column" | "row" | "grid"; /** The Style tab's sections, by key. */ type InspectorSectionKey = "block-style" | "layout" | "inside-parent" | "spacing" | "size" | "position" | "typography" | "background" | "border" | "effects" | "icon" | "css-properties"; /** Which state × breakpoint the panel reads and writes, and what the site is. */ interface StyleInspectionOptions extends StyleControlOptions { /** * The form an author picked for one union position, if any. * * Addressed by property AND path, because a union can sit below the property * root — `position.zIndex` is a number or `auto`. Consulted only where * nothing is stored: a stored value decides its own arm, and the engine * decides that. */ readonly variantAt?: (property: string, path: readonly string[]) => number | undefined; /** * The interaction state being edited. * * `base` unless a caller says otherwise. The switcher that changes it does * not exist yet, and defaulting to anything else would write hover styles * from a panel with no way to say so. */ readonly state?: StyleState; /** * The breakpoint being edited. * * The engine's unconditional context unless a caller says otherwise, for the * same reason: a panel with no breakpoint switcher must write the rules that * apply at every width, not a narrow band an author never chose. */ readonly breakpoint?: BreakpointId; /** * Whether the block renders a replaced element (an image, a video, an * embed), which is where the media fit properties have an effect. The canvas * knows what a block renders as; the document does not. `false` counts as * known only where the canvas has been read (the cascade's subject names the * element drawn); before that, every property is treated as applying. */ readonly media?: boolean; /** * The styles the controls read, when they are not the node's own: a shared * style the block wears, chosen as the target. The node's own otherwise. */ readonly styles?: NodeStyles; /** * The site's breakpoints, so the display a tier is judged by can be read * through the wider tiers that also apply at this one. Without them only * this tier and the unconditional one are read. */ readonly breakpoints?: BreakpointSet; /** * The page's compiled cascade and the node in it, so the display a tier is * judged by includes what a class or the block's own defaults set, not just * the node's stored styles. Without it only the node's own values are read. */ readonly cascade?: { readonly trace: readonly StyleTraceEntry[]; readonly subject: StyleSubject; }; } /** One catalog property as the Style tab offers it. */ interface InspectedStyleProperty { /** The catalog key, as stored in a `StyleValues` record. */ readonly property: string; /** The property's name as a human reads it. */ readonly label: string; /** The catalog's own one-line description, for a tooltip or a hint. */ readonly summary: string; /** One descriptor per editable position inside the property's value. */ readonly controls: readonly StyleControl[]; /** Every choice of form the property's shape offers, empty when it holds no union. */ readonly variants: readonly StyleControlVariants[]; /** What this node stores for the property at this address, if anything. */ readonly value: StyleValue | undefined; /** * Whether this node sets the property HERE. * * At this state and breakpoint only, and deliberately: a value inherited from * the base breakpoint is not one this panel would clear, so reporting it as * set would put a reset affordance on a control that has nothing to reset. * Where the value visibly comes from is `styleProvenance`'s question, and it * needs the compiler's trace rather than the document. */ readonly set: boolean; /** * Whether the block's `supports` still declares this property. * * False only for a property this node STORES and the block no longer offers — * a capability removed by a block update, or a value written through the API, * which never consults `supports` at all. Carried rather than dropped so the * panel can say why a control is there: the value is live on the page, and an * author looking at styling they cannot explain needs the control that clears * it more than they need it hidden. */ readonly offered: boolean; /** * Whether it has an effect on this block, as the engine answers it: true * wherever what the block is could not be read. */ readonly applies: boolean; /** * Whether its tier shows it without being asked for while the block is * edited this way, whether or not it applies. False makes it a property the * author adds from "Add CSS property", drawn in "CSS properties" once added * or holding a value. */ readonly tierShows: boolean; /** * The engine's answer for each field of an object property that answers * per field (`position`'s `zIndex`), where one does. */ readonly fieldApplies?: Readonly>; /** * Whether it shows without being asked for: its tier holds for this block * and it applies, or it holds a value here. */ readonly common: boolean; } /** One section of the Style tab, and the properties this block has in it. */ interface StyleSection { readonly key: InspectorSectionKey; readonly label: string; /** * In the placement table's order. Never empty — a section this block has * nothing in is not drawn. */ readonly properties: readonly InspectedStyleProperty[]; } /** The selected block, as something to style. */ interface StyleInspection { readonly nodeId: string; readonly state: StyleState; readonly breakpoint: BreakpointId; /** * Sections in the builder's order, Layout to Effects, each holding at least * one property. * * Empty for a block that opts into no style groups at all, which is a real * answer rather than a failure: the panel says the block offers none, exactly * as the content tab says when a block declares no props. */ readonly sections: readonly StyleSection[]; /** * How the block's parent arranges it at the edited device, which decides * what "Inside its parent" offers; absent where the parent isn't known. */ readonly parent?: ParentArrangement; /** The parent's way of laying the block out, beside its arrangement. */ readonly parentLayout?: ParentLayout; /** * The `object-fit` keyword in force here, lowercased, or `undefined` when * nothing sets one: what decides what the focal point says it does. */ readonly objectFit?: string | undefined; } /** * Describe the selected block's style surface, or `null` when there is none. * * `null` for no selection and for an id the document no longer holds — but NOT * for a block the registry does not know, which is where this parts company * with the content tab. A node whose plugin was disabled, or whose type was * renamed, still has its styles emitted: `compile-page.ts` walks every node and * hands `node.styles` to `envelopeRules` without asking the registry anything. * So the panel that could clear them is the one surface that must not go away * when the definition does. With no definition nothing is OFFERED, every stored * property is retained, and the whole section set is clear-only. */ export declare function inspectStyle(document: BlockDocument, selectedId: string | null, options?: StyleInspectionOptions): StyleInspection | null; /** * How the block's parent lays it out: its arrangement, and the alignment it * gives its items, which a child's automatic self-alignment defers to. */ interface ParentLayout { readonly arrangement: ParentArrangement; readonly alignItems: string | undefined; readonly justifyItems: string | undefined; } /** * What a selection holds at one address. * * `mixed` is a THIRD answer rather than an absence, and keeping it distinct is * the whole reason this type exists. A control showing nothing means every * selected block has nothing there and typing sets them all; a control showing * "Mixed" means typing REPLACES values that differ, and an author is entitled * to know which of those they are about to do. */ type SharedValue = { readonly kind: "same"; readonly value: StyleValue | undefined; } | { readonly kind: "mixed"; }; /** * What the selection shares at one address, or that it shares nothing. * * An EMPTY selection answers `same` with no value rather than `mixed`: nothing * disagrees when there is nothing to disagree, and reporting a conflict for an * empty set would put "Mixed" on a panel describing no blocks. * * Compared with `sameStyleValue`, which is the predicate `styleWriteOp` uses to * decide a write changes nothing. Sharing it is what keeps this reader and that * writer from disagreeing: a comparison of this module's own could call two * values equal that the writer treats as different, and a control committing * the value they "share" would then emit an op per node and an undo entry for a * gesture that changed nothing. * * The STYLE comparison rather than the general stored one, because the compiler * sorts a composite's keys before emitting it — so two blocks holding one value * in different key order render identically and do agree. * * What it brings: structural rather than serialised, so a value carrying its * own `toJSON` cannot decide its comparison; iterative, so a deep value cannot * exhaust the stack; bounded, and answering "different" when the budget runs * out. That direction is the safe one — MIXED makes the control say so and * makes typing a replacement, while a wrong "same" shows one block's value * while another holds a different one and the next edit overwrites it silently. */ export declare function sharedValueAt(nodes: readonly BlockNode[], address: StyleAddress): SharedValue; /** What a batch edit would do, before anything is applied. */ interface BatchStyleWrite { /** * The ops to apply as ONE group, in selection order. * * Pair an op with the node it NAMES rather than with the position it * arrived in: there is one op per block that needs writing, so a selection * where some blocks already hold the value yields fewer ops than nodes. * * Deliberately NOT ordered by what each op costs the document, though there * is a reason to want that. The editor folds a group and judges every step * against the byte cap, so a selection sitting at that cap — where one block * grows to the shared value and another shrinks by more — is refused when * the growing block comes first and accepted when it comes second, for the * same resulting document. Writing the reductions first would fix it. * * Knowing which block shrinks means measuring what each one currently holds, * and `measureBytes` invokes a value's own `toJSON` — measured, once per * call — on data no guard has accepted yet. Ordering is an optimisation of * the peak, never a gate, and running author code to obtain one is not a * trade worth making; a measurement that avoided it would be a second * implementation of a walk the engine already owns. Left to the surface * that can reach a multi-selection, which does not exist yet. * * Empty when every selected block already holds the value. That is not a * failure and must not be reported as one — it is the ordinary result of * setting a value half the selection already had, and applying an empty group * would ask the store for a history entry that undoes nothing. */ readonly ops: readonly BuilderOp[]; /** * Why the value cannot be written, or `undefined` when it can. * * ONE answer for the whole selection rather than one per block, because that * is what the value layer actually decides: `styleWriteOp` refuses on the * VALUE and the POLICY, and a batch passes the same two to every node — so a * refusal is a property of what is being written, never of which block is * receiving it. Measured rather than assumed: a node carrying an unrelated * invalid stored value is still accepted, so even a malformed document does * not split the answer. * * A per-block list was the first shape here and it was machinery for a case * that cannot arise. If a policy ever varies by block type — which is the * reason one would — this becomes a list again, as a change with its own * evidence rather than a shape kept in advance. */ readonly refused: string | undefined; /** * Findings the catalog reported that do NOT refuse the write. * * Carried rather than dropped, for the reason `style-values` gives beside * its own `warnings`: a warning is the validator explaining something about * a value it ACCEPTED — a token reference no supplied token table defines, * for instance, which renders as nothing — and a surface that discarded them * would present an accepted-with-reservations value as an unremarkable one. * The single-block panel already shows them; a batch that swallowed them * would be the same edit explaining less about itself the more blocks it * touched. * * DEDUPLICATED across the selection rather than repeated per block. Every * node is asked about the same value under the same policy, so an issue * arising from the value appears once per node and saying it six times is * noise. Deduplicated by CONTENT rather than assumed identical, because that * every node produces the same set is a property of today's value layer * rather than something this module is entitled to rely on. */ readonly warnings: readonly ValidationIssue[]; } /** * The ops that set one address across a selection. * * Built per node from that node's OWN styles, never from the primary's, and the * reason is the OTHER values each block holds. A style op patches the whole * `styles` envelope, so an op built from the primary and repeated carries the * primary's unrelated declarations with it: measured, writing `fontSize` to a * block from a primary that also set `color` produces a patch containing both, * so the batch silently gives every block the primary's colour. * * Not, as first written here, because the inverse would be wrong. `applyOp` * derives the inverse from the document it is applied to rather than from the * op, so undo is correct either way — which is exactly why this had to be * measured instead of reasoned about. */ export declare function batchStyleWriteOps(nodes: readonly BlockNode[], address: StyleAddress, value: StyleValue, policy?: StylePolicy): BatchStyleWrite; /** * The ops that clear one address across a selection. * * Clearing is not writing an empty value, and the distinction survives the * batch: a block with nothing there produces no op rather than an op that * writes nothing. */ export declare function batchStyleClearOps(nodes: readonly BlockNode[], address: StyleAddress, policy?: StylePolicy): BatchStyleWrite; /** One of the page's bindings that no longer fits, in the report's words. */ interface BindingToFix { /** The bound block. */ readonly nodeId: string; /** The bound setting, by its prop. */ readonly prop: string; /** Where the binding is, as the report names it. */ readonly where: string; /** What changed, and what visitors see until it is fixed, as a sentence. */ readonly change: string; } /** The page's count of data against its limit, or why there is none yet. */ type PageDataFact = { readonly state: "counting"; } | { readonly state: "failed"; } | { readonly state: "counted"; readonly report: PageReadReport; }; /** A part the page uses that isn't published. */ interface UnpublishedPart { /** A component placed on the page, or the page's header & footer set. */ readonly kind: "component" | "layout"; readonly id: string; readonly title: string | null; /** Whether the person editing may publish it. */ readonly mayPublish: boolean; } /** A header or footer the page shows twice: its set's, and one of its own. */ interface DoubledRegionFact { readonly area: "header" | "footer"; /** The page's own header (or footer) blocks, in page order. */ readonly nodeIds: readonly string[]; /** What the editor's notice says about it, in its words. */ readonly said: string; } /** The facts, each where the caller knows it. */ interface PageFacts { readonly bindingsToFix?: readonly BindingToFix[]; readonly pageData?: PageDataFact; readonly unpublished?: readonly UnpublishedPart[]; readonly doubledRegions?: readonly DoubledRegionFact[]; } /** The groups a finding is listed under. */ type PageCheckGroup = "accessibility" | "content" | "publishing" | "search"; /** * A header or footer drawn around the page, as its site's set places it: a * check that judges the page as a visitor reads it, top to bottom, reads * the header's blocks before the page's and the footer's after. */ interface PageRegionDocument { readonly area: RegionArea; readonly document: BlockDocument; /** * The definitions its component placements are drawn from, where it is * placed as a component, as a set's header is: the checks then read the * blocks the component draws, not the one placement. */ readonly definitions?: DefinitionsById; /** What the editor calls it, such as "Site header · Main", where known. */ readonly label?: string; /** Where it is changed, where the caller can say: its editor's address. */ readonly edit?: PageCheckLink; } /** A link out of the editor, as a finding offers one: its address and words. */ interface PageCheckLink { readonly href: string; /** What the link says. */ readonly text: string; /** Its accessible name, saying where it goes. */ readonly name: string; } /** A region as the checks read it, and as it is stored. */ interface ResolvedRegion extends PageRegionDocument { /** * The region as stored, its placements unresolved: what a read names, a * component placement among them, where `document` draws its blocks. */ readonly stored: BlockDocument; } /** The page a check reads. */ interface CheckedPage { /** The draft as it stands, unsaved changes included, or a stored page. */ readonly document: BlockDocument; /** * The definitions the page is drawn with, by block type: the registry this * process holds unless the caller resolves blocks its own way. */ readonly blocks?: (type: string) => AnyBlockDefinition | undefined; /** The header and footer drawn around it, where the caller knows them. */ readonly regions?: readonly PageRegionDocument[]; /** * The definitions the page's own component placements are drawn from, so * a check that reads what the page draws can read inside them. */ readonly definitions?: DefinitionsById; /** * The site's variables, light and dark, which a colour written as one is * read through; absent where the caller has none, and a colour that needs * them is then not judged. */ readonly tokens?: SiteTokenSet; /** * The site's shared styles, among them its edits to a block type's own * look, which a block is drawn with under its own values. */ readonly namedClasses?: readonly NamedClass[]; /** * What the caller knows of the page beyond its document: its bindings * that no longer fit, its count of data, the parts it uses that aren't * live, a header or footer it shows twice. A check of a fact the caller * leaves out finds nothing. */ readonly facts?: PageFacts; } /** The page as every check is handed it, its definitions resolved. */ interface ResolvedPage { readonly document: BlockDocument; /** * The page's blocks as it draws them: its component placements drawn as * their components' blocks, under the page's own limits, where the caller * gave the definitions; the stored blocks otherwise. A check reads these, * and a finding on a block a component drew is moved to its placement. */ readonly drawn: readonly BlockNode[]; readonly blocks: (type: string) => AnyBlockDefinition | undefined; /** The header and footer drawn around it; none where none is known. */ readonly regions: readonly ResolvedRegion[]; /** The page's component definitions, where the caller knows them. */ readonly definitions?: DefinitionsById; /** The site's variables, where the caller knows them. */ readonly tokens?: SiteTokenSet; /** The site's edits to each block type's own look, by type. */ readonly siteLooks: Readonly>; /** What the caller knows of the page beyond its document; none given, none. */ readonly facts: PageFacts; } /** What one check reports about one problem. */ interface PageCheckResult { /** The block it is about; absent for the page as a whole. */ readonly nodeId?: string; /** Which of several problems a check finds on one block this is. */ readonly part?: string; /** What is wrong, as a short line. */ readonly what: string; /** Why it matters, and to whom. */ readonly why: string; /** What to do about it. */ readonly todo: string; /** * The block's setting that fixes it, as the settings index names it; * absent where no one setting does, and the block alone is selected. */ readonly fix?: AskedSetting; /** * The tab of the document's own settings that fixes it, by its id, where * the fix is there rather than on a block (a plugin's tab of Page settings). */ readonly settingsTab?: string; /** * Where the fix is outside this editor, as a link the item is instead, * for a block it cannot select (a header's, changed in its own editor). */ readonly opens?: PageCheckLink; } /** One check: an id, the group it reports in, and what it finds. */ interface PageCheck { /** Stable and unique among the checks run together. */ readonly id: string; readonly group: PageCheckGroup; /** The problems on the page, in page order. Pure: no DOM, no writes. */ readonly run: (page: ResolvedPage) => readonly PageCheckResult[]; /** * A line the list shows under the group's name whatever is found, such as * how much data the page reads; never counted as an item. Pure, as `run`. */ readonly note?: (page: ResolvedPage) => string | undefined; } /** A check's line under its group's name. */ interface PageCheckNote { readonly check: string; readonly group: PageCheckGroup; readonly text: string; } /** One problem as the list shows it. */ interface PageFinding extends PageCheckResult { /** Which check found it. */ readonly check: string; readonly group: PageCheckGroup; /** The same problem keeps its key from one run to the next. */ readonly key: string; /** The block's name as Layers shows it, where the finding is on one. */ readonly block?: string; } /** What a run found, and which checks could not run. */ interface PageCheckReport { /** In the list's order: by group, then by where the block is on the page. */ readonly findings: readonly PageFinding[]; /** The ids of checks that threw, so the list can say they didn't run. */ readonly notRun: readonly string[]; /** The checks' lines under their groups' names, in the checks' order. */ readonly notes: readonly PageCheckNote[]; } /** One group of the list, with its findings. */ interface PageCheckGroupView { readonly group: PageCheckGroup; readonly label: string; readonly findings: readonly PageFinding[]; /** The lines under its name, which are not items. */ readonly notes: readonly string[]; } /** * Run the checks over a page. A check that throws is named in `notRun` and * the rest still run, so one broken check never hides the others' findings. */ export declare function runPageChecks(page: CheckedPage, checks: readonly PageCheck[]): PageCheckReport; /** * The list's groups: Accessibility, Content and data and Publishing always, * and Search only where one of the checks offered reports in it, each with * its findings in order. Derived from the findings, never counted apart. */ export declare function pageCheckGroups(findings: readonly PageFinding[], checks: readonly Pick[], notes?: readonly PageCheckNote[]): PageCheckGroupView[]; /** The builder's own checks, in the order they are run. */ export declare const CORE_PAGE_CHECKS: readonly PageCheck[]; /** * `@nextlyhq/builder` — the visual page-builder editor. * * The editor half of the page builder: the shell, the canvas, and the op store * that everything in it either produces or reads. It is deliberately NOT a * renderer. * * **The invariant this package is built around**: the canvas renders documents * through `@nextlyhq/blocks-react` — the same renderer that serves published * pages — and re-implements nothing downstream of the document model. Read-path * preparation, condition gating and slot pruning are consumed from the engine's * own entry points, never reproduced here. * * No test enforces it. Reimplementing rendering on React and the engine * imports exactly the same packages as delegating to the renderer, so the * layering guard cannot tell the two apart; it narrows what may be imported, * which makes the shortcut inconvenient rather than impossible. * * That rule is not stylistic. `plugin-page-builder` carries a second renderer of * its own, and the two disagree about condition gating in OPPOSITE directions — * one failing closed, the other not evaluating conditions at all. Sharing a * predicate would not have prevented that, because sharing a predicate does not * share the decision to call it; only sharing the entry point does. * * **Public surface**, all of it `@experimental` while the editor is being built * out: * * - {@link BUILDER_PACKAGE_NAME}, for diagnostics that report what a host loaded. * - The frame geometry — {@link pointToCanvas}, {@link pointToHost}, * {@link rectToHost}, {@link frameContentOrigin}, {@link frameInsetOf} — also * published at `@nextlyhq/builder/geometry`, which carries no `"use client"` * banner and so is reachable from a server component. * - The shell's declared bounds and preference port, also published at * `@nextlyhq/builder/shell-state`. * - `BuilderShell` itself at `@nextlyhq/builder/shell`, which is the ONLY entry * carrying `"use client"`. This one does not, so everything above is callable * from a Server Component. * - `@nextlyhq/builder/styles.css`, the chrome's stylesheet. It SUPPLEMENTS the * design system's rather than restating it, so a host loads * `@nextlyhq/ui/styles.css` — or the admin's, which contains it — alongside. * The shell says so in the console, in development, when it is missing. * * - {@link deepActiveElement} and {@link isHTMLElement}, which read focus and * node kinds without a realm's constructors. * * - The op store — {@link applyOp}, {@link OpError} and the op vocabulary — * which every edit is expressed in and which derives each edit's inverse. * * The package was created ahead of any of this so its name could be claimed on * npm, because trusted publishing cannot perform a package's first publish and * the bootstrap script will not claim a name that is not already a workspace * package. * * @module @nextlyhq/builder */ /** * This package's npm name, for diagnostics that report which packages a host * has loaded. * * The name and not the version. A version literal in source would be stale one * release after it was written, because every release bumps this package in * lockstep with its siblings; reporting a version means injecting the manifest's * value at build time, which belongs with the surface that displays it rather * than with a constant nothing reads yet. */ export declare const BUILDER_PACKAGE_NAME: "@nextlyhq/builder"; export { type AppliedOp, type BatchStyleWrite, type BindingToFix, type BlockCustomCssAccess, type BlockDuplication, type BlockSelection, type BuilderCommand, type BuilderCommandsInput, type BuilderOp, type BuilderShellProps, type CanvasZoom, type CheckedPage, type CommandPaletteProps, type CommandVerbs, type ComponentTitleOf, type ComponentVerbsOffer, DEFAULT_PREFERENCES, type DoubledRegionFact, type DropAxis, type DropQuery, type DropRefusal, type DropRegion, type DropResolution, type DropTarget, type EscapeOutcome, type ExposedRow, FIT_ZOOM, type FrameGeometry, FrameGeometryError, type FrameInset, type InsertTarget, type InspectedStyleProperty, type InstanceInspection, LEFT_PANELS, type LayerNode, type LayerSearch, type LeftPanel, type LockState, MAX_ZOOM, MIN_CANVAS_WIDTH, MIN_SHELL_WIDTH, MIN_ZOOM, type NodePatch, OpError, type OpPosition, type OrphanedOverride, PANEL_BOUNDS, type PageCheck, type PageCheckGroup, type PageCheckGroupView, type PageCheckNote, type PageCheckReport, type PageCheckResult, type PageDataFact, type PageFacts, type PageFinding, type PageRegionDocument, type PanelView, type PendingTarget, type PlacementTarget, type Point, type PreferenceStore, RAIL_WIDTH, type Rect, type RectSource, type ResolvedPage, type SavedComponent, type SavedPattern, type ScrubPreview, type ScrubTarget, type SelectionDuplication, type SelectionEdit, type SelectionMode, type SelectionMove, type SelectionMovePlan, type SelectionPlan, type SelectionRefusal, type SharedValue, type ShellPreferences, type SlotSource, type StyleAddress, type StyleControl, type StyleControlBehaviour, type StyleControlBehaviours, type StyleControlKind, type StyleControlOptions, type StyleControlSet, type StyleControlVariants, type StyleInspection, type StyleInspectionOptions, type StylePolicy, type StyleProvenance, type StyleProvenanceQuery, type StyleSection, type StyleWrite, type StyleWriteRequest, type TargetId, type TargetSwitchState, type ToolbarAction, type ToolbarActionId, type ToolbarPlacement, type ToolbarSize, type UnpublishedPart, ZOOM_STEPS, applyOp, browserStore, frameContentOrigin, pointToCanvas, pointToHost, readZoom, rectToHost, registryBlockSource, steppedZoom, writeZoom }; //# sourceMappingURL=index.d.ts.map