Docs

The preview protocol

The messages between the Capa editor and your page, for stacks other than Next.js.

View as Markdown

Every message is { source, v: 1, type, ...fields }. source is capa-admin on the admin's messages and capa on the site's. The admin sends hello, highlight { entryId, field } (entryId: "" clears), outline { on } and refresh. The site answers ready { path, entries } after every hello and every navigation, select { entryId, field } on a click, and hover. acceptMessage(event, allowedOrigins, parent) is the site's filter, exported for your own tests.

The site also sends visible { entryId, field } while the page scrolls (at most every 150ms, and only when it changes): the tagged element at the centre of the viewport, chosen by pickCentred. At the very top of a page, where a heading can never reach the centre, it is the topmost visible element instead, and at the very bottom the bottommost. The editor's "Follow the page" scrolls the form to that field. An overlay older than 1.0.0-next.2 never sends it, and the editor then does not follow.