Templates and locking

How a templated document differs from a free one.

A template is a document blueprint that you (or someone else) reuses to start new documents. A template can be free — meaning the new document is just a duplicate that you can edit freely — or it can be locked, restricting which parts of the document the user is allowed to edit.

Locking matters in two situations:

  1. Standard operating procedures where the steps must run in a fixed order, with fixed reagents, but the operator fills in observations as they go.
  2. Regulated forms (IACUC submissions, GxP procedure runs) where the language is institutionally approved and must not be changed without re-approval.

The three lock states

Try each — the demo below is fully interactive:

Blocks fixed; text inside still editable.
  1. 1
  2. 2
  3. 3
  4. 4
Structure is locked. Text edits are still allowed — useful for templated SOPs where you want notes inline but no skipped steps.
Switch the lock mode at the top. The structure-locked mode is what most SOPs use.

Behind the scenes, locking has three independent layers, all stored in the document's real-time state:

enabled
Master switch. Off → no locking at all.
structureLocked
When true, blocks cannot be added, removed or reordered. Text content still editable unless overridden.
defaultTextLock
Default text-edit policy for paragraphs and headings. Either "locked" or "editable".
nodeLocks
Per-block overrides. A block can be marked "locked", "editable", or "partial" (some attribute fields editable, others not).

partial is what makes form-style templates possible. A registration-table block can have schemaColumns locked but data editable, so an operator appends rows without touching the schema. The lock controls in template-edit mode write locked and editable; a partial rule with its editableFields list has to be written into the stored lock config directly, and only the editor plugin enforces it. The server validator checks fully locked blocks, so partial is a UX guard, not a trust boundary.

How a templated document differs from a free document

When you create a document from a template, the lock configuration travels with it. Three things happen:

  • The editor's slash menu is not mounted at all when structure is locked, so no block can be inserted.
  • The document's outline and block IDs are pre-populated; lock state travels with the document and is preserved through every edit.
  • The server independently re-validates every save against the lock config — client-side enforcement is for UX, server-side enforcement is for trust.

Versioning

Templates are versioned. Editing a template creates a new version (v1, v2, …) with an optional changelog. Documents track which template they came from and which version, so a document can be traced back to the exact template revision it came from. Editing a template never changes documents already created from it: they keep the content and the version they were created with.

If you publish the template to dalea.market, each release is immutable; yanking marks a release as unsafe but doesn't delete it.

What's next