Skip to content
HomePagesHomePages template kit

EditorBridge

The one object an editor canvas publishes for islands, on {@link EDITOR_BRIDGE_PROP}.

The one object an editor canvas publishes for islands, on {@link EDITOR_BRIDGE_PROP}. The host constructs it before hydrating any island; hooks only read it. Publishing a selection change means REPLACING selection with a new object (never mutating the current one — subscribers treat the reference as the change signal) and then calling every subscribed listener.

An island bundle is immutable once published, so the two sides may only ever diverge additively: bridge fields are added, never changed or removed, and {@link EDITOR_BRIDGE_PROTOCOL} bumps only on an unavoidable break. A hook meeting a bridge with a different protocol degrades to published-page behavior with a console warning — it never throws.

Import from @homepages/template-kit or @homepages/template-kit/island-runtime.

export interface EditorBridge {
protocol: number;
selection: EditorBridgeSelection | null;
subscribe(listener: () => void): () => void;
}