How the canvas renders

From template and sample data to the sandboxed preview frame. How it works in the DocStudio designer interface.

The canvas is a thin layer over the same pipeline that produces the output.

Steps

  1. Take the template and the sample data. Collections in the sample are capped to the preview row count.
  2. Compile. compile migrates, validates, resolves configuration, expands reusable components and binds the data. The result is the resolved document tree and diagnostics.
  3. Render. render turns the tree into HTML and CSS for the chosen target: screen, print or pdf.
  4. Show. The HTML is set as the content of a sandboxed frame. Updates replace the content on the same frame without remounting it.
  5. Measure. The designer finds each element through its data-ds-id attribute and measures it with its bounding box.
  6. Overlay. Selection, handles, guides and the drop indicator are drawn in the designer's own layer from those measurements.

Why this matters

  • The preview and the output share all code, so they cannot drift apart.
  • Overlay rectangles match the elements to within one CSS pixel.
  • The designer never builds document markup itself.

The sandbox

The frame uses sandbox="allow-same-origin" without scripts, has a content security policy that allows only inline styles and data: or https images and fonts, is not part of the tab order and ignores pointer events while you drag. Nothing in a template or in data can run code in the designer.

Compile limits

The canvas compiles with the editor's limits. Above the node limit the editor refuses the change. Compile problems are reported in the Problems tab.

Canvas-only styling

Two small changes apply to the canvas only: the Screen backdrop and shadow are removed and the frame document cannot scroll inside itself. A test confirms that the rendered document is otherwise identical to the output.

See Rendering pipeline and Renderer.