Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Docs Plugin (@lapis-notes/docs)

Source: packages/plugins/plugin-docs/src/

Manifest: id lapis-docs, version 0.1.0, min app version 0.20.0.

The docs package owns Univer-backed editing for native .lapisdoc and .lapissheet files. It ships as the official installable lapis-docs registry plugin instead of through the bundled workspace bootstrap.

Runtime Surface

  • View types: docs-document, docs-sheet.
  • Extensions: .lapisdoc, .lapissheet.
  • Commands: lapis-docs:create-document, lapis-docs:create-sheet.
  • Package exports: plugin runtime entry at @lapis-notes/docs, app stylesheet at @lapis-notes/docs/app.css, and standalone stylesheet artifact at @lapis-notes/docs/styles.css.
  • Official registry entry: lapis-docs in the locked lapis-official source, advertising .lapisdoc and .lapissheet editor-view contributions.

File Format

Both native file types store plain JSON wrappers in the vault:

{
  "kind": "univer-doc | univer-sheet",
  "version": 1,
  "snapshot": {},
  "meta": {}
}
  • kind selects the matching Univer runtime and view.
  • version gates future migrations.
  • snapshot preserves Univer-owned document or workbook state without normalizing its schema inside Lapis.
  • meta is optional provenance space for future import/export workflows.

Key Behaviors

  • Registers dedicated editor views for .lapisdoc and .lapissheet after the official lapis-docs plugin is installed and enabled. Before installation, the workspace on-demand install prompt can offer Install and open from the signed official registry contribution summary.
  • Parses native snapshot wrappers, rejects malformed JSON and wrong file kinds, and shows explicit in-view error states instead of falling back to raw text.
  • Bootstraps Univer Docs and Sheets lazily through the documented @univerjs/presets createUniver() entry point, with directly composed OSS Univer plugin lists for each editor type. The runtime keeps preset CSS and locale assets but avoids preset JS facade side effects that register sheet-only observers against document sessions.
  • Waits for the mounted editor pane to have usable dimensions before creating Univer, so sheets do not initialize against zero-width panes.
  • Keeps the Univer runtime lazy-loaded, but browser builds must still load the runtime dependency shim before Univer so async-lock, React, and related CommonJS dependencies initialize without ESM interop failures.
  • Mirrors the app light/dark state into Univer and bridges app theme tokens into the embedded surface so sheet borders, buttons, and other chrome remain visible under the workspace design system.
  • Persists snapshot changes back to the vault as debounced JSON writes and surfaces save failures with reload and retry actions.
  • Creates new native document and sheet files at the vault root through plugin-scoped commands.
  • Seeds the demo vault with representative .lapisdoc and .lapissheet fixtures that render visible document and sheet content for smoke verification and workspace e2e coverage.
  • Workspace e2e coverage verifies editor readiness and rendered Univer output, not only shell mount, and fails on unexpected page errors or console warnings/errors from the docs runtime.

Deferred Scope

  • .lapisslide is reserved conceptually but not registered because Univer Slides is still outside the repo’s production-ready target.
  • .xlsx, .docx, .pptx, .csv, and .tsv remain out of scope for this plugin. CSV/TSV stays with the CSV plugin, and Office exchange work remains a future server-backed follow-up.
  • Existing vaults that have data under the old bundled docs ID are migrated by the workspace startup path by copying that data to lapis-docs when the new target ID has no data yet. The source docs data is preserved during this release.

CSS Ownership

The package ships a standalone stylesheet artifact that combines Univer preset CSS with package-local shell styling. Registry installation stores that styles.css artifact under /.obsidian/plugins/lapis-docs/, and the plugin manager injects it when the installed plugin is enabled. Package selectors stay under the docs-view__ namespace and follow the shared Plugin CSS Contract.