@lapis-notes/lapis-plugin-notebook

中文文档
0.2.2发布于 2026/11/01AGPL-3.0-or-laterTypeScriptES Module构建来源已验证

Executable .notebook.md notebooks with reactive cells and rich outputs for Lapis Notes

原始使用文档
文档目录12 节
  1. Current package status
  2. Install
  3. Runtime surfaces
  4. Cell and output coverage
  5. Styling contract
  6. Layout conventions
  7. Usage example
  8. Storybook and local documentation
  9. CI and local parity
  10. Refreshing local development dependencies
  11. Release and validation
  12. Further reading

@lapis-notes/lapis-plugin-notebook

CI Storybook Pages Storybook

First-party external Notebook plugin for Lapis. It ports the legacy @lapis-notes/notebook plugin: executable .notebook.md Markdown documents with reactive cells, rich outputs, interactive inputs, and DuckDB queries, presented through public @lapismd/design-core surfaces inside the host workspace.

The plugin owns notebook documents, execution, panels, and settings. Hosts own routing, vault state, persistence, and application policy.

Plugin workspace

Plugin screenshots

Research notebook

Interactive analysis

Registry publication and manual verification: publishing guide.

Current package status

  • Prepared package version: @lapis-notes/[email protected] (publication pending). Validation uses published registry dependencies; qualification and publication evidence is tracked in spec/records/2026-10-31-notebook-canvas-release.md.
  • Runtime plugin id: lapis-notebook (preserved from the legacy plugin so persisted plugin-data keys stay compatible).
  • Runtime peers: @lapis-notes/api@^0.2.4, @lapis-notes/markdown@^0.2.1, @lapismd/design-core@^0.9.0, @lapis-notes/ui@^0.1.6, svelte@^5.
  • Canonical repository: lapismd/lapis-plugin-notebook.
  • Live catalog: https://lapismd.github.io/lapis-plugin-notebook/.
  • The port is staged per spec/src/plugins/notebook/; verification statuses in spec/src/verification.md track exactly which stage has landed.

Install

Hosts load the plugin class through the Lapis plugin lifecycle; onload registers the notebook editor view, commands, settings tab, and panels.

pnpm add @lapis-notes/lapis-plugin-notebook

Import the plugin stylesheet once at the application boundary:

import "@lapis-notes/lapis-plugin-notebook/styles.css";

Runtime surfaces

SurfaceEntryUse for
Notebook view*.notebook.md exclusive editor-view contributionCell rendering, source/preview modes, run-all header action, inline editors
ExecutionShared engine with Web Worker transport and in-process fallbackTypeScript/JavaScript, SQL, and Markdown/HTML cells with dependency-graph ordering
Inputspackages/input DOM runtime on Design Core primitivesviewof text/table/range and every UI-backed input factory with targeted reruns
DuckDBpackages/duckdb on pinned DuckDB-WASMSQL cells over app snapshot tables (lapis.notes, lapis.links, lapis.search_documents)
PanelsVariables, Dependencies, and Packages right-sidebar viewsData-source inspection, dependency graphs, and npm package management
Default groupingNotebook sidebar group seeded from layout stateOne right-sidebar group presenting Variables, Dependencies, and Packages together
SettingsVersioned plugin data plus settings tabExecution, autorun, and panel auto-open policy

Cell and output coverage

Embed a rendered notebook in another note with ![[Analysis.notebook.md]]. The embed shows notebook prose and available cell outputs, with an action to open the source notebook. Saved results restore without running cells; first execution remains manual. Repeated embeds share input values while keeping separate controls.

Cells execute through one shared engine reachable over two transports: a dedicated module Web Worker for eligible notebooks and an in-process fallback for notebooks that need DuckDB, live DOM outputs, or host-only providers. Reactivity is Lapis-owned and explicit — a marimo/Pluto-style dependency graph reruns or marks stale descendants; there is no implicit observer runtime. Generated outputs persist as typed generated state through the host appDatabase notebook-state contract, shared by web, desktop, and hosted Rust back ends.

Styling contract

The plugin uses native CSS, Design Core semantic tokens, and notebook-owned notebook- prefixed classes. Production sources stay free of Tailwind utility strings (pnpm check:no-tailwind).

  1. Import @lapis-notes/lapis-plugin-notebook/styles.css once.
  2. Theme through Design Core tokens; the notebook layer rebinds public custom properties (editor surfaces, table previews, status palette) at its own boundaries.
  3. Do not style private production selectors to make a story or host look correct.

Status tones use a static AA-contrast palette with .dark overrides; section anatomy paints grey full-bleed headers over white bodies.

Layout conventions

src/
  lib/            plugin class, settings, views, render layer, panels, styles
  stories/        App-backed shell stories, panel placement stories, demos
packages/
  notebook-core/  host-neutral document model, graph, and stdlib
  notebook-stdlib/
  notebook-input/ lazy DOM input runtime
  notebook-duckdb/
  notebook-duckdb-assets/
  notebook-worker/ transport-only worker entry
spec/
  src/            canonical specification (mdBook)
  records/        slice and acceptance records
stories/
  catalog/        story parity and taxonomy declarations

Private support packages keep host-neutrality boundaries (LN-NB-027) and resolve from TypeScript source through shared Vite/tsconfig plumbing, so the published root manifest stays free of workspace: dependencies.

Usage example

A notebook document is ordinary Markdown with :::cell directives:

---
notebook:
  autorun: true
---

:::cell{#calc lang="ts"}

```ts
const answer = 6 * 7;
display(`The answer is ${answer}.`);
```

:::

:::cell{#query lang="sql"}

```sql
SELECT count(*) AS note_count FROM lapis.notes;
```

:::

Interactive inputs use viewof cells; dependencies rerun targeted downstream cells on change.

Storybook and local documentation

Run the local catalog (defaults to port 7040):

pnpm storybook
pnpm storybook:stop
pnpm storybook:restart

Build the static catalog:

pnpm build-storybook

The canonical specification lives in spec/src. Prefer QMD-backed search for locating requirements and guidance, and keep the wiring healthy after tooling updates:

pnpm spec:search -- "panel group"
pnpm spec:search -- "worker transport" --semantic
pnpm spec:index
pnpm exec spec-validator doctor
pnpm spec:check

CI and local parity

Portable validation defaults to the fail-closed Docker runner (scripts/validation.mjs); Docker failure never falls back to the host. See docs/validation.md for contexts, reports, and owned cleanup. Native diagnosis requires the explicit LAPIS_NOTEBOOK_VALIDATION_RUNTIME=native override.

pnpm test:storybook runs the Storybook Vitest project in sequential shards, each with a fresh browser process and one worker, mirroring the Tasks mitigation for intermittent orchestrator transport drops. Keep the unbatched command available for diagnosis.

CI runs the validation, specification, quality, unit, build, publint, and Storybook interaction and static-build lanes on every pull request and push to main, and publishes the static catalog to GitHub Pages from main.

Refreshing local development dependencies

When the sibling repositories are present, .pnpmfile.cjs installs local package snapshots for development acceptance. These snapshots need refreshing after sibling source or public exports change. If Storybook reports missing files that exist in the owning repository, stop it and refresh the snapshots:

pnpm storybook:stop
pnpm install --lockfile=false --force
pnpm test
pnpm test:storybook
pnpm storybook

This temporary local validation setup leaves the registry lockfile unchanged. Validate releases and CI against the published registry dependencies.

The preview inherits DM Sans Variable and Source Code Pro Variable from Design Core, matching the Lapis hosts.

Release and validation

Common validation commands:

pnpm spec:first
pnpm spec:check
pnpm check
pnpm test
pnpm build
pnpm publint
pnpm test:storybook
pnpm build-storybook
pnpm validation:all

Further reading

ResourceUse
spec/src/plugins/notebook/index.mdCanonical plugin specification
spec/src/plugins/notebook/runtime.mdExecution, panels, and settings runtime
spec/src/spec-governance.mdGovernance, validation, and discovery rules
spec/src/verification.mdRequirement verification evidence
docs/validation.mdDocker validation contexts and reports
AGENTS.mdContributor and agent workflow
PROVENANCE.mdLegacy port provenance and exclusions

版本与发布记录

@lapis-notes/lapis-plugin-notebook 共发布 4 个版本,首次发布于 2026/10/31;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.2latest2026/11/011 天前
0.2.02026/11/012 天前
0.1.02026/10/313 天前
0.0.0-stage2026/10/313 天前

关于 @lapis-notes/lapis-plugin-notebook 的常见问题

@lapis-notes/lapis-plugin-notebook 是什么?

可执行.notebook。md笔记本与反应细胞和丰富的输出青金石笔记

如何安装 @lapis-notes/lapis-plugin-notebook?

在项目目录运行 npm install @lapis-notes/lapis-plugin-notebook,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:svelte(^5.0.0)、@lapis-notes/ui(^0.1.6)、@codemirror/view(^6.43.8)、@lapis-notes/api(^0.2.4)、@codemirror/state(^6.7.1)、@codemirror/search(^6.7.1)、@codemirror/commands(^6.10.4)、@codemirror/language(^6.12.4)、@lapismd/design-core(^0.9.0)、@lapis-notes/markdown(^0.2.1)、@codemirror/autocomplete(^6.20.3)、@codemirror/lang-markdown(^6.5.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@lapis-notes/lapis-plugin-notebook 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@lapis-notes/lapis-plugin-notebook 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@lapis-notes/lapis-plugin-notebook 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@lapis-notes/lapis-plugin-notebook 可以商用吗?

@lapis-notes/lapis-plugin-notebook 使用 AGPL-3.0-or-later 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@lapis-notes/lapis-plugin-notebook 还在维护吗?

最新版本 0.2.2 发布于 2026/11/01(1 天前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/10/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。