import * as React$1 from "react"; import { JSX, ReactElement, ReactNode, RefObject } from "react"; import { ActiveSlotLock, AnyBlockDefinition, BASE_BREAKPOINT as BASE_BREAKPOINT$1, BREAKPOINT_AXES, Binding, BindingFieldShape, BlockDocument, BlockInspectorProps, BlockNode, BreakpointAxis, BreakpointAxis as BreakpointAxis$1, BreakpointContextOptions, BreakpointDef, BreakpointId, BreakpointSet, BreakpointSet as BreakpointSet$1, BuilderOp, BuilderOp as BuilderOp$1, ComponentDocument, ComponentLookup, ComponentPath, ComponentUnresolvedReason, Condition, ConditionDayStart, ConditionFieldKind, ConditionOp, ConditionSubject, Declaration, DefinitionsById, DocumentLimits, ExposedProperty, ExposedPropertyType, ExposedValueSource, ExposureEdit, ExposureEditResult, ExposureSources, FamilyListKind, FieldStoragePrimitive, FluidRangeWidths, FluidRangeWidths as FluidRangeWidths$1, FluidSizes, FluidSizes as FluidSizes$1, FontFaceDef, LayersLockBreak, ListFieldKind, ListFilter, ListFilterOp, ListRelation, ListSortKey, LocatedLockBreak, LocatedPlacementBreak, LockSources, LogicalSidesShape, MAX_BREAKPOINTS_PER_AXIS, NamedClass, NamedParamProblem, NamedQueryDeclaration, NamedQueryHiddenRead, NamedQueryParam, NamedQueryParamValue, NamedQuerySource, NestingSource, NestingVerdict, NodePatch, NodeStyles, OpPosition, OpPosition as OpPosition$1, OverrideValue, PlacedNode, PlacementRefusal, PlacementRefused, PlacementSite, PlacementSources, PlacementTarget, PlacementTarget as PlacementTarget$1, PlacementVerdict, PropGroup, PropSchema, RegionArea, RemotePatternInput, RepairPlan, RepairStep, RequestedProperty, ResolvedComposition, RetiredExposures, RichTextValue, SiteSheetInput, SiteTextEntry, SiteTextMap, SiteTextRole, SiteToken, SiteTokenSet, SlotAddress, SlotDefaultSource, StyleCompileContext, StyleLeaf, StyleOrigin, StyleProperty, StyleShape, StyleState, StyleSubject, StyleTraceEntry, StyleUnionVariantOptions, StyleValue, TokenKind, TokenMode, TurnIntoDefinitions, ValidationIssue, VariantEditResult, VariantOption, VisitorUnreadableBinding, authoredBreakpoints, placementTypesOf as placementTypesOf$1, registryBlockSource as registryBlockSource$1 } from "@nextlyhq/blocks-engine"; import { BlockResolver, BlocksFieldShapes, EntryJudgement, ItemHiddenAs, PageContext, PageReadReport, PageRendererProps, PageStyleCascade, PartSheet, READ_KINDS, ReadKind, RemotePatternInput as RemotePatternInput$1, UnreadBlock } from "@nextlyhq/blocks-react"; import { BlockEnvironment } from "@nextlyhq/blocks-react/environment"; import { z } from "zod"; /** * How large the canvas draws the page it is previewing. * * The canvas has always had a scale, and it has never been the author's. It is * derived to make the requested width fit the region left over after the * panels, so opening a panel silently shrinks the page — measured at 89% with * the rail alone and 59.5% with a panel open. Nothing said which of those an * author was looking at, and nothing let them choose. * * ## Fit is a CHOICE, not the absence of one * * Modelled as a discriminated union rather than a nullable number, because * "fit" and "a scale I picked" are different intentions and a caller has to * tell them apart. `null` meaning fit would be the same overloaded absence * that a `number | null` scale invites: is it unset, is it fitting, or did * something fail to measure? * * Fit RE-DERIVES on every layout change, which is what makes it fit; a fixed * scale deliberately does not, so opening a panel narrows what is visible * rather than shrinking the page under the author. * * ## Why a percentage is absolute, and not a multiplier of the fit * * A multiplier is the obvious composition and it makes the number a lie: an * author choosing 100% is asking for actual size, and "fit × 1" is whatever * the panels happen to leave. Every editor that shows a zoom percentage means * the absolute one, so the number here means what it says and Fit is the mode * that computes one. * * @module canvas-zoom */ /** What the canvas was asked to draw at. */ type CanvasZoom = { readonly kind: "fit"; } | { readonly kind: "fixed"; readonly scale: number; }; /** The default, and what every canvas did before there was a choice. */ declare const FIT_ZOOM: CanvasZoom; /** * The steps the control offers, as fractions. * * Discrete rather than continuous. A slider or a free number invites values * whose arithmetic is exact and whose result is unreadable — 37% of a page is * not a view of anything — and every comparable editor offers steps for the * same reason. `1` is in the middle of the list because actual size is the * value an author returns to. */ declare const ZOOM_STEPS: readonly number[]; /** * The bounds a stored or typed scale is held to. * * Wider than the steps, because a value can arrive from storage written by a * later version, and clamping is what keeps that from painting the canvas * somewhere unreachable. Below the floor the page is illegible; above the * ceiling one block fills the region and the author has lost the page. */ declare const MIN_ZOOM = .25; declare const MAX_ZOOM = 4; /** * A fixed scale the canvas can actually paint at, or `null` when it cannot. * * The bounds are not only about what STORAGE may hold. `CanvasZoom` is * exported, so a host can construct `{ kind: "fixed", scale }` directly with * any number the type admits — `NaN`, `Infinity`, zero, or something far * outside these bounds — and none of those reach `readZoom` on the way in. * Interpolated into a `zoom` declaration they produce an invalid rule or a * canvas nobody can see, so the check belongs wherever a scale is USED rather * than only where one is parsed. */ declare function usableScale(scale: number): number | null; /** * A stored value read back as a zoom, or `null` when it is not one. * * `null` rather than a silent fall back to fit: a caller restoring preferences * needs to know it found nothing, and a fixed scale that quietly became fit * would look to an author like the editor forgetting what they chose. */ declare function readZoom(value: unknown): CanvasZoom | null; /** A zoom as it is stored: the string `"fit"`, or the scale itself. */ declare function writeZoom(zoom: CanvasZoom): "fit" | number; /** * The next step in a direction, or the same zoom when there is none. * * From FIT it steps off the scale the fit produced, so the first press moves * from what the author is looking at rather than jumping to an end of the * list. That needs the fit scale passed in, because only the canvas knows it. * * A scale the canvas cannot paint steps from the fit scale as well, for the * same reason and by the rule {@link usableScale} states: a host can construct * `{ kind: "fixed", scale }` with any number the type admits, and the canvas * already falls back to fit when it cannot use one. Stepping from the raw value * instead makes every comparison against `NaN` false, so both directions return * the zoom unchanged — leaving a stepper that cannot move off an unusable * scale, while the canvas is meanwhile painting the fit the steps would come * from. */ declare function steppedZoom(zoom: CanvasZoom, fitScale: number, direction: "in" | "out"): CanvasZoom; /** * Which sections of the block panel are open: each tab's sections fold on * their own, and stay as the author left them across selections and visits. * * Kept per tab and section NAME (`style:Spacing`), not per block, because an * author working on spacing selects one block after another and means to keep * Spacing open on each. "Expand all" and "Collapse all" store one entry for * the tab (`style:*`) and drop the tab's own, so they reach sections the panel * has not drawn yet. * * Held with the shell's other preferences (`panel-folds-context` lends them * to the panel). * * @module panel-folds */ /** The open or closed state of each section the author has folded. */ type SectionFolds = Readonly>; /** The most sections remembered; the oldest are dropped past it. */ declare const MAX_SECTION_FOLDS = 200; /** What a section's opening falls back to when nothing is remembered. */ interface SectionDefault { /** Whether it holds a value for what is being edited. */ readonly holdsValue: boolean; /** Whether it is the tab's first section. */ readonly first: boolean; } /** * Whether a section is open: as the author last left it, else as they last * left the whole tab, else open when it holds a value or is the tab's first. */ declare function sectionOpens(folds: SectionFolds, tab: string, label: string, fallback: SectionDefault): boolean; /** The folds with one section set open or closed, kept newest last. */ declare function withSectionFold(folds: SectionFolds, tab: string, label: string, open: boolean): SectionFolds; /** The folds with every section of a tab open or closed. */ declare function withTabFold(folds: SectionFolds, tab: string, open: boolean): SectionFolds; /** * Stored folds as the panel may read them: a record of booleans under keys a * section could have, bounded, and nothing else. */ declare function readSectionFolds(stored: unknown): SectionFolds; /** * The panels the left rail switches between, in the order an author meets * them. * * One at a time, by decision (PB-D17 D10-1): fixed sides, no docking, no * floating. The rail selects; it never opens a second panel beside the first. * Settings and Help sit at the rail's foot as dialogs, never panels, so * neither is one of these. */ declare const LEFT_PANELS: readonly ["add", "layers", "pages", "components", "design"]; type LeftPanel = (typeof LEFT_PANELS)[number]; /** * Whether a stored value still names a panel. * * Persisted preferences outlive the code that wrote them. A panel removed in a * later release leaves a string nothing answers to, and restoring it blindly * opens a panel that renders nothing — an empty region with no way back to a * real one. */ declare function isLeftPanel(value: unknown): value is LeftPanel; /** * Width bounds for the two resizable regions, in CSS pixels. * * DECLARED here and enforced by `react-resizable-panels`, which takes pixel * bounds directly (`minSize={240}`) and solves them — including which region * yields when a window resize leaves no room. This module deliberately does NOT * solve them a second time: a hand-rolled clamp beside a library that already * constrains the same drag is two answers to one question, and the two disagree * the first time the library changes how it distributes a shortfall. * * Lower bounds are the point below which a region stops being usable rather than * round numbers: a layers tree needs an indent plus a label, and the inspector * carries two-column controls. * * `MIN_CANVAS_WIDTH` is the reason bounds cannot be read per-panel. At the * minimum supported viewport, both panels at their individual maximums leave the * canvas at 232px — narrower than either panel, in an editor whose subject IS * the canvas — and no per-panel bound is violated, because the constraint was * never per-panel. Expressed as the canvas panel's OWN minimum, the library * enforces it jointly during a drag. */ declare const PANEL_BOUNDS: { readonly left: { readonly min: 240; readonly max: 480; readonly initial: 300; }; readonly inspector: { readonly min: 308; readonly max: 520; readonly initial: 320; }; }; /** * The rail's fixed width in CSS pixels: a 36px icon square with 6px either * side. The rail shows icons alone, each named by its tooltip, so it gives the * canvas back the width a labelled rail took. */ declare const RAIL_WIDTH = 48; /** * The narrowest the canvas may become before a drag stops taking from it. * * The canvas is the thing being edited, so it is the region with a floor rather * than the one that absorbs whatever is left. * * This is the EDITING SURFACE, and {@link MIN_CANVAS_PANEL_WIDTH} is what a * bound is read from. */ declare const MIN_CANVAS_WIDTH = 480; /** * The narrowest the canvas PANEL may become. * * The page meets the panel's edges with no gap around it, so the panel and the * editing surface it holds are one width, and the panel's floor is the * surface's own. Named apart from {@link MIN_CANVAS_WIDTH} because it is what * a resize bound is read from, and the surface is what the floor protects. */ declare const MIN_CANVAS_PANEL_WIDTH: number; /** * The narrowest viewport the full shell is supported at (PB-D17 D10-5). * * Below this the rail, both panels and a usable canvas do not fit at their * minimum widths, so the shell does not try: it shows the canvas and says where * to edit instead. A builder that merely gets cramped is worse than one that * says it needs more width, because the author discovers the limit by failing * at a task. */ declare const MIN_SHELL_WIDTH = 1280; /** * Whether a box of this width can carry the full shell. * * The parameter is the width of the space the shell was GIVEN, not the * window's. The shell sizes to its container, so the two differ whenever it is * embedded — a narrow column on a wide display being the case that matters. */ declare function fitsFullShell(width: number): boolean; /** * What the shell remembers between sessions. * * The layout is stored as the PROPORTIONAL map `react-resizable-panels` reports * from `onLayoutChanged` — panel id to a percentage — never as pixel widths. A * pixel layout is wrong on the next monitor; a proportional one survives a * window resize, and the pixel BOUNDS still hold because the library re-applies * them to whatever the proportions resolve to. * * Deliberately NOT stored: selection, scroll position, or anything describing * the document. Those belong to the document's own state, and a copy here is a * second source that goes stale the first time the document changes underneath * it. */ interface ShellPreferences { leftPanel: LeftPanel | null; /** * Which part of a panel is showing, for a panel with parts — the Design * panel's tab. The host decides what the names mean; the shell only keeps * the one the author last chose. */ leftPanelView: string | null; leftPinned: boolean; /** * Whether the author has hidden a side of the editor to give the canvas the * room. Kept apart from which left panel is open, so hiding the left side * and showing it again comes back to the same panel. The top bar's panel * buttons and mod+backslash set them. */ leftPanelHidden: boolean; inspectorHidden: boolean; /** * How large the canvas draws the page, as the author last left it. * * Chrome rather than document state, like everything else here: it describes * how one person is looking at the editor, not what the page IS, so it must * not travel with the document to another author. */ zoom: CanvasZoom; /** * The breakpoint the author is styling, as they last chose it: an id from the * site's breakpoints, or null for the base one, which is named Desktop. * * A choice, never a reading. Taking it from the width the canvas measured * made opening a panel, or a narrower window, move every edit to a narrower * breakpoint the author never picked. Opening and closing panels changes * only how far the canvas is zoomed to fit. * * Stored as the author left it even when the site no longer defines that * breakpoint: the host resolves an unknown id to the base one, so removing a * breakpoint and adding it back does not lose the choice. */ editingBreakpoint: string | null; /** * Layouts, one per PANEL TOPOLOGY. * * Keyed rather than singular because a layout only means anything alongside * the panel set it was measured for. The left panel is conditionally * rendered, so the group has two shapes — with it and without — and their * layouts have different keys and different arithmetic. Stored as one record * they overwrote each other: resizing with a panel open and then closing it * left a three-key layout that no two-panel group could accept, so the widths * were dropped on the next load. * * This is the shape the panel library's own persistence helper uses, for the * same reason — its `panelIds` prop exists so a group with conditionally * rendered panels can "save and restore multiple layouts". * * Outer key: {@link topologyKey} over the mounted panel ids. * Inner: panel id to percentage. */ layouts: Record>; /** * Whether the rail's single-letter keys (A, L, P, C, D) open its panels. * * ON by default, and a preference because a key with no modifier can be * set off by speech input or a stray press: WCAG 2.1.4 asks that such a * shortcut can be turned off. Help holds the switch, beside the keys. * * Optional in this published type, so a host that builds preferences * written before the switch still compiles; absent reads as on. */ panelKeys?: boolean; /** * Which sections of the block panel the author left open or closed, by tab * and section name (`panel-folds`). * * Optional in this published type, as `panelKeys` is; absent reads as none * remembered. */ sectionFolds?: SectionFolds; /** * Whether the block panel prints each control's CSS names under its label * ("Show CSS names" in the panel's options menu). Off by default, and * optional in this published type, as `panelKeys` is: absent reads as off. */ showCssNames?: boolean; } /** * The class marking the editor shell's own root element. * * The scope every piece of editor chrome is drawn inside. Kept here and away * from the component because `builder-chrome.css` has to spell it out * literally, and a marker spelled out literally is one a rename can break * silently: so it has one exported spelling that the shell writing it, the * code asking about it and the test pinning the stylesheet all take from. */ declare const BUILDER_CHROME_CLASS = "nx-builder-chrome"; /** * A scope that resolves `--nx-builder-*` without claiming to be the chrome root. * * For a surface the shell mounts OUTSIDE {@link BUILDER_CHROME_CLASS} — custom * properties inherit down and never across, so such a surface needs the tokens * declared on an ancestor of its own. Giving it the chrome class instead would * put a second chrome root in the document, and every selector and query * meaning "the editor" would match whichever came first. */ declare const BUILDER_TOKENS_CLASS = "nx-builder-tokens"; /** * The class marking the canvas root, and the boundary the hit-test stops at. * * Here rather than in `canvas.tsx` for the reason above: it is the middle term * of the empty-container affordance's selector, which `empty-slot.ts` composes * — and reaching into the canvas COMPONENT for it would pull a React module * into every consumer of that constant, for one string. `canvas.tsx` re-exports * it, so callers reading it as the canvas's own marker are unaffected. * * The hit-test walk needs an upper bound (see `nodeIdFromEvent`), and that * bound has to be identifiable from a DOM node rather than from React state, * because the walk starts at an event target and climbs. */ export declare const CANVAS_ROOT_CLASS = "nx-canvas"; /** * The identity of a panel arrangement, from the panels themselves. * * Sorted and joined rather than taken from `leftPanel`, so it is derived from * what is actually MOUNTED rather than from a second description of it that can * disagree. Sorting makes it independent of the order the ids arrive in, which * varies with how a host's JSON was serialised. */ declare function topologyKey(panelIds: readonly string[]): string; declare const DEFAULT_PREFERENCES: ShellPreferences; /** * Where preferences are read and written. * * A PORT rather than a direct `localStorage` call, for two reasons that both * bite later. The ratified plan wants these durable per user on the server * eventually, and a component reaching for `localStorage` makes that a rewrite * instead of a different argument. And `localStorage` does not exist while the * shell renders on a server, so a direct call is a crash rather than a default. * * Both methods may fail and the shell must not care: storage is unavailable in * private browsing on some engines, and a quota error is possible on write. */ interface PreferenceStore { read: () => string | null; write: (value: string) => void; } /** A store that remembers nothing, for a server render and for a browser that refuses storage. */ declare const NO_STORAGE: PreferenceStore; /** * A `localStorage`-backed store under one key. * * Takes the key rather than owning one, so the shell's chrome preferences and * anything else the editor remembers share this port instead of each writing * their own `typeof window` check and their own swallow. Outside a browser it * degrades to {@link NO_STORAGE} rather than throwing, which is the whole * reason the port exists. * * @param key - where to store the value * @returns a store, or one that remembers nothing outside a browser * * @experimental */ declare function browserStore(key: string): PreferenceStore; /** * Where the shell keeps its preferences in a browser: under this key alone * for a host that names no user, and under this key and the user's id for * one that does. */ declare const SHELL_PREFERENCES_KEY = "nextly.builder.shell"; /** * The shell's preferences for one signed-in user, so two authors of one * browser each get their own panel, device and zoom. * * Preferences stored before they were kept per user sit under the shell's key * alone. The first user to load with no record of their own takes that one: * it is copied to theirs and removed, so it moves once and no second author * inherits it. With no user known (signed out, or not read yet), nothing is * remembered: a record kept for a guess would be read by the wrong author. * * A host whose browser storage follows rules of its own (a site that keeps * nothing on the device, a sign-out that forgets the person) passes `open`, * which opens the store under a key; both records, the user's and the one * from before, are then read, written and removed through it alone. * * @param userId - the signed-in user's id, or null when there is none * @param open - opens the store under a key; this browser's storage by default * @returns a store under that user's own key, or one that keeps nothing */ export declare function userPreferenceStore(userId: string | null, open?: OpenPreferenceStore): PreferenceStore; /** * Opens the store under a key, one that can also remove what it holds: the * record from before is removed once moved, so no second author inherits it. * * @experimental */ type OpenPreferenceStore = (key: string) => PreferenceStore & { remove: () => void; }; /** * Preferences parsed from whatever was stored. * * Every field is validated separately and falls back on its own, rather than * one malformed field discarding the rest. A layout written under a different * panel set should reset the layout, not the author's panel choice with it. * * Only the fields named below are read, and anything else in the record is * ignored rather than refused. Records written by an earlier release still * carry `showEmptyElements`, a preference that no longer exists because empty * containers are always shown: such a record loads whole, without it. */ declare function readPreferences(store: PreferenceStore): ShellPreferences; /** Preferences written back, ignoring a store that refuses. */ declare function writePreferences(store: PreferenceStore, preferences: ShellPreferences): void; /** * The panel a rail click selects. * * Clicking the open panel's own rail item CLOSES it. That is what makes the * rail a toggle rather than a one-way switch, and it is the only way to reach a * full-width canvas without a separate control. */ declare function panelAfterRailClick(current: LeftPanel | null, clicked: LeftPanel): LeftPanel | null; /** * Whether the shell around this subtree is currently interactive. * * Defaults to `true`, which covers both callers outside a shell entirely and the * server render, where the width is unknowable — the same assumption the shell's * own width hook makes and for the same reason. */ declare const ShellActiveContext: React$1.Context; /** * Whether the surrounding shell is interactive, for content that has to answer for itself. * * The shell hides its slots behind `hidden` and `inert` below its minimum width, which is enough * for anything rendering in place. It is NOT enough for two other cases. Anything that portals to * the document body escapes the wrapper — a dialog would sit over the narrow-screen notice, fully * interactive. And anything DECIDING WHERE TO SPEAK has to know as well: `hidden` and `inert` do * not unmount, so a component behind the notice is still mounted and would go on reporting into a * subtree that is excluded from the accessibility tree. * * Such a component reads this instead of re-deriving the width, so one media query decides them * all and they cannot disagree. * * @experimental */ export declare function useShellIsActive(): boolean; /** 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; /** * Report a failure the caller cannot display itself. * * Answers a no-op when nothing above provides a sink, because a control must * not require a shell to render. The caller therefore cannot use a return value * to decide whether the author was told, and none is offered: a control that * needs to be sure reports for itself while it still can. */ declare function useNoticeSink(): RaiseNotice; /** * Report a failure that may outlive the control raising it. * * Two surfaces need this and they had a copy each: the class selector, keyed by * node, and the class manager, mounted only while its panel is the open one. * Both dispatch a site-style write, both can be unmounted before it answers, * and both must still tell the author. * * WHERE is the shared question and is answered here; WHETHER the caller can * still show it is not, so that stays with the caller. The selector's inline * message is scoped to the node the request was made against and must be * withheld when the author has moved to another one — a rule the manager has no * equivalent of. So `showInline` answers whether it took responsibility, and * the notice is raised only when nothing did. * * The two are exclusive on purpose: a region repeating what is already on * screen is one an author learns to stop reading. */ declare function useSurvivingReport(): (reason: string, showInline: () => boolean) => void; /** Put a sink in reach of everything the shell renders. */ declare function NoticeSinkProvider({ raise, children }: { raise: RaiseNotice; children: React$1.ReactNode; }): React$1.ReactElement; /** 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; } /** * The queue, owned by whoever renders the region. * * Identity is a counter rather than the message, because the same failure can * happen twice and an author who dismissed the first is owed the second. It is * a ref rather than state: bumping it must not schedule a render of its own, * and nothing reads it except the notice being built. */ export declare function useNoticeQueue(): NoticeQueue; /** * The notices, or nothing at all. * * The container is ALWAYS mounted, and only its rows come and go. A polite * live region has to exist before its content changes: unlike `role="alert"`, * one inserted already carrying its message is not reliably announced, so a * screen-reader user could miss the only report that a class was not created. * Empty it holds no rows and has no box of its own, so the layout carries no * permanent gap for a surface that is silent almost always. * * `role="status"` rather than `role="alert"`: these are reports about an action * the author already took, and `alert` interrupts a screen reader mid-sentence * for something that is not an emergency. `aria-live="polite"` follows from it * and is stated anyway, because the implicit value differs between engines. */ declare function BuilderNoticeRegion({ notices, onDismiss }: { notices: readonly BuilderNotice[]; onDismiss: (id: string) => void; }): React$1.ReactElement | null; /** * 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$1.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$1.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$1.ReactNode; /** The inspector's contents. */ inspector?: React$1.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$1.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$1.ReactNode; /** The top bar's end column, after the side-panel buttons: the actions. */ topBarEnd?: React$1.ReactNode; /** The ancestor breadcrumb, along the bottom bar. */ breadcrumb?: React$1.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$1.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$1.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; } /** * The shell, or a message saying where to edit instead. * * Below the supported width the shell does not try to compress: the rail, both * panels and a usable canvas do not fit at their minimums, and an editor that * merely gets cramped is worse than one that says it needs more width — the * author otherwise discovers the limit by failing at a task. * * @experimental */ export declare function BuilderShell({ store, openPanelRequest, onZoomChange, editingBreakpointRequest, onEditingBreakpointChange, appliedScale, notices: supplied, ...props }: BuilderShellProps): React$1.JSX.Element; /** * The one place geometry crosses between the canvas frame and the host page. * * The canvas renders inside an iframe and the editor's chrome — the insertion * indicator, selection outlines, drag affordances — is drawn in the host * document above it. Every one of those has to answer the same question: where * is this canvas rectangle, in host coordinates? * * **Asked here and nowhere else.** Two modules computing that separately agree * on the day they are written and drift the first time anything changes — a * scroll offset one of them forgot, a zoom the other did not apply — and the * symptom is an indicator drawn a few pixels off the gap it names. That class of * bug is not caught by either module's own tests, because each is correct about * the question it asked. * * How much of that is ENFORCED, stated plainly because the difference matters — * and the honest answer is: none of it, by a boundary. * * A sibling test scans for a rectangle READ across the frame elsewhere in this * package, and it recognises a bounded set of spellings: a property access, a * string element access, a destructured binding. A name assembled at runtime, a * `Reflect.get` or a property descriptor all walk past it, and its own tests say * so. It narrows the easy paths; it is not a wall. * * Nothing checks the other half at all. A module handed an origin and a scale can * open-code the arithmetic without touching the DOM, and two numbers multiplied * and added look like any other code. * * What holds instead is narrower and true: the e2e helper adapts these * functions rather than restating them, and every caller needing a content * origin asks {@link frameContentOrigin} for one. * * The functions are pure and take plain numbers rather than DOM nodes, so the * mapping can be exercised without a browser and the DOM reads stay at the edge. * * @module geometry */ /** A point in whichever coordinate space the caller is working in. */ interface Point { readonly x: number; readonly y: number; } /** A rectangle, in the shape `getBoundingClientRect` reports. */ interface Rect { readonly x: number; readonly y: number; readonly width: number; readonly height: number; } /** Four physical edge lengths, in unscaled CSS pixels. */ interface EdgeLengths { readonly top: number; readonly right: number; readonly bottom: number; readonly left: number; } /** * How much bigger a measured rectangle is than the layout it came from. * * Per-axis because a transform scales the two independently. `{ x: 1, y: 1 }` * for an untransformed element, which is the ordinary case. */ interface Scale { readonly x: number; readonly y: number; } /** * How the canvas frame sits inside the host page. * * `origin` is where the frame's CONTENT viewport lands in host coordinates, and * the word content is load-bearing. `getBoundingClientRect` on an iframe reports * its BORDER box, while every rectangle read inside the frame is relative to the * content viewport — so on a frame with any border or padding the two differ, * and an overlay built from the border box sits a couple of scaled pixels out * at every point. Measure that difference with {@link frameInsetOf}; the inset * is border PLUS padding, and `clientLeft`/`clientTop` alone are short by the * padding. A canvas that never sets * `border: none` gets the browser default and the fault is present from the * first render, which is exactly the sort of near-miss that reads as "the * indicator feels slightly off" rather than as a bug. * * Build one with {@link frameContentOrigin} rather than adding that correction * at the call site. Reading `clientLeft` needs a browser; turning it into an * origin is arithmetic over plain numbers, and splitting the two puts the sum * in every caller that measured a frame — where each writes it separately and * a correction reaches only the one being edited. * * `scale` is the visual scale the host applies to the frame: a zoomed-out canvas * at 50% has `scale: 0.5`. * * Scroll INSIDE the frame is deliberately not a field. A rectangle read from * inside the frame is already relative to the frame's viewport, so subtracting * its scroll would count it twice — the mistake that makes an overlay drift as * the canvas scrolls, rather than being wrong by a constant. */ interface FrameGeometry { readonly origin: Point; readonly scale: number; } /** * A frame geometry that cannot describe a mapping. * * Thrown rather than defaulted, because every value that could stand in is * wrong in a way that looks right: a scale of zero maps the whole canvas onto a * point, a negative one mirrors it, and a non-finite one yields `NaN` * coordinates that place an overlay nowhere and report no error. An overlay * silently drawn at the wrong place is the exact failure this module exists to * prevent, so an unusable frame has to be loud. */ declare class FrameGeometryError extends Error { constructor(message: string); } /** * How far the frame's content viewport sits inside its border box. * * The COMPLETE offset, border plus padding. A border alone is the tempting * reading, because `clientLeft`/`clientTop` report exactly that and are the * obvious things to reach for — but an iframe's nested viewport begins at the * content box, so padding displaces it too. Measured in Chromium: an 8px border * with 12px padding puts the content 20px in, while `clientLeft` reports 8. * * In CSS pixels of the FRAME's own untransformed space, which is the whole * reason this type exists rather than the caller passing two numbers. Every * other coordinate in this module is host space, and mixing the two is the * mistake {@link frameContentOrigin} exists to prevent. */ interface FrameInset { readonly left: number; readonly top: number; } /** * Where the frame's content viewport starts, in host coordinates. * * `borderBox` is the corner `getBoundingClientRect` reports for the frame * element, and `inset` is its border-to-content offset. That offset is laid out in the * frame's own pixels, so a host that has scaled the frame scales the border with * everything else: at 50% a 2px border occupies 1 host pixel. Adding the inset * unscaled therefore misplaces the origin by `(1 - scale) * inset`, which is * zero at 100% and grows as the canvas zooms out — a fault that is invisible in * exactly the configuration people develop in. * * Both facts are needed together and neither is guessable from the other, which * is why this is a function rather than a note telling callers to add them up. */ declare function frameContentOrigin(borderBox: Point, inset: FrameInset, scale: number): Point; /** A point inside the canvas frame, in host coordinates. */ declare function pointToHost(point: Point, frame: FrameGeometry): Point; /** * A point on the host page, in the canvas frame's coordinates. * * The exact inverse of {@link pointToHost}: a pointer event arrives in host * coordinates and has to be compared against rectangles read inside the frame, * which is the same mapping run backwards rather than a second one written to * match. */ declare function pointToCanvas(point: Point, frame: FrameGeometry): Point; /** * A rectangle inside the canvas frame, in host coordinates. * * Its size scales with the frame. An overlay sized from the unscaled rectangle * would be correct only at 100%, and would look correct there, which is the * one configuration a canvas is usually looked at in. */ declare function rectToHost(rect: Rect, frame: FrameGeometry): Rect; /** * The category an entry falls under when its block declares none. * * A literal rather than an empty string, because the panel groups by this value * and a heading has to be nameable. Blocks arrive from plugins that need not * categorise themselves, so this is the common case for third-party blocks * rather than an error state. */ declare const UNCATEGORISED = "other"; /** * The one category every component entry falls under, whatever its row says. * * A component is the site's own, placed as a link back to its definition, and * an author looks for it apart from the library's blocks: filing it under the * row's category would scatter the site's components among blocks they look * nothing like. Namespaced so no plugin's free-string category can collide * with it. */ declare const COMPONENT_CATEGORY = "nextly:components"; /** * One offerable BLOCK: a block, or a block under one of its named variations. * * Two tiers in one list rather than a nested structure, because the panel * filters and keyboard-navigates across both and a nested shape would make * every consumer flatten it first. The third tier — patterns — is * {@link PatternInsertEntry}, a separate member of {@link InsertEntry} rather * than a block wearing extra fields: a pattern has no block name, no version * and no props, so folding it in here would make four fields optional on the * common case and leave every reader handling an absence blocks never produce. */ interface BlockInsertEntry { /** * Which tier this is. * * Carried on the entry rather than inferred from which fields are present. * A shape test — "does it have a `blockName`" — is a second statement of the * same fact, and it answers wrongly the first time a tier gains a field the * test happens to name. */ readonly kind: "block"; /** * Stable identity, for React keys and for naming a selection across a * re-filter. * * Derived from the block and variation names rather than an index, because a * search narrows the list and an index-keyed selection would silently follow * the position instead of the entry — the highlighted row changing meaning * under the author as they type. */ readonly id: string; readonly blockName: string; /** Absent on a block's own entry; present on each of its variations. */ readonly variationName?: string; readonly label: string; readonly description: string; readonly category: string; readonly keywords: readonly string[]; readonly icon?: string; /** * The version to stamp, taken from the definition that produced this entry. * * Carried rather than looked up again at insert time. The registry is * mutable — a plugin can register while a panel is open — so a second lookup * can answer with a different definition than the one the author was shown, * and stamp a version the props do not match. */ readonly version: number; /** * The props this entry inserts with: the block's defaults, overlaid by the * variation's. * * A variation may narrow its block's props and never introduce one the * renderer does not accept, which is what makes the overlay safe to compute * here rather than at the call site. */ readonly props: Readonly>; } /** * 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; } /** * One offerable PATTERN: a saved document inserted as a copy that keeps no * link back. * * **The document travels with the entry.** The palette judges what it offers * from these roots and the insert plans from the same value, so the two cannot * read different versions of one pattern — which is the palette-and-drop * disagreement {@link entryAllowedAt} already exists to prevent, one tier up. * * The root types are NOT carried beside it. They are a narrower view of the * document, derived where they are needed; storing both would be two statements * of one fact, and the stored one goes stale the first time an entry is built * from a document that has moved on. */ interface PatternInsertEntry { readonly kind: "pattern"; /** * Stable identity across the whole catalog, which is why it is not the * pattern's own id. * * Blocks are keyed by their namespaced name, and nothing stops a stored * pattern being saved under `core/heading`. Two entries sharing a key make * React reuse one row's state for the other and make a selection ambiguous, * so the tier is part of the key. */ readonly id: string; /** The stored row's id, as {@link SavedPattern.id}. */ readonly patternId: string; readonly label: string; readonly description: string; readonly category: string; readonly keywords: readonly string[]; readonly icon?: string; readonly document: BlockDocument; } /** * Anything the palette can offer. * * A discriminated union rather than one widened shape: the two tiers share * what the panel DRAWS — a label, a description, a category, search words — * and share nothing about what inserting them does. One block becomes one node * from a name and a version; one pattern becomes a whole forest, re-identified, * planned against the destination document. A single shape would have to make * both halves optional and every consumer would branch on which half was * filled in — the branch this union makes the compiler check. */ type InsertEntry = BlockInsertEntry | PatternInsertEntry | ComponentInsertEntry; /** * 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; } /** * One offerable COMPONENT: a definition placed as a single instance node that * keeps pointing back at it. * * The document travels with the entry for the reason a pattern's does — the * palette judges placement from its roots — but what inserting it does is the * opposite of a pattern: nothing from the document is copied into the page. * One node is written, carrying the definition's id, and the renderer inlines * the definition at read time. That is what makes an edit to the definition * reach every page that placed it. */ interface ComponentInsertEntry { readonly kind: "component"; /** Prefixed, for the reason {@link PatternInsertEntry.id} is. */ readonly id: string; /** The definition's stored id, which the instance node will point at. */ readonly componentId: string; readonly label: string; readonly description: string; readonly category: string; readonly keywords: readonly string[]; readonly icon?: string; /** * The definition the canvas resolves the placed instance against — the * lookup's, by identity — which is what a preview of the tile draws. */ readonly document: ComponentDocument; /** * The block types at the roots of the definition AS THE CANVAS WILL DRAW * IT: a root that is itself an instance is followed into the definition it * names, through the same lookup the canvas resolves against. * * A definition may hold instances of other components, at its root included, * and an instance node's type is not a registered block — the nesting rule * answers "no restriction" for a type it cannot resolve. Judging placement * from the STORED roots would therefore offer a component whose real root is * confined to one parent at any destination, and the canvas would then draw * that root where it does not belong. The roots here are the block types * that actually land — each type once, in the order first met, which is all * a placement verdict reads. Read without composing the definition, because * a library of small wrappers around one large definition would otherwise * be cloned whole, once per wrapper, every time the panel opened. */ readonly roots: readonly string[]; 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. */ 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; /** * Every set of props a block can be placed with: its own, then each * variation's. The candidates the inserter offers, for anything that must * tell an author's values from ones a block was placed with. */ declare function insertionPropSets(definition: Pick): Record[]; /** * Build the offerable list from block definitions. * * Takes definitions rather than reading the registry, matching how the engine * hands out `NestingSource`: the caller supplies `allBlocks()`, and a test * supplies a fixture without a global registry to clear between cases. * * A block emits its own entry followed immediately by its variations, and * blocks are ordered by the label the author actually reads. Registration * order is an implementation detail of whichever plugin loaded first, so * ordering by it would rearrange the palette when an unrelated plugin is * installed. */ declare function catalogFrom(definitions: readonly AnyBlockDefinition[]): BlockInsertEntry[]; /** * Build the offerable pattern list from stored rows. * * **A pattern with no roots produces no entry.** Inserting it would add * nothing, so offering it is a row that reads as an action and is not one — * and it is the shape a pattern saved from a cleared selection actually takes, * rather than a hypothetical. Skipped rather than refused: an empty pattern is * a row someone can still finish, not an error to report from a palette. * * Order is the caller's. Blocks are sorted here because their order comes from * whichever plugin registered first, which is an implementation detail; stored * rows arrive from a query that already said what order it wanted, and sorting * them again would overrule it. */ declare function patternEntriesFrom(patterns: readonly SavedPattern[], nesting: NestingSource, definitions?: ComponentLookup): PatternInsertEntry[]; /** * The prefix that keeps a pattern's catalog id out of the block namespace. * * Blocks are keyed by their namespaced name and a stored pattern can be saved * under any string, `core/heading` included, so the tier has to be part of the * key. A colon rather than a separator a block name can contain: `#` already * separates a block from its variation, and reusing it would make * `core/heading#hero` and a pattern named `hero` compete for one id. */ declare const PATTERN_ENTRY_PREFIX = "pattern:"; /** The same rule for a component's catalog id, in its own namespace. */ declare const COMPONENT_ENTRY_PREFIX = "component:"; /** * The component entries a library of stored definitions yields. * * Skipped, never refused: a row the palette has nothing to offer for — see * {@link offerableDefinition} for which, and a row whose definition the * canvas's lookup does not hold — produces no entry, because a tile that * accepts a click and then fails is worse than no tile. The row supplies the * label, category and usage; the definition judged and drawn is the lookup's. Where a * definition's roots may sit on THIS page is asked per placement, by * {@link entryAllowedAt}, exactly as a pattern's are. */ declare function componentEntriesFrom(components: readonly SavedComponent[], definitions: ComponentLookup): ComponentInsertEntry[]; /** * The rows {@link componentEntriesFrom} offered no entry for, each as an entry * with nothing in it to place: no roots, and an empty definition. * * For a surface that lists the library to manage it as well as to place from * it. A component saved without content, or with none the canvas could draw, * is still one an author can open and fill, so it is listed, refused, rather * than left out. Never handed to the offers: there is nothing in it to judge * or to place, and the surface says so. * * Given the entries already built rather than the lookup, because building * them walks every definition's roots, and a second walk to learn which rows * were offered would repeat it. */ declare function unplaceableComponentEntries(components: readonly SavedComponent[], entries: readonly InsertEntry[]): ComponentInsertEntry[]; /** * Why the edit that turned `before` into `after` would leave an instance * standing on THIS page, or nothing when it would not. * * A definition is judged offerable on its own — its roots — but whether the * page has ROOM for it is a property of the page: the resolver spends one * node budget across every instance it inlines, in document order, and nests * to a depth counted from the page root, so a page near its cap can hold the * one stored instance node and then leave it unresolved when it renders. The * op layer cannot see that (it counts stored nodes, and an instance is one), * so the edit asks the RESOLVER ITSELF: the edited document is composed the * way the canvas will compose it, and the reason the resolver gives is the * reason the author is told. * * Asked of the two DOCUMENTS rather than of a placed node, because every * edit asks the same question: a move carries an instance ahead of another * and takes the budget that one had, or into another's slot content one * composition deeper; a duplicate or a paste places a copy; a pattern brings * instances of its own. What refuses is every instance the edit LEAVES * STANDING that stood before it — a placed one, an instance nested inside its * definition, which the resolver reports under an id it minted rather than * the node's, and an instance already on the page that the edit takes the * budget from. Each is a placeholder the edit would put on the page. An * instance the page could not hold BEFORE the edit is not the edit's doing, * so the two compositions are compared rather than the second read alone; * the resolver mints an instance's ids from what it derives them from, so the * same instance answers to the same id in both. * * Asked by the editor's own apply, once per accepted group, rather than by * each surface before it applies: room is a property of the page that moves * with every edit, every surface reaches the page through that apply, and a * surface that asked for itself would be one more that could forget to. Two * compositions per edit are cheap where one per tile per keystroke is not. * * `undefined` for "it composes", and for a reason that is not about room — * a missing definition is the tile's concern and was judged when it was * offered — so this refuses only what the page cannot hold. Judged under the * same `limits` the edit was applied under, since the editor and the canvas * both run under the site's. */ declare function compositionRefusal(before: BlockDocument, after: BlockDocument, definitions: ComponentLookup, limits?: DocumentLimits, compose?: (document: BlockDocument) => ResolvedComposition): CompositionRefusal | undefined; /** A refusal about room: the resolver's reason, and the words an author reads. */ interface CompositionRefusal { readonly reason: ComponentUnresolvedReason; readonly sentence: string; } /** * The single node placing a component writes. * * ONE node, carrying the definition's id and nothing of its content. The * renderer inlines the definition at read time, which is the whole point of * placing a component rather than copying a pattern: an edit to the definition * reaches this page without this page being touched. No variant and no * overrides yet — an instance freshly placed inherits everything. */ declare function nodeForComponentEntry(entry: ComponentInsertEntry): BlockNode; /** * 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. */ declare function blockLabel(type: string, lookup?: (type: string) => AnyBlockDefinition | undefined): string; /** * A variation's name as the surfaces show it: its label, or its own `name` * when it has none, so two unlabeled variations of one block stay apart. */ declare function variationLabel(variation: { readonly name: string; readonly label?: string; }): string; /** * Narrow the catalog by what the author typed. * * Matches the label, the namespaced block name, the declared keywords and the * description — the block name included because it is what appears in * documentation and in an agent's output, so someone who knows `core/heading` * should not have to guess that it is labelled "Heading". * * An empty or whitespace-only query returns the list unchanged rather than * nothing: the panel opens with no query, and a filter that treated that as * "match nothing" would show an empty palette on open. */ declare function filterEntries$1(entries: readonly TEntry[], query: string): TEntry[]; /** A category heading and the entries under it, in the order the panel draws them. */ interface InsertGroup { readonly category: string; readonly entries: readonly TEntry[]; } /** * Group entries under their categories. * * `preferred` names the headings a library wants offered first — a page starts * as structure, so "layout" belongs above "interactive", and neither * first-appearance nor an alphabetical sort produces that. It is a caller's * declaration rather than a constant here, because categories are free strings * contributed by any plugin and this module has no standing to rank them. * * Categories outside `preferred` follow, in first-appearance order. A plugin * that ships an unranked category still gets a heading rather than being hidden * behind a list it was never named in — dropping it would make a block * unreachable through the very panel that exists to reach it. */ declare function groupByCategory(entries: readonly TEntry[], preferred?: readonly string[]): InsertGroup[]; /** * The groups the Add panel draws, in its order: the categories the host ranks * (the library's own), then the site's components, then any other category a * plugin declared, then the blocks that declared none. * * Derived from {@link groupByCategory} rather than grouped again, so the two * cannot disagree about which entries share a heading; this only decides where * the two headings the panel itself names sit. The components follow the * ranked categories because they are what an author reaches for next once the * basic blocks are passed. The uncategorised go last, because "More blocks" is * a remainder and reads as one only at the end. */ declare function paletteGroups(entries: readonly TEntry[], preferred?: readonly string[], blockOrder?: readonly string[]): InsertGroup[]; /** * The words a category's heading is drawn with. * * The library's category ids are words for code ("content"), so the ones it * declares are named as an author reads them; "content" is "Text" because that * is what the blocks under it are. The two groups the panel itself makes are * named here too. A plugin's category is a free string it chose to be read, * so it is drawn as written. */ declare function categoryHeading(category: string): string; /** * What kind of block an entry adds, which decides the order its places are * tried in. * * - `content`: anything that is not a layout block (Heading, Text, Image, * Button, Divider, Accordion, Gallery…), which goes inside a selected block * that holds blocks. * - `layout`: a block in the Layout group that holds blocks (Box, Columns, * Column, Card), which goes after the selection, so Box then Box stays two * siblings. * - `band`: a Section or a saved section, a band of the page, which goes * after the top-level block holding a nested selection. */ type EntryRole = "content" | "layout" | "band"; /** * One place a click in the Add panel may put a block, and what it goes after. * * `afterId` names the block the new one follows ("Adding after Heading"), and * is absent at the end of the page and inside a container. `between` is an * explicit place someone chose, a gap between two blocks: `afterId` and * `beforeId` name the blocks either side, either absent at an end. */ interface InsertionCandidate { readonly kind: "after-selection" | "after-ancestor" | "document-end" | "inside" | "between"; readonly at: OpPosition$1; readonly target: PlacementTarget; readonly afterId?: string; /** The block a `between` place comes before. */ readonly beforeId?: string; /** The container a block goes inside, for `inside`. */ readonly insideId?: string; } /** What {@link insertionCandidates} reads besides the page and selection. */ interface InsertionOptions { /** A container someone chose to add into (its "+"): that place only. */ readonly inside?: string; /** A place someone chose, such as a gap between two blocks: that only. */ readonly at?: OpPosition$1; /** * A block someone chose to add right after (a gap's "+"): the place just * after it, in its own region, only. Resolved against the page as it is * now, so an undo that moves the block moves the place with it. */ readonly after?: string; /** The regions each block type declares, for "inside". */ readonly slots?: SlotSource; /** What kind of block is being added; a content block when absent. */ readonly role?: EntryRole; } /** * Where a click may put a block, in the order the places are tried. The ONE * answer every surface asks: a click or Enter on an Add panel tile, the * Components panel, search, the panel's line and each tile's description. * * - An explicit place (`at`, a gap's `after`, or a container's `inside`) is * that place only. * - Nothing selected, or a selection the page no longer holds: the end of * the page. * - A Section or saved section with a selection inside another block: after * the top-level block holding it, so a band never lands inside a band. * - A content block with a selection that holds blocks: inside it, at the * end of its shown region, then after it, then after each block around * it, out to the page. * - A layout block (or a Section at the top level) with a selection that * holds blocks: after it, then after each block around it, and inside it * only last, for a block that belongs only there (a Column in Columns). * - A selection that holds no blocks: after it, then outward. * * Which place a given block takes is {@link insertionFor}'s question, asked * of the placement rule: the first that accepts it. */ declare function insertionCandidates(document: BlockDocument, selectedId: string | null, options?: InsertionOptions): InsertionCandidate[]; /** * The place a block takes: the first of the candidates whose region accepts * it, by the caller's reading of the placement rule, or `undefined` when none * does (and the panel says why). */ declare function insertionFor(candidates: readonly InsertionCandidate[], accepts: (candidate: InsertionCandidate) => T | undefined): { readonly candidate: InsertionCandidate; readonly answer: T; } | undefined; /** * Each entry's {@link EntryRole}, by entry id, read from what its blocks * already declare: their group and their regions. A plugin block needs no * field of its own to be placed as a layout block. * * - a saved section is a `band`, and so is a Section block; * - a block is `layout` when it is in the Layout group and holds blocks; * - a component is `layout` when any of its top-level blocks is one; * - everything else is `content`. * * `definitions` are the palette's own, read before the registry's, as the * insert reads them; a component's blocks may be outside the palette, so the * registry answers for the rest. */ declare function entryRoles(catalog: readonly InsertEntry[], definitions: readonly AnyBlockDefinition[] | undefined): ReadonlyMap; /** * The role of a run of blocks placed together, such as pasted ones, from the * types its top-level blocks draw: a band when one is a Section, a layout * block when one is a layout block, and content otherwise. The same reading a * saved section's or a component's tile takes, so a pasted run lands where a * click on such a tile would put it. */ declare function runRole(types: readonly string[], definitions?: readonly AnyBlockDefinition[]): EntryRole; /** * Every registered block definition by name, with the supplied ones written * second, so they WIN for a name in both: the palette offered that * definition, so the insert must build, and place, that block. Read ONCE, so * one reading answers every lookup of a catalogue's build. */ declare function definitionsByName(definitions: readonly AnyBlockDefinition[] | undefined): ReadonlyMap; /** * Whether this entry may be placed at this target, and why not when it may not. * * The verdict travels rather than a boolean, because a caller explaining a * refusal is the only place the reason is still known — and recovering it means * classifying the placement a second time. * * BOTH halves are asked, and the child's first. `block.ts` is explicit that * neither implies the other: a slot naming a type does not confine that type to * it, and a child restricting its parents says nothing about which of that * parent's slots may hold it. Asking only the allow-list would offer a column * at the page root; asking only `parent` would let anything into a slot that * names 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. */ declare function entryAllowedAt(entry: InsertEntry, target: PlacementTarget, source: NestingSource, definitions?: ComponentLookup): NestingVerdict; /** * 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. */ declare function blockAllowedAt(blockName: string, target: PlacementTarget, source: NestingSource): NestingVerdict; /** * The entries a target will actually accept: {@link entryVerdictAt}'s allowed * ones, for a caller that needs the set rather than each reason. */ declare function allowedEntries(entries: readonly TEntry[], target: PlacementTarget, source: NestingSource, definitions?: ComponentLookup, placement?: EntryPlacement): TEntry[]; /** * Whether one entry may be placed at a target, with the rule's reason when it * may not. * * The verdict rather than a boolean, because the Add panel keeps a refused * entry in view and says why: an author who cannot see a block has no way to * learn where it would go. */ declare function entryVerdictAt(entry: InsertEntry, target: PlacementTarget, source: NestingSource, definitions?: ComponentLookup, placement?: EntryPlacement): NestingVerdict | PlacementVerdict; /** What {@link allowedEntries} needs to judge entries by the one placement rule. */ interface EntryPlacement { readonly site: PlacementSite; /** * Where the rule reads its answers. `components` is the lookup the catalog's * component and pattern entries were read through: the rule judges a * placement by the roots it reads there, and without it a placement's roots * are unknown and restrict nothing. */ readonly sources: PlacementSources; /** * The pair a click insert hands {@link nodeForEntry}, so a block is judged * with exactly the children its insert seeds. */ readonly expansion: { readonly definitions: SlotDefaultSource; readonly nesting: NestingSource | undefined; }; } /** * The node a BLOCK entry inserts, carrying whatever children its block declares * it starts with. * * Blocks only, and the parameter says so rather than the body branching. One * pattern is a forest, re-identified against the ids the destination already * holds and planned as one atomic group — `planInsertPattern` in the engine — * so there is no single node to hand back, and a function returning one for a * pattern would have to invent an answer or throw. * * Props are deep-copied. The entry outlives every insert made from it, so * handing out its own object would let an edit to one inserted block reach the * catalog — and through it every block inserted from that entry afterwards. * A shallow copy is not enough, because a default value may be an array or a * nested object and those would still be shared. * * The children come from `expandSlotDefaults` rather than from anything written * here, so "what does this slot start with" is answered in one place: the block * declares it, the engine expands it with ids minted per instance, and a * container that declares nothing still arrives with no `slots` key at all. * Building the children here instead would put a second answer beside the * declaration, and the two would agree only until one of them changed. */ declare function nodeForEntry(entry: BlockInsertEntry, definitions: SlotDefaultSource, nesting?: NestingSource): BlockNode; /** * The definitions an insert expands declared starting children from, given the * palette's own catalog. * * Supplied definitions are consulted FIRST and the registry second, which is * what keeps the offer and the insert reading one declaration. A caller may * hand the palette a definition the registry does not hold — a host block, a * fixture — and the catalog then offers it; resolving only against the registry * would find no declaration for that block and insert it stripped of the * children it declares, silently, because an absent declaration and a declared * emptiness are the same answer. * * The fallback is the other half and not a leftover: an entry names child TYPES * the supplied list has no reason to contain, so those still resolve against * everything registered. Consulting the supplied list first changes which * declaration wins for a name in both, and that is the intended order — the * palette offered THAT definition, so the insert must build THAT block. */ declare function blockSourceFor(definitions: readonly AnyBlockDefinition[] | undefined): SlotDefaultSource; /** * 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. */ 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. */ 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$1; /** 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$1; /** What that position is, for the nesting rule. */ readonly target: PlacementTarget$1; /** 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$1 { 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$1; } | { 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. */ 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. */ declare function collectRegions(document: BlockDocument, slots: SlotSource, rects: RectSource, slotsOfNode?: (node: BlockNode) => readonly string[] | undefined): DropRegion[]; /** * The page's top level as a region. One construction for every caller: a * drag's regions and the Add panel's insertion line read the same one. */ declare function rootRegion(document: BlockDocument, rects: RectSource): DropRegion; /** * One slot of a container as a region, or `undefined` when the container * rendered nothing measurable (see {@link collectRegions}). One construction * for every caller, as {@link rootRegion} is. */ declare function slotRegion(node: BlockNode, slot: string, depth: number, rects: RectSource): DropRegion | undefined; /** * 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. */ declare function targetsInRegion(region: DropRegion, rects: RectSource): DropTarget[]; /** * A target's line as a rectangle in the canvas's content coordinates: across * the region at `line` for a vertical flow, down it for a row, with no * thickness. One conversion for everything drawn from a target: the drag's * line, and the Add panel's preview of a place, its label and edge label. */ declare function targetLineRect(target: DropTarget): Rect; /** * 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. */ declare function movingSubtree(document: BlockDocument, movingId: string | undefined): Set; /** * Where the one placement rule reads its answers in the editor: the host's * nesting rules, the registered blocks, and the component definitions the * canvas draws instances from, when it has them. * * One builder for every surface that asks the rule — the canvas drag, the * Layers drag and the keyboard move — so a placement cannot be judged against * one set of sources on one surface and another set beside it. */ declare function placementSources(current: { nesting: NestingSource; definitions?: ComponentLookup; }): PlacementSources; /** 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. */ 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. */ declare function resolveDrop(query: DropQuery, pointer: Point): DropResolution; /** * The two facts a refusal's wording is built from. * * Narrower than {@link DropRefusal} on purpose. A drop carries a region id and * a parent id because the canvas needs them to draw the refusal in place; the * WORDS need only the reason and what the rule permits. Taking the pair rather * than the whole lets a caller that never had a region — a keyboard move, which * has a position and no pointer — reuse these sentences instead of inventing a * second vocabulary, without fabricating a region id to satisfy a type. */ type RefusalFacts = Pick; /** 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; } /** * Why this drop will not happen, and what would. * * `regionType` is optional because one reason has no region to name — * `restricted-at-root` is a block sitting where there is no parent at all — and * because the caller resolves the region from the document by id, which can * legitimately come up empty while the refusal itself is sound. Both cases get * a sentence rather than a gap where a name should be. */ declare function refusalWording(refusal: RefusalFacts, movingType: string, regionType: string | undefined): RefusalWording; /** * Why a placement the one rule refused will not happen, for any reason it * gives: a slot the container does not declare, a block that holds none, or * HTML's content model, as well as the name rules. Named for the block the * author moved; when the rule refused something inside it, both are named. */ declare function placementWording(verdict: PlacementRefused, movingType: string, regionType: string | undefined): RefusalWording; /** The choosers a block can ask for when it is first added. */ type FirstAddChooser = "columns-layout" | "collection-source"; /** The chooser a block of this type asks for when first added, if any. */ declare function firstAddChooserOf(type: string): FirstAddChooser | undefined; /** A block just added that asks for a choice, while it still does. */ interface FirstAdd { /** The block just added. */ readonly nodeId: string; /** The chooser the canvas draws in place of its body. */ readonly chooser: FirstAddChooser; /** * Make the author's choice: `ops` on the block as it was added, joined to * the insert as ONE step. Answers whether they landed. Ends the step. */ readonly choose: (ops: readonly BuilderOp$1[]) => boolean; /** Keep the block as it was added, and end the step. */ readonly skip: () => void; } /** The parts of the editor this step wraps and reads. */ type Host = Pick; /** * The editor with the first-add step: the history's ways in wrapped so each * one ends the step (and an insert of a block that asks starts it), and * `firstAdd` while it holds. */ declare function useFirstAdd(host: T): T & { firstAdd?: FirstAdd; }; /** 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; } /** The modifier keys a pointer gesture carried. */ interface SelectionModifiers { readonly shiftKey: boolean; readonly metaKey: boolean; readonly ctrlKey: boolean; } /** * Which gesture a click's modifiers mean. * * **Shift outranks the toggle modifier**, because a shift+mod click is a slip * rather than a third gesture, and extending is the one whose result an author * can see and undo with a plain click. * * **Both Meta and Control toggle.** Resolving the platform would be the * apparently-correct thing and is not available: the shortcut manager's * `detectApplePlatform` is not on `@nextlyhq/ui`'s public entry, and spelling * the platform a second time here would let this disagree with the keystrokes. * Accepting either is what every web application does, and it is right rather * than merely convenient — a Mac author presses Command, a Windows author * presses Control, and neither ever presses the other's. */ declare function selectionModeFor(modifiers: SelectionModifiers): SelectionMode; /** Nothing selected. */ 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. */ 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. */ 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. */ 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. */ 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. */ 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"; /** The tabs in the panel's order. */ declare const SETTING_TABS: readonly SettingTab[]; /** One setting, as the search and the filter read it. */ interface SettingEntry { readonly tab: SettingTab; /** The section it is drawn in: its key in the tab's accordion. */ readonly section: string; /** The section's plain label. */ readonly sectionLabel: string; /** The prop name, catalog key or built-in id the row is drawn for. */ readonly id: string; /** Its plain label. */ readonly label: string; /** Its options' labels. */ readonly options: readonly string[]; /** The CSS properties or HTML attributes it writes. */ readonly css: readonly string[]; /** Whether it holds its own value for what is being edited. */ readonly set: boolean; /** * A CSS property this block can use but doesn't show yet: found, it is * listed with "Add" in "CSS properties" rather than drawn as a row. */ readonly addable?: true; } /** What the panel is filtered by. Empty and off: nothing is filtered. */ interface SettingsFilter { readonly query: string; readonly onlyChanged: boolean; } /** * Text as the matcher reads it: lower case, accents gone, camel case, * hyphens and underscores split into words, one space between words. */ declare function normalise(text: string): string; /** Whether an entry answers a query. An empty query answers every entry. */ declare function entryMatches(entry: SettingEntry, query: string): boolean; /** Whether a filter narrows anything. */ declare function filtering(filter: SettingsFilter): boolean; /** The entries a filter keeps, in the panel's order. */ declare function filterEntries(entries: readonly SettingEntry[], filter: SettingsFilter): SettingEntry[]; /** How many entries each tab keeps. */ declare function tabCounts(kept: readonly SettingEntry[]): Readonly>; /** The words for each tab, as its label reads. */ declare const TAB_WORDS: Readonly>; /** * What a screen reader is told once the author stops typing: "5 settings * found: 3 in Style, 2 in Advanced", or that none is. */ declare function resultsAnnouncement(counts: Readonly>): string; /** A row of a section, as the index reads it. */ interface IndexedRow { /** The prop name, catalog key or built-in id. */ readonly id: string; readonly label: string; readonly options?: readonly string[]; /** The CSS properties or HTML attributes it writes, where it says. */ readonly css?: readonly string[]; readonly set: boolean; /** Whether it is offered to add rather than drawn. */ readonly addable?: boolean; } /** A section's rows as entries. */ declare function sectionEntries(tab: SettingTab, section: { readonly key: string; readonly label: string; }, rows: readonly IndexedRow[]): SettingEntry[]; /** One device or state the edited target holds values at, and how many. */ interface ElsewhereCount { readonly id: string; readonly label: string; readonly count: number; } /** * Where else the edited target holds values: by device at the edited state, * and by state at the edited device, each in the order given. */ interface ElsewhereCounts { readonly devices: readonly ElsewhereCount[]; readonly states: readonly ElsewhereCount[]; } /** Stored styles: state, then device, then property. */ type StoredStyles = Readonly>>>>>; /** * The values the edited target holds at the other devices and states, for * "Also changed on Tablet (2) · Hover (1)". Only those holding any are listed. */ declare function changedElsewhere(styles: StoredStyles | undefined, at: { readonly state: string; readonly device: string; }, names: { readonly devices: readonly { id: string; label: string; }[]; readonly states: readonly { id: string; label: string; }[]; }): ElsewhereCounts; /** "Also changed on Tablet (2) · Hover (1)", or nothing where none is. */ declare function elsewhereLine(counts: ElsewhereCounts): string | undefined; /** A setting of a block's panel: its tab, and its id in the settings index. */ interface AskedSetting { readonly tab: SettingTab; readonly id: string; } /** One ask to be taken to a block's setting. */ interface SettingAsked { /** The block's id. */ readonly id: string; readonly tab: SettingTab; /** The setting's id, as the settings index names it. */ readonly setting: string; readonly seq: number; } /** The asks as the editor's state carries them; an ask not made is absent. */ interface EditorAsks { sortFieldAsked?: { readonly id: string; readonly seq: number; }; askSortField: (id: string) => void; settingAsked?: SettingAsked; askSetting: (id: string, setting: AskedSetting) => void; } /** The asks, and the way to make each, selecting through `select`. */ declare function useEditorAsks(select: (id: string) => void, session?: unknown): EditorAsks; /** How deep the undo history goes before the oldest step is dropped. */ export declare const MAX_HISTORY = 100; /** * A change made outside the document that the editor's history takes back and * puts forward, such as a write to the site's shared styles. * * Each half resolves whether it took effect. A half that did not (a refused * or failed write) leaves the change where it was, so the step is dropped * rather than kept as an undo that never clears. */ interface HistoryStep { /** Takes the change back. */ readonly undo: () => Promise; /** Makes the change again. */ readonly redo: () => Promise; } /** * One entry of the history: a group of the op layer's inverses, or a step * recorded from outside the document. Both stacks hold the entry to replay * next, so a step on the redo stack is the recorded one with its halves * swapped. */ type HistoryEntry = { readonly kind: "ops"; readonly ops: readonly BuilderOp$1[]; } | { readonly kind: "step"; readonly step: HistoryStep; /** The step as recorded, kept as it moves between the stacks. */ readonly origin: HistoryStep; }; /** * The undo and redo stacks, and the depths a render reads from them. * * READONLY groups. A recorded inverse describes the document as it stood when * its op ran, so nothing may append to or reorder one after the fact — the * history would then describe an edit that never happened. `applyOps` returns * them already in undo order and already frozen to the type. */ declare function useHistoryStacks(): { depths: { undo: number; redo: number; document: number; }; push: (entry: HistoryEntry, into: "undo" | "redo" | "new") => HistoryEntry | undefined; pop: (from: "undo" | "redo") => HistoryEntry | undefined; remove: (entry: HistoryEntry) => void; /** * Take a run of typing's step back out, as if the run had never been * typed: its entry comes off the undo stack, and the redo branch and the * oldest step its first write ended come back. Answers the entry, whose * ops take the document back, or nothing when `run` is not the newest step. */ withdrawTyping: (run: object) => HistoryEntry | undefined; /** * Record a step from outside the document, answering the function that * withdraws it again: a no-op once the history has been cleared since, so * a change refused after its session ended cannot reach the next one. */ record: (step: HistoryStep) => () => void; /** A replay of the step took effect; the branch it ended is gone. */ settle: (origin: HistoryStep) => void; /** Forget everything: both stacks, and what fell off the old end. */ clear: () => void; }; /** * Replay a recorded step and move it to the other stack at once, so a second * press reaches the entry before it rather than waiting on a write. Dropped * again if the replay did not take effect, for the reason a refused inverse is * not pushed back. */ declare function replayStep({ step, origin }: { step: HistoryStep; origin: HistoryStep; }, into: "undo" | "redo", push: (entry: HistoryEntry, into: "undo" | "redo") => void, remove: (entry: HistoryEntry) => void, settle: (origin: HistoryStep) => void): Promise; /** * Run `restart` in the render that sees `session` change, never on the * first: for each piece of editor state that belongs to one editing session * (its document, its history, what the author asked of it), so a new session * starts with none of the old one's. Its updates are the calling component's * own state, so React drops that render and renders again at once with them. * The session is held through a function, so one named by a function is * stored as it is rather than called. */ declare function useRestartOn(session: unknown, restart: () => void): void; /** * 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; /** Whether the facts are a Layers lock's rather than a slot's. */ export declare function isLayersLockFacts(found: LockRefusalFacts): found is LayersLockRefusalFacts; /** * The facts for a block locked in Layers that stops an action aimed at * `subjectId`, worded by {@link lockRefusalWording} like every other lock. */ declare function layersLockFacts(locked: BlockNode, subjectId: string, verb: LockedVerb): LayersLockRefusalFacts; /** A break the engine found, as the facts a refusal is worded from. */ declare function factsOfBreak(document: BlockDocument, op: BuilderOp, broken: LayersLockBreak): LayersLockRefusalFacts | undefined; /** * What the save would refuse of this edit's Layers locks, judged against the * SAVED page with the engine's own comparison (`layersLockChanges`), the one * the server uses, or undefined. Only what this edit adds is asked, not what an * earlier edit already did. * * - A block the edit deletes that the saved page still holds locked, even one * unlocked since: the unlock has to be saved before the delete. * - A locked block a move of other blocks would read as moved: moving one * sibling across it is the sibling's move, but moving several past it at * once reads, at the save, as the locked block moving instead. * * A block unlocked since the save may otherwise be changed or moved in the * same save that carries its unlock. */ declare function savedLockBrokenBy(before: BlockDocument, after: BlockDocument, stored: BlockDocument, ops: readonly BuilderOp[]): LayersLockRefusalFacts | undefined; /** * The Layers lock `ops` would break, as refusal facts, or undefined when they * keep every lock: a block locked now, asked op by op with the engine's own * rule (`layersLockBreak`) as the apply asks it, and with `stored`, a block * the saved page still holds locked that the ops would delete. * * Ops the document cannot take for another reason answer undefined: they are * the apply's to refuse, for that reason. */ declare function layersLockRefusalFor(document: BlockDocument, ops: readonly BuilderOp[], stored?: BlockDocument): LayersLockRefusalFacts | undefined; /** An edit the op store refused for a lock, as its host is told. */ interface LockEditRefusal { readonly reason: "locked"; /** The sentence the author reads, as every lock refusal words it. */ readonly sentence: string; readonly lock: LockRefusalFacts; } /** A drop the locks refuse, as the canvas draws it over the refusing region. */ interface LockDropRefusal { readonly regionId: string; /** The container the refusing region belongs to, absent at the top level. */ readonly parentId?: string; readonly lock: LockRefusalFacts; } /** * Why a block locked in Layers, or one holding or held by it, will not move: * the locked block by the name the author knows it by, where it sits, and * the way forward. */ declare function lockedBlockWording(locked: BlockNode, subjectId: string, verb?: LockedVerb): RefusalWording; /** * The same refusal as one sentence, for a surface that says it in a single * line: a menu item's reason, an announcement. */ declare function lockedBlockSentence(locked: BlockNode, subjectId: string, verb: LockedVerb): string; /** * The headline names the locked area by the block that holds it; the remedy * says what the lock still allows, which is the author's way forward. A * Layers lock is worded by the block the author locked. */ export declare function lockRefusalWording(found: LockRefusalFacts): RefusalWording; /** * One step of a repair, as the preview lists it before the author confirms: * which block, whose locked area or which container, and what happens. * * Here beside the refusals so an area is named the same way in both: by the * block that holds it. A move says which rule moved the block, a lock or the * placement rule, since the author is told why it leaves. * * @param document - the document the plan was made from, where every block a * step names is found */ declare function repairStepSentence(step: RepairStep, document: BlockDocument): string; interface EditorState { /** The document as it currently stands. */ document: BlockDocument; /** The selected node's id, or null when nothing is selected. */ selectedId: string | null; /** * Everything selected, in document order, with the primary named. * * `selectedId` IS `selection.primary`, derived rather than stored twice: the * two disagreeing would put an outline on one block and the inspector on * another, and there is no render in which that is what an author meant. */ selection: BlockSelection; /** Select a node, or clear the selection with null. */ select: (id: string | null, mode?: SelectionMode) => void; /** * Apply an edit. Returns the applied op's outcome, or null when the op was * refused — a caller that needs to know whether its edit landed can ask, * rather than comparing documents afterwards. */ apply: (op: BuilderOp$1) => BlockDocument | null; /** * Apply several ops as ONE action, or nothing at all. * * For an edit whose subject is a multi-block selection. Atomic — a group that * failed halfway would leave a document the author never asked for — and it * costs exactly one undo, because "delete these six" is one thing an author * did and six presses to take it back would read as the history being wrong. * * Returns the new document, or `null` when any op was refused and nothing was * committed. */ applyAll: (ops: readonly BuilderOp$1[]) => BlockDocument | null; /** * The lock break `ops` would add, asked BEFORE they are applied, or * undefined when they keep every lock. Nothing is applied. * * The question `apply` asks, with the same baseline, so a surface that * refuses an action ahead of time (a drop indicator, the inserter, a * keyboard move, a toolbar action) can never disagree with the apply that * would follow. */ lockRefusalFor: (ops: readonly BuilderOp$1[]) => LockRefusalFacts | undefined; /** * The repair of everything the document holds that the engine's repair * rules put right (its lock breaks, then its placement breaks), planned by * the engine's one repair planner against the baseline `apply` judges by. * Nothing is applied: a surface shows the plan's steps and, once the * author confirms, applies it as one edit. No steps when there is nothing * to repair. * * Planned for `document` when given, which a surface rendering one passes * so its plan is the one it shows; else for the document as it stands. */ planRepair: (document?: BlockDocument) => RepairPlan; /** * The document as it stands with every component placement composed in, * through the composition the edits themselves are judged on (each document * composed once); `undefined` where no component library is known. What a * surface reads to show the locks a placement's content sits under inside * its component, which the page alone does not hold. */ composed: () => BlockDocument | undefined; /** * The block definitions lock questions are judged by: the host's own * `locks.definitions`, or the live registry. A surface showing what a lock * holds reads these, so it holds what `apply` refuses. */ lockDefinitions: SlotDefaultSource; /** * Take back the newest step, and answer whether it took effect: at once for * a document edit, and as a promise for a recorded step, once its own undo * has answered. So a surface says "Undone" only for a change that was undone. */ undo: () => boolean | Promise; /** Repeat the newest undone step, answering as `undo` does. */ redo: () => boolean | Promise; /** * Record a change made outside the document as one step of this history, * when the author makes it, so it takes its place in order among the page's * edits even while it is still being stored. It ends the redo branch, as an * edit does. Answers a function that withdraws the step, for a change that * did not take effect after all. * @experimental */ recordStep: (step: HistoryStep) => () => void; /** * Put back what a run of typing changed, and record nothing: the document * as it was before the run's first write, with the history as it was then, * redo branch included. For Escape in a field that writes as the author * types. Answers whether there was a run to put back: only while the run's * step is the newest, so once another edit, an undo or a blur has ended * the run it is an ordinary step of the history. * @experimental */ cancelTyping: (run: object) => boolean; canUndo: boolean; canRedo: boolean; /** * The caps every edit is judged under: the host's, or the engine's defaults * when the host named none. * * Exposed so a surface that asks the resolver whether a placement fits * BEFORE applying it asks under the same caps the apply will enforce. Two * readings of the site's caps — one here, one handed to the surface — agree * until the day one of them is pointed at a different config; the surface * reading this one cannot disagree with the apply that follows. */ limits: DocumentLimits; /** * The document's position in its history: the document edits on the undo * stack, plus those that fell off its old end. A recorded step is not one: * it is stored where it was made, so it is no unsaved work here. The same as * the number on the stack until the history passes its bound. * * Exported because "did anything change" is not answerable from the document * alone: an edit and its undo leave a document equal to the original but not * identical to it, so a host comparing references sees a change and a host * comparing values misses a real one. A depth is the honest signal, and a * test can read it — which a boolean derived inside a component cannot. */ undoDepth: number; /** * The collection lists the canvas draws in their empty state rather than * their entries, by id: what "Preview the empty message" chose, so an author * can design what visitors see when nothing matches. Editor state only, * never stored, and not a step of the history. * @experimental */ listsShowingEmpty?: ReadonlySet; /** Draw one list's empty state on the canvas, or its entries again. */ showListEmpty?: (id: string, empty: boolean) => void; /** * The collection lists whose author picked a new source that waits for an * input, by id, with the tag the canvas shows over each ("Still showing * Events"): the list still draws what it stores. Editor state only, never * stored, and not a step of the history. * @experimental */ listsStillShowing?: ReadonlyMap; /** Tag one list as still showing what it stores, or `undefined` to clear it. */ tagListStillShowing?: (id: string, words: string | undefined) => void; /** * The list whose sort the author last asked to fix, from its canvas note's * "Choose a field", with a count that grows on each ask, so the inspector * takes the author to the list's first sort row once per press. Editor * state only, never stored. * @experimental */ sortFieldAsked?: { readonly id: string; readonly seq: number; }; /** Select a list and take the author to its first sort row. */ askSortField?: (id: string) => void; /** The setting last asked for, counted per ask (`editor-asks`). @experimental */ settingAsked?: SettingAsked; /** Select a block and take the author to one of its settings. */ askSetting?: (id: string, setting: AskedSetting) => void; /** * A block just added that asks for a choice, while the canvas draws its * chooser: editor state only, never stored. See `first-add.ts`. * @experimental */ firstAdd?: FirstAdd; } /** * The editor's state without its selection: what a surface that shows * nothing about the selected block reads, such as the top bar. * * Derived from {@link EditorState} rather than declared beside it, so it * gains every field the state gains. Having no `selection` or `selectedId`, a * surface handed one cannot read the selection at all, so it can never show * a selection that is out of date: the compiler refuses the read. * @experimental */ type EditorDocumentView = Omit; /** * The view of `editor` without its selection, keeping its identity across a * change of the selection alone, so a surface given it and memoised draws * nothing again when only the selection moves. A change to any other field * (an edit, an undo, a list shown empty) makes a new view. * * Keyed on each field rather than on `editor`, whose identity changes with * every selection. Any editor state can be viewed, the page's or a header's * edited in place, so the view is taken where it is needed rather than kept * on the state. * @experimental */ export declare function useDocumentView(editor: EditorDocumentView): EditorDocumentView; interface UseEditorStateArgs { /** The document to start from. */ initialDocument: BlockDocument; /** The caps this site holds its documents to. */ limits?: DocumentLimits; /** * The definitions the canvas draws component instances from, so an edit is * refused when the page would no longer compose with it in. * * The op layer counts a stored instance as ONE node and cannot see that the * resolver spends a budget across every instance it inlines, in document * order, and nests to a depth counted from the page root. Handed the * definitions, the apply asks the resolver about every accepted group — * an insert, a move that carries an instance ahead of another, a duplicated * or pasted copy, a pattern bringing instances of its own — and refuses the * edit that would leave a placeholder where a component stood. Absent, a * host that resolves nothing keeps the apply it had. */ definitions?: ComponentLookup; /** * Told why an edit was refused for room, with the sentence the author * should read. Surfaces already treat a `null` apply as "nothing happened"; * this is the one place the reason is still known. */ onRefused?: (refusal: CompositionRefusal) => void; /** * Told why an edit was refused for a lock, with the sentence the author * should read. Separate from `onRefused`, whose refusals are about room and * keep the shape its callers were written against. */ onLockRefused?: (refusal: LockEditRefusal) => void; /** * A component's name by its id, for the refusal of an edit to a block the * component locks: the page cannot unlock it, so the author is told whose * it is. Absent, the refusal names no component. */ componentName?: (componentId: string) => string | undefined; /** * Where the locks an edit is held to are read: the block definitions and * nesting rules. Defaults to the live registry, so every host's editor holds * the locks its saves enforce. */ locks?: Pick; /** * The document as last saved: the stored form a save keeps `contentOnly` * values against, so the editor keeps exactly what the save would. A host * passes the saved value again after every save; absent, the document as * opened stands for it. */ stored?: BlockDocument; /** * Told when an edit was refused because it would put a block where the * placement rule forbids, with the block and the reason. Every editor path * (insert, drag, keyboard, toolbar, paste) ends in an op group here, so this * is the one check none of them can miss, whatever a surface asked first. */ onPlacementRefused?: (refusal: LocatedPlacementBreak) => void; /** * Which editing session this is. A different value starts the state again * from `initialDocument`: nothing selected and an empty history, as a fresh * mount would, while the component stays mounted. For a host that edits a * second document for a while (a header in place) and drops its history * when it is done. Absent, the state lives as long as the component. * @experimental */ session?: unknown; } /** * The editor's state: the document and its history, with which lists the * canvas shows empty and which list's sort the author asked to fix beside * them, which are editor state and no step of the history. */ export declare function useEditorState(args: UseEditorStateArgs): EditorState; /** * The prop types the Content tab has a control for. * * Its own module, free of React, so the inspection (`inspector.ts`) can say * which props are supported from this one list while the controls themselves * live in `content-controls.tsx`, which is typed as a record over exactly * these names: adding a type here without a control, or a control without a * type, fails to compile. * * @module content-control-types */ declare const CONTENT_CONTROL_TYPES: readonly ["text", "textarea", "url", "number", "checkbox", "select", "media", "icon", "richText", "array", "relation", "entryField"]; type ContentControlType = (typeof CONTENT_CONTROL_TYPES)[number]; /** Whether the Content tab has a control for a prop of this type. */ declare function hasContentControl(type: string): type is ContentControlType; /** * A stored key as a human reads it: `backgroundColor` becomes "Background color". * * Here rather than in a panel because both panels label the same way and from * the same kind of key — a prop name on the content tab, a catalog key on the * style tab — and two spellings of one rule would drift the first time either * learned about an acronym or a digit. */ declare function fieldLabel(name: string): string; /** * What an author calls a prop: the label its block gives it, or its name, * spaced and capitalised, when the block gives none. */ declare function propLabel(name: string, schema: PropSchema): string; /** * The prop types this inspector can draw a control for. * * Named as a set rather than inferred from what the switch happens to handle, * so an unsupported prop is a KNOWN gap rather than a silent fallthrough. A * block declaring `type: "array"` still appears in the panel — the author is * told the prop exists and is not editable here — because omitting it entirely * would present an incomplete block as a complete one. */ declare const SUPPORTED_PROP_TYPES: typeof CONTENT_CONTROL_TYPES; type SupportedPropType = (typeof SUPPORTED_PROP_TYPES)[number]; /** One editable prop, with everything a control needs to draw itself. */ interface EditableProp { readonly name: string; readonly schema: PropSchema; /** The node's current value, which may be absent. */ readonly value: unknown; /** * Whether this inspector can draw a control for it. * * Carried rather than recomputed by the panel: the panel would have to repeat * the membership test, and the two would disagree the first time this set * gained a member. */ readonly supported: boolean; /** The options a `select` offers, empty for every other type. */ readonly options: readonly string[]; /** * Whether the inspector draws a control for it: `false` for a prop that * applies only without another that is set, as a linked button's "Acts as", * and for a choice with nothing to pick. Listed even so, since a component * may still expose it to pages that clear what hides it. */ readonly offered: boolean; /** * Whether a lock fixes this prop where the block sits: it is not content, * and the block is inside an area locked to its content. Shown, not hidden, * so the author sees the value and is told why it holds. */ readonly readOnly: boolean; /** * What the block holds when the prop was never set: its `defaultProps` * entry, or `undefined`. A switch or a choice shows it until a value is * stored, since it is the value that applies. */ readonly defaultValue?: unknown; } /** * 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; } /** * The block's HTML surface: what it renders AS, rather than what it holds. * * Read here with everything else the inspector shows, so one function reads the * document and the panels read the function. A panel reaching back for the node * itself would be a second reader of the same selection, free to disagree with * this one about which node is selected. */ interface BlockHtml { /** * The element's `id`. `undefined` when the node does not carry the field at * all, which is NOT the same as carrying an empty one. * * The rule treats the field as present whenever it is a string, so a stored * `""` shadows any `id` in the attribute bag and the element renders no id * at all. Collapsing the two into `""` here left the panel unable to tell * them apart, so every * attempt to clear an empty-but-present field read as no change and the * field could never be removed. The distinction the document draws has to * survive the reading of it. */ readonly cssId: string | undefined; /** * The author's own attributes, absent when there are none. * * Absent rather than empty, because the node itself distinguishes them: a * block that never had attributes and one whose last was removed both store * nothing, and an empty record here would invite writing one back. */ readonly attributes: Readonly> | undefined; } /** The selected block, as something to edit. */ /** One section of a tab's settings: its name and its rows. @experimental */ interface InspectionSection { /** What the section is called. */ readonly label: string; /** For a Style section, its key, which the Style tab draws it under. */ readonly key?: string; /** Its settings, in the order the block declares them. */ readonly rows: readonly EditableProp[]; } /** A block's settings by the tab each is edited in. @experimental */ interface InspectionSections { readonly content: readonly InspectionSection[]; readonly advanced: readonly InspectionSection[]; /** The block's own props a Style section draws, beside its styles. */ readonly styleProps: readonly InspectionSection[]; } interface BlockInspection { readonly nodeId: string; readonly blockName: string; /** What the block IS, beside what it holds. */ readonly identity: BlockIdentity; /** What the block renders as, beside what it holds. */ readonly html: BlockHtml; /** * Whether the block holds custom CSS of its own. Only the answer, never the * text: the Style tab's line reads it for everyone, and the CSS itself is * shown only to a person who may change the site's code. */ readonly hasCustomCss: boolean; /** What to title the panel: the block's label, or its name. */ readonly label: string; /** * The block's one-line description, from its definition, for the card under * the title. Every definition declares one. */ readonly description: string; /** The concept its icon names, from `editor.icon`, if it names one. */ readonly icon: string | undefined; /** * Props in the order the definition declares them. * * Declaration order rather than alphabetical: a block author writes a heading * before its level and a button before its destination, and sorting that into * alphabetical order rearranges a form somebody designed. */ readonly props: readonly EditableProp[]; /** * The same props by the tab and section each is edited in, as the block * declares them (`group` and `section` on each prop): Content first in a * section named after the block, Advanced in "HTML", and Style in the Style * tab's section a prop names. Sections and their rows keep declaration * order. A block that declares no places has one Content section holding * every prop. * * @experimental */ readonly sections: InspectionSections; /** * The block's own inspector component (`editor.component`), when it names * one, drawn in place of the controls generated from {@link props}. * * Read here with everything else the panel shows, so the panel never goes * back to the registry for a second reading of the same definition. */ readonly inspector: ComponentPath | undefined; /** * Why the block's design and settings can't change, when it sits inside an * area locked to its content; undefined where nothing fixes them. Worded as * the store's refusal of the same edit is, so the read-only controls and a * refused edit give one reason. */ readonly designLock: RefusalWording | undefined; /** * Every set of props the block can be placed with (its defaults under its * example, then each variation's), for a control that must tell a value an * author set from one the block started with. */ readonly placedWith: ReadonlyArray>>; } /** The selected node together with the definition that describes it. */ interface SelectedBlock { readonly node: BlockNode; readonly definition: AnyBlockDefinition; } /** * The selected NODE, whether or not the registry knows what it is. * * Separate from {@link selectedBlock} because the two tabs need different * things from a selection, and only one of them needs the definition. Both * derive from this, so "which node is selected" has one answer. */ declare function selectedNode(document: BlockDocument, selectedId: string | null): BlockNode | null; /** * The block an inspector is describing, or `null` when there is none. * * `null` for no selection, for an id the document no longer holds, and for a * block the REGISTRY does not know. The last is the one worth stating, because * it is a policy rather than a lookup failing: an unregistered block's props * have no schemas, so every content control would have to be guessed from the * stored value's runtime type — which produces a text box for a number and * silently rewrites the value on save. * * The STYLE tab does not use this, and the difference is the point. It reads a * definition's `supports` where one exists and needs nothing from it where one * does not: a node whose block is unregistered still has its styles compiled, * because neither `validation.ts` nor `compile-page.ts` consults the registry * before emitting them. Withholding the style panel there would leave an author * looking at styling nothing can remove, so `inspectStyle` resolves the node * itself and treats every stored property as retained. */ declare function selectedBlock(document: BlockDocument, selectedId: string | null): SelectedBlock | null; /** * 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"; /** * Whether a stored prop value is there: anything but absent or empty text, * and for a URL, only one a page can follow. The engine's rule, the one the * renderer reads, so a refused `javascript:` link that renders no link * leaves the block offering what it does without one. Exported so the * link group asks the same question of whether a link is set. */ declare function propIsSet(schema: PropSchema | undefined, value: unknown): boolean; /** * 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. */ declare function lockStateOf(document: BlockDocument, ids: readonly string[]): LockState; /** * Describe the selected block for editing, or `null` when there is nothing to * edit. See {@link selectedBlock} for what "nothing" covers and why. */ /** * Whether the inspector can show anything for this selection. * * Exported because the CANVAS needs the same answer and cannot reach * {@link inspectSelection}'s result: when this is false the panel replaces its * whole tab strip, so a host still forcing an interaction state would draw the * selected block mid-hover with the control that explains it off screen. * * Derived from {@link selectedBlock}, which is the lookup `inspectSelection` * already starts with, so the two cannot disagree about what is inspectable — * an unregistered block type is the case that separates them, and it reads as * an ordinary selection to anything counting ids. */ export declare function selectionIsInspectable(document: BlockDocument, selectedId: string | null): boolean; declare function inspectSelection(document: BlockDocument, selectedId: string | null, view?: LockView): BlockInspection | null; /** One of the block panel's tabs, named as a block places a setting in it. */ type InspectorTab = PropGroup; /** * The block's own settings the Content tab draws: those it places in * Content, read from its sections so the tab and the placement are one * answer. A setting placed in Style or Advanced is drawn there instead. */ declare function contentRowsOf(inspection: Pick): readonly EditableProp[]; /** * The block's own settings the Advanced tab draws above the ones the builder * draws for every block: those it places in Advanced. */ declare function advancedRowsOf(inspection: Pick): readonly EditableProp[]; /** * The tabs the selected block has, in order: a tab that would hold nothing is * left out. * * Style and Advanced are there for every block. Style always offers a shared * style, which any block can carry, and Advanced always holds the settings * the builder draws for every block (where it shows, when, its CSS id and its * attributes). Content is there when the block declares a setting placed in * it, names its own inspector to draw it, or is a core block whose Content * sections the builder draws ({@link builderContentSectionsOf}). Judged by * what the block declares rather than by which settings show right now, so * a setting a condition hides does not make the tab come and go under the * author. */ declare function inspectorTabsOf(inspection: Pick): readonly InspectorTab[]; /** The Content sections the builder draws for a block, none for most. */ declare function builderContentSectionsOf(blockName: string): readonly string[]; /** * Whether the block may not be changed from the inspector at all: locked in * Layers, itself or by a block it sits inside, or no longer in the document. * * Asked of the LIVE document at the moment a change is attempted, not of the * one a panel rendered with: a lock set in Layers after the panel drew must * still stop the next write. */ declare function blockIsReadOnly(document: BlockDocument, id: string): boolean; /** * Whether one prop of the block may be set from the inspector. * * Nothing may change on a read-only block. Inside an area locked * `"contentOnly"`, only the props its definition declares `role: "content"` * may: the lock fixes the block's design and leaves what it says editable, * which is the rule validation applies on save. The area and the content * props are read through the engine's own `nodeLocks` and `contentPropsOf`, * so the inspector and a save cannot disagree about either. */ declare function propIsWritable(document: BlockDocument, id: string, name: string, view?: LockView): boolean; /** * {@link propIsWritable} for every prop of one block, its locks read once. * * A panel asks it of each field it draws, on each render: asked prop by prop, * each answer walked the page for the block's locks and composed the page * again, once per field and per keystroke. This reads them once, and each * prop's answer is then a lookup, the same answer by the same rule. */ declare function writablePropsOf(document: BlockDocument, id: string, view?: LockView): (name: string) => boolean; /** * Why `node`'s design is fixed, when it sits inside a `"contentOnly"` area. * * Read from the engine's `nodeLocks`, the walk that passes each slot's lock * down as validation does, against the live registry the store's lock check * defaults to, so the inspector holds read-only exactly what a save refuses * to change. The area is named by its outermost locked block, the one the * author sees on the canvas. The inspector and the canvas's spacing handles * both ask it, so the two hold the same blocks. */ declare function designLockOf(document: BlockDocument, nodeId: string, view?: LockView): RefusalWording | undefined; /** * 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 view's lock source, or the live registry the store defaults to. */ declare function lockSourceOf(view: LockView | undefined): SlotDefaultSource; /** An editor's {@link LockView}, read as it stands. */ export declare function lockViewOf(editor: Pick): LockView; /** * The locks that hold one block, each kept apart from the other. * * Two kinds, and the inspector says each in its own words because they are * lifted in different places: * * - `layers` is the block's own lock, set from Layers or the inspector's menu. * It is an edit of the page, so whoever may edit the page may lift it. * - `slot` is the lock of the slot the block sits in, which the block that * declares that slot sets in code. Nothing on the page can lift it. */ interface BlockLockStatus { /** Whether the block itself is locked in Layers. */ readonly layers: 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. */ readonly inheritedFrom?: string | undefined; /** * The lock of the slot the block sits in, and the label of the block that * sets it, or `undefined` where no slot lock applies. */ readonly slot: { readonly lock: ActiveSlotLock; readonly holder: string; /** What the lock fixes, in the words a refused edit uses. */ readonly reason: string; } | undefined; } /** * Whether the block's own Layers lock may be set or lifted here. Not inside a * `contentOnly` area, which pins the node's `locked` field with its design, so * the save would refuse the change. */ declare function layersLockChangeable(status: BlockLockStatus): boolean; /** * Which locks hold a block. * * The slot lock is read through the engine's own `nodeLocks`, the walk a save * is judged by, so the inspector and the save cannot disagree about it. * * A `contentOnly` area wins wherever one applies, in the page or in the page * composed around it, and is found by the same reading that holds the design * read-only ({@link designLockOf}): a block an `all` slot holds on the page and * a component's `contentOnly` slot holds once composed is design-locked, and a * card naming only the arrangement lock would offer a Layers lock the save * refuses. Otherwise the first tree with a lock gives it, and the holder is the * nearest ancestor whose slot declares it, the block whose definition says so. */ declare function lockStatusOf(document: BlockDocument, id: string, view?: LockView): BlockLockStatus; /** * Why a block's design may not be changed here, in an author's words, or * `undefined` while it may: its styles, classes, CSS id and attributes. * * Not on a block its Layers lock holds, and not inside a `"contentOnly"` area, * where the save refuses every one of them. Asked of the live document at the * moment of a write as well as when drawing, as {@link propIsWritable} is. */ declare function designReadOnlyReason(document: BlockDocument, id: string, view?: LockView): string | undefined; /** Whether a block's design may be changed: {@link designReadOnlyReason}, as a yes or no. */ declare function designIsWritable(document: BlockDocument, id: string, view?: LockView): boolean; /** * The patch that sets one prop. * * **The whole props object, not the one key.** `updateNode` merges at the top * level — `{ ...node, ...patch }` — so a patch carrying `{ props: { text } }` * REPLACES the node's props and drops every other one. Editing a heading's text * would silently discard its level. * * Built here rather than in the panel so that fact is stated once. A caller * assembling its own patch has to know a merge rule that is two files away, and * the failure is silent: the edit works and the other props are gone. */ declare function propPatch(node: BlockNode, name: string, value: unknown): NodePatch; /** * The op that names a block, or takes its name away. * * An empty name UNSETS the field rather than storing `""`. The field is * optional, so absent is what "no name" already means everywhere else — a * stored empty string would be a second spelling of the same state, and * `layerLabel` would have to know about both to avoid rendering a blank row. * * Trimmed, because a name of spaces is the same thing wearing a disguise: it * satisfies a non-empty check, renders as nothing, and cannot be typed to in * the layers panel's typeahead. */ declare function renameOp(id: string, name: string): BuilderOp$1; /** * The op that locks a block, or releases it. * * Unlocking UNSETS rather than storing `false`, for the reason above and one * more: `locked` is absent on every node in every document written so far, so * storing `false` on release would make an unlock a WRITE to every block an * author ever touched, and the documents would grow a field that means what * their absence already meant. */ declare function lockOp(id: string, locked: boolean): BuilderOp$1; /** * The declarations the compiler wrote for this document, in cascade order. * * `undefined` when no compile produced one, which is a real answer rather than a * failure — and callers must not read it as "nothing is authored". A control * told that would report every value as coming from nowhere, which is worse than * showing no indicator at all. * * The compile itself lives in `@nextlyhq/blocks-react`, and that is not * indirection for its own sake. Named classes, block bases, the token prefix and * the fetch predicate are each reconciled from TWO tiers — the route's context * and the site's — by a function private to that package. A context assembled * here instead compiles a cascade the page never had, and the shortfall is * silent: measured, with only `breakpoints` passed no class declaration reaches * the trace at all, so every value arriving from a named class reports as set by * nobody and the "Inherited from `.card`" indicator can never appear. */ export declare function pageStyleTrace(document: BlockDocument, styleContext: StyleCompileContext | undefined, site: SiteSheetInput | undefined, options?: { readonly remotePatterns?: readonly RemotePatternInput[]; /** * The resolver the CANVAS is rendering with, when the host named one. * * Forwarded rather than left to the default, because a custom resolver * decides two things the trace depends on: a block's base styles, and * whether a node draws at all. A canvas rendered with one and a trace * compiled without it disagree about which declarations exist, so an origin * goes missing or is attributed to the wrong tier. * * Omitted, the compile falls back to the registry `PageRenderer` uses when a * host names none — the same default, not a second one. */ readonly blocks?: BlockResolver; /** * The caps the canvas prepares and compiles under. * * The fourth input of this kind, after the site tier, the fetch policy and * the resolver — every one of them a field the renderer reads and this * wrapper silently defaulted. They fail the same way: the trace describes a * compile the page never ran, and says so confidently. */ readonly limits?: DocumentLimits; /** * The component definitions the canvas resolves instances against. * * The fifth input of the kind `limits` describes, and it fails the same * way: a trace compiled without them leaves every instance unresolved, so * the composed nodes the canvas draws — and every declaration they carry * — are missing from the cascade the inspector reads its provenance from. */ readonly definitions?: DefinitionsById; }): PageStyleCascade | undefined; /** * The keystroke that OPENS the palette, and the one nearly every editor uses for it. * * Opening only, never toggling. `CommandDialog` renders cmdk's `` internally and * forwards no props to it, so its vim bindings cannot be turned off from here — and those * bindings claim Ctrl+K for "move selection up" and call `preventDefault()`. The shortcut manager * skips an event another handler already prevented, so on Windows and Linux a toggle would open * the palette and then refuse to close it. Escape closes, which is what Radix already gives us * and what VS Code does. Better to not make the promise than to keep it on one platform. * * @experimental */ export declare const COMMAND_PALETTE_KEYS = "mod+k"; /** * 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$1.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$1.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$1.ReactNode | ((query: string) => React$1.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; } /** * The palette. * * Must be rendered inside the shell's `ShortcutProvider` — `useShortcuts` throws otherwise, which * is the right failure: a palette that silently registered nothing would look mounted and never * open. * * @experimental */ export declare function CommandPalette(props: CommandPaletteProps): React$1.JSX.Element; /** Where on the page an inserted block goes; the end of the page when absent. */ type ActionPosition = OpPosition; /** * One action on a stored page. * * @experimental Settles when the composition API ships. */ type PageAction = { readonly kind: "insert-pattern"; readonly patternId: string; readonly at?: ActionPosition; } | { readonly kind: "place-component"; readonly componentId: string; readonly variant?: string; readonly values?: Readonly>; readonly at?: ActionPosition; } | { readonly kind: "set-placement-values"; readonly instanceId: string; readonly values?: Readonly>; readonly reset?: readonly string[]; } | { readonly kind: "choose-variant"; readonly instanceId: string; readonly variant: string | null; } | { readonly kind: "set-list-query"; readonly listId: string; readonly query: ListQueryChange; } | { readonly kind: "set-conditions"; readonly nodeId: string; readonly conditions: readonly (readonly ConditionInput[])[] | null; } | { readonly kind: "bind-prop"; readonly nodeId: string; readonly prop: string; readonly binding: Binding; } | { readonly kind: "unbind-prop"; readonly nodeId: string; readonly prop: string; readonly keep?: UnbindKeep; } | { readonly kind: "set-layout"; readonly layout: string | null; readonly noHeaderFooter?: boolean; } | { readonly kind: "place-entry-content"; readonly field?: string; readonly at?: OpPosition; } | { readonly kind: "set-entry-content-field"; readonly nodeId: string; readonly field: string; }; /** * Which value an `unbind-prop` action keeps: the visitor's, as the page shows * it now (the default); that of a named entry or list item, read as a visitor * reads it; or a value the caller supplies. * * @experimental Settles when the composition API ships. */ type UnbindKeep = "visitor" | { readonly entry: string; } | { readonly item: string; } | { readonly value: unknown; }; /** * What an unbind kept in a prop's place and why, as the one unbind decision * answers the page actions API and the inspector alike. * * @experimental Settles when the composition API ships. */ interface UnbindAnswer { /** * What was kept: what a visitor sees now, the binding's fallback, the * prop's own value, or a value the caller gave. */ readonly kept: "visitor" | "fallback" | "own" | "value"; /** The value kept; absent when the prop keeps its own. */ readonly value?: unknown; /** The prop an image's address was kept in, where the bound prop could not hold it. */ readonly into?: string; /** * Set where the binding read a field visitors can't read: its value was * not copied in, and the fallback or the prop's own value was kept. */ readonly unreadable?: true; /** * Set where the unbound prop is a link's entry id, bound to a related * entry: the id visitors saw is kept beside the link's collection, so the * link keeps going to that entry's page, by reference. Its title where a * visitor may read it. */ readonly entry?: { readonly title?: string; }; /** Why, in words an author reads. */ readonly reason: string; } /** * The parts of a collection list's query a `set-list-query` action changes: * each one set when given, removed when `null`, kept when absent. Shaped as * the block stores them (`ListQuery` in the engine reads them back). * * @experimental Settles when the composition API ships. */ interface ListQueryChange { /** The collection read, or the one a related source's entries are in. */ readonly collection?: string | null; /** A to-many relation of the page's entry or of the outer list's item. */ readonly relation?: ListRelation | null; /** Rows an entry must all meet. */ readonly filters?: readonly ListFilter[] | null; /** Sort keys, comma-separated, `-` for descending: `-publishedAt,title`. */ readonly sort?: string | null; /** How many entries to show, 1 to 100. */ readonly limit?: number | null; /** How many matching entries to skip, from 0. */ readonly offset?: number | null; /** * Split into pages of `limit` entries, each at its own address * (`/news/page/2`). One list on a page may be, and not one inside another * list, one showing related entries, or one in a component or a Layout * region; the write is refused naming the reason. */ readonly paginate?: boolean | null; /** * A custom source: a named query the site registers, and one literal per * input set. Choosing one removes the collection, related entries, filters * and sort in the same write; inputs are replaced whole, not merged. */ readonly namedQuery?: { readonly name: string; readonly params?: Readonly>; } | null; } /** * One condition a `set-conditions` action sets, as a block stores it. * * @experimental Settles when the composition API ships. */ interface ConditionInput { readonly field: string; readonly op: ConditionOp; readonly value?: string | number | boolean; } /** Which part of a block an exposure targets: a prop, or its visibility. */ type ExposureTargetInput = { readonly nodeId: string; readonly propPath: string; } | { readonly nodeId: string; readonly visibility: true; }; /** * One edit to a component's definition, each the editor's own planner. * * @experimental Settles when the composition API ships. */ type DefinitionAction = ({ readonly kind: "expose"; readonly label: string; } & ExposureTargetInput) | { readonly kind: "rename-exposure"; readonly exposureId: string; readonly label: string; } | ({ readonly kind: "retarget-exposure"; readonly exposureId: string; } & ExposureTargetInput) | { readonly kind: "remove-exposure"; readonly exposureId: string; } | { readonly kind: "remove-exposed-slot"; readonly slotId: string; } | { readonly kind: "add-variant"; readonly label: string; } | { readonly kind: "rename-variant"; readonly variantId: string; readonly label: string; } | { readonly kind: "delete-variant"; readonly variantId: string; } | { readonly kind: "set-variant-value"; readonly variantId: string; readonly exposureId: string; readonly value: unknown; } | { readonly kind: "reset-variant-value"; readonly variantId: string; readonly exposureId: string; }; /** * A page action, as the page actions route reads `action`. * * @experimental Settles when the composition API ships. */ declare const pageActionSchema: z.ZodType; /** Every page action's `kind`, in the order the schema lists them. */ declare const PAGE_ACTION_KINDS: readonly PageAction["kind"][]; /** * A definition action, as the definition actions route reads `action`. * * @experimental Settles when the composition API ships. */ declare const definitionActionSchema: z.ZodType; /** Every definition action's `kind`, in the order the schema lists them. */ declare const DEFINITION_ACTION_KINDS: readonly DefinitionAction["kind"][]; /** * The JSON Schema form of a page action, as a client that does not run zod * reads it: the input the schema accepts, before the parse normalises it. * * A binding's `format` and an unbind's kept `value` are judged by a function, * which JSON Schema cannot state; the converter refuses such a schema outright * otherwise, and the manifest that carries this form with it. A format is * written as an object, which is what its function asks; a kept value as any * value (`{}`), since it may be any JSON. Each stays required where the action * requires it, and is judged by the route. * * @experimental Settles when the composition API ships. */ declare function pageActionJsonSchema(): Record; /** * The JSON Schema form of a definition action. The refinement that a target * names exactly one of `propPath` and `visibility` has no JSON Schema form of * its own, so it is written into each targeted action here: a tool that * validates against this schema refuses what the route refuses. * * @experimental Settles when the composition API ships. */ declare function definitionActionJsonSchema(): Record; /** * What a definition edit reads besides the definition. * * @experimental Settles when the composition API ships. */ interface DefinitionActionSources { /** The block definitions, for each prop's type and each slot's lock. */ readonly definitions: ExposureSources["definitions"]; /** The ids the component has retired, never to be handed out again. */ readonly retired?: RetiredExposures; /** The host's document limits, which its save judges the definition under. */ readonly limits?: DocumentLimits; } /** * Plan one definition edit with the editor's own planner: the edited * definition, or why the edit is refused. The definition passed in is never * changed. * * @experimental Settles when the composition API ships. */ declare function planDefinitionAction(definition: BlockDocument, action: DefinitionAction, sources: DefinitionActionSources): ExposureEditResult | VariantEditResult; /** * One prop of the component a placement may make a setting. * * @experimental Settles with the editor's binding controls. */ interface SettingCandidate { /** The component's block that holds it, by its id in the component. */ readonly nodeId: string; readonly propPath: string; /** How the panel lists it: the block's name, then the prop's. */ readonly label: string; /** The prop as the block declares it, which the field picker fits. */ readonly schema: PropSchema; /** What the component holds there now, the setting's default. */ readonly value: unknown; } /** * What a host is asked to add: a setting of the component filled by one of * its block's props, named as given. * * @experimental Settles with the editor's binding controls. */ interface ComponentSettingAsk { readonly componentId: string; readonly nodeId: string; readonly propPath: string; readonly label: string; } /** * The new setting's id, which the placement binds under, or why the host * would not add it. * * @experimental Settles with the editor's binding controls. */ type ComponentSettingAnswer = { readonly settingId: string; } | { readonly refusal: string; }; /** * The props of a component a placement may make a setting: each text, link * and image prop its blocks declare, inside their slots too, that is not a * setting yet and not bound to a field already, in the component's order. * * @experimental Settles with the editor's binding controls. */ declare function settingCandidates(definition: ComponentDocument): SettingCandidate[]; /** * The op binding `prop` of block `id` to `binding`, replacing a binding the * prop already had; `null` when the document holds no such block. * * `clear` names props emptied in the same op, for a prop another prop would * win over once bound: a button's entry reference is followed before its * address, so binding the address alone would leave the button going to the * entry. Only props the block holds are named in the patch, so a bind with * nothing to clear writes the bindings alone. * * @experimental Settles with the editor's binding controls. */ declare function bindOp(document: BlockDocument, id: string, prop: string, binding: Binding, clear?: readonly string[], more?: { /** * Props set in the same edit: what the bound value needs beside it, * such as the collection of the entry a link's bound id names. */ readonly set?: Readonly>; /** * Other props' bindings removed in the same edit: one the block would * follow before this one, such as a link's address bound before the * entry it now points at. */ readonly unbind?: readonly string[]; }): BuilderOp$1 | null; /** * What an unbind keeps in the block's props: values to set, and props to * empty. For an image a visitor saw by its address, the address is set on * the declared address prop and the media prop emptied. * * @experimental Settles with the editor's binding controls. */ interface KeptProps { readonly set: Readonly>; readonly empty?: readonly string[]; } /** * The op unbinding `prop` of block `id`, keeping `kept` in its props; `null` * when the document holds no such block. A block left with no binding stores * none. * * @experimental Settles with the editor's binding controls. */ declare function unbindOp(document: BlockDocument, id: string, prop: string, kept: KeptProps): BuilderOp$1 | null; /** * One field a binding can read, as the picker lists it. * * @experimental Settles with the editor's binding controls. */ interface BindingFieldChoice extends Omit { /** What the field is called, where its name alone reads poorly. */ readonly label?: string; /** Whether a visitor may read it; a binding to one shows its fallback. */ readonly public: boolean; /** * The start of its value, as the person editing reads it, a draft's * included (marked by `draft`). Absent for a field visitors can't read, an * empty one, and one whose value is not text, a number or a yes-or-no. */ readonly preview?: string; /** * Set when the value differs from what the published entry holds: the * picker shows it beside the value, so the author knows it isn't live yet. */ readonly draft?: true; /** * A small picture of the value, for a field holding an image visitors may * read: its address, as the author's read gave it. The picker draws it * beside the field's name. */ readonly thumbnail?: string; /** * Set on a field visitors may read that holds nothing: the picker says * "(empty)" beside it, rather than leaving the author to guess why no value * shows. */ readonly empty?: true; /** * The fields inside it: a group's own, or a relation's, one step in, as the * entry it names holds them. */ readonly fields?: readonly BindingFieldChoice[]; /** * Set on a related entry's own id, listed under a relation that names one * entry of one collection: the collection that entry is in. A link's entry * can be bound to it, and only a link's, since an id is no value a reader * is shown. */ readonly linksTo?: string; /** * Set on a related entry (`linksTo`) whose collection has no page yet, as * the host serves pages: the collection's name, which the picker says the * row is waiting for. Listed, so the author sees why, but not picked. */ readonly noPageFor?: string; } /** * One source of bound values, as the picker groups its fields. * * @experimental Settles with the editor's binding controls. */ interface BindingFieldSource { /** How a binding names the source. */ readonly binding: { readonly source: "entry"; } | { readonly source: "single"; readonly sourceKey: string; } | { readonly source: "site"; }; /** The source's name: a collection's or a Single's label. */ readonly label: string; readonly fields: readonly BindingFieldChoice[]; /** * Set where the source's read failed for a reason other than access: it is * named, with no fields, so the picker can say it could not be read while * the other sources still list. */ readonly readFailed?: true; } /** * One field's value in a list's entry, as the picker shows it: its start as * text, a picture's small thumbnail, or a field holding nothing. * * @experimental Settles with the editor's binding controls. */ type ListSampleValue = string | { readonly thumbnail: string; } | { readonly empty: true; }; /** * Each field's value in one entry a list shows, as the canvas reads it, by * the field's path (`title`, `author.name`): the samples the picker shows * beside a list item's fields. Text is cut short by the same rule as a * {@link BindingFieldChoice}'s `preview`; a field with nothing to show is * absent. * * @experimental Settles with the editor's binding controls. */ type ListSample = Readonly>; /** * An unbind the inspector asks the host to plan, in the document it holds. * * @experimental Settles with the editor's binding controls. */ interface UnbindAsk { readonly document: BlockDocument; readonly nodeId: string; readonly prop: string; readonly keep?: UnbindKeep; } /** * The props written in the binding's place and the answer, or why not. * * @experimental Settles with the editor's binding controls. */ type UnbindPlanAnswer = { readonly kept: KeptProps; readonly answer: UnbindAnswer; } | { readonly refusal: string; }; /** * What the binding controls read and do through the host: the fields, their * previews and an unbind's plan. Part of the editor's content services. * * @experimental Settles with the editor's binding controls. */ interface BindingServices { /** * The fields a binding can read, for the inspector's picker: the entry's, * each Single's and the site settings', only those the signed-in author may * read, each marked by whether visitors may and previewed as the author * reads it. Absent, a prop offers no binding. */ readonly listBindingFields?: () => Promise; /** * Each field's value in one entry a list shows, read as the canvas reads * that list, for the picker's samples beside a list item's fields. Takes * the list's stored props and the entry's place among those it shows * (the one the author clicked on the canvas), the first where none is * given or the list shows fewer. `undefined` for a list the canvas reads * no entry of. Absent, the item's fields show no samples. * * @experimental Settles with the editor's binding controls. */ readonly readListSample?: (props: Readonly>, entry?: number) => Promise; /** * The page's language, as the canvas's render formats bound values in it, * so the picker previews a date or a number as the page shows it. Resolved * as a render resolves it (`bindingFormatEnv`): absent, English. */ readonly bindingLocale?: string; /** * The site's time zone, as a published page shows its date-times in it, * read when a binding picker opens: `undefined` for a site with none set. * Until it is in, or where it is absent or fails, previews are in UTC, as * a page rendered with no zone. */ readonly readSiteTimeZone?: () => Promise; /** * An unbind's plan, made against the document the editor holds by the same * decision the page actions API takes: what to write in the binding's place * and why, or why it can't be kept. Absent, a bound prop offers no unbind. */ readonly planUnbind?: (ask: UnbindAsk) => Promise; /** * Where a binding's source is edited in the admin: the entry's edit * screen, the Single's, or the site settings. `undefined` for a source the * host has no screen for, such as a list's item, which leaves a bound * prop's menu without "Open source". */ readonly sourceHref?: (binding: Binding) => string | undefined; /** * Make one of a component's block props a setting of the component, for * a placement's "Make this a setting of the component": the host adds the * setting as the page's next save writes it, and answers its id, which * the placement then binds, or why it would not. Absent, the placement's * panel offers no new setting. * * @experimental Settles with the editor's binding controls. */ readonly makeComponentSetting?: (ask: ComponentSettingAsk) => Promise; } /** How a field finishes its passage: the document its write produced, if any. */ type FinishPassage = () => BlockDocument | null | void; interface OpenPassages { /** Hold a passage open; the answer releases it. */ hold(finish: FinishPassage): () => void; /** * Finish every passage held, in the order they opened, and answer the * document the last write produced, or `null` when none wrote. */ finishAll(): BlockDocument | null; /** Whether any passage is open, which is unsaved work. */ isOpen(): boolean; /** Told whenever a passage opens or closes. */ subscribe(listener: () => void): () => void; } /** A fresh registry, for one editor. */ export declare function createOpenPassages(): OpenPassages; /** * A block the bar makes the one the caret is in: a heading, a list or a * quote, and the paragraph pressing one of them again goes back to. */ type FormatBlock = "paragraph" | "h2" | "h3" | "bullet" | "number" | "quote"; /** The bar's block buttons, each making its block. */ type FormatBlockAction = Exclude; /** One thing the bar offers. */ type FormatAction = "bold" | "italic" | "link" | FormatBlockAction | "turnInto"; /** Whether an action is one of the bar's block buttons. */ declare function isBlockAction(action: FormatAction): action is FormatBlockAction; /** * What the bar offers a Text: bold, italic, a link, and "Turn into". * * Configured per block rather than drawn as one fixed row, so a passage that * holds more (headings, lists) is offered more by the same bar. "Turn into" * keeps its place in the list and is drawn only once a host can turn a block * into another. */ declare const TEXT_FORMAT_ACTIONS: readonly FormatAction[]; /** * What the bar offers a whole passage, as a Rich text holds: a Text's marks * and link, then H2, H3, bullets, numbers and quote, then "Turn into". */ declare const RICH_TEXT_FORMAT_ACTIONS: readonly FormatAction[]; /** What the selection in the passage holds. */ interface FormatSelection { readonly collapsed: boolean; readonly bold: boolean; readonly italic: boolean; readonly link: { readonly url: string; readonly newTab: boolean; } | null; /** * The block the caret is in, for a whole passage; `other` for one the bar * has no button for. Absent for a one-paragraph passage, which has one. */ readonly block?: FormatBlock | "other"; } /** The editor's hold on the passage, as the bar uses it. */ interface FormatSession { format(mark: "bold" | "italic"): void; link(url: string | null, options?: { readonly newTab?: boolean; }): void; /** * Make the caret's block `kind`, or a paragraph where it already is one; * offered for a whole passage only. */ block?(kind: FormatBlockAction): void; selection(): FormatSelection | undefined; /** Put the caret back in the passage, where it was. */ focus(): void; } /** The passage the bar serves. */ interface FormatTarget { /** The element being edited, which the bar is placed against. */ readonly element: HTMLElement; readonly session: FormatSession; readonly actions: readonly FormatAction[]; /** Finish the edit, as leaving the passage does. */ readonly finish: () => void; /** Turn the block into another; absent where the host cannot. */ readonly turnInto?: FormatTurnInto; } /** * What "Turn into" needs from the passage being edited: the block, the page * as it would stand with the words typed so far (what the choices are judged * on), and a way to finish the edit, answering the page it left, or `null` * when the words could not be written. The choices and the turn are the * editor's own verbs (`BlockActions.turnIntoIn`). */ interface FormatTurnInto { readonly nodeId: string; readonly typedPage: () => BlockDocument; readonly finish: () => BlockDocument | null; } /** Everything the bar draws from. */ interface FormatBarSnapshot { readonly target: FormatTarget | null; readonly selection: FormatSelection | null; /** The address field is open, by the Link button or ⌘K. */ readonly linking: boolean; /** The "Turn into" choices are open, by the Turn into button. */ readonly turning: boolean; /** A change (a paste) lost what the passage cannot hold. */ readonly dropped: boolean; /** Raised to ask the bar to take the focus, as Alt+F10 does. */ readonly focusRequest: number; } /** The store's surface. */ interface FormatBarStore { readonly get: () => FormatBarSnapshot; readonly subscribe: (listener: () => void) => () => void; /** Serve a passage, replacing whichever was served. */ readonly open: (target: FormatTarget) => void; /** Stop serving this passage; a later one already served is kept. */ readonly close: (element: HTMLElement) => void; readonly selected: (selection: FormatSelection) => void; readonly setLinking: (open: boolean) => void; readonly setTurning: (open: boolean) => void; readonly setDropped: (dropped: boolean) => void; readonly requestFocus: () => void; /** * Whether the focus is in the bar on the passage's behalf, so the * passage's blur does not finish the edit: an author moving to a button or * the address field is still editing. */ readonly holdsFocus: () => boolean; readonly setHoldsFocus: (held: boolean) => void; } /** A fresh store; the admin's one is {@link formatBar}. */ declare function createFormatBarStore(): FormatBarStore; /** The admin's one bar, for its one editor. */ declare const formatBar: FormatBarStore; /** * Whether the bar is shown: words are selected, or the address field or the * "Turn into" choices are open, or the bar holds the focus. */ declare function formatBarShown(state: FormatBarSnapshot): boolean; /** Why a finished edit could not be written. */ type InlineEditRefusal = "moved-on" | "rejected" | "no-longer-editable"; /** The edit produced a document. */ interface InlineEditWritten { readonly status: "written"; readonly document: BlockDocument; } /** There was nothing to write: no edit was open, or none of it changed. */ interface InlineEditUnchanged { readonly status: "unchanged"; } /** * The author changed the value, it could not be stored, and the surface has * been given back. * * The value stopped being editable while the caret was in it and its element * has left the page, so there is nothing to keep the words in: the block was * deleted, or the canvas re-rendered without it. Their typing is gone, and a * host that can say so should: nothing else will mention it. While the element * is still on the page the edit is {@link InlineEditRefused} instead, except * where the host itself finished a line of text: a host finishing an edit is * closing or opening something else, so the line cannot stay open, and its * unwritten words are reported here. * * Distinct from {@link InlineEditRefused} in the one way that matters to a * host: there is nothing left to protect, so this must not stop it closing. */ interface InlineEditDiscarded { readonly status: "discarded"; } /** * The edit could not be written and is STILL OPEN, holding the author's words. * * The surface deliberately kept itself mounted, because letting go is what * destroys the text — it lives in the editor and nowhere else, and the page * would put the older copy back in its place with nothing said. * * A host must not close, navigate, or open another value on this. What it * should do is leave the caret where it is and tell the author, so the text * they can still see is text they can still copy. */ interface InlineEditRefused { readonly status: "refused"; readonly reason: InlineEditRefusal; } /** * The edit never opened, because the shared editor is holding another one. * * There is ONE editor behind every surface, and a passage kept open because its * words exist nowhere else refuses to give it up. So this is not a failure of * the value the author just asked for — it is the previous edit still being * protected, and the only thing that resolves it is finishing that one. * * Reported through the same channel as the outcomes above rather than a second * one, because a host that told the author about a refused write in one voice * and a refused OPEN in another would be two messages about one editor. */ interface InlineEditUnavailable { readonly status: "unavailable"; } /** What became of an attempt to edit a value in place. */ type InlineEditOutcome = InlineEditWritten | InlineEditUnchanged | InlineEditDiscarded | InlineEditRefused | InlineEditUnavailable; /** The shared editor was busy protecting an edit that could not be written. */ declare const INLINE_EDIT_UNAVAILABLE: InlineEditUnavailable; /** Nothing was open, or nothing about the value changed. */ export declare const INLINE_EDIT_UNCHANGED: InlineEditUnchanged; /** The author's typing could not be stored and the surface has been released. */ export declare const INLINE_EDIT_DISCARDED: InlineEditDiscarded; /** * The document a host should hold after a commit. * * `held` is what it had before — the right answer for every outcome that did * not produce a new one, including a refusal, where the document genuinely has * not changed and the edit is still live. * * @param outcome - what the commit did * @param held - the document the host was holding * @returns the document to carry forward */ export declare function documentAfter(outcome: InlineEditOutcome, held: BlockDocument): BlockDocument; /** An exposed value the canvas may edit in place, addressed through its placement. */ interface ExposedTextTarget { /** The composed node the element belongs to, as the canvas addresses it. */ readonly nodeId: string; readonly prop: string; /** The placement the value is stored on, a node of the page document. */ readonly placementId: string; /** The exposure id the value is stored under. */ readonly exposureId: string; readonly multiline: boolean; /** The value the page shows now. */ readonly value: string; } /** * An exposed passage the canvas may edit in place, addressed through its * placement. The passage itself is read when the editor opens and again when * it closes ({@link exposedPassage}), never carried, so a change made to it * meanwhile is seen. */ interface ExposedRichTarget { /** The composed node the element belongs to, as the canvas addresses it. */ readonly nodeId: string; readonly prop: string; /** The placement the passage is stored on, a node of the page document. */ readonly placementId: string; /** The exposure id the passage is stored under. */ readonly exposureId: string; } /** What a double-click on a component's text means. */ type ComposedTextAnswer = { readonly kind: "exposed"; readonly target: ExposedTextTarget; } | { readonly kind: "exposed-rich"; readonly target: ExposedRichTarget; } | { readonly kind: "part-of"; readonly placementId: string; readonly heldExposureId?: string; }; /** * What the canvas may do with a value of a composed node, or `null` when the * node is the page's own and the ordinary inline edit answers for it. * * Text a `text` exposure feeds, and a passage a `richText` exposure feeds, on * an unlocked placement, are editable. Anything else in a component is "part * of" it: text it does not expose, a placement locked in Layers, and a value * the component's own locks hold (a block it locks in Layers, or a prop that * is not content inside an area locked to its content; the panel holds that * row read-only, with the reason). * * @param document - the page document, which holds the placement * @param composed - the editor's composition of it, with the exposure map * @param nodeId - the composed node's id, as the element carries it * @param prop - the prop the element renders * @param locks - the block definitions the editor judges locks by */ declare function composedTextAt(document: BlockDocument, composed: BlockDocument | undefined, nodeId: string, prop: string, locks?: SlotDefaultSource): ComposedTextAnswer | null; /** * The op that stores what the author typed as the placement's value, or * `null` when nothing changed or the placement is gone. * * An emptied value CLEARS the field (`$unset`), as the panel's field does: * the author took the text away, which inheriting would put back. */ declare function exposedTextOp(document: BlockDocument, target: ExposedTextTarget, next: string): BuilderOp$1 | null; /** * The passage an exposed target shows now, raw as the composition holds it, or * `null` once it is no longer editable in place (the placement was locked or * removed, or the exposure stopped feeding it). Judged by * {@link composedTextAt}, the one answer the canvas opens a passage by, so the * editor closes on exactly the rules it opened on. */ declare function exposedPassage(document: BlockDocument, composed: BlockDocument | undefined, target: ExposedRichTarget, locks?: SlotDefaultSource): { readonly stored: unknown; readonly value: RichTextValue | undefined; } | null; /** * The op that stores an edited passage as the placement's value, or `null` * when there is nothing to write: the passage is unchanged, the editor did not * return a passage, it is no longer editable, or the page's copy changed while * it was open (the older copy is never written over the newer). One op, the * same the panel's field writes, so one undo step. * * @param next - what the editor read when the edit finished * @param before - what it read when the passage opened * @param opened - the raw passage the session was handed */ declare function exposedRichOp(document: BlockDocument, composed: BlockDocument | undefined, target: ExposedRichTarget, next: unknown, before: unknown, opened: unknown, locks?: SlotDefaultSource): BuilderOp$1 | null; /** One passage a canvas may let an author edit in place. */ interface InlineRichTextTarget { readonly nodeId: string; readonly prop: string; /** * The passage EXACTLY as the document holds it, before any narrowing. * * Kept beside {@link InlineRichTextTarget.value} because the narrowing loses * the difference between two unusable values: a prop holding the string "A" * and one holding the string "B" both read as `undefined`, so a comparison * over the narrowed form reports no change between them. A passage opened on * one and committed after another surface stored the other would overwrite it * silently. */ readonly stored: unknown; /** * The passage as the document holds it, or `undefined` when it holds nothing * usable. * * Undefined rather than an empty passage, because what an EMPTY passage looks * like is the editor's answer and not this module's: inventing one here would * be a second statement of that shape, and the two would drift. */ readonly value: RichTextValue | undefined; /** * Whether the value is restricted to ONE paragraph of words with bold, * italic, links and line breaks (`oneParagraph`): edited with only those, * and written only as that. */ readonly oneParagraph?: true; } /** * Every passage on this node that may be edited on the canvas, in the order the * block declared them. * * Empty for a LOCKED block, and for a node whose type is not registered. A lock * is what an author set to stop the block changing, and editing is a change — * honoured at every entry point or it is honoured at none, which is the state * where an author believes a block is protected. * * @param document - the document being edited * @param nodeId - the node to ask about * @returns the editable passages, empty when there are none */ export declare function richInlineTargets(document: BlockDocument, nodeId: string): readonly InlineRichTextTarget[]; /** * One named passage, or `null` when it is not editable on the canvas. * * Derived from {@link richInlineTargets} rather than repeating its rules, so a * block that is locked, unregistered or has not declared the prop answers the * same way to both. * * @param document - the document being edited * @param nodeId - the node to ask about * @param prop - the passage's name * @returns the target, or `null` */ export declare function richInlineTarget(document: BlockDocument, nodeId: string, prop: string): InlineRichTextTarget | null; /** * Whether a finished edit actually changed the passage. * * Both sides must come from the SAME producer — the editor's own reading of the * passage when it opened, against its reading when it closed. Comparing what * the editor produced against what the DOCUMENT stored would report a change * for every passage merely opened and closed, because an editor normalises what * it loads: it fills in the version, direction and format fields its own * serializer always writes, and a value that reached storage from another * surface, an import or an older schema will not carry them identically. * * That difference is invisible to an author and would put an entry on the undo * stack that appears to do nothing — which reads as the history being broken * rather than as an empty change. * * Compared as serialized JSON, which is sound only because of that same * constraint: one producer emits one key order for one state, so two readings * of an untouched passage are identical strings. * * @param before - what the editor read when it opened the passage * @param after - what it read when the edit finished * @returns whether anything about the passage differs */ export declare function richTextChanged(before: unknown, after: unknown): boolean; /** * Whether the document's copy of this passage changed since a session opened * it. * * Asked separately from the write because the two `null`s a commit can produce * mean opposite things to an author. "Nothing to write" is an edit that changed * nothing, and letting go is right. "The document moved on" is an edit that * cannot be written — and letting go there discards words the author typed, * with the surface they were typing into gone before they could copy them. * * @param document - the document as it stands NOW * @param nodeId - the node being edited * @param prop - the passage being edited * @param opened - the RAW stored value the session was handed * @returns whether the stored value is no longer the one that was opened */ declare function richTextMovedOn(document: BlockDocument, nodeId: string, prop: string, opened: unknown): boolean; /** * The op a finished edit produces, or `null` when there is nothing to write. * * `null` for an unchanged passage, for one the editor did not return as rich * text at all, and for a value that stopped being editable while the edit was * open — a node can be deleted or locked from the layers panel, from a keyboard * action, or by another surface entirely, and writing then would either address * a node that is gone or defeat a lock applied after the caret went in. * * `null` too when the STORED passage changed while the caret was open. Another * surface, an undo, or an op applied from anywhere else can rewrite the same * prop, and this editor has been holding a copy taken before that happened — * writing it back would patch the older passage over the newer one and lose the * intervening change with nothing raised. Refusing keeps what is in the * document; the author's own edit is the one lost, but it is the one still on * their screen. * * @param document - the document as it stands NOW, not when the edit began * @param nodeId - the node being edited * @param prop - the passage being edited * @param next - what the editor read when the edit finished * @param before - what it read when the passage opened * @param opened - the RAW stored value the session was handed, before narrowing * @returns one op, or `null` */ export declare function richInlineTextOp(document: BlockDocument, nodeId: string, prop: string, next: unknown, before: unknown, opened: unknown): BuilderOp$1 | null; /** Where a passage being edited lives. */ interface RichPassageAddress { /** The node the element belongs to: the page's, or a composed one. */ readonly nodeId: string; readonly prop: string; /** * The placement and exposure the passage is stored under, when it is a * component's exposed passage; absent for a node's own. */ readonly exposure?: Pick; } /** What the questions read: the page, its composition, and the lock rules. */ interface RichPassageEditor { readonly document: BlockDocument; readonly composed?: () => BlockDocument | undefined; readonly lockDefinitions?: SlotDefaultSource; } /** The passage as it stands now, or `null` once it is not editable in place. */ declare function passageNow(editor: RichPassageEditor, address: RichPassageAddress): InlineRichTextTarget | null; /** Whether the stored passage changed since the editor opened it. */ declare function passageMovedOn(editor: RichPassageEditor, address: RichPassageAddress, opened: unknown): boolean; /** The op a finished edit writes, or `null` when there is nothing to write. */ declare function passageOp(editor: RichPassageEditor, address: RichPassageAddress, next: unknown, before: unknown, opened: unknown): BuilderOp$1 | null; /** * The block whose selection keeps the passage open: the node itself, or, for * an exposed passage, its placement, which is what a click on a component * selects. */ declare function passageKeptBy(address: RichPassageAddress): string; /** A point where the author pressed, in client coordinates. */ interface CaretPoint { readonly x: number; readonly y: number; } /** Which passage is being edited. */ interface InlineRichTextEditing { readonly nodeId: string; readonly prop: string; /** * The placement and exposure a component's exposed passage is stored * under; absent for a node's own passage. */ readonly exposure?: RichPassageAddress["exposure"]; } interface UseInlineRichTextResult { /** The passage being edited, or `null` when none is. */ editing: InlineRichTextEditing | null; /** * Start editing a passage, reporting whether it could be. * * `prop` defaults to the block's FIRST declared rich value, which is what a * keyboard caller wants: it has a selected block and no element. * * `element` is the one a pointer landed on. A caller that has it should pass * it: finding the element again from the document alone searches the whole * page, and two canvases showing one document carry the same node ids — so * the search can answer with the other canvas's passage, attaching there * while committing here. */ begin: (nodeId: string, prop?: string, element?: HTMLElement, point?: CaretPoint, exposure?: RichPassageAddress["exposure"]) => boolean; /** * Finish, writing whatever the author left behind. * * A caller about to hand the document somewhere else needs the outcome, not * just the document: its own copy is the one from before this commit, and a * REFUSED commit leaves the passage open with the author's words in it, so * closing or opening anything else on top of that destroys them. */ commit: () => InlineEditOutcome; /** Finish, discarding it. */ cancel: () => void; } /** One consumer's hold on the shared editor, as this module uses it. */ interface EditorSession { focus(at?: number): void; read(): unknown; detach(): void; /** Keep this attachment when something else asks for the shared editor. */ hold(): void; /** The format bar's verbs, where the editor offers them. */ format?(mark: "bold" | "italic"): void; link?(url: string | null, options?: { readonly newTab?: boolean; }): void; selection?(): FormatSelection | undefined; /** A whole passage's headings, lists and quote, where the editor has them. */ block?(kind: FormatBlockAction): void; } /** * How a passage is attached: held to ONE paragraph, for a value restricted * to one (`oneParagraph`), by the engine's own restriction. */ interface AttachOptions { readonly paragraph?: { readonly restrict: (value: unknown) => { readonly value: unknown; readonly dropped: boolean; }; readonly onDropped?: () => void; /** Told after every change of the words, with the restricted value. */ readonly onChange?: (value: unknown) => void; readonly onSelection?: (state: FormatSelection) => void; }; /** A whole passage's selection, told as it moves and changes. */ readonly onSelection?: (state: FormatSelection) => void; } /** What asking the facade for the editor produced, as this module reads it. */ type Attachment = { readonly status: "attached"; readonly session: EditorSession; } | { readonly status: "refused"; readonly reason: "unsupported" | "held"; }; /** The facade's editor, as this module uses it. */ interface LoadedEditor { /** Refused for a passage this editor cannot take, or while it is held. */ attach(element: HTMLElement, value: unknown, options?: AttachOptions): Attachment; } /** * Told how every finished edit turned out. * * A host cannot learn this from `commit`'s return value alone, because most * edits do not end by the host calling `commit`. Leaving the passage ends one, * so does opening another, so does the canvas unmounting — and the outcome that * most needs saying, an edit whose value stopped being editable while it was * open, is reached almost entirely through the first of those. A host reporting * only what its own calls returned would say nothing on the common path. * * Called for EVERY commit including the host's own, so that reporting has one * home. A host should read `commit`'s return value for control flow — whether * it may close, which document to save — and this for anything it says to the * author; doing both from the return value reports the same edit twice. */ type InlineRichTextFinished = (outcome: InlineEditOutcome) => void; /** * How the editor is fetched. * * A parameter rather than a hard import so the rules of this hook can be * exercised without loading Lexical — and because the editor is genuinely * optional: a builder embedded somewhere that never supplies one still edits * plain text, and a passage simply does not open. */ type InlineRichTextEditorLoader = () => Promise; /** * @param editor - the editor state whose document is being edited * @param load - how to obtain the shared rich-text editor * @returns the current edit and the ways in and out */ export declare function useInlineRichText(editor: EditorState, load: InlineRichTextEditorLoader | undefined, onFinished?: InlineRichTextFinished): UseInlineRichTextResult; /** One field a list may filter by, as the host's list names it. */ interface QueryField { readonly name: string; readonly label: string; readonly kind: ListFieldKind; /** A choice field's choices, as stored and as named. */ readonly options?: readonly { readonly value: string; readonly label: string; }[]; /** The collection an entry field points at. */ readonly relationTo?: string; } /** * One operator an author picks: the stored operator, and for `exists` which * way it points, since "has a value" and "is empty" are one operator with a * value of `true` or `false`. */ interface OperatorChoice { /** What keys it in a menu: the operator, or `exists:true` / `exists:false`. */ readonly key: string; readonly op: ListFilterOp; /** The value an `exists` choice stores. */ readonly exists?: boolean; readonly label: string; } /** * The operators offered for a field of each kind, in menu order: exactly * the engine's `LIST_KIND_OPS`, which the save judges a row by, so the menu * never offers a row the save refuses. `exists` is offered both ways, as * "has a value" and "is empty". */ declare const OPERATORS: Readonly>; /** A stored row's operator as offered for `kind`, if it is one offered. */ declare function operatorOf(kind: ListFieldKind, op: ListFilterOp, value: unknown): OperatorChoice | undefined; /** Whether an operator takes a list of values: is any of, is none of. */ declare function takesList(op: ListFilterOp): boolean; /** The words for a key's directions, plain where its field is not known. */ declare function directionWords(kind: ListFieldKind | undefined): { readonly ascending: string; readonly descending: string; }; /** * The direction a newly chosen field sorts in: newest first for a date, as a * list of posts is most often read, and ascending for anything else. */ declare function firstDirection(kind: ListFieldKind): boolean; /** A day as an author reads it: "1 Sept 2026". The stored day, never shifted. */ declare function dayWords(day: string): string; /** A filter row as one sentence, in its three parts. */ interface FilterSentence { /** The field: its label, or its stored name marked as gone. */ readonly field: string; /** The operator, as the field's kind words it. */ readonly operator: string; /** The value, or nothing for an operator that takes none. */ readonly value: string; } /** A row as the closed line reads it: "Category · is any of · News, Guides". */ declare function filterSentence(row: { readonly field?: string; readonly op?: ListFilterOp; readonly value?: unknown; }, field: QueryField | undefined, entryTitle?: (id: string) => string | undefined): FilterSentence; /** A row as one line of text, for its title and accessible name. */ declare function filterLine(sentence: FilterSentence): string; /** A row being edited: any part may be missing until the author chooses it. */ interface DraftFilter { readonly field?: string; readonly op?: ListFilterOp; readonly value?: unknown; } /** * A draft row as the stored row it would be, or why it is not one yet, in * words naming what to choose. Judged by the engine's own reading of a * filter row, so a row the editor writes is one the save accepts. */ declare function completedFilter(draft: DraftFilter, field: QueryField | undefined): { readonly filter: ListFilter; } | { readonly missing: string; }; /** * The value a row starts with when its field or operator changes: what the * new operator takes, kept from the old value where it still fits, so * changing "is" to "is any of" keeps the chosen value as the first of a list. */ declare function valueFor(kind: ListFieldKind, choice: OperatorChoice, previous: unknown): unknown; /** The stored filters with one row replaced, added or removed. */ declare function withFilter(filters: readonly ListFilter[], index: number, next: ListFilter | undefined): ListFilter[] | undefined; /** The stored keys with one moved from `from` to `to`, others in order. */ declare function movedKey(keys: readonly ListSortKey[], from: number, to: number): ListSortKey[]; /** The sort as stored for `keys`: `undefined` for none, which removes it. */ declare function sortValue(keys: readonly ListSortKey[]): string | undefined; /** * A typed bound read as the number it stores, or the message saying what to * type instead, judged by the engine's own reading of the prop so the field * and the save agree. Empty removes the prop, and the list reads its default. */ declare function readBound(prop: "limit" | "offset", typed: string): { readonly value: number | undefined; } | { readonly problem: string; }; /** One custom source the site offers: a registered query, without its run. */ interface CustomSource { readonly declaration: NamedQueryDeclaration; /** * The collections it reads that visitors can read nothing of, as the * server judged them with the engine's `namedQueryHiddenReads`. */ readonly readsHidden: readonly NamedQueryHiddenRead[]; } /** The site's custom sources, as the engine looks a list's query up. */ declare function customSourceLookup(sources: readonly CustomSource[]): NamedQuerySource; /** A query's inputs, by key, in the order it declares them. */ declare function inputsOf(declaration: NamedQueryDeclaration): [string, NamedQueryParam][]; /** Whether picking the query must wait for an input before it is written. */ declare function needsInput(declaration: NamedQueryDeclaration): boolean; /** * The Inputs group's note: the inputs the query needs, and, while one of * them is still empty, that nothing on the page changes until it is set. * Past two needed inputs, each needed label carries a dot instead * ({@link marksNeeded}), and the note says what the dot means. */ declare function inputsNote(declaration: NamedQueryDeclaration, missing: readonly NamedParamProblem[]): string; /** Whether the needed inputs' labels carry a dot, as the note says past two. */ declare function marksNeeded(declaration: NamedQueryDeclaration): boolean; /** * What an input shows while it is empty: what empty means for it. Its * default where it has one ("Today", "30", a choice's name), a prompt to * choose where it is needed, and otherwise that it narrows nothing ("Any * venue"), or the developer's own placeholder for text. */ declare function emptyWords(param: NamedQueryParam): string | undefined; /** A query's inputs as a list stores them: one literal per input set. */ type StoredParams = Readonly>; /** * The inputs with one set, or emptied: an emptied input (`undefined`) is * left out, never stored as `null`, so it reads its default. Each control * says when it is empty; an empty string is a value, as a choice may * declare `""` among its options. */ declare function withInput(params: StoredParams, key: string, value: NamedQueryParamValue | undefined): StoredParams; /** * A draft of a query's inputs judged as a save would: its problems, each by * input, and whether it can be written. Judged without a today of its own, * as the save is, so a day defaulting to today counts as set. */ declare function judgedDraft(declaration: NamedQueryDeclaration, params: StoredParams): { readonly problems: readonly NamedParamProblem[]; readonly writable: boolean; /** Stored inputs the query no longer takes, which are left out. */ readonly unknown: readonly string[]; }; /** * The one write that makes a custom source the list's source: its name and * inputs, with the collection, the related source, the filters and the sort * removed in the same edit, so it is one undo step and never stored beside * another source. Pages go too: a custom source's list is not split into * pages yet, which its save refuses. No inputs set stores none. */ declare function namedSourceChanges(name: string, params: StoredParams): Record; /** The inputs a stored list holds, as the note under a removed query lists them. */ declare function keptInputs(params: StoredParams): (readonly [string, NamedQueryParamValue])[]; /** What a list of custom sources is searched by: its name and its line. */ declare function sourceSearchText(declaration: NamedQueryDeclaration): string; /** One item the host's media picker returned. Only its id is ever stored. */ interface PickedMedia { readonly id: string; readonly url?: string | null; readonly filename?: string; } /** What a field shows of a chosen media item, read by its id. */ interface MediaSummary { /** The file's name, as the author uploaded it. */ readonly name?: string; /** An address to draw a small picture of it from. */ readonly thumbnail?: string; /** Its alt text in the library, when it has one. */ readonly alt?: string; } /** * One image a library search found: its summary, and the id a pick stores. * * @experimental Settles with the editor's binding controls. */ interface FoundMedia extends MediaSummary { readonly id: string; } /** * Put one file in the host's media library, through the library's own upload * and its checks (the types and size the site accepts, and the author's * right to upload), telling `onProgress` how far it is, from 0 to 100. * Resolves to the stored item, and rejects with the reason the upload was * refused, in words an author can read. * * @experimental Settles with the canvas's image empty state. */ type UploadMedia = (file: File, onProgress?: (percent: number) => void) => Promise; /** What the content controls hand the host's media picker. */ interface MediaPickerProps { open: boolean; onOpenChange: (open: boolean) => void; onSelect: (media: PickedMedia[]) => void; title?: string; /** The kinds of file it offers, as an `accept` list: `image/*`. */ accept?: string; /** What is chosen when it opens: the file the prop stores, if any. */ initialSelectedIds?: Set; /** * One file, or several: `multi` lets the author pick many, handed back in * the order they were picked, as a Gallery's "Add images" asks. Unset is * one. * * @experimental Settles with the Gallery's "Add images". */ mode?: "single" | "multi"; } /** What a relation control asks the host for: one collection's entries. */ interface EntryQuery { readonly collection: string; /** Entries whose title holds this, ignoring case; empty for the first few. */ readonly search?: string; /** These entries by id, to name the one a prop stores. */ readonly ids?: readonly string[]; readonly limit?: number; readonly signal?: AbortSignal; } /** One entry as a relation control shows it: its id and its title, nothing else. */ interface FoundEntry { readonly id: string; readonly title: string; } /** What the link control asks the host for: what a link can point at. */ interface LinkTargetQuery { /** Pages and entries whose title holds this, ignoring case; empty for the first few. */ readonly search: string; readonly limit?: number; readonly signal?: AbortSignal; } /** One page or entry the link control offers. */ interface LinkTarget { readonly id: string; /** Its collection's slug, which a link to the entry stores. */ readonly collection: string; /** The heading it is listed under: its collection's name ("Pages"). */ readonly group: string; readonly title: string; /** * Where it is served on the site (`/pricing`), when the host knows. A * heading or a box links by this address; without one, only a block that * can hold an entry reference can link to it. */ readonly path?: string; } /** * One field a collection list may filter by, and sort by unless it is a * relation: a field visitors can see, holding one value. */ interface LoopListField extends QueryField { /** A date picked as a day, which a filter compares as that day. */ readonly dateOnly?: boolean; } /** A to-many relation a related list can show the entries of. */ interface LoopRelation { /** The relation field a list's `relation.field` stores. */ readonly field: string; /** What the author calls it: "Categories". */ readonly label: string; /** The collection its entries are in. */ readonly collection: string; } /** One collection a loop can repeat over, as its controls offer it. */ interface LoopCollection { /** The slug a loop stores. */ readonly slug: string; /** Its name, as the admin shows it: "Blog posts". */ readonly label: string; /** Its name for one entry: "Post". Its label where it has none. */ readonly singular?: string; /** * The fields a list may filter and sort by, in the collection's order: * only those visitors can see, since the entries shown would otherwise * reveal a field no visitor may read. */ readonly fields: readonly LoopListField[]; /** Its to-many relations visitors can see, to a listed collection. */ readonly relations?: readonly LoopRelation[]; /** * Every field name it declares, so a stored filter on a field visitors * can't see is told apart from one on a field it no longer has. */ readonly declared?: readonly string[]; /** * Every field the public may read, as a save judges a list against them; * {@link fields} is the narrower view of these an author is offered. */ readonly readable?: readonly { readonly name: string; /** What the admin calls it: "Cover image". */ readonly label?: string; readonly type: string; readonly hasMany?: boolean; readonly relationTo?: string | readonly string[]; /** A time of day, which no list filters or sorts by. */ readonly timeOnly?: boolean; /** The primitive a plugin's field type is stored as, which gives its kind. */ readonly storage?: FieldStoragePrimitive; /** For an upload field: whether it takes images, where it says. */ readonly takesImages?: boolean; }[]; /** The field the admin titles its entries by, where visitors may read it. */ readonly titleField?: string; /** Whether its entries are served as pages of their own. */ readonly entriesHavePages?: boolean; } /** A list's matching entries, and how many of them it shows. */ interface ListEntriesCount { readonly matching: number; readonly shown: number; } /** * One form a provider lists for an author to pick in a Form block. * * @experimental Settles with the form provider contract. */ interface PickableForm { /** The provider's own reference to it, which the block stores. */ readonly ref: string; readonly title: string; readonly state: "draft" | "published" | "closed"; /** Where the author edits it in the admin, as the provider gives it. */ readonly editHref?: string; } /** * A source of forms other than the block's own fields (the forms plugin), * with the forms the author may pick from it. * * @experimental Settles with the form provider contract. */ interface FormSource { /** The provider's id, which the block stores beside a form's reference. */ readonly id: string; /** What authors read: "Forms" in "Fields … come from Forms." */ readonly label: string; readonly forms: readonly PickableForm[]; } /** * A picked form's state as its author sees it on the canvas. * * @experimental Settles with the form provider contract. */ type PickedFormState = "published" | "draft" | "closed" | "missing"; /** * What the host lends the Content tab: the parts of the admin this package * cannot reach itself. Each is optional, and a control whose service is absent * says so rather than offering a button that does nothing. * * The binding controls' share is {@link BindingServices}. * * @experimental Grows with the controls registry. */ interface ContentServices extends BindingServices { /** The admin's media library, as a dialog the control opens. */ readonly MediaPicker?: React$1.ComponentType; /** * The admin's media library upload, for a file an author drops on an * Image or chooses from its empty state. Absent, an Image offers no * Upload and takes no dropped file. * * @experimental Settles with the canvas's image empty state. */ readonly uploadMedia?: UploadMedia; /** * Copy the picture a video's provider shows for it into the media library, * once: a second copy for the same video answers the first. Given the * Embed's link as stored; the host fetches only from the provider's fixed * picture host. Absent, an Embed offers no "Use the video's thumbnail". * * @experimental Settles with the Embed's poster. */ readonly copyEmbedThumbnail?: (link: string) => Promise; /** The shared rich-text editor, loaded when a passage is first focused. */ readonly loadRichTextEditor?: InlineRichTextEditorLoader; /** * A collection's entries, read with the signed-in author's own access, for * a prop that points at one of them. */ readonly findEntries?: (query: EntryQuery) => Promise; /** * The pages and entries a link can point at, read with the signed-in * author's own access and listed by collection, the site's own pages first. * Absent, a link control takes typed addresses only. */ readonly findLinkTargets?: (query: LinkTargetQuery) => Promise; /** * The collections a collection loop can repeat over, read with the * signed-in author's own access, each with the fields visitors can see * and its to-many relations. Absent, a loop's collection and sort are * typed as text. */ readonly listLoopCollections?: () => Promise; /** * The custom sources a collection list may show: the named queries the * site registers, each without its run function, with the collections it * reads that visitors can read nothing of. Absent, the Source menu offers * collections and related entries only. */ readonly listCustomSources?: () => Promise; /** * How many entries a list's stored query matches as the canvas reads them, * and how many of those its window shows, from one count read. Asked only * for the list selected in the editor. Undefined where one read cannot * count it, such as a list of an entry's related entries. */ readonly countListEntries?: (props: Readonly>) => Promise; /** * The collection the document being edited is an entry of, so a list on * it can show the entry's related entries. `null` where the document is * known to be no collection's entry, such as a Single, so a list there * showing the entry's related entries is refused as the save refuses it; * absent where that is not known. */ readonly entryCollection?: string | null; /** * A media item by its id, read with the signed-in author's own access, so a * stored file is shown by its picture and name rather than as "a file". */ readonly readMedia?: (mediaId: string) => Promise; /** * The media library's images found by name, read with the signed-in * author's own access: the newest first, a handful at a time, and the * newest of all for an empty search. Rejects where the library cannot be * read, and once `signal` aborts. Absent, an image binding's Fallback * offers the host's `MediaPicker` dialog alone. * * @experimental Settles with the editor's binding controls. */ readonly searchMedia?: (search: string, signal?: AbortSignal) => Promise; /** * Where a rich-text field holds the passage it has open, so the host * finishes it before the document is stored. */ readonly openPassages?: OpenPassages; /** * Where the icons this author chose last are kept, for the Icon control's * Recent row: the host's, so it is one per signed-in author. Absent, the * picker offers no Recent row. */ readonly recentIcons?: PreferenceStore; /** * A form a Form block picked from a provider, read with the signed-in * author's own access, for what its own "After sending" setting is. * Absent, or answering `undefined`, the panel names the choice without * saying what it is. * * @experimental Settles with the form provider contract. */ /** * The site's form sources other than the block's own fields, each with * the forms the signed-in author may pick, for a Form block's "Form: ". An empty list is a site with no such source, where the panel * says what installing one adds. Absent, the panel offers neither. * * @experimental Settles with the form provider contract. */ readonly listForms?: () => Promise; /** * A picked form's state, read with the signed-in author's own access, for * what the canvas says over it: a draft, closed, or deleted. Rejects where * it could not be read, and the canvas then says nothing. * * @experimental Settles with the form provider contract. */ readonly pickedFormState?: (form: { readonly provider: string; readonly ref: string; }) => Promise; readonly describeForm?: (form: { readonly provider: string; readonly ref: string; }) => Promise<{ readonly afterSending: { readonly kind: "message" | "page"; }; } | undefined>; } /** * The host's content services for a surface below the inspector that is not * a Content tab control, such as a component placement's exposed image, so * it reaches the same media library without a prop threaded through every * surface between. */ declare const ContentServicesContext: React$1.Context; /** What every content control is given. */ interface ContentControlProps { /** The id its field takes, which its label points at. Unique per mount. */ readonly id: string; readonly prop: EditableProp; /** Whether the prop may not be changed here: a lock, or a `contentOnly` area. */ readonly disabled: boolean; /** * Set the prop, through the editor's one write path; `undefined` removes * it. Answers the document the write produced, when the caller knows it. */ readonly onCommit: (name: string, value: unknown) => BlockDocument | null | void; /** What the host lends, for the controls that need the admin. */ readonly services?: ContentServices | undefined; /** * How many lists this control sits inside: 0 at the top of the tab. Lists * nest only as deep as the engine's `ITEM_SCHEMA_MAX_DEPTH`. */ readonly depth?: number; /** * The label to show, when it is not the prop's own name: an item of a list * is labelled by its list and its position. */ readonly label?: string | undefined; /** * The block's other props as stored, read-only, for a control whose * choices depend on one: a loop's sort offers the fields of the collection * its `collectionProp` names. Absent inside a list's items. */ readonly values?: Readonly> | undefined; } /** A content control: a label and the field it names. */ type ContentControl = (props: ContentControlProps) => React$1.JSX.Element; /** * A media item, chosen from the host's library. Only the id is stored: the * page resolves it to the file's current address when it draws, so a file * moved or renamed in the library stays right on the page. */ declare function MediaControl({ id, prop, disabled, onCommit, services }: ContentControlProps): React$1.JSX.Element; /** * A media field: the chosen file, the button that opens the host's picker, * and Remove. Shared by the media control and an image's source, which * writes the same id alongside the props it keeps in step. */ declare function MediaField({ id, label, stored, accept, disabled, services, showAlt, onChange }: { id: string; label: string; /** The stored id, or `null` for none. */ stored: string | null; accept: string | undefined; disabled: boolean; services: ContentServices | undefined; /** Whether to show the library's alt text under the file's name. */ showAlt?: boolean; /** Store an id, or `undefined` to remove it. */ onChange: (mediaId: string | undefined) => void; }): React$1.JSX.Element; /** * A chosen media item as a field shows it: its thumbnail, its name and its * alt text, read by its id. Shared with a placement's exposed image, so a * stored file reads the same in both. Until it is read, or where it cannot * be, the name of the last pick, else a plain sentence that a file is chosen. */ declare function ChosenMedia({ mediaId, read, pickedName, fallback, showAlt }: { mediaId: string | null; read: ContentServices["readMedia"]; pickedName: string | undefined; fallback: string; /** Whether to show its library alt text, where a row of its own does not. */ showAlt?: boolean; }): React$1.JSX.Element; /** * The summary of `mediaId`, read once per id; `undefined` until it is read, * and for the id it was read for only, so a summary never shows beside * another file's id. */ declare function useMediaSummary(read: ContentServices["readMedia"], mediaId: string | null): MediaSummary | null | undefined; /** * The button that opens the host's media picker, and the picker while open. * Shared with a component placement's exposed image, so both choose a file * the same way. */ declare function MediaChoice({ id, Picker, label, stored, selected, accept, disabled, onChoose }: { /** The button's id, for a field label that names it. */ id?: string; Picker: React$1.ComponentType; label: string; stored: string | null; /** * The media id the library opens with selected: what `stored` names, unless * a field stores something other than an id (a background's address). */ selected?: string | null; accept: string | undefined; disabled: boolean; onChoose: (media: PickedMedia) => void; }): React$1.JSX.Element; /** What a paste that lost formatting says under a one-paragraph field. */ declare const ONE_PARAGRAPH_DROPPED = "Text keeps words, bold, italic and links. Use Rich text for headings and lists"; /** * The Content tab's rich-text prop: its name, and the passage under it. * * A whole passage (a Rich text's) also says where it is best edited, on the * canvas with the format bar, and offers "Open the full editor" for longer * work, where the host has an editor to open. */ declare function RichTextControl({ id, prop, disabled, onCommit, services }: ContentControlProps): React$1.JSX.Element; /** * A passage's words for the field while no editor is attached: one line per * block, and one per item of a list, as the editor will lay them out, so the * field is as tall before it is focused as after. */ declare function passagePreview(passage: RichTextValue): string; /** * A rich-text passage, edited in the inspector with the admin's one rich-text * editor. Shared by every surface that edits one: the Content tab's prop and a * placement's exposed field, each with its own label and write path. * * The editor is attached when the field is focused, loaded with the stored * passage, and what it reads is committed once when the field is left, so an * edit is one entry in the history. There is one editor for the whole admin: * while it is held on the canvas the field says so and writes nothing. * * Read-only is passed to the element itself: a disabled fieldset does not * stop typing in a `contenteditable`. */ declare function RichTextField({ id, labelledBy, value, disabled, onCommit, services, oneParagraph }: { id: string; /** The id of the element naming the field. */ labelledBy: string; /** * The value is one paragraph of words with bold, italic, links and line * breaks (a Text's): edited held to that, and written as it is typed, the * typing joined into one step of the history, so the canvas shows the words * as they go in. */ oneParagraph?: boolean; /** The passage stored, or `undefined` for none. */ value: unknown; disabled: boolean; /** * Write the passage the editor reads; `null` when the write was refused, * which keeps the passage open with the author's words. */ onCommit: (value: unknown) => BlockDocument | null | void; services: ContentServices | undefined; }): React$1.JSX.Element; /** * A choice of one among a few options, as a row of radio buttons: the arrow * keys move the choice, as in any radio group, and only the chosen one (or the * first, with none chosen) is in the tab order. */ declare function SegmentedChoice({ id, labelledBy, options, labels, value, disabled, onChoose }: { id: string; labelledBy: string; options: readonly string[]; labels: readonly string[]; value: string | undefined; disabled: boolean; onChoose: (option: string) => void; }): React$1.JSX.Element; /** * A prop this panel has no control for, listed rather than omitted, at the * top level and inside a list's items alike. A block declaring a prop the * panel cannot draw is still a block with that prop, and hiding it presents * an incomplete block as a complete one: an author would conclude the field * does not exist rather than that it is edited elsewhere. * * Named in plain text, not by a label: a label names a control, and one * pointing at nothing reads to a screen reader as a field nobody can reach. */ declare function UnsupportedField$1({ prop }: { prop: Pick; }): React$1.JSX.Element; /** * The control for a prop type, or `undefined` when there is none. Asked of the * listed names only, so an inherited name such as `constructor` resolves to * nothing rather than to something that is not a control. */ declare function contentControlFor(type: string): ContentControl | undefined; /** * A field a condition can check: one a list filters by, with its kind, or a * field the public may read that no list filters by (several entries, media, * rich text, a time of day), which a condition can only ask has a value. */ interface ConditionField { readonly name: string; readonly label: string; readonly kind: ConditionFieldKind; readonly options?: QueryField["options"]; readonly relationTo?: string; readonly dateOnly?: boolean; /** What the field menu calls a field of kind `other`: "Several entries". */ readonly kindWords?: string; } /** * The fields a block's conditions can check in a collection: its list * fields, then every other field the public may read, as the engine's kind * for it says (`other`), in the collection's order. Derived from the readable * schema the save judges by, so the editor offers what the save accepts. */ declare function conditionFieldsOf(collection: LoopCollection): readonly ConditionField[]; /** * The fields a block's conditions can check in a list's items whose source * is a named query with rows of its own schema: the fields its rows declare, * each of the kind the save judges it by. */ declare function conditionFieldsOfShapes(shapes: readonly BindingFieldShape[]): readonly ConditionField[]; /** A field as a list's filter controls take it, for one a list filters by. */ declare function asListField(field: ConditionField | undefined): LoopListField | undefined; /** One operator an author picks, keyed for a menu. */ interface ConditionChoice { readonly key: string; readonly op: ConditionOp; readonly label: string; } /** * The operators offered for a field of each kind, in menu order. A yes-or-no * field offers one, "is", whose Yes or No is stored as `is_true` or * `is_false`. The engine's `equals` and `not_equals` against Yes read as * those (see `toDraft`); against No they differ on an empty value, so a * stored one is listed as it is, `current`, and is otherwise not offered. */ declare function conditionChoices(kind: ConditionFieldKind, current?: ConditionOp): readonly ConditionChoice[]; /** The menu key a stored condition's operator is listed under. */ declare function choiceKey(op: ConditionOp): string; /** * The list filter operator whose value control a condition's value is chosen * with: the same value, compared the other way round for a negation. A * yes-or-no field's "is" is the filter's "is" with Yes or No. */ declare function valueOpFor(op: ConditionOp): ListFilterOp | undefined; /** A condition being edited: any part may be missing until it is chosen. */ interface DraftCondition { readonly field?: string; readonly op?: ConditionOp; readonly value?: unknown; } /** * A stored condition as a row reads it, its operator in its canonical * spelling; an operator conditions do not have reads as not chosen, and the * engine's finding says why. */ declare function conditionDraftOf(condition: Condition): DraftCondition; /** The value a yes-or-no condition's Yes or No stands for. */ declare function booleanValueOf(op: ConditionOp | undefined): boolean | undefined; /** A condition as one sentence, in its three parts. */ interface ConditionSentence { readonly field: string; readonly operator: string; readonly value: string; } /** A condition as the closed line reads it: "Reading time · is more than · 5". */ declare function conditionSentence(draft: DraftCondition, field: ConditionField | undefined, entryTitle?: (id: string) => string | undefined): ConditionSentence; /** A sentence as one line of text, for a row's title and accessible name. */ declare function conditionLine(sentence: ConditionSentence): string; /** * A draft as the stored condition it would be, or why it is not one yet, in * words naming what to choose. Whether the value fits its field is the * engine's to say, as the save does, once the condition is stored. */ declare function completedCondition(draft: DraftCondition, field: Pick | undefined): { readonly condition: Condition; } | { readonly missing: string; }; /** * What a hidden block's marker shows: the block's name and why it is hidden, * in words, and whether that is because its conditions can't be checked. */ type ConditionHiddenProps = { readonly name: string; readonly reason: string; readonly unchecked: boolean; }; /** * The entry the conditions are checked against, as a visitor reads it. * * @experimental Settles with the editor's condition controls. */ interface ConditionsPreview { /** * The entry's published values and the fields a visitor may read, or * `undefined` where a visitor reads no entry at all: one never published, * or one the public may not read. The page then hides every conditioned * block, as the published page does. */ readonly subject: ConditionSubject | undefined; /** What the entry is called in words, lower case: "post". */ readonly noun: string; /** The entry's fields as a condition reads them, for the reasons' words. */ readonly fields: readonly ConditionField[]; /** Where a site starts its days, for a date compared by day. */ readonly dayStart?: ConditionDayStart; } /** A block the conditions hide, with what its marker says. */ type HiddenBlock = ConditionHiddenProps & { readonly id: string; }; /** * The page with its conditions applied. * * @experimental Settles with the editor's condition controls. */ interface AppliedConditions { /** The page as the canvas draws it: hidden blocks as markers. */ readonly document: BlockDocument; /** The judged blocks a visitor would see. */ readonly shown: ReadonlySet; /** The judged blocks a visitor would not, outermost first, in page order. */ readonly hidden: readonly HiddenBlock[]; /** * Whether the page holds a conditioned block left unjudged, so what is said * of the judged blocks is not said of all: one a list's item decides, where * the lists do not draw what a visitor reads, or one in a region of the * page's Layout. */ readonly unjudged: boolean; /** * Whether the page holds conditioned blocks judged for each list entry * drawn, by the renderer, which `shown` and `hidden` do not count: each * one an entry hides is drawn as its marker in that entry. */ readonly byEntry: boolean; /** * How the canvas's renderer judges the blocks of the components the page * places, for the previewed entry, as the page's route judges them: each * one they hide drawn as its marker, keeping the placement it belongs to. * The page's own blocks are judged in `document` already. */ readonly entryJudgement: EntryJudgement; } /** * The page with its conditions applied for the previewed entry: every block * judged, every conditioned block drawn (a shown one as itself, a hidden one * as its marker), as the canvas shows the page while conditions apply. * * @experimental Settles with the editor's condition controls. */ declare function appliedConditionsOf(document: BlockDocument, preview: ConditionsPreview, nameOf: (node: BlockNode) => string, drawn?: DrawnWith): AppliedConditions; /** * What else the canvas draws the page with, whose conditioned blocks are not * judged here: the definitions of the components it places, and the regions * of its Layout. */ interface DrawnWith { /** The limits the canvas draws under, so every block it draws is judged. */ readonly limits?: DocumentLimits; /** * Whether the canvas's lists draw the entries a visitor reads, so a block a * list's item decides is judged for each item drawn, by the renderer, and * keeps its conditions in the page drawn rather than being shown for every * item. Otherwise such a block is left unjudged, drawn for every item. */ readonly itemsJudged?: boolean; /** The definitions of the components the page places. */ readonly definitions?: DefinitionsById; /** The regions of the page's Layout, drawn around it, each with its own definitions. */ readonly regions?: readonly { readonly document: BlockDocument; readonly definitions?: DefinitionsById; }[]; } /** * What the canvas reads to say why a list's item hides a block: the fields a * visitor may read of a collection's entries, the same fields as the "Show * when" rows name them where the host lists them, each block's name, and * where the site's days start. * * @experimental Settles with the editor's condition controls. */ interface ItemMarkerSources { readonly fieldsOf: (collection: string) => readonly BindingFieldShape[] | undefined; readonly labelledOf?: (collection: string) => readonly ConditionField[] | undefined; readonly nameOf: (node: BlockNode) => string; readonly dayStart?: ConditionDayStart; } /** * What the canvas draws where a list's item hides a block, while conditions * apply: the block's marker, saying why this entry hides it, as a hidden * block of the page itself says it. Judged against the item as the published * page judges it; an item whose fields are not known, a named query's row * among them, fails closed there, so its marker says the block can't be * checked. * * @experimental Settles with the editor's condition controls. */ declare function itemHiddenAsOf(sources: ItemMarkerSources): ItemHiddenAs; /** * The definitions a page reaches, the components it places and those they * place, with each one's conditions lifted so the canvas draws its * conditioned blocks; every other definition as it is. The reached ones are * those the resolver reads composing the page as the canvas does, so a * component a variant or an override selects, at any depth and through any * setting a placement rewrites, is lifted exactly when it is drawn. Only * those are walked, so a large component library costs nothing on a page * that places none of it. * * Exported so a surface that reads the page as the canvas draws it composes * it from these same definitions. * * @experimental */ export declare function revealedDefinitions(document: BlockDocument, definitions: DefinitionsById, limits: DocumentLimits | undefined): DefinitionsById; /** * The page as the canvas draws it: every conditioned block drawn, its * conditions lifted, but, while a list's entries are judged (`byEntry`), * a block a list's entry decides, which keeps its conditions for the * renderer to judge against each entry drawn. * * @experimental Settles with the editor's condition controls. */ declare function revealedForCanvas(document: BlockDocument, applied: Pick | undefined, limits?: DocumentLimits): BlockDocument; /** * Which conditioned blocks a document holds: any at all, and any that reads * the entry it is drawn for, which is what applying conditions judges. With * `definitions`, the blocks of the components it places too, read as the * resolver composes them, each in the scope it is drawn in. * * @experimental Settles with the editor's condition controls. */ export declare function conditionedBlocksIn(document: BlockDocument, limits?: DocumentLimits, definitions?: DefinitionsById): { readonly any: boolean; readonly readingEntry: boolean; /** Whether any is in a list's per-entry slot, read against each item. */ readonly readingItems: boolean; }; /** * How far the pointer travels before a press becomes a drag. * * Large enough that the hand-shake in a deliberate click never reaches it, small * enough that a short drag still starts. The same order as the field's other * editors; the exact figure is not load-bearing, because the threshold only has * to separate a click from an intent to move. */ declare const DEFAULT_ACTIVATION_PX = 4; /** * How far a rival target must be held before it replaces the committed one. * * Measured as pointer TRAVEL rather than as a property of the blocks, which is * the whole reason this canvas can have hysteresis at all: `core/spacer` takes * its height from an author-set prop with no lower bound and `core/divider` * renders one pixel tall, so any rule keyed on a block's size makes some * authored block impossible to drop beside. Travel is a property of the gesture * and treats a 1px divider and a 900px hero identically. */ declare const DEFAULT_SWITCH_PX = 8; /** * What a drag is carrying: a node the document already holds, or a block type * that has no node yet. * * The two differ in exactly two places — whether anything is being detached, * and what the release commits — and are identical everywhere between. Holding * that as a payload rather than a second hook is what makes "one engine" * checkable rather than aspirational: `resolveDrop`, the switch rule, * autoscroll and the indicator cannot tell the kinds apart, because they are * never given the chance to. * * An insert builds its node from a THUNK the caller supplies rather than * resolving the type here. The palette reads its definitions from one snapshot * per mount and a block arrives with the children it declares, so resolving * again at drop would answer from a second reading — and the row the author * dragged could differ from the subtree that lands. */ type DragSubject = { readonly kind: "move"; readonly nodeId: string; } | { readonly kind: "insert"; readonly blockName: string; readonly makeNode: () => BlockNode | null; /** * Notified with the node that landed, after a drop the editor accepted. * * Carried on the subject so the two ways a palette inserts report the * same event. The panel already tells its host about a click insert, and * a host reacting to that — scrolling to the block, opening its settings * — would silently miss every insert made by dragging. */ readonly onInserted?: (node: BlockNode) => void; }; /** * What a palette hands the drag when a row is pressed. * * Named rather than written inline at both the type and the implementation: * the two used to state it separately, and adding a field to one left the * other rejecting it. */ interface InsertDragEntry { /** The block type in flight, which the drop position is resolved for. */ blockName: string; /** Builds the node at the release, from the palette's own snapshot. */ makeNode: () => BlockNode | null; /** Notified with the node that landed, after a drop the editor accepted. */ onInserted?: (node: BlockNode) => void; } /** What a drag is doing right now, for the canvas to draw. */ interface CanvasDragState { /** * The node being dragged, or null when no MOVE-drag is in flight. * * Null for the whole of an insert-drag as well as between drags: the block * has no node until the release makes one, and minting an id early to fill * this would hand the canvas an id addressing nothing in the document. */ readonly draggingId: string | null; /** * The block type in flight, whichever kind of drag it is, or null when none * is. * * This is the field to ask "is a drag happening", because it is the only one * that does not assume the subject has a node. Anything gated on the id * instead is blind to a drag from the palette. */ readonly draggingBlockName: string | null; /** Where a drop would land, or null when nowhere would accept it. */ readonly target: DropTarget | null; /** * Why the region under the pointer will not take the block, or null. * * Distinct from a null target: the author has aimed at something, and saying * nothing tells them the editor did not notice. */ readonly refusal: DropRefusal$1 | LockDropRefusal | null; } /** The handlers the canvas root must carry for a drag to work. */ interface CanvasDragHandlers { readonly onPointerDown: React$1.PointerEventHandler; readonly onPointerMove: React$1.PointerEventHandler; readonly onPointerUp: React$1.PointerEventHandler; readonly onPointerCancel: React$1.PointerEventHandler; } interface CanvasDrag extends CanvasDragState { readonly handlers: CanvasDragHandlers; /** * Begin a drag whose subject is not in the document yet. * * Called from a PALETTE row's own `onPointerDown`, which is why it cannot be * {@link CanvasDragHandlers.onPointerDown}: that one takes the canvas root * from `event.currentTarget`, and for a press on a palette row the current * target is the row. * * Does nothing when no canvas root was supplied, which leaves the press * exactly as it was — the row's click still inserts, and that click is the * non-drag route WCAG 2.2 SC 2.5.7 requires. This only ever supplements it. */ readonly beginInsertDrag: (event: React$1.PointerEvent, entry: InsertDragEntry) => void; } interface UseCanvasDragOptions { /** The editor whose document a drop edits. */ editor: EditorState; /** Which child regions each block type declares. */ slots: SlotSource; /** The nesting rule, asked before any position is offered. */ nesting: NestingSource; /** * The definitions the canvas draws instances from, so a MOVED instance is * judged by the roots of the definition it draws rather than by its own * type, which the nesting rule cannot restrict. Absent, an instance moves * anywhere — the posture of a host that resolves nothing. */ definitions?: ComponentLookup; /** * The canvas root, for a drag that begins outside it. * * Optional, and its absence means only that {@link CanvasDrag.beginInsertDrag} * does nothing: a host that never drags from a palette has no use for the * ref, and requiring it would make every existing caller supply a value to * satisfy a feature it does not mount. */ canvasRoot?: React$1.RefObject; activationPx?: number; switchPx?: number; } interface DropIndicatorProps { /** Where a drop would land, or null to draw nothing. */ target: DropTarget | null; } /** * The line showing where a dropped block will go. * * The target is in the canvas root's content coordinates, which is what the * rectangles were measured in. Where the line is drawn in those coordinates * depends on where it is drawn: inside the root over a canvas sharing the * editor's document, or in the layer over the canvas's frame, where they are * scaled to the frame's zoom while the line keeps its own thickness. Asked of * the line's own element, through `overlaySpaceOf`, the one mapping every * piece of chrome uses. * * Written to the element's style before paint rather than rendered: the * mapping needs the element in the document, and a render to apply it would * draw the line at the unmapped position for a frame on every pointer move. * * `aria-hidden`, and deliberately: the equivalent keyboard move announces its * own outcome through the editor's one live region, and a second element * describing the same pointer gesture would be read alongside it. A pointer drag * is also self-describing to anyone who can see the line. */ export declare function DropIndicator({ target }: DropIndicatorProps): React$1.JSX.Element | null; /** * Wire pointer events on the canvas root to the drop rules. * * Returns handlers to spread onto the root and the state to draw. The canvas * owns the element; this owns the gesture. */ export declare function useCanvasDrag({ editor, slots, nesting, definitions, canvasRoot, activationPx, switchPx }: UseCanvasDragOptions): CanvasDrag; /** * The class on a Layout region's frame. Its blocks are a document of their * own, drawn inside the canvas around the page's, so a mark that belongs to * the page's blocks is kept off anything inside it. */ declare const CANVAS_REGION_CLASS = "nx-canvas-region"; /** One region of the page's layout, as the host hands it to the canvas. */ interface CanvasRegion { /** Which area: drawn before the page for a header, after it for a footer. */ readonly area: RegionArea; /** The region's document: one instance of the component filling the area. */ readonly document: BlockDocument; /** The PUBLISHED definitions that document reaches, nested ones included. */ readonly definitions?: DefinitionsById; /** * What the region is and where it comes from, as it is announced: "Site * header, from the Main header & footer". */ readonly label: string; /** Its tag while the pointer or focus is on it: "Site header · Main". */ readonly badge: string; /** Its tag while it is selected: "Site header". */ readonly name: string; /** * The way to edit what it comes from, for someone who may: a link that * opens in a new tab, offered where a block of it is named off the canvas * (the page data panel). Absent for anyone else. */ readonly edit?: { readonly href: string; /** The visible text. */ readonly text: string; /** The accessible name, which says it opens in a new tab. */ readonly name: string; }; } /** The attribute naming a drawn region's area, for a host scrolling to it. */ export declare const REGION_ATTRIBUTE = "data-nx-region"; /** * One region on the canvas, selected as a whole. * * Its content is `inert`: the region's links and forms cannot be followed or * focused, and the pointer falls through to the region itself, which answers * a click by asking to be selected. The region is its own one Tab stop, named * for what it is and where it comes from; Enter or Space selects it. * * Marked as chrome, so the canvas's block selection, hit-testing and link * guard all leave it alone: it is not part of the document being edited. */ declare function CanvasRegionFrame({ region, rendered, sheet, selected, onSelect, onEdit, dimmed }: { region: CanvasRegion; /** The canvas's own renderer inputs, less what belongs to the page alone. */ rendered: Omit | undefined; /** How this part treats the site sheet, and the scope it compiles under. */ sheet: PartSheet; /** Whether this region is the canvas's selection. */ selected: boolean; /** Ask for this region to be selected; absent, the region selects nothing. */ onSelect: ((area: RegionArea) => void) | undefined; /** * Ask to edit this region in place: a double-click, or Enter while it is * selected. Absent, the region is only ever selected. */ onEdit: ((area: RegionArea) => void) | undefined; /** * Whether another region is edited in place: then this one is out of * reach, as the page is, and hidden from assistive technology. */ dimmed: boolean; }): JSX.Element; /** * The region being edited in place: drawn from the live document being * edited, its blocks addressed and within reach, so it is edited as a page * is. No longer chrome and no longer a button: a click lands on its blocks. * It keeps its area's attribute, so the dim over the rest of the canvas is * measured around it, and its edge where it meets the page. */ declare function EditedRegionFrame({ area, document, definitions, rendered, sheet }: { area: RegionArea; /** Its document as it stands, edit by edit. */ document: BlockDocument; definitions: DefinitionsById | undefined; rendered: Omit | undefined; sheet: PartSheet; }): JSX.Element; /** The attribute a region carries while it is edited in place. */ declare const REGION_EDITED_ATTRIBUTE = "data-nx-region-edited"; /** The attribute on a band drawn where an area has no region, naming the area. */ export declare const EMPTY_REGION_ATTRIBUTE = "data-nx-region-empty"; /** A rectangle in the editor's own coordinates, where a menu opens from. */ interface EmptyRegionAnchor { readonly x: number; readonly y: number; readonly width: number; readonly height: number; } /** * What the host has the band say and offer where an area has no region: why * the area is empty, and either the two ways to fill it or who to ask. * @experimental Settles with the site's empty header and footer. */ interface EmptyRegionBandProps { /** The area has nothing yet, and what that means for the site's pages. */ readonly sentence: string; readonly actions: { /** Fill it with a new one, as "Create a header" says. */ readonly create: string; readonly onCreate: () => void; /** Choose one already made, as "Use a component" says. */ readonly use: string; /** * Open the choice, from the button's place in the editor's own * coordinates: the menu is drawn there, over the canvas. */ readonly onUse: (anchor: EmptyRegionAnchor) => void; /** While a choice is being written: both wait. */ readonly busy?: boolean; } | { /** For someone who may not fill it: who can. */ readonly ask: string; }; } /** * The band drawn in an area's place on the canvas while the page's header & * footer set has nothing there: a dashed box saying so, with the host's ways * to fill it. Drawn in the editor's canvas alone, in the region's place and * never in the page: a visitor's page draws nothing there. * * Its buttons are the frame's own, styled by the frame's sheet with the * values the editor hands it, since the editor's stylesheet does not reach * into the frame. The choice it opens is the host's, drawn over the canvas * in the editor's document, from the button's place mapped there. */ declare function EmptyRegionBand({ area, band }: { readonly area: RegionArea; readonly band: EmptyRegionBandProps; }): JSX.Element; interface CanvasProps { /** The document being edited. */ document: BlockDocument; /** * Receives the canvas root element, for a caller that needs to measure * against it. * * A drag that begins OUTSIDE the canvas — from a palette row — has no event * whose `currentTarget` is this element, and it must resolve a drop position * against the same box every other reader uses. This canvas owns that * element, so handing it over is more honest than a caller finding it by * class name: a query would be a second place that decides which element the * canvas root is. * * READ IT IN A HANDLER, NOT AN EFFECT, and that is a property of the call * site rather than of this prop — so it travels with nothing and has to be * said here. A ref answers "where is the canvas now" at press time, long * after mount. An effect asking the same ref reads `null` on its first run * and is never told otherwise, because assigning `.current` changes no * dependency and this canvas mounts only once styles have loaded. Anything * that must REACT to the canvas arriving takes {@link CanvasProps.onRoot}. */ rootRef?: React.RefObject; /** * The interaction state the panel is editing, forced on the primary * selection so an author can SEE what they are editing. * * A page cannot force a pseudo-class on itself — there is no CSS or DOM way * to make an element match `:hover` without a pointer. So the sheet has to be * compiled with `previewStates`, which gives each state a class alternative * beside its pseudo-class, and this canvas puts that class on one element. * Passed a state without that compile, nothing happens and nothing breaks: * the class is simply in no selector. * * `base` forces nothing. It is what applies when no state does. */ forcedState?: StyleState; /** * The same element, published as a VALUE so a caller can react to it * appearing. * * A ref is not reactive. This canvas mounts only once styles have loaded * while the surfaces beside it stay mounted throughout, so a reader that * captured `rootRef` on its first render sees `null` and is never told * otherwise — assigning `.current` changes no dependency, so an effect * listing the ref never looks again. * * `rootRef` stays for the readers that only ever ask "where is it now" during * a gesture, where a ref is exactly right. */ onRoot?: (root: HTMLDivElement | null) => void; /** * The site sheet, the same value the published route passes. Required — see * the module docblock for why this one is not optional. */ siteStyles: NonNullable; /** * The PRIMARY selected node's id, or null when the selection is empty. * * The one the inspector edits. Marked `data-nx-selected="primary"` so a * multi-block selection can show which member the panels answer for — with * one block selected there is nothing to distinguish and the distinction * costs nothing. */ selectedId?: string | null; /** * Every selected id. Defaults to the primary alone. * * A separate prop rather than derived from `selectedId`, because the canvas * must not decide what a selection IS — `selection.ts` does, and a canvas * that reconstructed the set from one id would silently disagree with it the * moment there were two. */ selectedIds?: readonly string[]; /** * Raised with the clicked node's id and the gesture its modifiers meant, or * null when the click hit no node. * * The MODE travels with the id because only the event knows it, and a caller * reading modifiers off a later render's event would read a different click. */ onSelect?: (id: string | null, mode: SelectionMode) => void; /** * Raised with a collection list's id when its note's "Choose a field" is * pressed, for the host to select the list and take the author to its * sort. Absent, the press selects the list as any click inside it does. */ onListSortField?: (id: string) => void; /** * Everything else the renderer needs, passed through untouched. * * Spread rather than re-declared field by field: `PageRenderer` owns that * contract, and restating it here would be a second copy that silently stops * accepting whatever the renderer gains next. */ render?: Omit; className?: string; /** * Pointer handlers for dragging blocks, from `useCanvasDrag`. * * Taken as an object rather than as individual props so the set cannot be * partially wired: a canvas carrying `onPointerDown` without `onPointerUp` * starts gestures it never ends, and the failure is a canvas that behaves * normally until the first drag. */ dragHandlers?: CanvasDragHandlers; /** * What the pointer currently means, or absent when nothing is being dragged. * * ONE object rather than separate `draggingId`, `target` and `refusal` props, * for the reason {@link CanvasProps.dragHandlers} and * {@link CanvasProps.preview} are each one: a set spread across several * optional props can be PARTIALLY wired, and every partial wiring here fails * silently. A host passing the refusal without the moving id explains a * refusal while dimming nothing; one passing the id without the refusal is * precisely the state this prop exists to end. * * It is the shape `useCanvasDrag` already returns, so a host forwards what it * holds and restates none of it. Deriving a narrower view here would be a * second answer to a question the hook has already answered. * * Drawing only. Nothing here decides where a block may land — `resolveDrop` * does that, and this canvas draws whatever it was told. */ drag?: CanvasDragState; /** * Raised when a double-click lands on the page. * * Separate from `onSelect` because the two gestures mean different things and * one handler deciding between them by counting clicks would be a second * place the distinction lives. A double-click that hits no editable value * does nothing, which the handler decides — the canvas does not know what is * editable. */ onDoubleClick?: (event: React.MouseEvent) => void; /** * Editor chrome drawn ABOVE the page, for a canvas sharing the editor's * document. * * Inside the root rather than beside it, because the overlay is positioned in * the canvas's own content coordinates and the root is what establishes them. * Rendered after the page so it paints on top without needing a stacking * context of its own. * * A canvas in a `CanvasFrame` takes no overlay here: its chrome is the * frame's `overlay`, drawn in the editor's document over the frame, where * the site's CSS cannot reach it. */ overlay?: React.ReactNode; /** * The regions of the page's Layout, drawn locked around the page: a header * before it, a footer after it, as a visitor gets them. * * Drawn inside the canvas root, as part of what the canvas renders, so any * surface the canvas is mounted on carries them with the page. They share * the page's one site sheet and its previewed breakpoints, each compiled * under a scope of its own (`layoutPartSheets`), so the canvas shows the * cascade the published route serves. Absent or empty, the canvas draws the * page exactly as it always has. */ regions?: readonly CanvasRegion[]; /** * Which of `regions` is selected, or `null`: the canvas's second kind of * selection, which the host holds beside the block selection * (`useRegionSelection`). The selected region wears its outline and name. */ selectedRegion?: RegionArea | null; /** * Select a region, from a click or from Enter or Space on its Tab stop. * Absent, a region selects nothing. */ onSelectRegion?: (area: RegionArea) => void; /** * Ask to edit a region in place: a double-click on it, or Enter on its Tab * stop while it is already selected (Enter selects it first). The host * decides whether the author may, and enters it. Absent, a region is only * ever selected. * @experimental Settles with editing a header or footer in place. */ onEditRegion?: (area: RegionArea) => void; /** * The region being edited in place, while one is: drawn from this LIVE * document (the editor state the host edits it with) with its blocks * addressed, so hover, selection, inline editing and drag work in it as on * a page. Meanwhile `document`, the page, stays drawn as it was, but `inert`, * hidden from assistive technology and with no block addressed, as is the * other region; the host's dim over them is drawn in the chrome layer, so * nothing here changes the page's own colours. `selectedId`, `selectedIds` * and `onSelect` are the region's then. Absent, the page is edited. * @experimental Settles with editing a header or footer in place. */ editingRegion?: CanvasEditingRegion; /** * What is drawn where an area has no region, by area: a band saying the * site shows no header (or footer) yet, with the host's ways to fill it. * In the editor's canvas only, in the region's place; never in the page. * @experimental Settles with the site's empty header and footer. */ emptyRegions?: Partial>>; /** * The blocks whose visibility conditions the page can't check, which the * canvas marks in red: visitors never see them. Judged by the host, which * knows the collections' fields. Absent, every conditioned block is marked * only as conditional. */ conditionsUnchecked?: ReadonlySet; /** * The page with its visibility conditions applied for the entry it is * previewed with (`appliedConditionsOf`): a block hidden for that entry is * drawn as a one-line marker in its place, and one shown is badged so. * Absent, every conditioned block is drawn and marked as conditional. * * Applied to the page as drawn: a template's with the previewed entry's * own blocks already composed into its Entry content (`composed`), so the * entry's blocks are judged with the template's and the canvas draws this * document as it is, composing nothing of its own. */ conditionsApplied?: AppliedConditions; /** * `document` with the previewed entry's own blocks composed into its Entry * content block (`useComposedEntryContent`), where the host composed it * for the conditions it applies: the canvas draws it rather than composing * its own, so the page has one composition. Absent, the canvas composes * `document` with the entry the seam names. */ composed?: BlockDocument; /** * Words drawn in a grey box in the page's place, between `regions`, for a * document view with no page of its own (a header and footer shown around * where any page goes). `document` is still drawn, so the site's styles * reach the regions as on a page; a host passing this passes an empty one. * Absent, the page is drawn alone, as it always is. * @experimental Settles with the header & footer set view. */ placeholder?: string; } /** A region of the page's layout as the canvas draws it while it is edited. */ interface CanvasEditingRegion { /** Which region of `regions` is edited. */ readonly area: RegionArea; /** Its document as it stands, edit by edit. */ readonly document: BlockDocument; /** The definitions its component placements are drawn from. */ readonly definitions?: DefinitionsById; } /** * The marker for editor chrome drawn inside the canvas. * * @module canvas-chrome */ /** * Marks editor chrome drawn over the page, which is not part of the page. * * A click on the canvas background CLEARS the selection, and the overlay sits * inside the canvas root — so without this a press on any control drawn over * the page resolves to "no node" and deselects the very block that control * acts on. The floating toolbar would run its action and then watch itself * disappear. * * An attribute rather than each overlay calling `stopPropagation`: the rule * belongs to what chrome IS, and the version where every new overlay has to * remember it is the version where the next one does not. The drop indicator * needs no marker only because it takes no pointer events at all. */ declare const CHROME_ATTRIBUTE = "data-nx-chrome"; /** * The block toolbar's class, drawn by `BlockToolbar`: how the chrome around * it, and a test laying it out, find the bar. Here beside the chrome marker * rather than in the toolbar's module, which imports a great deal. */ declare const BLOCK_TOOLBAR_CLASS = "nx-block-toolbar"; /** * How a pointer event on the canvas resolves to a node id, or to nothing. * * `closest` rather than reading the target directly: a click lands on whatever * leaf is under the pointer — a `` inside a heading, an `` inside a * card — and the node that owns it is an ancestor. Reading the target alone * selects nothing for every block that renders more than one element, which is * most of them. * * The attribute name comes from `@nextlyhq/blocks-react` rather than being * spelled here. The renderer writes it and this reads it, so two spellings * would be two declarations of one name, and the day it moves the hit-testing * would resolve nothing while every test that hard-coded it still passed. * * **Bounded at the canvas root, which is not a detail.** The renderer applies * the attribute by cloning the block's root element and returns the output * untouched when it is not a single host element — so a block rendering a * fragment or a component carries none. An unbounded `closest` then walks past * it to the nearest ANCESTOR that has one, and returns that node's id: a * confidently WRONG selection rather than a missing one. * * The two failures are not equally bad. A miss is visible immediately — the * author clicks and nothing happens. A wrong hit selects a container while the * author believes they selected the child inside it, and every edit afterwards * lands on the wrong node with nothing to indicate it. */ export declare function nodeIdFromEvent(target: EventTarget | null): string | null; /** * Which node an element stands for, once components are inlined. * * EXPORTED because it is the one rule, and every reader of the element-to-node * mapping has to use it. Slice one of this work updated the click path and the * geometry lookup and left three other readers on the raw attribute — the * context menu, the selection markers and the drag rectangles — which is how a * right-click came to act on the previously selected block. * * A component is inlined at render: the instance node is replaced by the tree * its definition describes, and every element of that tree carries a RE-MINTED * id the page's document does not contain. Returning that id hands the editor * an address it cannot select, edit or delete — so a definition-owned element * answers with the INSTANCE the author actually placed, which is a real node in * the page. * * ## Asked of the ELEMENT, never of its ancestors * * `owner.closest(\`[${"$"}{INSTANCE_ATTRIBUTE}]\`)` is the obvious implementation and * it is wrong. An instance's SLOT CONTENT belongs to the page and is * deliberately unmarked, but it renders NESTED INSIDE the definition's marked * box — so a walk upwards finds that box and answers with the component for a * node the author can and should select directly. That content is exactly what * a marketer opened the editor to change. * * The marker is per-node rather than a wrapper element precisely so this * question can be asked without walking, and `hasAttribute` is what asks it: * marked means definition-owned, unmarked means the page's own whatever * encloses it. */ declare function nodeAddressOf(owner: Element): string | null; /** * Whether this element is the OUTERMOST one standing for its address. * * Two different things put one address on several elements, and they need * opposite answers: * * - A node rendered more than once — a block that draws its child twice — puts * the same node id on SIBLING elements. Every copy is a rendering of that * node, and marking only one outlines a single row of ten while previewing a * state on another. Neither copy encloses the other, so both are outermost. * - A component instance puts one address on every element its definition * contributed, NESTED. Those are renderings of different definition nodes * that share a host, so marking all of them outlines everything inside the * component and measuring all of them keys the drag geometry to whichever was * visited last. * * Enclosure is what separates them, so enclosure is what this asks. The host * marker is contiguous over a subtree, so the nearest enclosing one carrying * the same value is the whole test — no walk to the root is needed. */ declare function isOutermostForAddress(element: Element, address: string, container: HTMLElement): boolean; /** * Every element standing for each of `addresses` on this canvas: the * outermost per address, in document order. What a toolbar or a gap measures a * block by, so that a component placement whose definition draws several * top-level elements is measured as all of them rather than as its first. * Only this canvas's own: a canvas nested inside a block (component edit * mode) scopes ids to its own document, which may reuse an address from out * here. */ declare function outermostElementsOf(root: HTMLElement, addresses: ReadonlySet): Map; /** * The element a node id was rendered as, or `null` when it is not on screen. * * The inverse of {@link nodeIdFromEvent}, and beside it because the two are one * mapping read in two directions — separated, they become two answers to what a * node id means in the DOM. * * Ids are COMPARED rather than interpolated into a selector. A node id reaches * here from stored data, so any character CSS treats specially makes * `querySelector` either throw or match something else entirely. * * Deliberately not the {@link SELECTED_ATTRIBUTE} marker. That marker is applied * in a passive effect, so on the render where the selection changes it is still * on the previously selected element, and any chrome measuring in a layout * effect would spend a frame measuring the wrong block. */ declare function nodeElement(root: HTMLElement, id: string): Element | null; /** * Whether this element belongs to the canvas doing the marking. * * A node id is unique within a DOCUMENT and not across documents, so a block * that renders a second canvas puts another document's ids inside the outer * walk's reach. An inner node sharing the dragged id would then be dimmed by a * drag it has no part in, and the refusal could anchor to it. */ declare function ownedByCanvas(element: Element, container: HTMLElement): boolean; /** * The element drawing a node, restricted to the canvas that owns it. * * {@link nodeElement} answers with the first match anywhere beneath the root, * which is the wrong question once a block can render a canvas of its own: node * ids are unique within a DOCUMENT, so an inner document may legitimately carry * the same id and appear earlier in tree order. */ declare function ownedNodeElement(root: HTMLElement, id: string): Element | null; /** * The entry a template is previewed with, or why there is none. * * - `entry`: an entry of the template's collection. `editorValues` are what * the person editing reads, a waiting working draft included; * `publicValues` are the published entry as an anonymous visitor reads it, * or `null` where the visitor may not read it (a draft never published, * or a collection the public may not read); `fields` are the collection's * fields as a visitor may read them. * - `none`: no entry to preview. `reason` says why as far as the person may * know it: `empty` when there is no entry they may read, which reads the * same whether the collection holds none or holds only entries they may * not read; `loading` while the first answer is on its way; `unavailable` * when the entry could not be read. * * @experimental Settles when collection templates ship. */ type PreviewedEntry = { readonly kind: "entry"; /** The template's collection. */ readonly collection: string; readonly id: string; readonly title: string; readonly publicValues: Readonly> | null; readonly editorValues: Readonly>; readonly fields: readonly BindingFieldShape[]; } | { readonly kind: "none"; readonly reason: "empty" | "loading" | "unavailable"; }; /** * One top-level blocks field of a template's collection: what an Entry * content block may draw. * * @experimental Settles when collection templates ship. */ interface PreviewedBlocksField { /** The field's name, which the block stores. */ readonly name: string; /** What the admin calls it: "Body". */ readonly label: string; } /** * The collection a template draws, as its editor names it: its names, its * top-level blocks fields, and where one of its entries is edited. * * - `blocksFields` is `undefined` while they are not known (the first * answer is on its way, or the author may not read the collection), so a * choice is never called removed for want of an answer. * * @experimental Settles when collection templates ship. */ interface PreviewedCollection { /** The collection's slug. */ readonly slug: string; /** Its name for one entry, as a sentence reads it: "post". */ readonly singular: string; /** Its name, as a heading reads it: "Posts". */ readonly plural: string; /** Its top-level blocks fields, in the collection's order. */ readonly blocksFields: readonly PreviewedBlocksField[] | undefined; /** * What a field of the collection is called, by its name: its label where * it is one of {@link blocksFields}, else its name in words as the admin * words a key ("membersOnly" is "Members Only"), for a field the * collection no longer has. The one name a field is shown by, on the * canvas, in Layers and in the inspector alike. */ readonly fieldLabel: (name: string) => string; /** The admin address where entry `id` is edited. */ readonly entryHref: (id: string) => string; } /** * The keys that preview the next and the previous entry of a template's * collection: Shift with the block-move chord, so the two read as related * and never collide (a chord's modifiers are matched exactly). * * @experimental Settles when collection templates ship. */ export declare const PREVIEWED_ENTRY_KEYS: { readonly next: "shift+alt+ArrowDown"; readonly previous: "shift+alt+ArrowUp"; }; /** * Hands the editor the entry a template is previewed with. The host mounts * it only around a template's editor, so a page, a component or a Layout * reads `undefined`. * * @experimental Settles when collection templates ship. */ export declare function PreviewedEntryProvider({ value, collection, children }: { readonly value: PreviewedEntry; /** * The template's collection, for what reads its fields: an Entry content * block's mark, its inspector and its canvas notes. */ readonly collection?: PreviewedCollection | undefined; readonly children?: ReactNode; }): React.JSX.Element; /** * The entry the template being edited is previewed with, or `undefined` * where the document is not a template and nothing is previewed. * * @experimental Settles when collection templates ship. */ export declare function usePreviewedEntry(): PreviewedEntry | undefined; /** * The collection the template being edited draws, or `undefined` where the * document is not a template, or its editor names none. * * @experimental Settles when collection templates ship. */ export declare function usePreviewedCollection(): PreviewedCollection | undefined; /** * The words an Entry content block is named by on the canvas and in * Layers, with the field it draws: "Entry content · Body", or the field's * name where the collection's fields are not known. * * @experimental Settles when collection templates ship. */ declare function entryContentLabel(field: string | undefined, collection: PreviewedCollection | undefined): string; /** * The name a field an Entry content block draws is shown by: the * collection's (`PreviewedCollection.fieldLabel`), or the field's own name * where no template's collection is known. * * @experimental Settles when collection templates ship. */ declare function fieldName(field: string, collection: PreviewedCollection | undefined): string; /** * Whether the collection is known to have no top-level blocks field named * `field`. Never while its fields are not known, so a choice is not called * removed for want of an answer. */ declare function entryFieldRemoved(field: string | undefined, collection: PreviewedCollection | undefined): boolean; /** * Marks the selected block's own element. * * Boolean by presence rather than carrying the id: the element already states * its id through `NODE_ID_ATTRIBUTE`, and repeating it here would be a second * copy that a partial re-mark could leave disagreeing with the first. * * Exported because a host styling the canvas, and a test asserting what is * selected, both need to name it — and a string typed twice is a contract with * no compiler behind it. */ declare const SELECTED_ATTRIBUTE = "data-nx-selected"; /** * Marks a node the drag engine will refuse to pick up. * * Drawn so the grab cursor can be withheld from it. With no drag handle, that * cursor is the only thing advertising a block as movable, so offering it on a * node `useCanvasDrag` returns early for leaves an author pressing repeatedly * at something that will never move — an affordance promising what the engine * has already decided against. */ declare const LOCKED_ATTRIBUTE = "data-nx-locked"; /** How a block is locked in Layers: by its own lock, or by one around it. */ type LockMark = "own" | "inherited"; /** * Every locked block's mark, from one walk: a block's own lock, else the lock * of a block it sits inside, carried down rather than climbed per block. */ declare function lockMarksOf(document: BlockDocument): Map; /** * Marks a block whose visibility conditions decide who sees it. The canvas * draws it whoever the page would show it to, so the author can see and * select it, and this says it isn't shown to everyone: `conditional`, or * `unchecked` for one whose conditions the page can't check, which visitors * never see. */ declare const CONDITIONED_ATTRIBUTE = "data-nx-conditioned"; /** * Marks an element whose condition mark is its own block's, a block of a * placed component's definition, rather than its placement's: the marks * badge each such block apart, where a placement's roots share one badge. * Its value names the placement nested in a component whose gate the block * carries, when that gate is all it carries, so that placement's roots share * one badge too; empty for a block's own conditions. */ declare const CONDITIONED_OWN_ATTRIBUTE = "data-nx-conditioned-own"; /** * How a conditioned block is marked on the canvas: conditional, or conditions * the page can't check, or, while conditions are applied, shown for the * previewed entry. */ type ConditionMark = "conditional" | "unchecked" | "shown"; /** * Every conditioned block's mark, and for a composed block gated only by a * placement nested in a component, which placement: the badge its roots * share. */ interface ConditionMarks { readonly marks: ReadonlyMap; readonly nested: ReadonlyMap; } /** * Every conditioned block's mark, from one walk, asked of the engine's own * gate so the canvas marks exactly the blocks the page judges. `unchecked` * names the blocks whose conditions the page can't check, which only a host * knowing the collections' fields can say. */ declare function conditionMarksOf(document: BlockDocument, unchecked: ReadonlySet | undefined, composed: { definitions?: DefinitionsById; limits?: DocumentLimits; }, applied?: AppliedConditions): ConditionMarks; /** * Marks an Entry content block, with the words its at-rest mark's tab reads: * "Entry content · Body". The block draws the entry's own content rather * than the template's, which is edited on the entry, so the canvas says so * whether or not it is selected. */ declare const ENTRY_CONTENT_ATTRIBUTE = "data-nx-entry-content"; /** * Every Entry content block's words, by its id, from one walk: the field it * draws named as the template's collection names it. */ declare function entryContentMarksOf(document: BlockDocument, collection: PreviewedCollection | undefined, maxNodes: number | undefined): Map; /** * The words a block's outermost element carries, by its address, from * `marks`: an Entry content block's, or a hidden block's tag. Never inside a * Layout region, a document of its own whose ids may repeat the page's. */ declare function outermostMarkFor(element: Element, container: HTMLElement, marks: ReadonlyMap): string | undefined; /** * The mark a drawn element carries: a definition's own conditioned block by * its composed id, else the block or placement it is the outermost element * of, by its address. Never inside a Layout region, a document of its own * whose ids may repeat the page's. */ declare function conditionMarkFor(element: Element, container: HTMLElement, { marks, nested }: ConditionMarks): { mark: ConditionMark; own: boolean; nested?: string; } | undefined; /** * Marks every element drawing the block currently being dragged. * * EVERY element rather than one: a node id is unique in a document and not in * the tree drawn from it, so a repeating block is many elements for one id and * a mark that stopped at the first would dim one copy of a block that is * wholly in flight. * * Boolean by presence, for the reason {@link SELECTED_ATTRIBUTE} is: the * element already states its id. */ declare const DRAG_SOURCE_ATTRIBUTE = "data-nx-drag-source"; /** * Marks the container a drop would land in. * * The line says WHERE among siblings; this says WHICH container, and the two * are different questions. They come apart exactly where the line alone is * ambiguous — the coordinate at the bottom edge of one container is also the * top edge of the next, and only this mark separates them. */ declare const DROP_PARENT_ATTRIBUTE = "data-nx-drop-parent"; /** * Marks the container that will not take the block being dragged. * * Mutually exclusive with {@link DROP_PARENT_ATTRIBUTE} by construction: the * engine answers with a target or a refusal, never both, so an element carrying * the two at once is drawing a state that cannot exist. */ declare const DROP_REFUSED_ATTRIBUTE = "data-nx-drop-refused"; /** * Add or remove a boolean attribute, writing only when the answer changes. * * The comparison is the point rather than a saving. `setAttribute` queues a * mutation record even when the value it writes is the value already there, * the empty-container appender observes this subtree, and a drag re-marks on * every pointer move — so an unguarded write is a re-measure per frame rather * than one per drop. * * One function rather than the same three lines at each mark: they are one * rule, and four copies of it are four chances for the guard to be dropped * from whichever copy is edited next. */ declare function setFlag(element: Element, attribute: string, wanted: boolean): void; /** * Set an attribute to a value, or remove it for `undefined`, writing only when * it changes, for the reason {@link setFlag} gives. */ declare function setMark(element: Element, attribute: string, value: string | undefined): void; /** A region of the page's Layout, with how it treats the site sheet. */ interface DrawnRegion { region: CanvasRegion; sheet: PartSheet; } /** The page and the regions drawn around it, each with its sheet inputs. */ interface LayoutParts { page: PartSheet; header: DrawnRegion | undefined; footer: DrawnRegion | undefined; } /** * The page and the regions around it, each with its site-sheet inputs. * * Asked of `layoutPartSheets`, the answer the published route uses, so the * first part drawn emits the site sheet and each part compiles under its own * scope. `undefined` when there is no region to draw. */ declare function useLayoutParts(regions: readonly CanvasRegion[] | undefined, rendered: Omit | undefined, sheet: NonNullable): LayoutParts | undefined; /** * The page between its Layout's header and footer, as the canvas draws them. * * Each region is drawn in the page's environment, so a header block that * measures itself or listens is told the frame the canvas draws in, as the * page is. Without regions it is the page alone, exactly as before. * * With regions, the page sits in a part of its own that lays out as if it * were not there (`display: contents`), always, so editing a region in place * and leaving it never draws the page again from scratch: the part only * turns `inert` and hidden from assistive technology while a region is * edited, with the other region likewise, and the edited one is drawn from * its live document. Leaving gives that region back its focus, where the * author went in. */ declare function RegionsAround({ drawn, rendered, environment, selection, editing, bands, children }: { drawn: LayoutParts | undefined; rendered: Omit | undefined; environment: BlockEnvironment | undefined; /** The region selected, and the ways to select and edit one. */ selection: { readonly selectedRegion?: RegionArea | null; readonly onSelectRegion?: (area: RegionArea) => void; readonly onEditRegion?: (area: RegionArea) => void; }; /** The region edited in place, while one is. */ editing: CanvasEditingRegion | undefined; /** * What is drawn where an area has no region, by area: the host's band * saying so, with its ways to fill it. None while a region is edited. */ bands?: Partial>>; children: React.ReactNode; }): React.JSX.Element; /** * The document and window the blocks are drawn in, for block code that * measures itself or listens (`useBlockEnvironment`). Read from the canvas * root's OWN document rather than the globals, so the answer is the frame's * once the canvas renders inside one, with nothing here to change. * `undefined` until the root has mounted, which the hook passes on rather * than falling back to the admin page. Built as a `CanvasEnvironment` rather * than an object literal; see there for why. */ declare function useCanvasEnvironment(root: React.RefObject): BlockEnvironment | undefined; /** * The page, drawn, and the regions of its Layout around it. * * The parts in drawing order, each with how it treats the site sheet: * `undefined` when there are no regions, so a canvas without a Layout renders * exactly as it did. */ declare function useDrawnPage({ regions, rendered, sheet, document, environment, applied, addressed, placeholder }: { regions: readonly CanvasRegion[] | undefined; rendered: Omit | undefined; sheet: NonNullable; document: BlockDocument; environment: BlockEnvironment | undefined; applied: AppliedConditions | undefined; /** * Whether the page's blocks carry their addresses: false while a region of * its layout is edited in place, so no surface can find, mark or select a * block of the page then, nor take one for the region's block of the same * id. */ addressed: boolean; /** * Words for a grey box drawn after the page, where any page goes, for a * document view with no page of its own; absent, none is drawn. */ placeholder?: string | undefined; }): { drawn: LayoutParts | undefined; page: React.JSX.Element; }; /** * The refusal a canvas should DRAW, which is not every refusal it is given. * * `useCanvasDrag` holds the committed target across a short crossing so the * indicator does not flicker, while setting the refusal from the region under * the pointer immediately — so both are non-null for the width of the switch * threshold. Drawing the refusal there contradicts two things at once: the * line still points at the held target, and releasing commits it. The chrome * would say the block cannot land while letting go moves it. * * So a refusal is the honest answer only once there is no target to disagree * with. One function rather than the same condition written at the mark and * again at the message, because two spellings of one rule drift and the drift * shows up as chrome that half-agrees with itself. */ declare function drawnRefusal(drag: CanvasDragState | undefined): CanvasDragState["refusal"]; /** * Why the block being dragged cannot land where it is, drawn over the * container that refused it, or nothing while there is no refusal to draw. * * Chrome like the drop line, so it goes where the chrome goes: the overlay of * the `CanvasFrame` the canvas is drawn in, in the editor's document, or the * canvas's own `overlay` over a canvas sharing that document. * * @experimental */ export declare function DropRefusal({ drag, document }: { /** What the pointer means, from `useCanvasDrag`, as the canvas is given it. */ drag: CanvasDragState | undefined; /** The document the canvas is drawing, which names the refusing block. */ document: BlockDocument; }): JSX.Element | null; /** * Marks the drawn element of each of the entry's own blocks this canvas draws * in Entry content as ours to make `inert`. Its value says whether the `inert` * is ours to give back ({@link INERT_ADDED}) or was the block's own before the * canvas marked it ({@link INERT_KEPT}). */ declare const ENTRY_CONTENT_INERT_ATTRIBUTE = "data-nx-entry-content-inert"; /** * Watch whose `inert` each element marked in Entry content holds, as its block * changes its own after the canvas marked it. Returns the unsubscribe. * * A block that starts rendering inert on an element the canvas already made * inert changes nothing the tree shows, so only the mutation tells: React's * `setAttribute` on a present attribute still queues a record, with the old * value. The canvas writes `inert` only where it is absent, so a record with an * old value that leaves the attribute present is the block's write, and the * element's inert is now its own. One that leaves it absent is the block * dropping its inert, and the canvas holds the element inert in its place. */ declare function observeEntryContentInertOwnership(container: HTMLElement): () => void; /** * Make the entry's blocks an Entry content block draws on this canvas inert, * and nothing else: each child of a drawn wrapper, so no link, field or button * inside takes focus, a caret or a press, while the wrapper, the block's own * element, stays the one a click lands on and selects. The page's markup is * not changed, so the canvas lays the blocks out as the published page does. * An element no longer drawn there gives back the inert this set, and only * that: one a block rendered inert itself (a custom block whose root is inert) * keeps its `inert` when it leaves, as the canvas frame keeps a site's own. * Written only where it changes, as every mark here is. */ declare function markEntryContentInert(container: HTMLElement): void; /** * The block a context gesture is aimed at, or `null` when it is aimed at * nothing a block menu could act on. * * Published because a context menu can be opened TWO ways and they arrive by * different events. A secondary click arrives as `contextmenu`, which the * canvas sees; a touch or pen long-press is opened by Radix from its own timer * on `pointerdown`, and never produces a `contextmenu` event at all. A menu * that filtered one path and not the other would offer a block's verbs for a * press aimed at chrome, or — worse — offer the PREVIOUS selection's verbs, * with Delete among them, for a press on a block that was never selected. * * So the decision lives here once and both callers ask it, rather than each * spelling out three rejections and drifting. */ declare function contextMenuTargetOf(target: EventTarget | null, root: Element): string | null; /** * Which ids to mark, given what the host supplied. * * The primary alone when a host has not adopted the set yet, which keeps every * existing caller correct without a change. `[]` rather than `[null]` for an * empty selection: the marker is applied by id, and a null in the set would * match the elements carrying no id at all. */ declare function markedIds(selectedIds: readonly string[] | undefined, selectedId: string | null): readonly string[]; /** * The canvas's pointer handlers, which share one rule: chrome is not the page. * * Together rather than separately, because that rule is the whole of what they * have in common and a version where each handler remembers it for itself is * the version where the next one does not. Pressing a control drawn over the * canvas would otherwise resolve to "no node" and deselect the very block that * control acts on. */ declare function useCanvasPointer(onSelect: ((id: string | null, mode: SelectionMode) => void) | undefined, onDoubleClick: ((event: React.MouseEvent) => void) | undefined, marked: readonly string[], onListSortField?: (id: string) => void): { onClick: (event: React.MouseEvent) => void; onDoubleClick: (event: React.MouseEvent) => void; onContextMenu: (event: React.MouseEvent) => void; onPointerDown: (event: React.PointerEvent) => void; }; /** * Point the editor's hovered block at the deepest block under the pointer, so * the canvas outlines it as a Layers row does, and at nothing when the * pointer leaves the canvas or is over its background. * * Nothing while a block is dragged: the drag's own marks say where it will * land, and an outline under the moving pointer would compete with them. The * drag's own move handler runs first, so the gesture behaves exactly as it * did; a move over the editor's chrome points at nothing new. */ declare function useCanvasHover(dragMove: React.PointerEventHandler | undefined, dragging: boolean): { onPointerMove: (event: React.PointerEvent) => void; onPointerLeave: () => void; }; /** * A click on the page around the canvas, inside its frame, answered as a * click on the canvas's own ground: the selection is cleared. * * On a page the site serves, the site's layout decides how tall the canvas * is, so below a short page the frame shows the site's own page rather than * the canvas, and the click an author makes there to let go of a block lands * outside the canvas root. Only inside a frame: where the canvas shares the * editor's document, everything outside it is the editor's own panels. */ declare function useFrameGroundClick(root: React.RefObject, onSelect: CanvasProps["onSelect"]): void; /** * The canvas. * * Selection is addressed by node ID and never by position. The engine's document * makes ids the only addressing anything stores, and a positional selection * breaks the moment a sibling is inserted above it — silently, by pointing at a * different block rather than at nothing. */ export declare function Canvas({ document, rootRef, onRoot, forcedState, siteStyles, selectedId, selectedIds, onSelect, render, className, dragHandlers, drag, onDoubleClick, onListSortField, overlay, regions, conditionsUnchecked, conditionsApplied, composed, ...regionUse }: CanvasProps): JSX.Element; /** * The stored groups, an OR of AND groups of conditions; none when nothing is * stored, and `undefined` for a shape no row can show, such as a flat list of * conditions or a group holding something else. The engine hides a block * whose conditions it can't read, and says why. */ declare function storedGroups(node: BlockNode): readonly (readonly Condition[])[] | undefined; /** * The blocks in a forest whose conditions the page can't check. A problem * that needs the collections' fields is judged once they are listed, so a * block isn't marked while they load. If they can't be listed, what needs no * fields is still judged (an operator conditions don't have, an entry a * Single's page doesn't have). One stored in a shape no row can show needs no * fields and is always marked. Read as far as `maxNodes`, the limit a save * surveys a document to. */ declare function uncheckedConditionIds(nodes: readonly BlockNode[], collections: readonly LoopCollection[] | "loading" | "unavailable", entryCollection: string | null | undefined, maxNodes?: number): ReadonlySet; /** * {@link uncheckedConditionIds} for a document, as an editor's services list * the collections: its own blocks, and with `definitions` the blocks its * placed components hold too, judged in the tree composed as the canvas * draws it, by the ids the canvas draws them with. */ export declare function useConditionsUnchecked(document: BlockDocument, services: Pick | undefined, limits?: DocumentLimits, definitions?: DefinitionsById): ReadonlySet; /** * The viewport tiers a canvas of this width is applying, widest first. * * The same question {@link matchedBreakpoints} answers for the browser window, * asked of a box whose width the editor owns instead. Under a preview compile * the window cannot answer at all — the tiers are container queries and * `matchMedia` has nothing to say about an element — which is why the canvas * has to answer for itself, and why the panel withholds its provenance * indicator until something does. * * Note the set is read WITHOUT the preview option. That is deliberate and it is * the whole point: the preview option decides how the sheet is EMITTED, and * this decides what a box of a given width shows. A canvas at 800px shows what * a real viewport at 800px would show, and the preview compile exists so that * remains true inside a box. * * @experimental */ export declare function breakpointsAtWidth(set: BreakpointSet | undefined, width: number | undefined): BreakpointId[]; /** * The tier an edit lands in at this width: the NARROWEST one applying. * * Narrowest rather than widest, because that is the one whose declaration wins. * At 800px on a site defining tablet (991) and mobile (575), both the base and * tablet contexts apply and tablet is what the browser paints — so an edit made * while looking at 800px must land in tablet, or the author changes a value they * cannot see change. * * Falls back to {@link BASE_BREAKPOINT} rather than to whatever came first: a * site that has defined no breakpoints, or a width above every bound, is * editing the unconditional tier, and that is a real answer rather than a * default standing in for a missing one. * * @experimental */ export declare function editedBreakpointAtWidth(set: BreakpointSet | undefined, width: number | undefined): BreakpointId; /** * The tiers a canvas width can actually select, widest first. * * ONE per distinct bound. Selecting a tier sets a WIDTH and everything else is * derived from it, so two tiers sharing a bound are not two choices: both * radios would emit the same number, the match would resolve to one of them, * and clicking the other would silently select the first. * * Among tiers sharing a bound the LAST is kept, because that is the one the * browser paints — the compiler emits both into a single at-rule in order, so * the later declaration wins. Keeping the first would name a tier whose value * is overridden by the one below it, and {@link editedBreakpointAtWidth} would * disagree with this list about which tier an edit lands in. * * Taken from the compiler's contexts rather than the stored definitions, so a * definition it declines to emit a bounded context for is not offered: sizing * the canvas to a number nothing responds to reads as the feature being broken * rather than as the definition being unusable. * * @experimental */ export declare function offeredTiers(set: BreakpointSet | undefined): Array<{ id: BreakpointId; maxWidth: number; }>; /** * The canvas width that puts a tier on screen, or `undefined` for the widest. * * The switcher's whole job in one function: choosing a tier SETS a width, and * everything else follows from the width. `undefined` means "as wide as the * region allows" — the unconditional tier has no upper bound, so pinning it to * a number would invent one and make the widest preset narrower than the space * available. * * The tier's own `maxWidth` rather than one pixel below it. The query is * `(max-width: Npx)` and therefore inclusive, so N is inside the tier — and it * is the width at which the author sees the tier at its roomiest, which is * where a layout decision is actually made. * * @experimental */ /** * The narrowest canvas width at which the UNCONDITIONAL tier applies. * * One past the widest bound, because a bounded tier applies at `width <= bound` * — so the first width no bounded tier claims is `bound + 1`, and that is where * the base rules are what an author is editing. * * Derived rather than chosen. A conventional desktop number would be a width * the site never declared, and the canvas would then simulate a viewport * nothing in the document mentions; one past the widest bound is the only width * the site's own tiers imply. It is also the SMALLEST such width, which matters * because the canvas is scaled to fit: every pixel past it costs the author * legibility for nothing. * * `undefined` when the site bounds no viewport tier at all. Base already * applies at every width there, so there is no width to go to — and offering * one would size the canvas to a bound the site never declared, which is what * the switcher's own tier list refuses to do. */ declare function baseWidth(set: BreakpointSet | undefined): number | undefined; /** * Every tier the breakpoint control can put the canvas at, widest first. * * The bounded tiers AND the unconditional one, which is offered at the width it * applies from. Published as one list because two places need the same answer * and they are not the same code: the control builds its options from it, and * the host clears a requested width that is not on it — a canvas pinned to a * bound the stylesheet no longer has, after an author deletes the tier they * selected, has no control on screen to release it. * * Measured: those two DID disagree. The host compared against the bounded tiers * alone while the control had begun offering the unconditional one, so choosing * base set a width the host cleared on the very next render — the canvas * returned to filling the region, and base stayed uneditable exactly where it * had been. Nothing failed; the option simply did nothing. */ export declare function selectableTiers(set: BreakpointSet | undefined): Array<{ id: BreakpointId; maxWidth: number; unconditional?: boolean; }>; export declare function widthForBreakpoint(set: BreakpointSet | undefined, id: BreakpointId): number | undefined; /** * The narrowest the base breakpoint, Desktop, is previewed at. * * A fixed width rather than the region's: the region changes as panels open * and close, and a preview that followed it would show a different layout for * the same device. 1280 is the narrowest window the editor supports. */ export declare const DESKTOP_PREVIEW_WIDTH = 1280; /** * The width the canvas lays a device out at, which the zoom then fits into * the room the panels leave. * * A bounded breakpoint is shown at its own bound, the widest width at which * it applies, rather than at some device's width: that is the width whose * layout the author is styling. The base is shown at 1280, or one pixel past * the widest bound on a site whose widest bound reaches 1280, so the base * preview never sits inside a narrower breakpoint. * * `undefined` for an id the site does not define as a viewport breakpoint, * and on a site with no viewport breakpoints at all, where there is nothing * to simulate and the canvas fills its region. */ export declare function previewWidth(set: BreakpointSet | undefined, id: BreakpointId): number | undefined; /** The narrowest width the canvas previews a page at: a small phone. */ declare const NARROWEST_PREVIEW_WIDTH = 320; /** The widths a preview width can take, both ends included. */ interface PreviewWidthRange { readonly min: number; readonly max: number; } /** * The widths the author can preview the page at by dragging the frame's * edges: from a small phone to the Desktop preview width, which is 1280 or * one pixel past the widest bound where a site's widest breakpoint reaches * 1280. A site with no viewport breakpoints previews up to 1280 too, the * width its canvas is drawn at. * * @experimental */ declare function previewWidthRange(set: BreakpointSet | undefined): PreviewWidthRange; /** A width brought into the range, in whole pixels. @experimental */ declare function clampPreviewWidth(width: number, range: PreviewWidthRange): number; /** * The breakpoint an edit goes to, from the device the author chose. * * The choice is stored as the author left it, so it can name a breakpoint the * site has since removed, or a container breakpoint, which is not a device. * Either way the edit goes to the base breakpoint: a value written under an * id the site does not define as a device would never be drawn. */ export declare function editingBreakpointOf(set: BreakpointSet | undefined, chosen: string | null): BreakpointId; /** * 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 */ declare function fallbackBreakpoint(before: BreakpointSet | undefined, after: BreakpointSet | undefined, chosen: string | null): BreakpointId; /** * The height of the device a width previews, in three bands: a phone, a * tablet, a laptop. * * The canvas's frame fills its region instead (see {@link frameFillingRegion}) * and takes this only until the region is measured; a host that wants a * frame laid out at the device's own height states this as the frame's. * * Bands rather than one height per breakpoint, because a site can add its own * breakpoints at any width and each still needs a height. The same three * bands answer for those: a site-added 700px breakpoint is previewed at a * tablet's height, like any other width in that band. * * @experimental */ export declare function previewHeight(width: number): number; /** A width and a height, in CSS pixels. */ interface FrameSize { readonly width: number; readonly height: number; } /** * The scale that fits a whole frame into the region around it. * * BOTH dimensions, because the frame has a height of its own: fitting only the * width leaves a desktop frame taller than a short region, and the bottom of * the previewed viewport is then off screen with nothing to say so. The * smaller of the two ratios is the one at which the frame fits both ways. * * Never above 1, for the reason the width-only fit gives: a frame shown larger * than life makes every measurement an author takes from the screen wrong in * the flattering direction. `1` for a region not yet measured, or one of zero, * because a ratio taken from either is infinite or `NaN` and would paint the * frame nowhere. * * @experimental */ declare function frameFitScale(frame: FrameSize, region: { readonly width?: number; readonly height?: number; }): number; /** * The frame that fills its region: the scale it is painted at, and the height * the page is laid out at so that, painted, the frame is exactly as tall as * the region. * * The canvas is the author's window onto the page, as a browser window is a * visitor's: it fills the room the editor gives it at any zoom, and a page * taller than that scrolls inside it. So only the WIDTH is fitted, the * device's; the height follows the room. `vh` on the page then answers for * the window the author is looking through, as it does for a visitor. * * Never above 1 to fit, for the reason {@link frameFitScale} gives. Until the * region is measured, the device's own height at actual size: a frame sized * from nothing would be drawn nowhere. * * @experimental */ declare function frameFillingRegion(width: number, region: { readonly width?: number; readonly height?: number; } | undefined, zoom: CanvasZoom): { readonly scale: number; readonly height: number; }; /** * Where the canvas is rendered, as the code around it needs to know. * * `document` and `window` are `null` only where there is no DOM at all, a * server render, and in a frame whose document is not readable. Every reader * here runs in an effect or an event, so a `null` there means there is nothing * to listen on rather than something to work around. * * @experimental */ interface CanvasFrame$1 { /** The iframe the canvas renders in, or `null` while it shares the editor's document. */ readonly frame: HTMLIFrameElement | null; /** The document the canvas's nodes belong to. */ readonly document: Document | null; /** That document's window: the one whose media queries describe the canvas. */ readonly window: (Window & typeof globalThis) | null; /** * How much larger the editor paints the frame than it lays it out: `0.5` at * 50%. `1` with no frame, where nothing is scaled. * * A value that changes whenever the zoom or the fit does, so chrome drawn * over the frame can depend on it to be placed again: nothing inside the * frame resizes when only its painted scale moves, so no observer there * reports it. */ readonly scale: number; /** * The part of the frame's page on screen, in the frame's own CSS pixels and * without its scrollbars, or `null` with no frame. What chrome that has to * stay visible, such as a toolbar flipping at the top edge, is kept inside. */ readonly viewport: FrameSize | null; /** A point in the canvas document's client coordinates, in the editor's. */ readonly toHost: (point: Point) => Point; /** A point in the editor's client coordinates, in the canvas document's. */ readonly toCanvas: (point: Point) => Point; } /** What a mounted frame reports about how it is drawn. */ interface CanvasFrameLayout { readonly scale: number; readonly viewport: FrameSize | null; } /** * How a frame rendered beneath an uncontrolled provider hands its iframe and * its layout up to it. * * `null` under a provider told its frame directly, and with no provider at * all: the frame then provides for itself. */ interface FrameRegistration { readonly register: (frame: HTMLIFrameElement | null) => void; readonly report: (layout: CanvasFrameLayout) => void; } /** * Where a frame registers itself, or `null` when nothing above will hear it. * * @internal */ declare function useFrameRegistration(): FrameRegistration | null; /** * Names the iframe the canvas renders in, for everything beneath it. * * `null`, like no provider at all, means the canvas is in the editor's own * document. * * The frame's document is HELD in state and re-read on the frame's `load`, * rather than read off `contentDocument` while rendering. A frame replaces its * document when it loads — its first `about:blank` gives way to its content, * and a reload builds another — and nothing in that renders. Read during * render, every listener and media query beneath would stay on the document * that was thrown away until some unrelated render happened to read again. * Held here, the replacement is itself the update: consumers depending on the * document or window re-run, detaching from the old one and attaching to the * new. * * @experimental */ export declare function CanvasFrameProvider({ frame: given, children }: { /** * The frame, when the caller holds it. Left out, the provider waits for a * `CanvasFrame` beneath it to register its own, which is how an editor * provides the frame to the panels and keys around the canvas as well as to * the canvas itself. */ frame?: HTMLIFrameElement | null; children?: React$1.ReactNode; }): React$1.JSX.Element; /** * The document and window the canvas is rendered in. * * In a frame, the document its provider last saw it load, which changes when * the frame loads another: a dependency on `.document` or `.window` then * re-runs the effect that listened on the old one. With no frame, the * editor's own document and window, which do not change. * * @experimental */ export declare function useCanvasFrame(): CanvasFrame$1; /** * Every document an input gesture on the canvas can be delivered to. * * Two while the canvas is in a frame: the editor's own, where the palette, * the panels and their search fields are, and the frame's, where the page is. * A pointer moving over the frame is delivered to the frame's document alone * and one moving over the panels to the editor's alone, so a gesture that * crosses between them is only heard whole by listening on both. A key goes to * whichever document holds focus, which is either. * * One while the canvas shares the editor's document, because the two are the * same document and listening on it twice would run every listener twice. * * The editor's document is the frame's OWNER document: the iframe element is * part of the editor's page, whichever window is asking. */ declare function inputDocuments(canvas: CanvasFrame$1): readonly Document[]; /** * Hears the editor's shortcuts in the canvas's document too. * * A key pressed with focus inside the frame is dispatched in the FRAME's * document, and the shell's shortcut manager listens on the editor's. Without * this, Mod+S, undo, Escape and every other binding would go dead the moment * the author clicked into the page. * * The SAME manager, attached to a second document, never a second manager. A * `ShortcutProvider` nested with the frame as its target would build one of its * own, and the bindings registered on the shell's — the admin's save among * them — would not be in it, so they would not fire inside the frame at all. * * Nothing while the canvas shares the editor's document: the manager already * listens there, and a second listener would run every binding twice. * Released when the frame's document goes, so a reloaded frame is listened on * once, in its new document. Counted per document by {@link attachOnce}, so a * Strict Mode replay or a second caller does not install a second listener. * * Rendered inside the shell's `ShortcutProvider`. * * @experimental */ declare function CanvasFrameShortcuts(): null; /** * What the host gives the frame to preview widths with: the site's * breakpoints, the device being edited and its own width, the width the * author previews at (`null` for the device's own), and where a new one goes. * * @experimental */ interface PreviewWidthControl { readonly breakpoints: BreakpointSet | undefined; /** The breakpoint every edit goes to, whatever the width shown. */ readonly edited: BreakpointId; /** The width the device being edited is laid out at. */ readonly deviceWidth: number; /** The width previewed instead, or `null` for the device's own. */ readonly override: number | null; /** Told a settled width, `null` once it is the device's own again. */ readonly onChange: (width: number | null) => void; } /** How long after the last key the settled width is announced. */ declare const ANNOUNCE_AFTER_KEYS_MS = 500; /** * The handles, the ruler, the line under the frame and the live region, for * a frame laid out at `width` and painted at `scale`; nothing where the host * previews no other width. * * @experimental */ declare function PreviewWidthEdges({ control, width, scale, onDragging }: { control: PreviewWidthControl | undefined; width: number; scale: number; /** * Told when a drag starts and ends, so the frame holds back what it reads * off the page's resizing until the width settles. */ onDragging?: (active: boolean) => void; }): React$1.JSX.Element | null; /** * Where the site's own layout draws around the page on a page the site * serves: something with a box before the page, as a header is, and after it, * as a footer is. Read from where each part sits in the site's page against * the canvas's mount point, so it holds whatever the site's markup calls it. * * @experimental Settles with the editor's notices about the site's layout. */ interface SiteChromeDrawn { /** The layout draws something before the page. */ readonly before: boolean; /** The layout draws something after the page. */ readonly after: boolean; } /** * Make the site's own layout around the mount point inert and quiet, on a * page the site serves: every element beside the mount point and beside each * of its ancestors up to the body. The ancestors themselves cannot be inert, * since the canvas is inside them. * * Marked again when an ancestor gains a child, for a site whose layout draws * part of itself once its own scripts have run. Answers with the elements it * marked, for the cues drawn over them, and tells `onSiteChrome` where they * draw around the page. */ declare function useSiteChrome(page: Document | null, mountPoint: HTMLElement | null, onSiteChrome: ((drawn: SiteChromeDrawn) => void) | undefined): readonly Element[]; /** * Where the frame's page comes from, and where in it the canvas is mounted. * * Either the editor's own blank document, or a page the SITE serves: a route * rendering an empty mount point inside the site's own layouts, so the site's * global stylesheets, fonts, header and footer are around the canvas exactly * as they are around the published page. * * @experimental */ type CanvasFrameSource = BlankFrameSource | SiteFrameSource; /** @experimental */ interface FrameSourceReading { /** * Whether a document the frame holds is this source's page, ready for the * canvas, rather than the blank page a frame shows before its content loads * or a site page still starting up. */ readonly ready: (doc: Document) => boolean; /** Where in that page the canvas is mounted. */ readonly mountPoint: (doc: Document) => HTMLElement | null; } /** * The editor's own document, as `srcdoc`. * * @experimental */ interface BlankFrameSource extends FrameSourceReading { readonly srcDoc: string; } /** * A page the site serves for the canvas, loaded by URL. * * The site's own React root runs in that page, so the canvas is portalled in * only once the page says it is ready: before the site's root has hydrated, an * element the editor added inside it would not match what the server sent. * * @experimental */ interface SiteFrameSource extends FrameSourceReading { /** The page's URL. Only one on the editor's own origin is loaded. */ readonly src: string; /** * Whether a loaded document is this route's page at all, ready or not. A * page that is not — a "not found" page, a redirect elsewhere — is never * going to be, and the frame falls back to the blank page. */ readonly served: (doc: Document) => boolean; /** * Call `changed` whenever the page's readiness may have changed, until the * returned function is called. */ readonly watch: (doc: Document, changed: () => void) => () => void; } /** * Why the frame shows the blank page rather than the site's: * - `other-origin`: the page is on another origin, whose document the editor * can neither reach nor draw into; * - `not-served`: the page loaded but is not the canvas route, so the site * has not mounted it; * - `not-ready`: the page is the route, but never said it was ready. * * @experimental */ type CanvasFrameFallback = "other-origin" | "not-served" | "not-ready"; /** * A blank, standards-mode page of the editor's own. * * The doctype is what keeps the page out of quirks mode, where several layout * rules differ from the published page's. The page inherits the admin's base * URL, as every `srcdoc` document does, so a relative URL in the site's sheet * or a block resolves as it does on the admin's origin. Its head opens with * the frame's defaults, so their layer is the first the page declares and the * lowest, beneath anything loaded into the frame after it. * * @experimental */ declare const SRCDOC_FRAME_SOURCE: BlankFrameSource; /** What the frame's accessible name begins with. */ export declare const CANVAS_FRAME_TITLE_PREFIX = "Page canvas"; /** * The frame's accessible name, for the page it shows. * * A screen reader moving into the frame announces this, so it names the page * being edited rather than the editor. */ export declare function canvasFrameTitle(pageTitle: string | undefined): string; /** @experimental */ interface CanvasFrameProps { /** The width the page is laid out at: the device being previewed. */ width: number; /** * The height the page is laid out at, fitted into the region with the width. * Left out, the frame fills the region's height at any zoom and a taller * page scrolls inside it, as in a visitor's browser window; `vh` then * answers for that window. See {@link frameFillingRegion}. */ height?: number; /** * The zoom: fitting the device's width into the region (both dimensions, * where the host states a height), or a chosen scale. */ zoom?: CanvasZoom; /** The scale the frame is painted at, reported as it changes. */ onScale?: (scale: number) => void; /** The page's title, for the frame's accessible name. */ title: string | undefined; /** * The site's theme the page is shown in, stated as `data-nx-theme` on the * frame's root element where a site's dark tokens are switched by it, and * again on the element the canvas is mounted into, so a marker the site's * own layout puts on `` or a wrapper, nearer the canvas than the root, * cannot keep the canvas in its own mode: the nearest marker is the one a * site's tokens follow. When it is `light` or `dark`, it is also the iframe * element's `color-scheme`, which the frame's `prefers-color-scheme` * follows. Left out, the page shows whatever the site applies by default, * and both markers are given back as the page stated them. */ theme?: string; /** * The language the page's content is written in, as `lang` on the frame's * root element: a frame's document does not inherit the language of the * document embedding it, so a screen reader would otherwise have none. * Left out, the editor document's own language is the nearest statement * there is, and the frame takes that. */ lang?: string | undefined; /** * The direction the page's content is written in, as `dir` on the frame's * root element, for the same reason as `lang`. Left out, the editor * document's own direction, where it states one. */ dir?: "ltr" | "rtl" | undefined; /** The editor's chrome, drawn over the frame in the editor's document. */ overlay?: React$1.ReactNode; /** * Chrome held at the frame's viewport rather than on the page: drawn in * the same layer as `overlay` but outside the box the page's scroll moves, * so it stays at the viewport's edges while a long page scrolls under it. * For what says how the whole canvas is drawn, such as its preview tags. * * @experimental Settles with the canvas's preview tags. */ pinned?: React$1.ReactNode; /** * Previewing the page at a width other than the device's own: the frame * draws a handle at each edge, the ruler and the line saying which device * is still edited, and tells the host the width settled on. The host lays * the frame out at that width through `width`. Left out, no handles. * * @experimental Settles with the canvas's preview width. */ previewWidth?: PreviewWidthControl; /** The canvas, rendered inside the frame. */ children?: React$1.ReactNode; /** Where the frame's page comes from. The editor's blank page by default. */ source?: CanvasFrameSource; /** * Told why the frame shows the blank page in place of the site's page it * was given, and `null` again when it shows that page, so the host can say * which the author is looking at. */ onSourceFallback?: (reason: CanvasFrameFallback | null) => void; /** * Told where the site's own layout draws around the page whenever that * changes: as the site's page arrives, as its layout draws a part later or * takes one away, and with nothing drawn once the frame is gone. Never told * on the editor's blank page, which has no layout of its own. * * @experimental Settles with the editor's notices about the site's layout. */ onSiteChrome?: (drawn: SiteChromeDrawn) => void; className?: string; } /** * What `useCanvasFrame` answers with, under the component's name, so a host * importing one `CanvasFrame` has both the component and what it provides. * * @experimental */ export type CanvasFrame = CanvasFrame$1; /** * The canvas's frame. * * Registers its iframe with the `CanvasFrameProvider` above it, so the panels, * the toolbar and the keys outside the canvas see the frame too. With no * provider above that waits for one, it provides for itself, which is enough * for the canvas and the chrome drawn over it. * * @experimental */ export declare function CanvasFrame(props: CanvasFrameProps): React$1.JSX.Element; /** * Whether a frame's document, at `address`, is the page `src` names: the same * address, whatever its fragment, `src` read against the document's `base` * when it is relative. The frame's starting page is at no address, so it never * is. * * @internal */ declare function isPageAt(address: string, base: string, src: string): boolean; /** A documentation page Help links to. */ interface DocsLink { readonly label: string; readonly href: string; } /** The Page Builder's pages, in the order Help offers them. */ declare const PAGE_BUILDER_DOCS: readonly DocsLink[]; /** * Where the docs explain the canvas route a site mounts to draw the canvas * inside its own layout: the page a fallback's Details link opens. */ export declare const CANVAS_ROUTE_DOCS_HREF: string; /** * Where the docs explain how the site's background jobs are run: the usage * counts are filled in by one, and on a site nothing runs them for they never * finish, so the counting note links here. */ declare const BACKGROUND_JOBS_DOCS_HREF: string; /** * Where the docs explain how site code meets the site's Content Security * Policy: the link beside what Settings says to add to that policy. */ export declare const SITE_CODE_POLICY_DOCS_HREF: string; /** * Where the docs explain how a site's text is set: Site text, type sizes, * fluid sizes, text styles, the Body and Headings fonts and where fonts are * kept. Linked from the Design panel's Type tab, where those are set. */ declare const HOW_TEXT_WORKS_DOCS_HREF: string; /** @experimental */ interface CanvasMarksProps { /** * Selected blocks the page hides on the device being shown, which the * canvas draws anyway while they are selected. Their ring is hatched and * tagged, so a block a visitor will not see is never mistaken for one they * will. */ readonly revealed?: readonly string[]; /** * The site's breakpoints and the device being shown, which names the tag * on such a ring: "Hidden on Mobile". */ readonly device?: { breakpoints: BreakpointSet | undefined; id: string; }; /** * A block's name by its address, for the tag on a component placement's * frame: the name its author gave it, or its component's. A placement it * does not name is tagged as a component. */ readonly nameOf?: (address: string) => string | undefined; /** * What a block shown for the previewed entry is badged with while * conditions are applied: "Shown for this post". */ readonly shownLabel?: string; } /** * The marks over the canvas's blocks. * * Re-measured whenever the canvas may have moved or been re-marked — * `watchCanvasFor` hears the attributes change as well as the layout — and * when the frame's zoom or page changes, which moves every block on screen * while nothing inside the frame changes size. * * @experimental */ export declare function CanvasMarks({ revealed, device, nameOf, shownLabel }?: CanvasMarksProps): React$1.JSX.Element; interface InsertionLineProps { /** The page the place is in, as the panel judged it. */ readonly document: BlockDocument; } /** * How long an edge label outlasts the panel letting go of its place: long * enough for the pointer to cross from the tiles to the label and press it. * Pointed at, it stays for as long as the pointer does. */ declare const EDGE_HOLD_MS = 1500; export declare function InsertionLine({ document }: InsertionLineProps): React$1.JSX.Element; /** * Block the editor's shortcuts for as long as `active`. * * Registered at the CALLER's own depth. `useShortcuts` reads the depth from the * surrounding context and only a `ShortcutScope` increments it, so nothing here * nests the hold — and nesting is not what would make it work anyway. The host * chooses how deeply its own shortcuts are scoped, so any depth this picked * could be tied or beaten by a scope the host nests one level further. * * `priority: 1` is what carries it: the manager sorts priority ABOVE depth, so * the hold outranks an ordinary layer however deeply that layer sits. Priority * is the one axis the host does not control. * * The manager already exempts text insertion and Tab, so a form's fields and * its focus trap keep working underneath this. * * `name` identifies the holder in the manager's own diagnostics, which is worth * having now that more than one layer raises its priority: two holds at equal * priority fall back to depth, and a name is what tells them apart in a trace. */ export declare function useModalKeyboardHold(name: string, active: boolean): void; /** What the region selection reads of the editor: its block selection. */ interface RegionSelectionEditor { readonly selectedId: string | null; readonly select: (id: null) => void; } /** The selected region, and the ways to change it. */ interface RegionSelection { /** * The region selected, or `null`: always `null` while a block is selected * or while the region is not drawn. */ readonly area: RegionArea | null; /** Select a region, clearing the block selection. */ readonly select: (area: RegionArea) => void; /** Select no region. */ readonly clear: () => void; } /** * The region selection for an editor whose canvas draws `areas`. * * Its verbs keep one identity, reading the newest editor when called, so a * canvas or a Layers row holding them is not drawn again on every edit. */ export declare function useRegionSelection(editor: RegionSelectionEditor, areas: readonly RegionArea[]): RegionSelection; interface RegionEditingScrimProps { /** The region edited in place, or `undefined` while the page is edited. */ area: RegionArea | undefined; /** A press on the dim: the host pulses Done. */ onPress: () => void; } export declare function RegionEditingScrim({ area, onPress }: RegionEditingScrimProps): JSX.Element | null; /** * The parts of `whole` to dim around `region`: above it and below it, the * full width, each left out where it has no height. Without the region * drawn, the whole canvas, so nothing of the page is ever left in reach. */ declare function dimmedAround(whole: Rect, region: Rect | undefined): Rect[]; /** What the host says about a region while it is edited. */ interface RegionEditingWords { /** The bar above the canvas: "Editing the site header · changes show on 11 pages". */ readonly bar: string; /** The bar's button that ends the editing: "Done". */ readonly done: string; /** Announced on entering: "Editing the site header. Changes show on 11 pages." */ readonly entered: string; /** Announced on leaving: "Back to the page." */ readonly left: string; } /** A region of the page's layout to edit in place, as the host hands it over. */ interface RegionEditing { /** Which region: the header or the footer. */ readonly area: RegionArea; /** Its document as editing starts: the latest version of what fills it. */ readonly document: BlockDocument; /** The definitions that document's component placements are drawn from. */ readonly definitions?: DefinitionsById; /** Its name, "Site header": "Layers · Site header", "Navigation · in Site header". */ readonly label: string; /** What is said about it while it is edited. */ readonly words: RegionEditingWords; } /** What the editor edits: the page, or a region of its layout in place. */ type EditingTarget = { readonly kind: "page"; } | ({ readonly kind: "region"; } & RegionEditing); /** The editing target, the state that edits it, and the ways to switch. */ interface EditingTargetState { /** What is being edited now. */ readonly target: EditingTarget; /** * The state of the document being edited: the region's while one is edited, * else the page's. Everything that edits or reads "the document being * edited" (the inspector, Layers, the Add panel, the keyboard, the palette, * the toolbar, the canvas marks, Undo and Redo, a recorded site-style step) * is handed this, so one switch routes them all. */ readonly active: EditorState; /** Edit `region` in place, with a history of its own that starts empty. */ readonly enter: (region: RegionEditing) => void; /** Back to the page, dropping the region's history. */ readonly leave: () => void; /** * How many times the dimmed page was pressed this session: each press * briefly highlights Done, the one way back, and changes nothing else. */ readonly pulse: number; /** Count one press on the dimmed page. */ readonly pulseDone: () => void; /** * What a live region says now: the region's `entered` words after entering, * its `left` words after leaving, empty before either. */ readonly announcement: string; /** * The definitions the region is drawn from now, while one is edited: the * host's current ones, else those it was entered with. */ readonly definitions?: DefinitionsById; } /** The arguments the region's state takes beyond its own document. */ type RegionStateArgs = Omit & { /** * The definitions the host draws component placements from now, which a * region edited in place is drawn and judged by over the ones it was * entered with: a component made or loaded while it is edited is known to * it at once, its history kept. */ readonly definitions?: DefinitionsById; }; /** * The editing target for an editor whose page state is `page`. * * The region's state is always mounted, so entering and leaving change which * state is active without mounting anything: each entry is a new session of * it (`useEditorState`'s `session`), started from the region's document with * nothing selected and an empty history, and leaving starts it again on an * empty document, which drops that history. The page's selection is never * touched, so it is as it was when the author comes back. * * `args` are what the region's edits are judged by beside its own document: * the host's caps, refusal reporting and locks, as the page's are. */ export declare function useEditingTarget(page: EditorState, args?: RegionStateArgs): EditingTargetState; /** * What the canvas draws as the region being edited: its area, the region * state's LIVE document and its definitions, or nothing while the page is * the target. Derived from the editing target, so the canvas cannot draw one * region while the panels edit another. */ export declare function canvasEditingOf(editing: Pick): { readonly area: RegionArea; readonly document: BlockDocument; readonly definitions?: DefinitionsById; } | undefined; /** * What Escape does once nothing inside the region is selected and no popover * is open (the keyboard's Escape has already cleared those, innermost * first): it ends the region's editing as Done does, the host's `done` where * it asks first about unsaved changes, else at once. While the page is the * target it runs the host's own `otherwise`. * * For `BlockKeyboardActions`'s `onEscapeWithoutSelection`. */ export declare function regionEscape(editing: Pick, { done, otherwise }: { readonly done?: () => void; readonly otherwise?: () => void; }): () => void; interface RegionEditingBarProps { /** The editing target, from `useEditingTarget`. */ editing: Pick; /** * What Done runs: the host's, where it asks first about unsaved changes. * Absent, Done leaves at once. */ onDone?: () => void; } export declare function RegionEditingBar({ editing, onDone }: RegionEditingBarProps): JSX.Element; /** A placement's exposed passage, by the placement and the exposure. */ interface CanvasPassage { readonly placementId: string; readonly exposureId: string; } /** The passage the canvas is editing, or `null` while it edits none. */ declare const CanvasPassageContext: React$1.Context; /** * What the host knows about the component being edited that its document does * not hold. * * @experimental Settles when the component editor ships. */ interface ComponentFieldsHost { /** * Field and slot ids this component must never mint again: those its * PUBLISHED definition holds, and every one it has retired. A draft that * dropped a published field still has placements holding values under its * id, so a new field minted under that id would take them over. * * `unavailable` while the host has not read them, or could not: adding a * field then waits, with that sentence, rather than minting an id the live * definition may still hold. Absent where the host has nothing live to * reserve. */ readonly reserved?: RetiredExposures | ReservedUnavailable; /** * How many documents place this component DIRECTLY (pages, Singles, other * components and patterns), for the removal dialog: `complete` false makes * the number a floor, said as "at least". Pages reaching it through another * component are not counted, so it is never said as a count of pages. */ readonly reach?: { readonly count: number; readonly complete: boolean; }; /** * How many distinct pages and Singles a change to the component reaches: * placed on them directly, inside another component, or in a Layout that * wraps them. What the banner over the view says; `complete` false makes * it a floor, said as "at least". Absent while the host has no count. */ readonly pages?: { readonly count: number; readonly complete: boolean; }; /** The component's name, for the card heading its own view. */ readonly name?: string; } /** Why the ids a new field must avoid are not known, said to the author. */ interface ReservedUnavailable { readonly unavailable: string; } /** What an exposure is called in a sentence. The engine's names are code. */ declare const EXPOSURE_TYPE_LABEL: Readonly>; /** The component a document is, or `undefined` for a page or a pattern. */ declare function editedComponent(document: BlockDocument): ComponentDocument | undefined; /** * The fields a component exposes, read as a list whatever is stored. * * An entry that is not a field (a stored or imported row holding `null`, or * one without an id or a type) is left out rather than read: the view has to * open on such a component so the author can repair it, and the envelope * check names the broken entry on save. */ declare function exposedFields(component: ComponentDocument): readonly ExposedProperty[]; /** The ids of the slots a component exposes. */ declare function exposedSlotIds(component: ComponentDocument): readonly string[]; /** The field exposing one prop of a node, if one does. */ declare function propExposure(component: ComponentDocument, nodeId: string, propPath: string): ExposedProperty | undefined; /** The field letting placements hide a node, if one does. */ declare function visibilityExposure(component: ComponentDocument, nodeId: string): ExposedProperty | undefined; /** * Whether a prop can be exposed, by its declared type: the field type it would * be, or the sentence saying why not. Shown rather than hidden, so an author * learns the prop is not exposable rather than wondering where the switch went. */ declare function exposeOffer(schema: PropSchema): { readonly type: Exclude; } | { readonly reason: string; }; /** * The one op that turns `before`'s envelope into `after`'s, or `undefined` * when the two hold the same fields, slots and variants. */ declare function envelopeOpFor(before: ComponentDocument, after: ComponentDocument): BuilderOp$1 | undefined; /** * Every id this component may not mint: what the host reserved, and every id * the editing session has seen, so a field removed and then added again under * the same name gets a new id rather than the removed one's values. */ declare function reservedIds(host: RetiredExposures | ReservedUnavailable | undefined, seen: RetiredExposures): RetiredExposures | ReservedUnavailable; /** The ids a component holds now, to add to what a session has seen. */ declare function idsIn(component: ComponentDocument): RetiredExposures; /** What an edit came to: applied, or refused with the sentence to show. */ type FieldEditOutcome = { readonly applied: true; readonly edit: ExposureEdit; } | { readonly applied: false; readonly reason: string; }; /** * Apply a planned edit to the editor as one op, or say why it was not. * * The planner's result is applied as it stands: it is the whole edited * definition, judged by the same envelope check the save asks. */ declare function applyFieldEdit(editor: Pick, component: ComponentDocument, result: ExposureEditResult): FieldEditOutcome; /** What the planners read from the editor and the host, gathered once. */ interface FieldEditContext { readonly editor: Pick; readonly component: ComponentDocument; /** The ids a new field must avoid, or why they are not known yet. */ readonly reserved: RetiredExposures | ReservedUnavailable; } /** Expose one prop of a node as a new field under `label`. */ declare function exposeProp(context: FieldEditContext, nodeId: string, propPath: string, label: string): FieldEditOutcome; /** Let placements hide a node, through a new visibility field. */ declare function exposeVisibility(context: FieldEditContext, nodeId: string, label: string): FieldEditOutcome; /** Rename a field; its id and every placement's value stay. */ declare function renameField(context: Omit, id: string, label: string): FieldEditOutcome; /** * The removal of a field or an exposed slot, planned but not applied: the * dialog shows what it prunes before the author confirms. */ declare function planFieldRemoval(component: ComponentDocument, removing: { readonly kind: "field" | "slot"; readonly id: string; }, limits: EditorState["limits"]): ExposureEditResult; /** * "at least 3 documents", "1 document", or nothing when the host could not * count. A floor of none says nothing, so it is not said. */ declare function reachPhrase(reach: ComponentFieldsHost["reach"]): string | undefined; /** * What the removal dialog says about the placements and variants a removal * takes a value from. */ declare function removalSentences(edit: ExposureEdit, removing: { readonly kind: "field" | "slot"; }, reach: ComponentFieldsHost["reach"]): { readonly placements: string; readonly variants: readonly { readonly variant: string; readonly sentence: string; }[]; }; /** * Where a field comes from, in the words an author reads: the block and the * property, by the names the block gives them, never a stored prop name or an * id. "Heading text", "Button link"; the block alone where the property is * named as the block is ("Image"); and "Heading · level" where the plain line * would only repeat the field's own name. A visibility field says what it * does instead, since it drives no property. */ declare function fieldSource(document: BlockDocument, field: ExposedProperty): string; /** Where an exposed slot sits, and what each placement does with it. */ declare function slotSource(component: ComponentDocument, slotId: string): string; /** * How many placements chose a variant, for the delete dialog. * * @experimental Settles when the component editor ships. */ interface VariantUse { /** Placements that chose it. */ readonly placements: number; /** The documents holding them: pages, Singles, components and patterns. */ readonly documents: number; /** * False when the count is a floor: the usage index did not list every host, * or a host could not be read. Said as "at least". */ readonly complete: boolean; } /** * What the host knows about a component's variants that its document does not * hold. * * @experimental Settles when the component editor ships. */ interface ComponentVariantsHost { /** * Counts the placements that chose a variant, across every document that * places the component. Absent where the host cannot count; the delete * dialog then says the placements fall back without a number. */ readonly countUse?: (variantId: string) => Promise; /** * Which variant is open, held by the host so the canvas can preview it. * Absent, the section holds it alone and the canvas draws the defaults. */ readonly preview?: VariantPreviewBinding; /** * The variants are edited in the component's own view alone, and no * section is drawn here: a header or footer edited in place from a page, * whose canvas has no variant of it to preview. */ readonly editedInOwnView?: boolean; /** * Opens the component's own view, where its variants are edited: offered * beside the line saying so while `editedInOwnView`. Absent where the host * cannot open it, and the line then stands alone. */ readonly onOpenOwnView?: () => void; } /** The open variant, as the host holds it for the canvas to preview. */ interface VariantPreviewBinding { /** The open variant's id, or nothing while none is open. */ readonly open: string | undefined; /** Open a variant, or close the open one with `undefined`. */ readonly onOpen: (variantId: string | undefined) => void; } /** What the variant edits read from the editor, gathered once. */ interface VariantEditContext { readonly editor: Pick; readonly component: ComponentDocument; /** * Keys a new variant must not take though the component no longer holds * them: every key this editing session has seen, so a variant deleted and * added again under its old name does not inherit the old one's placements. */ readonly taken: readonly string[]; } /** What an edit came to: applied, or refused with the sentence to show. */ type VariantEditOutcome = { readonly applied: true; readonly id: string; } | { readonly applied: false; readonly reason: string; }; /** * A name for a new variant no other variant has: "Variant 2" when there is * one already, and so on. The designer renames it in place. */ declare function nextVariantName(component: ComponentDocument): string; /** Define a variant. It presets nothing until it is given values. */ declare function addVariant(context: VariantEditContext, label: string): VariantEditOutcome; /** Rename a variant; every placement that chose it keeps it. */ declare function renameVariant(context: VariantEditContext, id: string, label: string): VariantEditOutcome; /** Delete a variant; its placements show the defaults with their own values. */ declare function deleteVariant(context: VariantEditContext, id: string): VariantEditOutcome; /** Set what a variant presets for one field. */ declare function setVariantValue(context: VariantEditContext, id: string, fieldId: string, value: OverrideValue): VariantEditOutcome; /** Take a variant's value for one field away, back to the default. */ declare function resetVariantValue(context: VariantEditContext, id: string, fieldId: string): VariantEditOutcome; /** * The component's own value for each exposed field, by field id: what a * variant that sets nothing for a field shows. * * Read from what the resolver itself makes of a placement that sets nothing, * once for the whole component, so a visibility field gated by its node's * conditions reads as hidden, and a field the resolver cannot use has no * value, exactly as a page shows them. */ declare function defaultValues(component: ComponentDocument): ReadonlyMap; /** How many values a variant presets, in words: "2 changes", "No changes yet". */ declare function valuesSummary(option: VariantOption): string; /** * What the delete dialog says will happen to the variant's placements. * * `undefined` use is a count still in flight; `null` is one that could not be * made, which says what happens without a number rather than "none". */ declare function deleteSentence(use: VariantUse | null | undefined): string; /** * A placement's variant, as its picker shows it. * * @experimental Settles when the component editor ships. */ interface VariantChoice { /** The variants the component offers, in its stored order. */ readonly options: readonly VariantOption[]; /** The key the placement stores, if any. */ readonly chosen?: string; /** * True when the stored key names a variant the component no longer has: * the placement then shows the defaults, and the picker says so. */ readonly removed: boolean; } /** What a placement's picker offers and shows, read off the definition. */ declare function variantChoiceOf(definition: ComponentDocument | undefined, node: BlockNode): VariantChoice; /** * The op that sets a placement's variant, or clears it with `undefined`. * * The whole props object, as every placement op writes it: `updateNode` * merges at the top level, so a patch of the one key would drop the * component's id. Clearing removes the key, since absent is "no variant". */ declare function chooseVariantOp(node: BlockNode, variantId: string | undefined): BuilderOp$1; /** * 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. */ 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. */ declare function styleControlsFor(property: StyleProperty, value?: StyleValue, options?: StyleControlInput): StyleControlSet; /** * Each form of a variant in plain words: its own names, or, for a variant * built without them, names read from the forms' kinds. */ declare function formNamesOf(variant: StyleControlVariants): readonly string[]; /** * 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$1 | 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. */ declare function styleValueAtPath(path: readonly string[], value: StyleValue): StyleValue; /** The value a control is currently showing, or `undefined` when nothing set it. */ declare function readStyleValue(styles: NodeStyles | undefined, address: StyleAddress): StyleValue | undefined; /** * Whether a state holds any declaration of its own, at any breakpoint. * * Here rather than beside the control that draws the answer, because this file * is the chokepoint for reading this envelope and the reading is the whole * difficulty. The value arrives from storage, so a migration, a DTCG import or * a hand-edited row can leave `hover: null` or `{ base: null }` behind, and the * field's own guard admits both — it checks that `nodes` is an array and no * more, deliberately, so a malformed document stays repairable instead of * throwing. `Object.values(null)` throws during RENDER, which takes the Style * tab down and removes the only surface that could repair the value that broke * it. * * Own keys at every level, for the reason `valuesAt` gives: a state or * breakpoint reached through a PROTOTYPE is one the compiler will not read, so * reporting it as styled would mark a state whose values never reach the page. * * A PLAIN RECORD at every level, and the engine's own predicate rather than a * looser one, for the same reason stated positively: this must agree with what * the COMPILER will read. An array is a non-null object, so a guard asking only * that would accept `hover: []` and count its numeric indexes as declarations — * while `isPlainRecord` makes the compiler emit nothing for it. A state marked * as styled that cannot affect the page is worse than an unmarked one, because * it sends an author looking for a value that was never going to apply. * * A TIER THE SHEET HAS. A value stored under a breakpoint the site has since * deleted is not reachable by any visitor — the compiler iterates the * breakpoint contexts it was given and never looks at the rest — so counting it * would mark a state whose appearance nobody can see. * * EMPTY IS NOT SET. Both levels are sparse and either can survive empty — a * state whose last declaration was cleared leaves the keys behind — so a * presence test reports a state as styled when it carries nothing, which is * precisely the false reassurance the marker exists to remove. * * REFUSED IS NOT UNSET, and this is the one boundary here that is a judgement * rather than a fact about the shape. A declaration the current policy rejects * emits no CSS, so validating here would make the marker agree with the sheet * in that case too. It is deliberately not done: a policy is a HOST SETTING * that changes without the document changing, so a value refused today is * still the author's, still deliberate, and restored by a policy change. A * marker that vanished for it would report their work as ABSENT rather than as * refused — and refusal already has a better channel, the control that shows * the value and says why it did not apply. * * So this answers "you have set something here that this site can express", * and the tiers and shapes above are the part of that question decided by the * document rather than by configuration. */ declare function stateHasOwnValues(styles: NodeStyles | undefined, state: StyleState, breakpoints: BreakpointSet | undefined): boolean; /** The op that sets one control's value, or the reasons the value was refused. */ 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 */ 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. */ declare function styleClearOp(nodeId: string, styles: NodeStyles | undefined, address: StyleAddress, policy?: StylePolicy): StyleWrite; /** * Where copied text goes: the system clipboard, or a clipboard event being * handled. Answers whether the text was taken, now or later. */ type ClipboardWrite = (text: string) => boolean | Promise; /** The three verbs, plus a paste of text a clipboard event already carries. */ interface BlockClipboardVerbs { /** Copy the selected blocks; answers whether anything was copied. */ readonly copy: (write?: ClipboardWrite) => boolean; /** Copy then remove the selected blocks, lock permitting; answers whether it did. */ readonly cut: (write?: ClipboardWrite) => boolean; /** Paste what the clipboard holds, read from the clipboard. */ readonly paste: () => void; /** * Paste text a paste event carries. Answers whether the text was copied * blocks, pasted or refused, so other text is left to the page. */ readonly pasteText: (text: string) => boolean; } /** What the verbs need from the provider that offers them. */ interface BlockClipboardOptions { /** The newest editor, read when a verb runs. */ readonly latest: React$1.RefObject; /** Say something in the editor's live region. */ readonly announce: (message: string) => void; /** Show a notice the author reads, for a paste that is refused. */ readonly notify: (message: string) => void; readonly nesting: NestingSource; readonly components?: ComponentLookup | undefined; /** * In a template, its collection's blocks fields by name, for a pasted * Entry content block; `undefined` while they are being read. */ readonly entryFields?: readonly string[] | undefined; } declare function useBlockClipboardVerbs({ latest, announce, notify, nesting, components, entryFields }: BlockClipboardOptions): BlockClipboardVerbs; /** * Where a family's glyphs would come from. * * `not-provided` is deliberately not called "missing" or "unavailable". A named * family this site loads no face for may still be installed on the reader's * device — `Georgia` and `Helvetica` are the ordinary cases — so declaring it * absent would be a claim about a machine this code cannot see. What IS true is * that the site does not provide it, and that is what the word says. * * `dynamic` is a `var()` whose value only exists at render. Reporting it as * provided or not would be a guess either way, and the guess that reads worst * is the confident one: a host wiring a font through a custom property, which * is how `next/font` exposes one, would be told their token is broken. */ type FamilySource = "hosted" | "generic" | "dynamic" | "not-provided"; /** One family from a stack, and where it would come from. */ interface FamilyReading { /** The family name, with quotes removed and escapes resolved. */ readonly family: string; readonly source: FamilySource; } /** A whole `font-family` value, read against the faces the site loads. */ interface StackReading { /** * How CSS reads the value, from the engine's own classification. * * Four states rather than usable/unusable, because the browser has four * answers and collapsing them misdescribes two: a `var()` stack is read * perfectly and cannot be resolved here, and a lone `inherit` is valid while * naming no family at all. */ readonly kind: FamilyListKind; /** Each family in the author's order. Empty unless `kind` names families. */ readonly families: readonly FamilyReading[]; /** * The author's FIRST choice, which is the one they were expressing. * * Separated from the rest because a stack is a fallback chain and every entry * after the first is a concession. An author who wrote `Brand, serif` chose * `Brand`; reporting the stack as fine because `serif` resolves would answer * a question they did not ask. */ readonly firstChoice: FamilyReading | undefined; /** * Whether a family AFTER the first exists to fall back to. * * What separates "readers see the next family in the list" from "readers see * the browser's default", which are different sentences and only one of them * is true of a single-family stack. */ readonly hasFallback: boolean; /** * Whether the site guarantees SOMETHING renders. * * True when any family is generic or hosted. A stack of named families alone * can still render — every one may be installed — so this is a floor, not a * prediction. */ readonly guaranteed: boolean; } /** * Read one `font-family` value against the faces this site loads. * * The split and the classification are the engine's, asked through one call. * A family list is quoting, comma, escape and identifier rules together — * `"ACME, Inc", serif` is two families rather than three, and `Brand,` is a * parse error the browser drops the declaration for. A second reading of that * grammar here would agree on the easy values and diverge on the ones a site's * real font name produces. */ export declare function readStack(value: string, faces: readonly FontFaceDef[]): StackReading; /** Which value of a token is being read. */ type TokenMode$1 = "light" | "dark"; /** A `fontFamily` token, read against the faces the site loads. */ interface FontTokenRow { readonly token: SiteToken; /** The light value's reading. Always present: `values.light` is required. */ readonly reading: StackReading; /** * The dark value's reading, when the token defines one. * * Read because the emitter applies it: a token whose light stack is hosted * and whose dark stack is not would otherwise report an all-clear while every * dark-mode reader gets a substitution. Absent when the token states no dark * value, which is not the same as stating the same value twice. */ readonly darkReading: StackReading | undefined; } /** * Every `fontFamily` token in the set, with what each would render as. * * Only `fontFamily` tokens: a `dimension` holding a font SIZE is typography and * is not a typeface, and including it would put rows in this panel that its * question does not apply to. */ export declare function fontTokenRows(tokens: SiteTokenSet | undefined, faces: readonly FontFaceDef[]): FontTokenRow[]; /** One thing worth saying about one mode of one token. */ interface TokenNote { readonly mode: TokenMode$1; readonly text: string; } /** * Everything worth saying about one token, one entry per affected mode. * * A list rather than a string because a token can be sound in light and not in * dark, and one sentence for both would have to name a mode it did not check. */ declare function tokenNotes(row: FontTokenRow): readonly TokenNote[]; /** * The rows worth an author's attention, in EITHER mode. * * A row is drawn to attention when a mode's value cannot be read at all, or * when its FIRST family is one this site does not provide — that is the choice * the author expressed, and the one that silently does not happen. */ export declare function rowsNeedingAttention(rows: readonly FontTokenRow[]): FontTokenRow[]; /** Where a family on the site came from, in the editor's terms. */ type FamilyOrigin = "google" | "upload" | "code"; /** One family the site loads, as the Fonts tab lists it. */ interface SiteFamily { /** The family lower-cased, as CSS matches it. */ readonly key: string; /** The family as first written. */ readonly family: string; readonly faces: readonly FontFaceDef[]; /** * `code` when any face comes from the site's configuration, which the * editor cannot change; otherwise where the stored faces say they came from. */ readonly origin: FamilyOrigin; /** Whether Remove is offered: when the site stored any of the faces. */ readonly removable: boolean; /** The styles in a few characters: `3 styles`, or a variable `100–900`. */ readonly styles: string; /** The licence in words, when the faces name one. */ readonly licence?: string; /** The catalogue's category, when the faces name one. */ readonly category?: string; } /** A licence in words; an unknown one as the catalogue wrote it. */ declare function licenceName(id: string | undefined): string | undefined; /** * The families the site loads, grouped as CSS matches them (case-insensitive, * the first spelling kept), in the order the faces are listed. * * @param faces - Every face the page emits, from code and stored * @param fromCode - The faces the site's configuration supplies */ declare function siteFamilies(faces: readonly FontFaceDef[], fromCode: readonly FontFaceDef[]): SiteFamily[]; /** The weights a font is named at, lightest first: 100 to 900. */ declare const NAMED_WEIGHTS: readonly number[]; /** * The named weights some face draws: each face's own weight, and every named * weight inside a variable face's range. Only the faces the stylesheet emits * count, the ones the Font picker lists, so a face kept only so its issue can * be said draws no weight. */ declare function weightsDrawn(faces: readonly FontFaceDef[]): Set; /** A weight in words with its number: `Bold 700`. */ declare function weightName(weight: number): string; /** * Which cut of a family a face is: `Regular 400`, `Bold Italic 700`, or * `Variable 100–900` for a face covering a range. */ declare function cutName(weight?: string, style?: string): string; /** A family in words, for its row's accessible name. */ declare function familyDescription(family: SiteFamily): string; /** The stored faces without one family's, matched as CSS matches a family. */ export declare function withoutFamily(faces: readonly FontFaceDef[], key: string): FontFaceDef[]; /** * What picking a family stores: its name quoted, then the generic family its * category falls back to, so a reader still gets a sensible face while the * file loads or if it never does. */ declare function familyStack(family: string, category?: string): string; /** * What picking a family for the site's Body or Headings font stores: its name * quoted, then the generic family of its kind ({@link roleGeneric}). */ declare function roleStack(family: string, category?: string): string; /** * Whether the faces draw an upright bold: some upright face at weight 600 or * heavier, which a browser picks for a bold heading rather than thickening a * lighter one. An italic bold leaves upright headings thickened. */ declare function drawsBold(faces: readonly FontFaceDef[]): boolean; /** The specimen, one sentence with ascenders, descenders and round forms. */ declare const SPECIMEN: string; /** What to draw for one face, so a specimen demonstrates the file it names. */ declare function specimenText(face: FontFaceDef): string; /** * One weight the specimen element can actually carry. * * A variable face declares a RANGE — `100 900` — which is valid in * `@font-face` and invalid as a `font-weight` on an element: the browser drops * the whole declaration and draws at its normal weight, so a range excluding * 400 renders the specimen in a FALLBACK while the row claims to demonstrate * the file. * * 400 when the range covers it, because that is what a reader sees in ordinary * text; otherwise the lower bound, which the face definitely provides. */ declare function specimenWeight(weight: string | undefined): string | undefined; /** The kinds of document a shared style is counted on. */ type SharedStyleKind = "pages" | "components" | "patterns" | "layouts"; /** How widely one shared style is used across the site, from the index. */ interface SharedStyleReach { /** How many documents apply it. */ readonly documents: number; /** The same documents, by kind. */ readonly byKind: Readonly>; /** * How many blocks wear it across those documents, as saved. Optional, so a * host written before it existed still compiles; absent, the sentence names * the open page's blocks and the documents apart. */ readonly blocks?: number; /** * What the open document contributes as saved, when the host could name it, * in the parts the sentence needs to count the open field from its live * copy instead, so an unsaved edit counts at once. Absent while the open * document is saved nowhere yet. */ readonly here?: SharedStyleHereParts; /** False makes every number a floor: "at least". */ readonly complete: boolean; } /** * The open document's saved blocks wearing a style, in parts. With the open * field's saved rows set aside: `alongside` is the largest saved copy the * open field is part of (its language, or each language for a field they * all share), `elsewhere` the largest of the document's other copies (its * other languages, its other stored form, and the open copy as saved where * that stays live until the edit is published), so with the live blocks * the document counts `max(alongside + live, elsewhere)`. `saved` is what * the document adds to `SharedStyleReach.blocks` as saved, 0 when it holds * none. `null` where a count is not known. */ interface SharedStyleHereParts { readonly saved: number | null; readonly alongside: number | null; readonly elsewhere: number | null; /** The kind of document it is, which its place is counted under. */ readonly kind: SharedStyleKind; } /** One read of how widely some shared styles are used. */ interface SharedStylesUsage { /** Whether every page has been counted, so counts can be exact. */ readonly whole: boolean; /** * Whether counts that are not whole may still become whole, so they are * worth asking for again. False when something the index cannot reach * keeps them floors for good. * * Optional, so a host written before it existed still compiles. Absent * means unknown, and the tab asks again as it does while counting: every * 15 seconds while the counts are not whole, until 20 asks in a row change * nothing (`USAGE_RECOUNT_MS` and `USAGE_RECOUNT_IDLE_MAX` in the panel), so * it neither stops while the counts still move nor asks for ever where they * cannot finish. */ readonly counting?: boolean; /** Whether this author may lock and unlock shared styles. */ readonly mayLock: boolean; /** * Whether this author may ask for the pages to be counted now * ({@link SharedStylesAccess.count}). Optional, so a host written before it * existed still compiles; absent means no. * * @experimental Settles with the Shared styles tab. */ readonly mayCount?: boolean; /** Each style asked about, by id. */ readonly styles: ReadonlyMap; } /** * What asking for the pages to be counted now answered: how far the counting * got, in the usage read's terms, or why it was refused. * * @experimental Settles with the Shared styles tab. */ type SharedStylesCount = { readonly kind: "counted"; /** Every page is counted now, so the counts can be exact. */ readonly whole: boolean; /** Pages are left that a further count would reach. */ readonly counting: boolean; } | { readonly kind: "refused"; readonly reason: string; }; /** One document a shared style is used on. */ interface SharedStyleUse { /** Unique only within its collection. */ readonly id: string; readonly title: string; /** The collection holding it: with `id`, what tells one document from another. */ readonly collection: string; readonly kind: SharedStyleKind; } /** One page of the documents a shared style is used on. */ interface SharedStyleUsesPage { readonly items: readonly SharedStyleUse[]; /** Every document this author may open, across all pages. */ readonly total: number; /** Documents using it that this author may not open. */ readonly hidden: number; /** Whether another page follows. */ readonly hasNext: boolean; /** False while some pages are still being counted. */ readonly complete: boolean; } /** * A removal the host refused, with whether the route said the style is still * used (its in-use refusal) rather than refusing for another reason, such as * a lock or a count no longer whole. * * @experimental Settles with the Shared styles tab. */ interface SharedStyleRefusal { readonly reason: string; readonly inUse: boolean; } /** * A host's answer to a removal as a refusal, or nothing when it was stored. * Words alone are a refusal that does not say the style is used. */ declare function sharedStyleRefusalOf(answer: string | undefined): SharedStyleRefusal | undefined; /** One shared style as the tab lists it. */ interface SharedStyleRow { readonly id: string; /** The name an author gave it, or its slug when it has none. */ readonly name: string; readonly slug: string; /** The class the page carries, as hand-written CSS selects it: `.nx-c-card`. */ readonly className: string; readonly locked: boolean; /** Supplied by the site's code: shown, never renamed, locked or removed. */ readonly inCode: boolean; /** A look, bound to one block type, rather than a shared style. */ readonly look?: boolean; /** * A text style, worn from the Style tab's "Text style" picker rather than * as a shared style. */ readonly text?: boolean; readonly styles: NodeStyles; } /** The tab's own name inside a sentence. */ declare const SHARED_STYLES_WORD: string; /** Every shared style the site renders, in the order that decides precedence. */ declare function sharedStyleRows(library: readonly NamedClass[], suppliedIds: ReadonlySet): SharedStyleRow[]; /** * The library without its looks and text styles: the shared styles an author * applies to any block, as the Shared styles tab and the picker list them. A * look is bound to one block type and is picked from that block's own tiles; * a text style is picked from the Style tab's "Text style" and listed in * Design's Type tab. */ declare function sharedStylesOnly(library: readonly NamedClass[]): NamedClass[]; /** A style's name: its label, or its slug for a style made before labels. */ /** A class's name as the surfaces show it: its label, or its slug when blank. */ declare function sharedStyleName(entry: Pick): string; /** * The class name a name gives: lowercase letters, digits and dashes, starting * with a letter, as the engine's slug grammar requires. Empty when the name * holds no letter or digit at all. */ declare function sharedStyleSlug(name: string): string; /** A rename's verdict: the label and slug to store, or why not. */ type SharedStyleRename = { readonly ok: true; readonly label: string; readonly slug: string; } | { readonly ok: false; readonly reason: string; }; /** * Whether a style may take a new name, and the label and class name to store * if it may. The class name is derived from the name, and a class name * another style already has is refused, since two styles with one class name * would write one selector and the later would be dropped. */ declare function renameSharedStyle(name: string, classId: string, library: readonly NamedClass[]): SharedStyleRename; /** * What a row is found by: its name, its class name as written and as the page * emits it, and every property and value it sets, in every state and at every * breakpoint. A value naming a variable is found by the variable's name, * since the reference compiles to that name. */ declare function sharedStyleSearchText(row: SharedStyleRow, context?: StyleCompileContext): string; /** * The rows a search finds, by name, class name, property or value, in their * order. Any row a shared style's row extends, so a look's row comes back as * the row it was. */ declare function searchSharedStyles(rows: readonly Row[], query: string, textOf: (row: Row) => string): Row[]; /** What a style declares at the base, as lines, and how much more elsewhere. */ declare function sharedStyleDeclares(styles: NodeStyles, context?: StyleCompileContext): { lines: string[]; elsewhere: number; }; declare function sharedStylePreview(styles: NodeStyles, context?: StyleCompileContext): Record; /** * The tile a row's "Aa" is drawn on: the site's page, its background and text * colours in the mode the canvas shows, so a style's own colours read as they * do on a page rather than against the panel. Resolved through the colour * controls' own reading of the site's variables ({@link colourHexOf}), by the * identities the engine gives the page's two colours. * * Empty without the site's variables, or for a colour that cannot be read: * the tile then keeps its neutral look. */ declare function sharedStylePageTile(tokens: SiteTokenSet | undefined, mode: TokenMode$1): { backgroundColor?: string; color?: string; }; /** One row's tile: the page under the preview, the preview, and a dark-mode flag. */ interface SharedStyleTile { /** The page the preview stands on; empty for the neutral tile. */ readonly page: { backgroundColor?: string; color?: string; }; /** The "Aa": the style's own colours, with readable text where it sets none. */ readonly specimen: Readonly>; /** * The style's text is under 4.5:1 on the site's dark page, so the tile * shows the light page instead and says so. */ readonly darkUnreadable: boolean; /** * The "Aa" is not shown to read on its background, a colour this cannot * measure, so it carries an outline in the page's colour: visible on any * background, without measuring it. */ readonly outlined: boolean; } /** * A row's tile in the mode the canvas shows. In dark mode a style whose text * (its own, or the page's where it sets none) would be under 4.5:1 on its * background (its own, or the dark page's) is drawn on the light page * instead and marked, since on the site it is hard to read in dark mode. A * style with a background and no text colour gets text that reads on that * background, so it never draws as a blank square. */ declare function sharedStyleTile(tokens: SiteTokenSet | undefined, mode: TokenMode$1, preview: Readonly>): SharedStyleTile; /** What a marked tile says, in its tooltip and the row's accessible name. */ declare const SHARED_STYLE_DARK_UNREADABLE = "Hard to read in dark mode"; /** A kind as a document is labelled in a list: "Page", "Component". */ declare function sharedStyleKindName(kind: SharedStyleKind): string; /** "a", "a and b", "a, b and c". */ declare function listedWords(parts: readonly string[]): string; /** The blocks on the open page that carry a style. */ interface BlocksOnThisPage { readonly count: number; /** False when the page has more blocks than could be read. */ readonly complete: boolean; } /** What a reach sentence says before the site has answered. */ declare const SHARED_STYLE_COUNTING = "Counting where it’s used…"; /** * How widely a style is used, in words: "Used on 12 blocks on 4 pages and 1 * component". The site's saved counts, with the open page counted from its * live copy in place of its saved one, so an unsaved edit counts at once and * none is counted twice. "At least" goes before a floor; "Counting where it’s * used…" before the site has answered; "Not used anywhere" only when every * count is whole. Empty where there is nothing to count from. */ declare function sharedStyleReachSentence(blocks: BlocksOnThisPage | undefined, reach: SharedStyleReach | undefined): string; /** A row's count in words, and whether it is a zero not counted yet. */ interface SharedStyleReachChip { readonly words: string; /** No use found so far on a site not counted in full: drawn muted. */ readonly uncounted: boolean; } /** * A row's count: its documents, with "+" when that is a floor, and what they * are. A bare number was read as uses, 17 blocks on 2 pages reading "2", so * the chip names the kind it counts: "4 pages", or "5 places" across several * kinds, which the row's name says one by one. A zero that is a floor says * "Not counted yet" rather than "0+ pages", a number that says nothing. */ declare function sharedStyleReachChip(reach: SharedStyleReach): SharedStyleReachChip; /** * Whether a style may be removed from its popover: only when it is stored * here, unlocked, every page has been counted, and nothing uses it, this open * page included (its unsaved blocks are not in the index yet). * * `quiet` when the popover already says why elsewhere (locked, set in code) * or while the usage is still being read. */ type SharedStyleRemoval = { readonly kind: "removable"; } | { readonly kind: "refused"; readonly reason: string; } | { readonly kind: "quiet"; }; /** * Why a style a block on the open page wears can't go, saying where, since * the site's saved counts may not hold that block yet. */ declare const USED_ON_THIS_PAGE_REMOVAL = "Used on this page, so it can’t be removed. Take it off the blocks that use it first."; /** * Whether the open page keeps a style from being removed: a block on it wears * the style, or the page could not be read in full, which reads as worn. The * saved documents are the route's to judge; this is what the route can't see, * an unsaved edit, so it is asked before the route is. */ declare function heldByThisPage(blocks: BlocksOnThisPage | undefined): boolean; declare function sharedStyleRemoval(row: Pick, blocks: BlocksOnThisPage | undefined, reach: SharedStyleReach | undefined, whole: boolean | undefined): SharedStyleRemoval; /** * Whether nothing uses a style: no document the index counted, in full, and * no block on the open page, read in full. Unknown reads as used. */ declare function isUnused(blocks: BlocksOnThisPage | undefined, reach: SharedStyleReach): boolean; /** * Where a style stands for the Used and Unused filters: "used" once any use * has been counted, on a block of the open page or a document in the index, * complete or not; "unused" only when it certainly is ({@link isUnused}, the * one rule removal also reads). Undefined otherwise: not read yet, or a zero * while some count is incomplete, which is "none counted yet", not unused. */ declare function sharedStyleUse(blocks: BlocksOnThisPage | undefined, reach: SharedStyleReach | undefined): "used" | "unused" | undefined; /** Which styles the tab lists: every one, or those used, unused or locked. */ type SharedStyleFilter = "all" | "used" | "unused" | "locked"; /** The filters in the order the tab offers them, with their words. */ declare const SHARED_STYLE_FILTERS: readonly { readonly filter: SharedStyleFilter; readonly word: string; }[]; /** * Whether a row belongs under a filter. A style whose usage has not been read * yet is under neither Used nor Unused until it has. */ declare function inSharedStyleFilter(row: Pick, filter: SharedStyleFilter, use: "used" | "unused" | undefined): boolean; /** What the tab says when a filter, with or without a search, lists nothing. */ declare function sharedStyleFilterEmpty(filter: Exclude, query: string): string; /** * The words the remove route refuses with while the index is not whole, so * the tab says the same before it is asked. */ declare const SHARED_STYLE_NOT_WHOLE_REMOVAL = "Some pages haven't been counted yet, so no shared style can be removed."; /** * Why Lock, Remove and Remove unused wait: a rename writes the whole list of * styles, and so does each of them, so whichever landed second would put the * other's list back. */ declare const SHARED_STYLE_RENAME_PENDING = "Wait until the name change is saved."; /** * The one note while the tab's counts are floors and Unused holds rows back: * it covers the minimums, the withheld rows and Remove unused waiting. */ declare const SHARED_STYLE_COUNTING_NOTE = "Some pages haven't been counted yet, so the numbers are minimums and no style can be called unused or removed."; /** * The note while counts are floors for good: content the index cannot reach * keeps them so, so it promises no wait. */ declare const SHARED_STYLE_UNCOUNTABLE_NOTE = "Some pages can't be counted, so these numbers are minimums."; /** Why Remove unused waits when counts are floors for good. */ declare const SHARED_STYLE_UNCOUNTABLE_REMOVAL = "Some pages can't be counted, so no shared style can be removed."; /** * What Unused says when every page is counted but some style's count was cut * short, so it holds that style back, beside any rows it does list. */ declare const SHARED_STYLE_UNUSED_UNCERTAIN = "Some uses could not all be counted, so some styles can't be called unused yet."; /** * What a removal's confirmation says the count cannot see. The count reads * only the styles chosen in the editor; a class written by hand elsewhere is * invisible to it, so a zero is what the editor knows, not a promise. */ declare const SHARED_STYLE_UNCOUNTED_USES = "A class written by hand, in custom code, an HTML attribute or another plugin, isn't counted."; /** The note under counts that are floors. */ declare const SHARED_STYLE_NOT_WHOLE_NOTE = "Some pages haven't been counted yet, so these numbers are minimums."; /** What an author without the right to change the site's design is told. */ declare const NO_DESIGN_RIGHT = "You can't change this site's design."; /** * The shared styles a block wears that the page renders, in library order * (the order that decides which wins), with their names. Classes the site * does not define, or stored past the page's limit, are not listed: they * style nothing. */ declare function nodeSharedStyles(library: readonly NamedClass[], nodeClassIds: readonly string[]): SharedStyleRow[]; /** Whether an envelope sets any value at all, in any state or breakpoint. */ declare function hasOwnStyles(styles: NodeStyles | undefined): boolean; /** 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; } /** * Why the block's look cannot be saved as a shared style, in words, or * `undefined` when it can. The first release lets a block wear one shared * style, so a block already wearing one is refused; the reason names it. */ declare function saveAsSharedStyleRefusal(document: BlockDocument, nodeId: string, offer: SharedStyleOffer, view?: LockView): string | undefined; /** A plan's answer: what to store, or why not. */ type SharedStylePlan = ({ readonly ok: true; } & T) | { readonly ok: false; readonly reason: string; }; /** * Why a new style's name can't be used because another style already has its * class name, in words naming it as the author typed it, or `undefined`. One * rule for the dialog, which asks it of the library it read, and for the host, * which asks it again of the library its queue holds just before it stores. */ export declare function sharedStyleNameTaken(name: string, slug: string, library: readonly Pick[]): string | undefined; /** The name typed in the save dialog, checked: the label and class name, or why not. */ declare function newSharedStyleName(name: string, library: readonly NamedClass[]): SharedStylePlan<{ label: string; slug: string; }>; /** * "Save as shared style": a new style made of the block's own styles, whole * (every state and breakpoint, variable references as they are), and the op * that clears them from the block and puts the style on it. The block looks * the same after, because a class's rules and a block's have one specificity * and the class comes first: with the block's values gone, the class's apply. * * The style must be stored before the op is applied, since a page may not * reference a style the site does not define. */ declare function planSaveAsSharedStyle(document: BlockDocument, nodeId: string, name: string, offer: SharedStyleOffer, view?: LockView, mintId?: () => string): SharedStylePlan<{ entry: NamedClass; ops: BuilderOp$1[]; }>; /** * Save as's page half: the new style put on the block, and the values it took * cleared from it. Built from the block as it stands once the style is stored, * so a value the block gained meanwhile (one the style does not hold) is kept. */ declare function saveAsSharedStyleOps(node: Pick, entry: Pick): BuilderOp$1[]; /** * What the save dialog says will move: "Moves this block's 6 values (2 * devices, Hover) into Card." A value is one property set in one state at one * breakpoint; the devices are named only when there is more than one. */ declare function sharedStyleMoveSummary(styles: NodeStyles | undefined, name: string): string; /** * What a save would move, in words: "this block's 6 values (2 devices, * Hover)". The summary's subject, also said on its own while the name in * the dialog cannot be used. */ declare function sharedStyleMoveWhat(styles: NodeStyles | undefined): string; /** Why a style can't be detached when its look can't be kept exactly. */ declare const DETACH_LOOK_NOT_KEPT = "This look depends on screen and container width together, so it can't be detached yet."; /** * "Detach": keep the look on this block only. The style is taken off the * block, and the block is given what it needs to show what it shows today, in * every state and at every width: the detached style's values where they win, * and, since the block's own rules come after every style's, a later style's * narrower or interaction-state value wherever the copy would otherwise beat * it. The block's own values are kept as they are. Where that can't be done * exactly (a look that depends on a viewport and a container width * together), it refuses and the style stays worn. A page edit, so a locked * style may be detached; the block's own lock refuses. * * @param worn - every shared style the block wears, in library order */ declare function planDetachSharedStyle(document: BlockDocument, nodeId: string, style: Pick, worn: readonly Pick[], view?: LockView, breakpoints?: BreakpointSet): SharedStylePlan<{ ops: BuilderOp$1[]; }>; /** Take a shared style off a block, leaving the block's own values. */ declare function planRemoveSharedStyle(document: BlockDocument, nodeId: string, styleId: string, view?: LockView): SharedStylePlan<{ ops: BuilderOp$1[]; }>; /** * One edit to a shared style, applied to whatever its styles are when the * host stores it: an edit is a change at one address, never a whole envelope, * so two edits made before the first is stored both survive. */ interface SharedStyleChange { (styles: NodeStyles): SharedStyleWrite; /** * The change that puts back what this one replaced, given the styles it was * applied to: the same address, its previous value (or cleared, where it * held none). An undo is then a change at that address too, applied to the * style as it stands when undone, so nothing else changed meanwhile is * put back with it. */ readonly invert: (before: NodeStyles) => SharedStyleChange; } /** The change that sets (or with `null`, clears) one control's value. */ declare function sharedStyleChange(address: StyleAddress, value: StyleValue | null, policy?: StylePolicy): SharedStyleChange; /** One address of a {@link sharedStyleChanges} change, and its value or `null`. */ interface SharedStyleSet { readonly address: StyleAddress; readonly value: StyleValue | null; } /** * The change that sets (or clears) several addresses as one: the sides of a * margin set together in a shared style, stored by the host as one change and * so undone as one. Each write is judged on its own leaf, folded onto the * last, and the first refusal refuses the whole; its inverse puts back every * address's previous value at once. */ declare function sharedStyleChanges(sets: readonly SharedStyleSet[], policy?: StylePolicy): SharedStyleChange; /** A style write's answer: the styles to store, no change, or the refusal. */ type SharedStyleWrite = { readonly kind: "write"; readonly styles: NodeStyles; } | { readonly kind: "unchanged"; } | { readonly kind: "refused"; readonly reason: string; }; /** * One control's value written into a shared style's envelope: the block's * own write path (`styleWriteOp`, `styleClearOp`), judged under the same * policy, so a value a block may hold is a value its style may hold. `null` * clears, as it does for a block. */ declare function sharedStyleWrite(styles: NodeStyles, address: StyleAddress, value: StyleValue | null, policy?: StylePolicy): SharedStyleWrite; /** * "Move to Card": the block's value at one control written into the style * and cleared from the block. Two writes (the style, then the page), so the * style is stored first and the op applied after it lands. The style's part * is a change at that address, applied to the style as it is when stored. */ declare function planMoveToSharedStyle(node: Pick, style: Pick, address: StyleAddress, policy?: StylePolicy): SharedStylePlan<{ change: SharedStyleChange; moved: StyleValue; }>; /** * Move to's page half: the block's value cleared at one address, built from * the block as it stands when the style has taken the value, so an edit made * to the block meanwhile is kept, at another address or at this one. Nothing * for a block that is gone or no longer holds the moved value there. */ declare function moveToSharedStyleClear(node: Pick | undefined, address: StyleAddress, moved: StyleValue, policy?: StylePolicy): BuilderOp$1[]; /** * What the author asked for. * * `indent` makes the block the last child of the sibling above it; `outdent` * makes it the next sibling of its parent. Those two are inverses, which is the * property the whole design rests on. */ type MoveDirection = "up" | "down" | "indent" | "outdent"; /** * What a move does, beyond where it lands. * * A bare position cannot say whether the block stayed among its siblings or * changed parent, and the difference is the whole thing a keyboard author cannot * see. Someone driving the editor through a screen reader needs "moved down" and * "moved into Group" announced differently, and the focus draw needs to know the * block left its container. Deriving it in the wiring by comparing parents * before and after would be a second implementation of a decision this function * has already made. */ type MoveEffect = "reorder" | "indent" | "outdent"; /** Where a block goes, what that does, and what it leaves behind. */ interface KeyboardMove { /** The position, in the shape the op store's `move` consumes. */ readonly to: OpPosition$1; readonly effect: MoveEffect; /** * The slot the block is leaving, when leaving it may empty it. * * Supplied for the depth axis only, because `up` and `down` land the block in * the container it started in and vacate nothing. Without it, moving the last * child out of a container leaves an empty slot the page-builder validator * rejects — and a keyboard author meets that far sooner than a pointer one, * because they move a single block at a time. * * A request rather than a command: the store drops the slot only if it is * actually empty afterwards, so a slot something else has filled stays. */ readonly dropSlotIfEmpty?: SlotAddress; } /** * Whether `container` has anywhere to put a block: a slot its definition * declares, or, with no definition to read, a slot it already holds. * * Read from the same declaration {@link indentSlot} reads, so a surface that * offers nesting by this answer offers it exactly where an indent could name a * slot. A block that declares none — a heading, a button — holds no blocks, * which is what lets a drag stop offering "inside" for it rather than offering * a place the placement rule would only refuse. */ declare function holdsBlocks(container: BlockNode, components: ComponentLookup | undefined): boolean; /** * The slot a block indented into `container` enters, or `null` when no single * slot can be named. * * Read from the container's DEFINITION, because a slot the definition does not * declare is one the container never renders: a block filed there is stored * and invisible, selected in the inspector and gone from the canvas. * * - One declared slot: that one, whatever it is called, so a plugin container * or a component exposing `items` or `default` receives the block where it * draws children. * - Several: the engine's default slot when it is among them, the region a * keyboard author reaches without choosing between regions they cannot see; * otherwise `null`. * - None declared: the engine's default slot. Whether the target may hold * children is the nesting rules' question, not this one's, and they refuse * the move for a block that cannot. * - No definition to read: the one slot the container already holds, when it * holds exactly one, since that is a slot something renders; otherwise the * engine's default slot. */ declare function indentSlot(container: BlockNode, components: ComponentLookup | undefined): string | null; /** * Where the selected block lands if the author moves it one step. * * @param nodes - the document's top-level blocks * @param selectedId - the block the author has selected * @param direction - which move they asked for * @param components - the component definitions the canvas draws, so an * indent into a component instance enters a slot its component exposes * @returns the position to move it to, or `null` when that move is not * available — the id is not in the document, the block is already at the end of * its container, there is no sibling above it to indent into, that sibling has * several slots and none is the default (see `indentSlot`), or it is already * at the top level and cannot outdent further. * * @remarks * **Indices are stated as the op store consumes them, which is AFTER the node * has been removed.** `moveNode` removes and then re-inserts, so a same-list * step down to `index + 1` is a move of one place rather than two: taking the * node out shifts every later sibling back by one, which exactly absorbs the * difference. Written against a store that inserted before removing, the same * arithmetic would skip a sibling going down and be correct going up — a defect * that appears in only one direction. * * The same removal is why `indent` targets the previous sibling's child count * unadjusted: the node leaves a DIFFERENT list from the one it arrives in, so * that list's length does not change under it. * * **A returned position is not permission.** Locking and validity belong to the * store, so a caller must handle a refusal rather than assume this will apply. */ declare function keyboardMovePosition(nodes: BlockNode[], selectedId: string, direction: MoveDirection, components?: ComponentLookup): KeyboardMove | null; /** 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; /** Whether an action id is one of the "Turn into" verbs. */ declare function isTurnIntoAction(id: string): id is TurnIntoActionId; /** One type the selected block can become. */ interface TurnIntoOffer { readonly id: TurnIntoActionId; /** The type it becomes: `"core/heading"`. */ readonly to: string; /** What the type is called: "Heading". */ readonly name: string; /** The verb: "Turn into Heading". */ readonly label: string; readonly enabled: boolean; /** Why it is not open, for an author, when it is not. */ readonly reason?: string; /** What the turn removes, said before it is chosen. */ readonly note?: string; } /** The editor's own lock question, asked of the op a turn would apply. */ type TurnIntoLockQuestion = (ops: readonly BuilderOp[]) => LockRefusalFacts | undefined; /** What judging a turn may ask beyond the document. */ interface TurnIntoJudging { /** The editor's lock question; absent, a slot's lock is not asked. */ readonly ask?: TurnIntoLockQuestion; /** * Whether to judge the turn in full: the slot locks and the placement rule, * which apply the op to answer. False for what a surface shows as the * selection changes; a menu that opens, and the verb, judge in full. */ readonly planned?: boolean; readonly nesting?: NestingSource; readonly definitions?: TurnIntoDefinitions; /** * The site's styles, so a block style the new type cannot wear is kept as * its own styles (`planTurnInto`). Absent, its id is carried as is. */ readonly library?: readonly NamedClass[]; /** * The editor's size limits, which the trial edit the placement rule is * asked of is judged by, as the editor's own apply is. Absent, the * defaults. */ readonly limits?: DocumentLimits; } /** * Every type the block `id` can be turned into, in the order its block * declares them, each open or closed with the reason; nothing for a block * that declares none, or that is not in the document. */ declare function turnIntoOffers(document: BlockDocument, id: string, judging?: TurnIntoJudging): TurnIntoOffer[]; /** The editor, as the verb uses it. */ interface TurnIntoEditor { /** The document to turn the block in: the latest the editor holds. */ readonly document: BlockDocument; readonly apply: (op: BuilderOp) => BlockDocument | null; readonly lockRefusalFor?: TurnIntoLockQuestion; } /** * Turn the block `id` into `to`, as one undo step, saying what happened: why * it did not, or that it did and what it removed. Answers whether it did. */ declare function runTurnInto(editor: TurnIntoEditor, id: string, to: string, say: (words: string) => void, judging?: Omit): boolean; /** The editor's own lock question, asked of the ops a verb would apply. */ type LockQuestion = (ops: readonly BuilderOp$1[]) => 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; } /** * What "Turn into component…" may do with a selection: replace the blocks * with a placement of the new component, or keep them and save a copy. Each * way is asked of its planner rather than restated: keeping shares the * pattern save's selection rules; replacing is planned in full, and the ops * it would apply are put to the editor's lock question, since a slot's lock * can refuse the placement that replaces the run. A way that is refused * carries its reason; both open, the object is empty. */ interface TurnIntoChoice { /** Why the blocks cannot be replaced, so only a copy can be saved. */ readonly replaceRefused?: string; /** Why no copy can be saved leaving them, so only replacing is open. */ readonly keepRefused?: string; } /** Each way "Turn into component…" may go, and why not where it may not. */ declare function turnIntoChoice(document: BlockDocument, ids: readonly string[], nesting: NestingSource, ask?: LockQuestion): TurnIntoChoice; /** * Where a block's move in one direction goes: the keyboard move's own answer. * * Passed in by a caller that runs the move, so the availability it shows is * asked with the very function, and the very component definitions, its verb * moves by. The default reads no definitions, as the bar's Move up and Move * down always have — a step within one list needs none. */ type MovePosition = (document: BlockDocument, id: string, direction: MoveDirection) => KeyboardMove | null; /** * Whether the placement rule refuses a block's move to `to`, and its words, * or `null` when it allows it. Passed in by a caller that runs the move, so * an item it offers is judged by the very call its verb judges by. */ type MoveJudge = (document: BlockDocument, id: string, to: OpPosition$1) => RefusalWording | null; /** * Whether this selection could be stored in the library, and why not. * * ASKED OF THE PLANNER, never restated. The ways a selection can be unsavable * are not a short list a toolbar should keep its own copy of — a run with a gap, * a block that may not be a document root, a node the op layer will not carry, * one HTML id on two of the run's nodes, a document past the byte cap — and a * surface enumerating them drifts the first time the planner learns a new way to * say no. It drifts SILENTLY: the button stays enabled and the save fails. * * Offered for a SET as readily as for one block, because saving several blocks * as one pattern is the ordinary case rather than the exception — a hero is a * heading, a paragraph and a button. * * The refusal carries a reason whatever the cause, unlike a move at the edge of * its container. There is nothing on the canvas that explains why a selection * cannot be saved, so leaving it dimmed and silent would be a control an author * can only guess at. */ /** * What an author is told when they hold no grant to save a pattern. * * Names the OPERATION the author attempted, not a permission. Saving needs more * than one grant — the pattern is stored and published in the same act — so a * message naming any single one is wrong for somebody: an author who may create * a pattern but not publish it would be told they cannot create, and would go * and ask for the grant they already hold. "Save" is also the word on the * control they pressed, which is the thing they can describe when they ask. * * Which grant is missing is deliberately NOT reported. The answer arrives as * one boolean because that is the question the verb asks, and a message * enumerating server-side permission names would tie this copy to slugs the * browser has no other reason to know — the same coupling the resolved-slug * lookup exists to avoid. * * ONE string, exported, because two surfaces say it: this list, which dims the * control and titles it, and the runner in `keyboard-actions`, which announces * it when a dimmed control is pressed anyway. Written twice they would drift, * and the drift would be invisible — each reads correctly on its own. */ declare const SAVE_PATTERN_GRANT_REFUSAL = "You do not have permission to save to Saved sections."; /** * Why the selection cannot be saved as a pattern, in the words the menu and * the keys say, or `undefined` where it can: Entry content first, which a * pattern may not hold (`compositionEntryContentRefusal`), then the save's * planner. One answer for Save as pattern and Update a pattern, whichever * route asks. */ declare function patternSaveRefusal(document: BlockDocument, ids: readonly string[], nesting: NestingSource): string | undefined; /** * 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. */ 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. */ 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. */ declare const TOOLBAR_GAP_PX = 6; /** How far inside the block's top-left corner an `inside` bar is drawn. */ declare const TOOLBAR_INSET_PX = 4; /** * 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. */ declare function toolbarPlacement(block: Rect, toolbar: ToolbarSize, canvas: ToolbarSize, gap?: number, screen?: ToolbarScreen, parts?: readonly Rect[]): ToolbarPlacement; /** The block menu's moves across depth: into the block above, and out. */ type DepthMoveId = "move-in" | "move-out"; /** One of them, and the keyboard move it runs. */ interface DepthMoveAction extends Omit { readonly id: DepthMoveId; readonly direction: Extract; } /** * Move in and Move out for the current selection, or `[]` when there is none. * * The menu path to what Alt+ArrowRight and Alt+ArrowLeft do, so every move a * drag in Layers makes has a way without dragging. Decided as the bar decides * Move up and Move down — the keyboard move's position, the node's lock and a * slot's — and run through the same verb the keystroke runs. Kept off the bar * itself, whose five buttons are fixed so the one an author aims at does not * move. * * A set is offered them dimmed with the reason, as the bar dims a verb that * has no meaning for several blocks. */ declare function depthMoveActions(document: BlockDocument, selectedId: string | null, selectedIds?: readonly string[], lockRefusalFor?: LockQuestion, position?: MovePosition, judge?: MoveJudge): DepthMoveAction[]; /** The selection's verbs, and the depth moves the block menu adds. */ interface SelectionVerbs { readonly actions: ToolbarAction[]; readonly depthMoves: readonly DepthMoveAction[]; } /** What a provider publishes for the surfaces below it. */ interface SelectionOffer extends SelectionVerbs { /** * The same verbs with the locks asked, for a menu that is opening: worked * out on the first call for this selection and page, and read back after. */ readonly withLocks: () => SelectionVerbs; } /** What the verbs are decided from. */ interface SelectionOfferInputs { readonly document: BlockDocument; readonly selectedId: string | null; readonly selectedIds: readonly string[]; readonly nesting: NestingSource; readonly mayCreatePattern: boolean; readonly lockRefusalFor: EditorState["lockRefusalFor"]; readonly components: ComponentVerbsOffer | undefined; readonly offersEditComponent: boolean; readonly sharedStyles: SharedStyleOffer | undefined; readonly movePosition: MovePosition; readonly placementRefusal: MoveJudge; /** The editor's size limits, which the "Turn into" choices are judged under. */ readonly limits?: DocumentLimits; } /** * The offer for the current selection, rebuilt only when one of its inputs * changes. The locks are asked on the first `withLocks` call for those * inputs, never while the selection merely changes. */ declare function useSelectionOffer(inputs: SelectionOfferInputs): SelectionOffer; /** Tells whoever listens that the offer a provider shares has changed. */ interface OfferSignal { /** Listen for changes; answers the call that stops listening. */ readonly subscribe: (listener: () => void) => () => void; readonly notify: () => void; } /** A signal with no listeners yet. */ declare function offerSignal(): OfferSignal; /** * The shared verbs with the locks asked, for a menu drawn outside the * provider (the Layers row menu, the block card's menu) while it is open. * * Read when the menu opens, read again once the page has settled, and read * again whenever the provider's offer changes, without asking the locks in * between: a menu opened on a block that was not selected selects it as it * opens, and the provider takes in the new selection after this menu has * first drawn, and an edit, a save or new lock rules can change the answers * while it stays open. Each offer answers with the same list each time, so a * reading that has not changed draws nothing more. */ declare function useAskedSharedVerbs(verbs: { readonly withLocks: () => readonly ToolbarAction[]; readonly subscribe?: OfferSignal["subscribe"]; } | undefined): readonly ToolbarAction[]; /** * The structural verbs, as callables. * * Published so a POINTER surface can press exactly what a keystroke presses. * The floating toolbar offers the same five actions, and a toolbar that applied * its own ops would be a second answer to "what does duplicate do" — which an * author meets as two buttons that disagree, months after the second one was * written. * * Every one is silent when it has no subject, so a caller may press any of them * without first asking whether it applies. `toolbarActions` answers that * separately, for drawing a control as unavailable rather than for guarding the * call. */ interface BlockActions { /** Move the selection one step in `direction`, lock permitting. */ readonly move: (direction: MoveDirection) => void; /** Delete the selection and everything inside it, lock permitting. */ readonly delete: () => void; /** Copy the selection in beside itself and select the copy. */ readonly duplicate: () => void; /** Put the selection on the clipboard, to paste on this page or another. */ readonly copy: () => void; /** Put the selection on the clipboard and remove it, lock permitting. */ readonly cut: () => void; /** Paste copied blocks where a clicked block would land. */ readonly paste: () => void; /** * Take the one selected block's look: its own values and the styles it * wears. Optional, so a host built before it keeps compiling. */ readonly copyStyle?: () => void; /** Give every selected block the copied look, as one undo step. */ readonly pasteStyle?: () => void; /** Select the container holding the selection. */ readonly selectParent: () => void; /** * Begin storing the selection in the pattern library. * * Unlike the four above it this runs NO op: it hands the gesture back to the * host, which owns the library, the form that names what is saved and the * write that stores it. It travels with the others because every surface over * these verbs — toolbar, context menu, palette — must reach it the same way, * and a second channel for one verb is how one surface comes to offer what * another cannot run. * * No keystroke is bound to it here. The others are direct manipulations of a * selection an author is looking at; this opens a form, and a shortcut that * opens a modal belongs to the host's own key map rather than to the canvas. */ readonly saveAsPattern: () => void; /** * Begin saving the block's look as a shared style, handed to the host as * the pattern save is. Absent where the host offers no shared styles. */ readonly saveAsSharedStyle?: () => void; /** * Open the selected placement's component in its own view, through the * host. Like Save as pattern it runs no op: where the component opens, and * whether this author may, are the host's. Silent for any other selection. * Optional, so a host built before it keeps compiling. */ readonly editComponent?: () => void; /** * Begin turning the selection into a component: replacing it with a * placement, or keeping it and saving a copy. Like `saveAsPattern`, this * hands the gesture to the host, which owns the form and the write. Absent * where the host offers no components. */ readonly turnIntoComponent?: () => void; /** Detach the selected placement, duplicate its component, update a pattern. */ readonly detachComponent?: () => void; readonly duplicateComponent?: () => void; readonly updatePattern?: () => void; /** Put the selected blocks in a new Box at their place, as one step. */ readonly wrapInBox?: () => void; /** Replace the selected container by its blocks, as one step. */ readonly unwrap?: () => void; /** * Turn the selected block into another type (`"core/heading"`), as one undo * step, saying what it removes or why it cannot. Optional, so a host built * before it keeps compiling. */ readonly turnInto?: (to: string) => void; /** * "Turn into" for a block in a page the caller holds rather than the * selection: the format bar's, which writes the words typed first and turns * the block in the page that left. The same judging and words as * {@link turnInto}. */ readonly turnIntoIn?: { readonly choices: (document: BlockDocument, id: string) => readonly TurnIntoOffer[]; readonly run: (document: BlockDocument, id: string, to: string) => void; }; } /** * The verbs, for a surface rendered under {@link BlockKeyboardActions}. * * `null` until a provider is above it, which {@link useBlockActionsContext} * turns into a thrown error rather than a silently inert toolbar. */ declare const BlockActionsContext: React$1.Context; /** * The nesting rules the editor is judging placements by, for surfaces below it. * * A SECOND context rather than a field on {@link BlockActions}, because the two * are different kinds of thing: those are verbs to run, this is a rule source to * ask. Folding it in would make every consumer of the verbs re-render when a * host swapped its rules, and would put a non-verb in a type whose name promises * verbs. * * `null` means no provider, which {@link useNestingSource} answers with the * registry — the same default every surface here already applies. */ declare const NestingContext: React$1.Context; /** * The verbs for the current selection, computed once for every surface. * * The bar, the right-click menu and the palette each need the same list, and * `toolbarActions` is not a cheap read: deciding whether a selection can be * saved BUILDS the document a save would store — it clones the selected forest, * re-identifies it and surveys the result — because that is what makes the * answer exact. Asked three times, an ordinary edit copies and walks a large * selection three times before anything is drawn. * * Published from here because this is the one place above all three that * already holds the editor and the rules they must agree about. */ declare const SelectionActionsContext: React$1.Context; declare function useSelectionActionsContext(): SelectionOffer | null; declare const ToolbarFocusContext: React$1.Context; /** * The nearest provider's toolbar focus slot, or `null` outside one: the * block toolbar puts its focus call here for Alt+F10. */ declare function useToolbarFocusSlot(): ToolbarFocusSlot | null; /** * The verbs from the nearest {@link BlockKeyboardActions}. * * Throws when there is none. A toolbar without them would render its buttons * and do nothing on every press, which looks like a broken editor rather than * like a missing wrapper — and it would reach a person before it reached a * developer. */ export declare function useBlockActionsContext(): BlockActions; /** * The nesting rules to judge a placement by, from the nearest provider. * * Falls back to the registry, which is what the canvas, the insert panel and the * keyboard route all default to — so a surface outside a provider answers the * way it did before this existed. * * It exists because a host MAY supply its own rules, and until this a surface * had no way to reach them: `BlockKeyboardActions` took a `nesting` option and * kept it, so the keyboard enforced the host's rules while the toolbar and the * context menu consulted the registry. One selection could then be offered on * one surface and refused on another, for the same document. */ declare function useNestingSource(): NestingSource; /** * Holds the call that finds an editor's block toolbar's tab stop, which * answers `null` while no bar is drawn. */ type ToolbarFocusSlot = React$1.MutableRefObject<(() => HTMLElement | null) | null>; /** * The verbs for the current selection, as a surface OUTSIDE the provider is * handed them: which are offered and why not, and a way to run one. * * The inspector is drawn beside the canvas rather than under this provider, * and its card offers Duplicate and Delete. Handing it these is what keeps * that menu to the toolbar's verdicts and verbs rather than a second copy. */ interface SharedBlockVerbs { /** What to show while no menu is open: the locks are not asked. */ readonly actions: readonly ToolbarAction[]; /** The same verbs with the locks asked, for a menu as it opens. */ readonly withLocks: () => readonly ToolbarAction[]; /** Listen for a change to what `withLocks` would answer; optional. */ readonly subscribe?: OfferSignal["subscribe"]; readonly run: (id: ToolbarActionId) => void; } interface BlockKeyboardActionsOptions { /** * The editor whose document these move blocks in. * * The whole state rather than a document and an `apply` separately: the move * is computed against a document and applied through a store, and passing * them apart lets a caller hand a document from one render to an `apply` * bound to another. */ editor: EditorState; /** * The nesting rule source, for explaining a refused move. * * Optional, defaulting to the registry — which is what the canvas asks, so a * refusal reads the same whether the author dragged the block or moved it * with the keyboard. Present as an option only so a test can supply a rule * set without registering blocks globally. */ nesting?: NestingSource; /** * The component definitions the canvas draws, for judging a moved instance. * * An instance node's own type is not a registered block, so the nesting * rule restricts it nowhere; a move is judged by the ROOTS of the definition * it draws instead, resolved through this map as a drop of the same instance * is (`placementTypesOf`). Optional, because a host whose library has not * loaded has nothing to resolve against — an unresolvable instance is judged * by its own type, which is how a placeholder stays movable. */ definitions?: ComponentLookup; /** * Begin storing the selection in the library, when the author asks to. * * Supplied by the host because everything the gesture needs is the host's: * which collection a pattern goes in, what it is called, and the route that * writes it. Nothing here can do any of that, and a builder that guessed would * be guessing about somebody else's schema. */ onSaveAsPattern: () => void; /** * Whether the author may create a pattern at all. Defaults to true. * * Supplied by the host for the same reason `onSaveAsPattern` is: the grant is * held against the collection a pattern goes in, a site may have renamed it, * and nothing here can know either. A builder that guessed would be guessing * about somebody else's schema. * * Permissive while unknown — see `toolbarActions`, which explains why this one * refusal defaults the opposite way to the rest. */ mayCreatePattern?: boolean; /** * Open a placed component in its own view, given its id and the * placement's node id. Supplied by the host, which knows where that view is * and whether this author may update components; omitted, "Edit component" * is not offered anywhere. */ onEditComponent?: (componentId: string, nodeId: string) => void; /** * Whether the bindings are live. Defaults to true. * * A host that mounts the canvas inside something modal turns them off rather * than unmounting the canvas, so the selection survives whatever is over it. */ enabled?: boolean; /** * Begin typing the selected block's text in place, reporting whether it * could be. * * The keyboard route to the gesture a double-click performs. A pointer-only * way into editing would leave the text of every block unreachable without a * mouse, which is the plainest kind of WCAG 2.1.1 failure — and it is a real * one here, because the canvas is where the text is. * * Optional: a host that has not wired inline editing registers no binding at * all, rather than one that presses and does nothing. */ onEditText?: (nodeId: string) => boolean; /** * Making components from a selection, where the host has a component * library: whether the author may, and the gestures that open the host's * forms. Absent, neither verb is offered. */ components?: ComponentVerbsHost; /** * Saving a block's look as a shared style, where the host has the site's * shared styles: what it knows of them and the author's right, and the * gesture that opens its form. Absent, the verb is not offered. */ sharedStyles?: SharedStyleVerbHost; /** * Esc pressed with no block selected, which otherwise does nothing: a host * editing a look on its own leaves it, back to editing blocks. * * @experimental Settles with the Design panel's Block looks group. */ onEscapeWithoutSelection?: () => void; /** * The header or footer selected on the canvas, while one is: Delete and * Backspace then remove nothing and announce `refusal`, the host's words * for where it is changed ("The site header isn't part of this page. * Change it in Page settings."). The other block keys have no subject. */ selectedRegion?: { readonly refusal: string; }; /** * "/" pressed with a block selected, or with nothing selected, while no * text is being typed: the host opens its in-place picker there, adding * by the placement rule. Absent, "/" is left to the browser and Help does * not list it. * * @experimental Settles with the in-place picker. */ onAddBlockHere?: () => void; } /** * The host's side of "Save as shared style…". * * @experimental Settles with the shared-styles editor. */ interface SharedStyleVerbHost extends SharedStyleOffer { readonly onSaveAsSharedStyle: () => void; } /** * The host's side of "Turn into component…". * * @experimental Settles when the composition API ships. */ interface ComponentVerbsHost extends ComponentVerbsOffer { /** * Open the form, told which way is open: replacing the selection with a * placement, keeping it and saving a copy, or both, with the reason for a * way that is not. */ readonly onTurnIntoComponent: (choice: TurnIntoChoice) => void; /** Detach the selected placement. Absent, with no definitions, Detach is not offered. */ readonly onDetachComponent?: () => void; readonly onDuplicateComponent?: () => void; /** Update a pattern. Absent, with no `mayUpdatePattern`, it is not offered. */ readonly onUpdatePattern?: () => void; } /** The verbs the host runs for the menu's component group. */ type ComponentVerbId = "turn-into-component" | "detach-component" | "duplicate-component" | "update-pattern"; /** The host's gesture for one component verb, if it offers it. */ declare function componentVerbRunner(host: ComponentVerbsHost, id: ComponentVerbId, choice: () => TurnIntoChoice): (() => void) | undefined; /** What the hook hands back: the region's text, and the verbs behind the keys. */ interface BlockKeyboardActionsResult { /** The live region's current text. Owned by one region and one only. */ readonly announcement: string; /** The same verbs the keystrokes run, for a pointer surface to press. */ readonly actions: BlockActions; /** * The rules this resolved placements by: the host's, or the registry. * * Returned so the provider can publish the SAME source it enforced, rather * than every surface below resolving the default again and a host-supplied * one reaching only the keyboard. */ readonly nesting: NestingSource; /** * What to OFFER for the current selection, computed once for every surface. * * Told apart from {@link BlockKeyboardActionsResult.actions} by the question * each answers: those are verbs to RUN, this is the list of what may be run * and why not. Returned so the provider publishes the same list it built * rather than each surface rebuilding it — and rebuilding it is not cheap, * because deciding whether a selection can be saved builds the document a * save would store. Its depth moves are judged with the position function * the move verb itself runs; its locks are asked only by a menu that opens. */ readonly offer: SelectionOffer; /** `offer.actions`, as this result has always carried it. */ readonly selectionActions: ToolbarAction[]; /** `offer.depthMoves`, as this result has always carried it. */ readonly depthMoves: SelectionOffer["depthMoves"]; /** * Where this editor's block toolbar puts the call that finds its tab stop, * for Alt+F10 to focus. Held per editor rather than looked up in the * document, which may hold another editor's toolbar first. */ readonly toolbarFocus: ToolbarFocusSlot; /** * Where the canvas's frame is put for Escape to send focus back to, filled * by {@link BlockKeyboardActions}. Empty, Escape moves the selection from * wherever it is pressed. */ readonly canvasFrame: CanvasFrameSlot; /** * Copy, Cut and Paste, for the clipboard events {@link BlockKeyboardActions} * listens for: the same verbs the menus run, writing to the event in hand. */ readonly clipboard: BlockClipboardVerbs; } /** * Holds the canvas's frame, or `null` while there is none. * * A slot rather than a context read inside the hook: the canvas frame's * context changes with every zoom and resize the canvas reports, and the * Escape binding needs only the frame, when the key lands. Filled by a child * of its own, so a resize re-renders that child alone. */ type CanvasFrameSlot = React$1.MutableRefObject; /** * The bindings, and why these keys. * * `alt+ArrowUp`/`alt+ArrowDown` is the line-move gesture from VS Code and the * editors that copied it, so it arrives already known rather than needing to be * taught. `alt+ArrowLeft`/`alt+ArrowRight` follows the indent convention every * outliner and list editor shares, and it matches the axis the rule itself * names — `indent` and `outdent` are its own words for the effect. * * Deliberately NOT Gutenberg's `mod+shift+alt+T`/`Y`. A four-key chord for the * commonest structural edit in the editor is undiscoverable and awkward on a * laptop, and the two letters carry no relationship to the direction they move. */ declare const MOVE_KEYS: ReadonlyArray<{ keys: string; direction: MoveDirection; description: string; }>; /** * What each effect is announced as. * * Derived from the effect the rule already decided rather than inferred here * from the direction pressed. `alt+ArrowLeft` is `outdent` only when there is a * container to leave, and re-deriving it from the keystroke would announce a * move out of a group that never happened. * * Three sentences rather than one, because the three are not the same event to * someone who cannot see the result: reordering keeps a block among its * siblings, while indenting and outdenting change which block CONTAINS it. */ declare const EFFECT_ANNOUNCEMENT: Readonly>; /** * How a deletion is announced. * * Names what went AND how to get it back. A screen-reader user cannot see an * undo control, so for them the announcement is the only place the recovery * path exists — and a container takes its children with it, which is invisible * from the block they had selected: a collapsed section looks exactly like an * empty one. * * The count is stated rather than prompted for. A confirmation on every delete * is friction people learn to click through, so it stops being a decision and * becomes a keystroke — protecting nobody while costing everybody. That trade * only holds because undo is reachable, which is why these ship together. */ /** * @param name - what to CALL the block, already resolved by the caller. * * A resolved name rather than a type, so the one rule that decides what a block * is called lives in `layerLabel` and this only phrases it. Taking a type and * resolving here would put a second resolution in the one surface a * screen-reader user hears — and it would have to reach for `blockLabel`, which * knows nothing about the name the author gave this instance. */ declare function deletionAnnouncement(name: string, descendants: number): string; /** How the undo shortcut is READ ALOUD, which is not how it is parsed. */ declare const UNDO_KEYS_SPOKEN = "Control or Command Z"; /** * The shared verb list, or `null` when there is no provider above. * * Deliberately NOT "compute it for me": a caller that handed this a fallback to * run would have to be told when to run it, and the honest answer — whenever * anything the fallback closes over changes — is exactly what this hook cannot * see. Written that way it memoised on the context alone, so a surface outside a * provider kept its FIRST answer for ever: stale availability and stale refusal * reasons on every later selection. * * Answering `null` hands that decision back to the caller, which is the only * place the inputs are known. */ /** * The sentence for ops the editor's locks refuse, or null when they keep every * lock: the editor's own question, worded as every lock refusal is. */ declare function lockSentence(editor: Pick, ops: readonly BuilderOp$1[]): string | null; /** * Register the move bindings for as long as the caller is mounted. * * The verbs come back as well as the announcement, and the reason is the one * this hook's earlier note argued against: a returned handler could be bound to * a second set of keys. What settles it is that the alternative is worse. The * toolbar needs the same five verbs AND the same live region, and a surface * that reimplemented either would produce two answers to one gesture — a second * region that talks over the first, or a button whose op drifts from its * keystroke's. Sharing them is what keeps there being one of each. * * The keys stay this module's alone: nothing here is bindable by a caller, and * {@link BlockKeyboardActions} is the only supported way to reach the verbs. */ export declare function useBlockKeyboardActions({ mayCreatePattern, editor, enabled, onEditText, nesting, definitions, onSaveAsPattern, onEditComponent, components, sharedStyles, onEscapeWithoutSelection, onAddBlockHere, selectedRegion }: BlockKeyboardActionsOptions): BlockKeyboardActionsResult; /** * The bindings as a component, for mounting inside the shell. * * `BuilderShell` provides the shortcut context, so the hook cannot be called by * whatever RENDERS the shell — only by something inside it. A host would * otherwise have to invent a null-returning wrapper of its own, and every host * would invent a slightly different one. * * Renders the live region, and publishes the verbs to whatever it wraps. Both * belong to the same mount deliberately: a toolbar reachable without the region * could act without announcing, and a keyboard author would meet a button that * changes the page and says nothing. * * `children` is optional. A host that wants only the keystrokes passes none and * gets exactly what this rendered before. */ export declare function BlockKeyboardActions({ onShareVerbs, children, ...options }: BlockKeyboardActionsOptions & { readonly children?: React$1.ReactNode; /** * Called with the verbs whenever they change, and with `undefined` when this * provider goes, for a surface drawn outside it. */ readonly onShareVerbs?: (verbs: SharedBlockVerbs | undefined) => void; }): React$1.JSX.Element; /** * The block verbs the card's menu runs, handed in by the host: the SAME verbs * and verdicts the toolbar, the context menu and the palette use, rather than * a second implementation here. A menu that decided for itself whether Delete * was allowed is how one surface comes to offer a verb another refuses. */ type CardVerbs = SharedBlockVerbs; interface BlockCardProps { /** The block's icon concept, if it names one. */ readonly icon: string | undefined; /** What the block is: "Heading", "Image". */ readonly type: string; /** The author's own label for this block, empty when there is none. */ readonly name: string; /** One line about the block, from its definition. */ readonly description: string; /** Which locks hold it. */ readonly lock: BlockLockStatus; /** Store a new label, or remove it with an empty one. Omitted withholds Rename. */ readonly onRename?: ((name: string) => void) | undefined; /** Set or lift the Layers lock. Omitted withholds Lock and Unlock. */ readonly onLock?: ((locked: boolean) => void) | undefined; /** * Why Lock and Unlock are held here, when they are: shown disabled with * this reason rather than left out, so the menu says why. */ readonly lockHeld?: string | undefined; /** The shared block verbs, when the host supplies them. */ readonly verbs?: CardVerbs | undefined; /** The id the lock reason takes, so held controls can point at it. */ readonly reasonId?: string | undefined; /** * The block it belongs to, where it sits in one that names its children * (a picture in a gallery): the title it reads by while it has no name of * its own, the words after it, and the way back to the block it is in. */ readonly placedIn?: PlacedIn | undefined; /** * The region of the page's layout the block is in, while that region is * edited in place ("Site header"): the title then reads "Navigation · in * Site header", so the author always sees which document they are editing. */ readonly inRegion?: string | undefined; } /** A block named by where it sits, and the way back to what it sits in. */ interface PlacedIn { /** Its title while unnamed: "Picture 2". */ readonly title: string; /** What follows the title: "in Team photos". */ readonly within: string; /** The button's words: "← Back to the gallery". */ readonly backLabel: string; readonly onBack: () => void; } declare function BlockCard({ icon, type, name, description, lock, onRename, onLock, lockHeld, verbs, reasonId, placedIn, ...where }: BlockCardProps): React$1.JSX.Element; /** * The card for several selected blocks: how many, and a menu with the one * control well defined across a set, the lock. */ declare function SelectionCard({ count, lock, unlocking, held, onLock }: { count: number; /** The lock across the set; `mixed` when some are locked. */ lock: "locked" | "unlocked" | "mixed"; /** Whether the menu unlocks rather than locks. */ unlocking: boolean; /** How many of them sit where their own lock can't change here. */ held: number; /** Lock or unlock the blocks it may change; omitted when there are none. */ onLock: (() => void) | undefined; }): React$1.JSX.Element; /** * 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[]; } /** The section's name in Advanced, which its fold is remembered by. */ declare const CUSTOM_CSS_SECTION = "Custom CSS"; /** The section's key in the Advanced tab's accordion. */ declare const CUSTOM_CSS_KEY = "custom-css"; /** The setting's id, as the settings index and an ask for it name it. */ declare const CUSTOM_CSS_SETTING = "customCss"; /** The Layers mark's words: its tooltip and its accessible name. */ declare const HAS_CUSTOM_CSS = "Has custom CSS"; /** * Whether a block holds custom CSS: a stored value with more than white * space in it. One answer for the Layers mark, the Style tab's line, the * section's value dot and "Only changed". */ declare function holdsCustomCss(node: Pick | undefined): boolean; /** * The op that stores a block's CSS, or removes it once the box is emptied, so * a block whose CSS was cleared keeps no empty value behind. One update, so it * is one undoable step. */ declare function customCssOp(nodeId: string, css: string): BuilderOp$1; /** Whether the site's breakpoints are its own set yet, as the editor reads it. */ type BreakpointsStatus = "loading" | "unavailable" | "ready"; interface HideOnProps { readonly editor: EditorState; readonly nodeId: string; /** The site's breakpoints. */ readonly breakpoints: BreakpointSet | undefined; /** The device being edited, marked among the others. */ readonly editing: string; /** * Whether `breakpoints` is the site's own set: while it is being read, or * when the read failed, the toggles are held, since a change resolved * against a stand-in set is stored wrong, and a sentence says which. */ readonly status?: BreakpointsStatus; /** * Why a lock holds the block's design, which includes where it shows, or * `undefined` while nothing does: the inspector's own reading, which holds * every other design control. */ readonly heldBy?: string | undefined; /** The id of the element saying why, which held toggles point to. */ readonly reasonId?: string; } declare function HideOn({ editor, nodeId, breakpoints, editing, status, heldBy, reasonId }: HideOnProps): React$1.JSX.Element | null; /** * The line at the top of a tab while the block is hidden on any device: * "Hidden on Mobile. Visitors on that device won't see it." From a tab other * than Advanced it ends in "Change", which takes the author to Hide on. * Nothing while the block shows everywhere. */ declare function HiddenStatus({ editor, nodeId, breakpoints, onChoose }: { readonly editor: EditorState; readonly nodeId: string; readonly breakpoints: BreakpointSet | undefined; /** * Show another tab, for "Change"; absent on the Advanced tab, where Hide * on is already in view. */ readonly onChoose?: ((tab: "advanced") => void) | undefined; }): React$1.JSX.Element | null; /** * Which look is meant: its id and its block type together. Two block types' * own looks may share an id, since an own look claims none, so the type is * what tells them apart. */ interface LookKey { readonly id: string; readonly blockType: string; } /** Whether a row is the look a key names. */ declare function sameLook(row: LookKey, key: LookKey | null | undefined): boolean; /** * A look's key as one string, for a map keyed by look: its block type and id * together, as {@link sameLook} compares them. JSON, since an id is any * string and no separator could be told apart from one. */ declare function lookKeyOf(look: LookKey): string; /** One look as the Design panel lists it. */ interface BlockLookRow extends SharedStyleRow { /** The block type the look belongs to. */ readonly blockType: string; /** * The block's own look: its styles are the site's edits to the type's * base, it is never a class, so its class name is empty and it has no * usage count of its own. */ readonly own: boolean; /** * Another entry in the library carries the own look's id, whether another * type's own look, a worn look or a shared style, so a write by id would * reach both: the look is shown, and held from editing. Always false for a * worn look. */ readonly sharedId: boolean; /** * The look carries ★: the one a block of its type has until another is * picked. The worn look the compiler reads as starred, or the block's own * look while no worn look of its type is. */ readonly starred: boolean; /** Hidden from the block panel's tiles; a block already wearing it keeps it. */ readonly hidden: boolean; } /** One block type's looks, its own look first. */ interface BlockLookGroup { readonly blockType: string; readonly rows: readonly BlockLookRow[]; } /** * Every block type's looks, in the order their first look sits in the * library, each type's own look first and then its worn looks in the order * that decides precedence. A type with only an own look is still listed, * since its own look is still the site's to edit. */ declare function blockLookGroups(library: readonly NamedClass[], suppliedIds: ReadonlySet): BlockLookGroup[]; /** * A block type's base as the site draws it: the block's own base styles with * the site's edits to its own look laid over. Every look's specimen of that * type is drawn on it, as the canvas draws the blocks. */ declare function siteBaseOf(library: readonly NamedClass[] | undefined, blockType: string): NodeStyles | undefined; /** Who an edit to a look reaches, in the words the editing bar shows. */ declare function lookReachWords(row: Pick, blockTitle: string): string; /** The Default chip's description: what a block's own look is to its type. */ declare function ownLookDescription(blockTitle: string): string; interface FontFamilyFieldProps { /** The control's id, so its label can point at it. */ id?: string; /** The id of the element naming the property. */ labelledBy?: string; /** What the block stores now. */ stored: StyleValue | undefined; /** The site's variables, whose font variables are offered first. */ tokens: SiteTokenSet | undefined; /** * The faces the page loads, or `undefined` while the site's style is being * read. Families with files are offered from them. */ faces: readonly FontFaceDef[] | undefined; /** The faces the site's code supplies, which the editor cannot remove. */ fromCode: readonly FontFaceDef[]; /** Store a choice, or `null` to clear the property. */ onCommit: (value: StyleValue | null) => void; /** * Draws the family the keyboard or the pointer is on in the open list, * before anything is stored; `null` once the list closes, said before a * pick's commit. Absent, nothing is drawn until a family is picked. */ onPreview?: (value: StyleValue | null) => void; /** Open Design's fonts, where fonts are added. Absent, no link shows. */ onManageFonts?: () => void; } /** * What the inspector's host knows about the site's fonts: the faces the page * loads, the ones the site's code supplies, and a way to Design's fonts. */ interface FontChoices { /** The faces the page loads, or `undefined` while they are being read. */ readonly faces: readonly FontFaceDef[] | undefined; /** The faces the site's code supplies. */ readonly fromCode: readonly FontFaceDef[]; /** Open Design's fonts. */ readonly onManageFonts?: () => void; } /** * The site's fonts, for the Font control wherever the inspector draws it. * * A context rather than a prop threaded through each section and field: only * one control reads it, and every layer between the panel and that control * would otherwise carry a value it never uses. */ export declare const FontChoicesContext: React$1.Context; /** Whether a stored value is one this control can show: none, a stack, a reference. */ declare function fontFamilyShowable(stored: StyleValue | undefined): boolean; declare function FontFamilyField({ id, labelledBy, stored, tokens, faces, fromCode, onCommit, onPreview, onManageFonts }: FontFamilyFieldProps): React$1.JSX.Element; /** How the edited element runs, in the two properties a box grid needs. */ interface SideOrientation { /** The element's `writing-mode`, which decides the axes. */ readonly writingMode: string; /** The element's `direction`, which decides which end of the inline axis starts. */ readonly direction: string; /** * How the element lays out its children, read in the same measurement, so * alignment icons follow the layout the canvas draws: its `display` and * `flex-direction`. Absent where none was measured. */ readonly display?: string; readonly flexDirection?: string; } /** * The orientation of the node's drawn element, or `undefined`. * * @param root - the canvas root the node is drawn under * @param nodeId - the block being edited * @returns the element's writing mode and direction, or `undefined` */ declare function orientationOf(root: HTMLElement | null | undefined, nodeId: string | null): SideOrientation | undefined; /** * The orientation of one element, or `undefined` when it cannot be read. * * @param element - the element to measure * @returns its writing mode and direction, or `undefined` */ declare function orientationOfElement(element: Element | null | undefined): SideOrientation | undefined; /** * The site's own direction, read from the canvas root, for editing that has * no element of its own on the canvas (a look). * * Only the axes are taken. The root's layout (`display`, `flex-direction`) is * the page's, not the block a look styles, so alignment icons are left to * draw as they do with no layout measured. * * Left to right where the root can't be read (not drawn yet, or no canvas): * a look is edited for the whole site, and a site that states no direction * runs left to right. * * @param root - the canvas root the page is drawn under * @returns the site's writing mode and direction */ declare function siteOrientationOf(root: HTMLElement | null | undefined): SideOrientation; /** A write that makes a block style: the new style's id, or why it wasn't made. */ type BlockStyleMade = { readonly ok: true; readonly id: string; } | { readonly ok: false; readonly reason: string; }; /** What the Block styles section asks of its host. */ interface BlockStyleActions { /** Make a block style for a type, named by the author, from the ★ style's values. */ readonly create: (blockType: string, name: string) => Promise; /** Copy a block style, built-in or the site's own, as the site's own. */ readonly duplicate: (id: string) => Promise; /** Rename a block style the site made: its name only, never its id or class name. */ readonly rename: (id: string, name: string) => Promise; /** Remove a block style the site made, refused while a page uses it. */ readonly remove: (id: string) => Promise; /** Hide a built-in block style from the block panel, or show it again. */ readonly setHidden: (id: string, hidden: boolean) => Promise; /** * Make a style the ★ of its type, the look its blocks have until another is * picked; `null` gives ★ back to the block's own style. */ readonly setDefault: (blockType: string, id: string | null) => Promise; } /** The Block styles section's words, as decided. */ declare const BLOCK_STYLE_WORDS: { readonly heading: "Block styles"; readonly line: "Saved looks for one kind of block. ★ is the look a block has until you pick another."; readonly sharedLine: "Your own styles for any block."; readonly setDefault: "Set as default ★"; readonly defaultChip: "★ Default"; readonly hidden: "Hidden"; readonly edit: "Edit"; readonly rename: "Rename"; readonly duplicate: "Duplicate"; readonly hide: "Hide"; readonly show: "Show"; readonly remove: "Remove"; }; /** "+ New button style": the add row that ends a block type's styles. */ declare function newStyleWords(blockTitle: string): string; /** * One action's class list: the whole list after it, composed from the list * the host's queue holds, or why it can't be stored. */ type ClassListEdit = (existing: readonly NamedClass[]) => { readonly classes: readonly NamedClass[]; } | { readonly reason: string; }; /** * The host's whole-list class write: the list `compose` makes stored as one * history step, answering the refusal in words, or nothing once stored. */ type EditClasses = (compose: ClassListEdit) => Promise; /** The host's removal of unused styles, answering the refusal in words. */ type RemoveClasses = (ids: readonly string[]) => Promise; /** * The Block styles section's writes over the host's one whole-list class * writer and its removal. Without a removal, removing is refused in words. */ declare function blockStyleActionsOf(edit: EditClasses, remove: RemoveClasses | undefined): BlockStyleActions; /** * How many CSS pixels a length is, or `undefined` for one this cannot measure * without a page: a percentage, a viewport unit, `clamp()`, a keyword. * * One reading of a length for every sample that sizes itself by one, the * Design panel's type specimen and the inspector's bars, so the two draw the * same variable at the same scale. */ declare function lengthInPx(value: string): number | undefined; /** The smallest and largest a fluid length comes to, in px. */ interface FluidRange { readonly minPx: number; readonly maxPx: number; } /** * What a length comes to at a page `width`, in px: a plain length as it * is, a clamp held between its bounds; `undefined` for what cannot be read. */ declare function pxAtWidth(value: string, width: number): number | undefined; /** A fluid length's range, from its clamp's bounds; `undefined` otherwise. */ declare function fluidRange(value: string): FluidRange | undefined; /** * The two sizes a written value comes to at the range's ends, rounded to * the px, to start "Fluid…" from on a value written by hand; `undefined` * for one that can't be read. */ declare function nearestFluidSizes(value: string, range: FluidRangeWidths): FluidSizes | undefined; /** * What each kind is called in the interface. * * Written out rather than derived from the union, because a label is a piece of * copy and `fontFamily` is not one. Keyed by the kind so adding a kind to the * engine surfaces here as a type error rather than as a tab labelled with its * own identifier. */ declare const TOKEN_KIND_LABELS: Readonly>; /** * An example value for a new token of each kind. * * A new row has to hold SOMETHING, and an empty value is refused by the emitter * — so a token created empty would arrive already broken, with an error the * author did not cause. These are the smallest valid value of each kind, chosen * to be obviously placeholder rather than plausibly deliberate. */ /** * A new shadow: one soft layer under the box, so it shows from the start. * It is also the layer the shadow control's "+ Add layer" adds. */ declare const NEW_SHADOW_VALUE = "0 4px 12px rgba(0, 0, 0, 0.12)"; /** One token as the studio draws it. */ interface TokenRow { /** * WHERE this token sits in the stored list, and the handle every edit uses. * * Not the identity, which is the obvious choice and is wrong: a legacy or * imported set can hold two entries with the SAME identity, and the read path * keeps both deliberately so the engine's complaint about the collision is * visible on the row that has it. Addressed by identity, every edit to the * second row would resolve to the first — so the one state the studio exists * to help an author repair would be the one state it cannot address. */ /** * Whether the ENGINE emitted this token, as `emitTokenBlocks` reports it. * * Carried rather than re-derived because the engine refuses on five separate * conditions — a name that is not a token name, no light value, a value the * guard rejects, a value that would fetch, and a collision on one custom * property — and a surface restating any of them agrees today and describes * a different stylesheet afterwards. A preview drawn for a token the page * does not carry is exactly that disagreement made visible. */ readonly written: boolean; readonly at: number; /** * A React key that survives a removal elsewhere in the list. * * The position cannot be one: deleting any non-tail token shifts every * following `at`, so React reuses the deleted row's component for its * successor and the uncontrolled fields and the confirm state come with it — * a successor showing the deleted token's values, still in removal * confirmation, one click from removing the wrong token. * * The identity cannot be one either, for the reason `at` exists: two entries * can share one. So the key is the identity plus which occurrence of it this * is, which is unique always and stable under any removal that is not of the * same identity — and when it IS, remounting is the correct answer, because * the row's meaning has changed. */ readonly key: string; /** What references STORE. Never changes once a token has been renamed. */ readonly identity: string; /** What the author reads and edits. */ readonly name: string; readonly kind: TokenKind; /** The value for the mode being shown, falling back to light. */ readonly value: string; /** * What this MODE itself holds, or `undefined` when it holds nothing. * * Distinct from {@link value}, which is what to display and therefore falls * back. An editor comparing a typed value against the display cannot tell * "unchanged" from "pinned to the same value the fallback was giving" — and * the second is a real edit, the one that fixes a dark value in place before * the light one is changed later. */ readonly stored: string | undefined; /** Whether the shown value belongs to this mode or is inherited from light. */ readonly inherited: boolean; /** * What the engine says about this token, empty when it is happy. * * Shown to the author rather than counted, because the messages name the * repair — "is a measurement, not a colour" tells them what to type next, and * a bare invalid flag does not. */ readonly issues: readonly string[]; } /** * The rows of ONE kind. * * Derived from {@link tokenRows} rather than projecting again, so a caller * asking for every kind pays for one pass over the set instead of one per * kind, and the two can never disagree about a row's key or its issues. */ declare function tokenRowsFor(tokens: SiteTokenSet | undefined, kind: TokenKind, mode?: TokenMode): readonly TokenRow[]; /** * Why this name cannot be used, or `undefined`. * * The GRAMMAR is the engine's own rule, which is the same one a stored * `$token` reference is held to — so a table cannot hold a name that no * reference could spell. Checked before the edit rather than after, because the * emitter's answer to a bad name is to drop the token silently. */ declare function tokenNameIssue(tokens: SiteTokenSet | undefined, at: number, name: string): string | undefined; /** * The set with one token renamed, its identity pinned where it already was. * * Delegates to {@link renameSiteToken} rather than spreading a new name over * the token, which is the whole point: that helper is the ONE place the freeze * rule lives, and a second expression of it here would be one edit away from * writing the new name as the identity and silently breaking every reference. */ declare function renameToken(tokens: SiteTokenSet, at: number, name: string): SiteTokenSet; /** * The set with one token's value changed, for one mode. * * Writing `dark` never disturbs `light`, because light is what a reader with no * mode set resolves and a token that lost it would vanish for them. */ declare function setTokenValue(tokens: SiteTokenSet, at: number, mode: TokenMode, value: string): SiteTokenSet; /** The site's fluid range: its own, else 360px to 1280px. */ declare function fluidRangeOf(tokens: SiteTokenSet): FluidRangeWidths$1; /** * The set with a new fluid range, and every size made with "Fluid…" made * again across it from its own two sizes, so each still reads the same at * the smallest and the largest screen. A fluid value written by hand, the * built-in spacing among them, has no sizes and is left as it is. One set, * so the range and the sizes it remakes are saved and undone together. */ declare function setFluidRange(tokens: SiteTokenSet, range: FluidRangeWidths$1): SiteTokenSet; /** * The set with a size made fluid from two sizes: its light value grows * from `small` on the range's smallest screen to `large` on its largest, * and the two sizes are kept beside it so it can be made again when the * site's fluid range changes. */ declare function setFluidSize(tokens: SiteTokenSet, at: number, sizes: FluidSizes$1, range: FluidRangeWidths$1): SiteTokenSet; /** * What a dark line height is told when it would need a kind other than * light's. A token has one kind, and a number token refuses a length as surely * as a length token refuses a number; the light value is the one that sets it. */ declare const LINE_HEIGHT_MIXED = "Light and dark line heights are both numbers, like 1.4, or both lengths, like 24px. Use the light value first to change which."; /** What writing a variable's value comes to: the new set, or why not. */ type TokenValueWrite = { readonly tokens: SiteTokenSet; /** Something the write changed beyond the field, said in words. */ readonly note?: string; } | { readonly issue: string; }; /** What the author is told when a light line height's new kind drops dark. */ declare const DARK_FOLLOWS_LIGHT = "Dark now follows the light value."; /** * The set with one variable's value changed for one mode, or why it cannot be. * * Every variable but one is {@link setTokenValue}. A line height is the one * value that is right as a plain number or as a length, so its KIND follows * what is written: held as a `dimension`, `1.4` is a number where a length * belongs, and the save is refused for it. A value no line height can be is * refused here, in words, rather than stored for the page to drop. * * The LIGHT value sets the kind. A light edit of the other kind drops a dark * value that no longer fits, so dark follows light, and says so; a dark edit * of a kind other than light's is refused. Otherwise, with both modes set as * lengths, neither could be the first to become a number. */ declare function writeTokenValue(tokens: SiteTokenSet, at: number, mode: TokenMode, value: string): TokenValueWrite; /** * The set with one token's dark value REMOVED, so it follows light again. * * Distinct from writing the light value into dark, which looks identical on * screen and is not the same document: an explicit dark value stops tracking * later edits to light, so the two drift apart the next time anyone changes the * light one. */ declare function clearDarkValue(tokens: SiteTokenSet, at: number): SiteTokenSet; /** * The set without the token at this position. Any reference stops resolving. * * By POSITION rather than by identity, so removing one of two entries that * share an identity removes exactly one. Filtering on the identity would take * both, which is the opposite of what an author repairing a collision means. */ declare function removeToken(tokens: SiteTokenSet, at: number): SiteTokenSet; /** * The set with a new token of this kind appended, and where it landed. * * The position comes back because the panel has to address the new row, and * finding it afterwards by name or identity would break the moment two tokens * share one — which is a state this table can legitimately be in. * * Created with NO `id`, so its identity is its name until the first rename * freezes one. That is the same shape every token stored before `id` existed * has, which is why nothing needs migrating. */ declare function addToken(tokens: SiteTokenSet | undefined, kind: TokenKind): { tokens: SiteTokenSet; at: number; }; /** The groups the Design panel shows variables in, in order. */ type VariableGroup = "colours" | "type" | "fonts" | "spacing" | "radius" | "shadows" | "content" | "other"; /** The Design panel's tabs, by kind, in the order they are shown. */ type DesignTab = "colours" | "type" | "spacing" | "styles"; /** * The variable groups each Design tab lists, in order: a font and a weight * sit with the type sizes, and what belongs to no other group ends Spacing. * Styles lists none. */ export declare const DESIGN_TAB_GROUPS: Readonly>; /** * The groups narrowed to a search, matched on the name shown only: the code * name is hidden, so a match on it would list a row with nothing in it that * matches what was typed. The one rule for a variable search, so a count * beside a tab and the rows that tab lists cannot disagree. */ export declare function searchVariableGroups(groups: readonly G[], needle: string): G[]; /** * Every group with its heading, in the order the Design panel lists them, for * a list elsewhere that groups variables the same way. */ declare function variableGroupHeadings(): readonly { group: VariableGroup; heading: string; }[]; /** The families a length variable belongs to, each made for its own fields. */ type LengthFamily = "font-size" | "line-height" | "spacing" | "radius"; /** * The family a length variable belongs to, read from its code name as the * Design panel groups it, or `undefined` for a length that names none (a * content width) and for anything that is not a length. * * The inspector offers each field its own family, so a padding lists the * spacing steps and a radius the radii; asked here so the Design panel's * groups and the inspector's lists cannot disagree about what a variable is. */ declare function lengthFamilyOf(token: { name: string; kind: TokenKind; }): LengthFamily | undefined; /** * The CSS property a type-scale variable is made for: `font-size` for a type * size, `line-height` for its paired line height, or `undefined` for any other * variable. * * Read from the code name, as the Design panel groups by it, and asked here * once so the panel's "Type scale" group and the inspector's offer of a type * size only where text is sized cannot disagree about what a type size is. */ declare function typeScaleProperty(token: { name: string; kind: TokenKind; }): "font-size" | "line-height" | undefined; /** * Which group a variable belongs in: by kind for colours and shadows, and by * its code name for the lengths, since a size, a gap and a radius are all * dimensions. * * Exported so the inspector's variable list groups exactly as Design does. */ declare function variableGroupOf(token: { name: string; kind: TokenKind; }): VariableGroup; /** One row of the Design panel. */ interface VariableEntry { /** The variable itself; for a type size, its font size. */ readonly row: TokenRow; /** The plain name shown: the label, or one derived from the code name. */ readonly label: string; /** A type size's line height, paired by name, when there is one. */ readonly lineHeight?: TokenRow; /** * What kind of variable it is, in words ("radius"), when another row is * shown under the same name: `space.card` and `radius.card` both read * "Card", and side by side nothing else says which is which. */ readonly kindWord?: string; } /** * Every group with its rows, Other included even when empty: the panel * decides what an empty group shows. * * A font size and the line height of the same name are ONE row, so a type * size reads as "16 / 26" the way designers write it. A line height with no * size of its own still gets a row. */ declare function variableGroups(tokens: SiteTokenSet | undefined, mode?: TokenMode): readonly { group: VariableGroup; heading: string; entries: readonly VariableEntry[]; }[]; /** * How many variables a search matches in each Design tab that lists * variables: the rows each tab would list, counted, through the same groups * and the same search the tab draws with, so a count beside a tab and the * rows under it cannot disagree. */ export declare function variableMatchesByTab(tokens: SiteTokenSet | undefined, needle: string): Readonly, number>>; /** * Why this label cannot be given to the variable at `at`, or nothing. * * The engine's rule for a label, plus one of the panel's own: two variables * shown under one name cannot be told apart in a list or a picker. */ declare function variableLabelIssue(tokens: SiteTokenSet | undefined, at: number, label: string): string | undefined; /** * The names shown for more than one variable in a set, once each, ignoring * case, since "Brand" and "brand" cannot be told apart in a list. * * The same rule {@link variableLabelIssue} holds one edit to, asked of a whole * set, as an import produces one. */ declare function labelClashes(tokens: SiteTokenSet): string[]; /** * The set with one variable's label changed. A blank label is removed, so the * derived label shows again and nothing is stored for it. */ declare function relabelToken(tokens: SiteTokenSet, at: number, label: string): SiteTokenSet; /** What a group's "+" can add. */ type NewVariable = "colour" | "type size" | "spacing" | "radius" | "shadow" | Exclude; /** * The set with a new variable for a group's "+", and where it landed. * * Named so its derived label reads in plain words ("New colour") until the * author names it. A type size adds its line height too, under the same * name, which is what pairs them. */ declare function addVariable(tokens: SiteTokenSet | undefined, what: NewVariable): { tokens: SiteTokenSet; at: number; }; /** * The set with a just-added variable labelled, and its code name made from * that label (`Heading 1` gives `font-size.heading-1`), its line height * following. * * Only for a variable created moments ago, which nothing can reference yet: * once a variable may be in use, its code name stays put and only the label * changes, through {@link relabelToken}. */ declare function labelNewVariable(tokens: SiteTokenSet, at: number, label: string): SiteTokenSet; /** * The set with a copy of one variable right below it, and where the copy * landed: the same values, labelled "