reactive-md 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG-ch.md +128 -113
- package/CHANGELOG.md +128 -113
- package/LICENSE +21 -21
- package/README-ch.md +152 -123
- package/README-en.md +176 -147
- package/README.md +176 -147
- package/THIRD_PARTY_NOTICES.md +94 -1
- package/bin/reactive-md.mjs +1 -1
- package/dist-library/reactive-md-editor.css +2 -0
- package/dist-library/reactive-md-editor.js +3710 -0
- package/dist-library/reactive-md-react.js +9035 -1558
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +98 -97
- package/dist-library/{runtime-D3QTVYaz.js → runtime-DPuMxM_y.js} +1978 -1583
- package/dist-library/types/editor/ReactiveMarkdownEditor.d.ts +7 -0
- package/dist-library/types/editor/editor-commands.d.ts +50 -0
- package/dist-library/types/editor/editor-i18n.d.ts +102 -0
- package/dist-library/types/editor/editor-toolbar.d.ts +24 -0
- package/dist-library/types/editor/extended-native-components.d.ts +58 -0
- package/dist-library/types/editor/index.d.ts +9 -0
- package/dist-library/types/editor/locale.d.ts +13 -0
- package/dist-library/types/editor/native-components.d.ts +47 -0
- package/dist-library/types/editor/source-authoring.d.ts +57 -0
- package/dist-library/types/editor/types.d.ts +44 -0
- package/dist-library/types/editor/use-gutter-metrics.d.ts +5 -0
- package/dist-library/types/editor/use-source-history.d.ts +16 -0
- package/dist-library/types/local/code-block.d.ts +24 -0
- package/dist-library/types/local/footnotes.d.ts +51 -0
- package/dist-library/types/local/image-view.d.ts +21 -0
- package/dist-library/types/local/types.d.ts +7 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +47 -36
- package/docs/compatibility-ch.md +12 -8
- package/docs/compatibility-en.md +12 -8
- package/docs/component-protocol-ch.md +2 -2
- package/docs/component-protocol-en.md +2 -2
- package/docs/editor-ch.md +216 -0
- package/docs/editor-en.md +216 -0
- package/docs/local-guide-ch.md +11 -5
- package/docs/local-guide-en.md +11 -5
- package/docs/local-interaction-syntax-ch.md +7 -2
- package/docs/local-interaction-syntax-en.md +7 -2
- package/docs/release-0.4.1-ch.md +23 -23
- package/docs/release-0.4.1-en.md +23 -23
- package/docs/release-0.5.0-ch.md +41 -0
- package/docs/release-0.5.0-en.md +41 -0
- package/docs/releasing-ch.md +108 -101
- package/docs/releasing-en.md +108 -101
- package/docs/shareable-export-ch.md +4 -2
- package/docs/shareable-export-en.md +4 -2
- package/examples/integration/core/package.json +7 -7
- package/examples/integration/react/index.html +12 -12
- package/examples/integration/react/main.jsx +21 -21
- package/examples/integration/react/package.json +9 -9
- package/examples/integration/react-editor.tsx +74 -0
- package/examples/local/catalog.reactive.md +20 -20
- package/examples/local/checklist.reactive.md +32 -32
- package/examples/local/comparison.reactive.md +47 -47
- package/examples/local/components.reactive.md +44 -44
- package/examples/local/counter.reactive.md +7 -7
- package/examples/local/diagnostics.reactive.md +54 -54
- package/examples/local/diagram.reactive.md +44 -44
- package/examples/local/gallery.reactive.md +61 -61
- package/examples/local/parameters.reactive.md +36 -36
- package/examples/local/planning.reactive.md +24 -24
- package/examples/local/pricing.reactive.md +20 -20
- package/examples/local/zh/catalog.reactive.md +20 -20
- package/examples/local/zh/charts.reactive.md +73 -73
- package/examples/local/zh/checklist.reactive.md +32 -32
- package/examples/local/zh/comparison.reactive.md +47 -47
- package/examples/local/zh/components.reactive.md +44 -44
- package/examples/local/zh/counter.reactive.md +7 -7
- package/examples/local/zh/diagnostics.reactive.md +54 -54
- package/examples/local/zh/diagram.reactive.md +44 -44
- package/examples/local/zh/gallery.reactive.md +61 -61
- package/examples/local/zh/parameters.reactive.md +36 -36
- package/examples/local/zh/planning.reactive.md +24 -24
- package/examples/local/zh/pricing.reactive.md +20 -20
- package/package.json +133 -91
package/README-ch.md
CHANGED
|
@@ -1,123 +1,152 @@
|
|
|
1
|
-
# Reactive MD
|
|
2
|
-
|
|
3
|
-
[English](README.md)
|
|
4
|
-
|
|
5
|
-
用 Markdown 写本地交互文档。放入输入控件,用 `bind` 命名参数,用 `{{ 表达式 }}` 连接文字、公式、图表和图解。文档作者无需编写 JavaScript 或 CSS。
|
|
6
|
-
|
|
7
|
-
本地模式采用 HTML 风格标签,参数和表格数据直接写在正文中,LaTeX 公式可用于函数绘图。TypeScript 核心和 React 渲染器可独立集成。`0.
|
|
8
|
-
|
|
9
|
-
## 从这里开始
|
|
10
|
-
|
|
11
|
-
- [新用户入门指南](docs/local-guide-ch.md):从 Markdown 过渡到交互文档,含完整练习与错误速查。
|
|
12
|
-
- [本地交互语法规范](docs/local-interaction-syntax-ch.md) · [功能演示与示例](examples/local/README.md):48 个标签名、标签、就地参数与 LaTeX 绘图。
|
|
13
|
-
- [本地模式集成](docs/local-integration-ch.md):`compileLocal`、状态运行时、React 嵌入、URL 策略与样式作用域。
|
|
14
|
-
- [可分享文档与静态导出](docs/shareable-export-ch.md):单文件交互 HTML、静态输出、版本化状态文件、图片资源、CLI 与独立浏览器 API。
|
|
15
|
-
- [主题协议](docs/theme-protocol-ch.md):文档主题选择、自定义 CSS 与深浅模式。
|
|
16
|
-
- [作者工具](docs/author-tools-ch.md):源码高亮、补全、绑定定位、重命名、格式化与命令行检查。
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [0.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
npm install
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
|
|
108
|
-
- [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
1
|
+
# Reactive MD
|
|
2
|
+
|
|
3
|
+
[English](README.md)
|
|
4
|
+
|
|
5
|
+
用 Markdown 写本地交互文档。放入输入控件,用 `bind` 命名参数,用 `{{ 表达式 }}` 连接文字、公式、图表和图解。文档作者无需编写 JavaScript 或 CSS。
|
|
6
|
+
|
|
7
|
+
本地模式采用 HTML 风格标签,参数和表格数据直接写在正文中,LaTeX 公式可用于函数绘图。TypeScript 核心和 React 渲染器可独立集成。`0.5.0` 是面向 `next` 渠道的预览版,新增 `reactive-md/editor` 源码编辑器;`latest` 仍为 `0.4.0`。语法修订继续为 `local-draft-2`。
|
|
8
|
+
|
|
9
|
+
## 从这里开始
|
|
10
|
+
|
|
11
|
+
- [新用户入门指南](docs/local-guide-ch.md):从 Markdown 过渡到交互文档,含完整练习与错误速查。
|
|
12
|
+
- [本地交互语法规范](docs/local-interaction-syntax-ch.md) · [功能演示与示例](examples/local/README.md):48 个标签名、标签、就地参数与 LaTeX 绘图。
|
|
13
|
+
- [本地模式集成](docs/local-integration-ch.md):`compileLocal`、状态运行时、React 嵌入、URL 策略与样式作用域。
|
|
14
|
+
- [可分享文档与静态导出](docs/shareable-export-ch.md):单文件交互 HTML、静态输出、版本化状态文件、图片资源、CLI 与独立浏览器 API。
|
|
15
|
+
- [主题协议](docs/theme-protocol-ch.md):文档主题选择、自定义 CSS 与深浅模式。
|
|
16
|
+
- [作者工具](docs/author-tools-ch.md):源码高亮、补全、绑定定位、重命名、格式化与命令行检查。
|
|
17
|
+
- [React 源码编辑器](docs/editor-ch.md):受控编辑器、属性、ref 句柄、诊断、语言、主题与历史。
|
|
18
|
+
- [独立接入示例](examples/integration/README.md):可复制到仓库外运行的 Node 核心和 React 页面。
|
|
19
|
+
- [版本与兼容性](docs/compatibility-ch.md):0.x 规则、迁移、诊断契约和平台范围。
|
|
20
|
+
- [组块协议](docs/component-protocol-ch.md) · [组块开发指南](docs/component-development-ch.md):新增组件的声明、行为契约和兼容性验收。
|
|
21
|
+
- [0.5.0 发布说明](docs/release-0.5.0-ch.md):编辑器入口与文档渲染修复。
|
|
22
|
+
- [0.4.1 发布说明](docs/release-0.4.1-ch.md):界面与交互修复,兼容 0.4.0。
|
|
23
|
+
- [0.4.0 发布与迁移](docs/release-0.4.0-ch.md):本 minor 系列包含的能力,以及从 `0.3.1` / `local-draft-1` 升级的方法。
|
|
24
|
+
|
|
25
|
+
## 写一份文档
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
<panel title="费用估算">
|
|
29
|
+
<slider bind="people" label="人数" initial="2" min="1" max="20">
|
|
30
|
+
<toggle bind="annual" label="年度付款">
|
|
31
|
+
</panel>
|
|
32
|
+
|
|
33
|
+
每月费用:**{{ people * (annual ? 80 : 100) }} 元**。
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
输入立即更新结果,面板自带“恢复默认”。独立使用的计数器只需一行 `<counter label="人数">`。
|
|
37
|
+
|
|
38
|
+
`0.4.0` 新增 `local-draft-2`、命名计算、校验、集合、主题和离线 HTML 导出;旧版 `0.3.1` 使用 `local-draft-1`。见[0.4.0 发布与迁移](docs/release-0.4.0-ch.md)。
|
|
39
|
+
|
|
40
|
+
## 安装
|
|
41
|
+
|
|
42
|
+
需要 Node.js 22.12 或更新版本,包提供 ESM 入口:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm install reactive-md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`latest` 当前为 `0.4.0`。0.5.0 预览版面向 `next` 渠道:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
npm install reactive-md@next
|
|
52
|
+
# 或固定预览版
|
|
53
|
+
npm install reactive-md@0.5.0
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
使用预览版前请阅读[0.5.0 发布说明](docs/release-0.5.0-ch.md);从 `0.3.1` / `local-draft-1` 升级前请阅读[迁移说明](docs/release-0.4.0-ch.md)。
|
|
57
|
+
|
|
58
|
+
`reactive-md` 入口提供本地编译器、表达式和运行时,`reactive-md/react` 提供 React 渲染器。组件样式通过 `reactive-md/styles.css` 引入。`reactive-md/editor` 提供源码编辑器,并使用独立样式 `reactive-md/editor/styles.css`。现有渲染器和样式导入在 0.5.0 中保持不变。
|
|
59
|
+
|
|
60
|
+
React 入口需要 React 19:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
npm install react@19 react-dom@19
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
68
|
+
import 'reactive-md/styles.css';
|
|
69
|
+
|
|
70
|
+
export function Article({ source }: { source: string }) {
|
|
71
|
+
return <LocalReactiveDocument source={source} />;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`reactive-md` 核心入口不依赖 React。完整的编译与运行时 API、宿主 URL 策略、生命周期和样式覆盖见[本地模式集成](docs/local-integration-ch.md)。
|
|
76
|
+
|
|
77
|
+
## 用 React 编辑源码
|
|
78
|
+
|
|
79
|
+
0.5.0 预览版在 `reactive-md/editor` 提供可复用的源码编辑器,样式位于 `reactive-md/editor/styles.css`。组件是受控的,需要 React 19:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { useState } from 'react';
|
|
83
|
+
import { ReactiveMarkdownEditor } from 'reactive-md/editor';
|
|
84
|
+
import 'reactive-md/editor/styles.css';
|
|
85
|
+
|
|
86
|
+
export function Editor() {
|
|
87
|
+
const [source, setSource] = useState('# 笔记');
|
|
88
|
+
return <ReactiveMarkdownEditor value={source} onChange={setSource} />;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
编辑器处理高亮、格式与插入工具、补全、绑定工具、撤销重做及行号。它不编译、不渲染预览;源码由应用保存,并用 `reactive-md/react` 渲染。属性、ref 句柄、诊断、主题、语言和历史规则见 [React 源码编辑器](docs/editor-ch.md)。
|
|
93
|
+
|
|
94
|
+
0.x 次版本可能包含破坏性变更。升级前阅读[变更记录](CHANGELOG-ch.md)与[兼容规则](docs/compatibility-ch.md),并保存原始 `.reactive.md` 源码。
|
|
95
|
+
|
|
96
|
+
## 分享文档
|
|
97
|
+
|
|
98
|
+
构建读者可以离线打开的单个 HTML 文件,或不含脚本的静态快照:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npm run build
|
|
102
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter.html
|
|
103
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter-static.html --mode static
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
交互文件内嵌原始源码、React 19、运行时、样式以及经过校验的本地图片。它先渲染静态首屏,因此禁用 JavaScript 时仍可阅读。使用 `--state-file doc.state.json` 导出已保存的 `reactive-md-state/v1` 基线;省略时使用作者初值,并把它作为读者的重置基线。Demo 导出对话框可以把当前预览参数保存成此类状态文件。
|
|
107
|
+
|
|
108
|
+
图片上限、CSP/安全、打印、退出码、`ReactiveMD.mount`/`mountAll` 与 `<reactive-md-doc>` 见[可分享文档与静态导出](docs/shareable-export-ch.md)。单文件导出的静态首屏水合由 Playwright Chromium 和本地 Edge 检查覆盖;Firefox、Safari/WebKit 与通用 SSR 水合仍未验证。
|
|
109
|
+
|
|
110
|
+
## 体验 Demo
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
npm ci
|
|
114
|
+
npm run dev
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
该命令先构建语言包,再启动独立的 `demo/` 应用,地址为 `http://127.0.0.1:5173`。`/embed.html` 展示嵌入方式。页面顶部的语言按钮可以在中文和英文之间切换,选择会保存在浏览器中。Demo 的页面、编辑器、演示服务、资产和浏览器检查均在 `demo/`,通过语言包的公开入口集成。
|
|
118
|
+
|
|
119
|
+
## 仓库结构
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
src/ 本地语法编译、表达式、运行时和 React 渲染器
|
|
123
|
+
examples/ 可复制的本地交互示例,与 demo 应用无关
|
|
124
|
+
docs/ 本地语法规范、集成与发布文档
|
|
125
|
+
tests/ 语言与渲染器测试
|
|
126
|
+
demo/ 独立的 Playground 应用
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## 文档
|
|
130
|
+
|
|
131
|
+
- [新用户入门指南](docs/local-guide-ch.md)与[本地交互语法规范](docs/local-interaction-syntax-ch.md)。
|
|
132
|
+
- [本地模式集成](docs/local-integration-ch.md):核心与 React API、URL 策略、生命周期、样式和版本固定。
|
|
133
|
+
- [可分享文档与静态导出](docs/shareable-export-ch.md):CLI build/lint、状态文件、本地图片内联、打印与独立浏览器运行时。
|
|
134
|
+
- [功能演示与示例](examples/local/README.md)与[独立接入示例](examples/integration/README.md)。
|
|
135
|
+
- [React 源码编辑器](docs/editor-ch.md):编辑 `.reactive.md` 源码的受控组件,使用独立样式表。
|
|
136
|
+
- [版本与兼容性](docs/compatibility-ch.md)与[0.5.0 发布说明](docs/release-0.5.0-ch.md)。
|
|
137
|
+
- [0.4.0 发布与迁移](docs/release-0.4.0-ch.md)。
|
|
138
|
+
- [组块协议](docs/component-protocol-ch.md)与[组块开发指南](docs/component-development-ch.md)。
|
|
139
|
+
- [性能说明](docs/performance-ch.md)与[发布清单](docs/releasing-ch.md)。
|
|
140
|
+
|
|
141
|
+
更多开发与测试命令见[贡献指南](CONTRIBUTING-ch.md)。
|
|
142
|
+
|
|
143
|
+
## 贡献与安全
|
|
144
|
+
|
|
145
|
+
- [贡献指南](CONTRIBUTING-ch.md):环境、检查命令和改动要求。
|
|
146
|
+
- [安全策略](SECURITY-ch.md):威胁边界、资源上限、宿主责任和漏洞报告渠道。
|
|
147
|
+
- [变更记录](CHANGELOG-ch.md)。
|
|
148
|
+
- [发布清单](docs/releasing-ch.md):验证门禁、notice、tarball 和人工发布流程。
|
|
149
|
+
|
|
150
|
+
## 许可证
|
|
151
|
+
|
|
152
|
+
[MIT](LICENSE)
|
package/README-en.md
CHANGED
|
@@ -1,147 +1,176 @@
|
|
|
1
|
-
# Reactive MD
|
|
2
|
-
|
|
3
|
-
[中文](README-ch.md)
|
|
4
|
-
|
|
5
|
-
Write local interactive documents in Markdown. Add input controls, name parameters with `bind`, and connect prose, formulas, charts and diagrams with `{{ expressions }}`. Document authors do not write JavaScript or CSS.
|
|
6
|
-
|
|
7
|
-
Local mode uses HTML-style tags, with parameters and table data written directly in the prose; LaTeX formulas can drive function plots. The TypeScript core and the React renderer can be integrated independently. `0.
|
|
8
|
-
|
|
9
|
-
## Start here
|
|
10
|
-
|
|
11
|
-
- [Beginner guide](docs/local-guide-en.md): move from Markdown to interactive documents, with a complete exercise and an error quick reference.
|
|
12
|
-
- [Local interaction syntax specification](docs/local-interaction-syntax-en.md) · [Feature tours and examples](examples/local/README.md): 48 tag names, tags, in-place parameters and LaTeX plots.
|
|
13
|
-
- [Local mode integration](docs/local-integration-en.md): `compileLocal`, the state runtime, React embedding, URL policy and style scoping.
|
|
14
|
-
- [Shareable documents and static export](docs/shareable-export-en.md): single-file interactive HTML, static output, versioned state files, assets, the CLI and the standalone browser API.
|
|
15
|
-
- [Theme protocol](docs/theme-protocol-en.md): document theme selection, custom CSS and light/dark modes.
|
|
16
|
-
- [Author tools](docs/author-tools-en.md): source highlighting, completion, binding navigation, rename, formatting and command-line lint.
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [0.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
# Reactive MD
|
|
2
|
+
|
|
3
|
+
[中文](README-ch.md)
|
|
4
|
+
|
|
5
|
+
Write local interactive documents in Markdown. Add input controls, name parameters with `bind`, and connect prose, formulas, charts and diagrams with `{{ expressions }}`. Document authors do not write JavaScript or CSS.
|
|
6
|
+
|
|
7
|
+
Local mode uses HTML-style tags, with parameters and table data written directly in the prose; LaTeX formulas can drive function plots. The TypeScript core and the React renderer can be integrated independently. `0.5.0` is the preview for the `next` channel and adds the `reactive-md/editor` source editor; `latest` remains `0.4.0`. Syntax revision stays `local-draft-2`. See [README-ch.md](README-ch.md) for the Chinese overview.
|
|
8
|
+
|
|
9
|
+
## Start here
|
|
10
|
+
|
|
11
|
+
- [Beginner guide](docs/local-guide-en.md): move from Markdown to interactive documents, with a complete exercise and an error quick reference.
|
|
12
|
+
- [Local interaction syntax specification](docs/local-interaction-syntax-en.md) · [Feature tours and examples](examples/local/README.md): 48 tag names, tags, in-place parameters and LaTeX plots.
|
|
13
|
+
- [Local mode integration](docs/local-integration-en.md): `compileLocal`, the state runtime, React embedding, URL policy and style scoping.
|
|
14
|
+
- [Shareable documents and static export](docs/shareable-export-en.md): single-file interactive HTML, static output, versioned state files, assets, the CLI and the standalone browser API.
|
|
15
|
+
- [Theme protocol](docs/theme-protocol-en.md): document theme selection, custom CSS and light/dark modes.
|
|
16
|
+
- [Author tools](docs/author-tools-en.md): source highlighting, completion, binding navigation, rename, formatting and command-line lint.
|
|
17
|
+
- [React source editor](docs/editor-en.md): controlled editor, props, ref handle, diagnostics, locale, theme and history.
|
|
18
|
+
- [Standalone integration examples](examples/integration/README.md): Node core and React pages you can copy and run outside the repository.
|
|
19
|
+
- [Versions and compatibility](docs/compatibility-en.md): 0.x rules, migration, the diagnostics contract and supported platforms.
|
|
20
|
+
- [Component protocol](docs/component-protocol-en.md) · [Component development guide](docs/component-development-en.md): declarations, behavior contracts and compatibility acceptance for new components.
|
|
21
|
+
- [0.5.0 release notes](docs/release-0.5.0-en.md): the editor entry and document rendering fixes.
|
|
22
|
+
- [0.4.1 release notes](docs/release-0.4.1-en.md): visual and interaction fixes, compatible with 0.4.0.
|
|
23
|
+
- [0.4.0 release and migration](docs/release-0.4.0-en.md): what the minor series adds and how to upgrade from `0.3.1` / `local-draft-1`.
|
|
24
|
+
|
|
25
|
+
## Write a document
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
<panel title="Cost estimate">
|
|
29
|
+
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
30
|
+
<toggle bind="annual" label="Annual billing">
|
|
31
|
+
</panel>
|
|
32
|
+
|
|
33
|
+
Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Inputs update the result immediately, and the panel includes a restore-defaults action. A standalone counter is a single line: `<counter label="People">`.
|
|
37
|
+
|
|
38
|
+
`0.4.0` adds `local-draft-2`, named calculations, validation, collections, themes and offline HTML export. The earlier `0.3.1` release uses `local-draft-1`. See [0.4.0 release and migration](docs/release-0.4.0-en.md).
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
Reactive MD requires Node.js 22.12 or newer and ships only ESM entries:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm install reactive-md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`latest` resolves to `0.4.0`. The 0.5.0 preview targets `next`:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
npm install reactive-md@next
|
|
52
|
+
# or pin the preview
|
|
53
|
+
npm install reactive-md@0.5.0
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Read the [0.5.0 release notes](docs/release-0.5.0-en.md) before using the preview, and the [migration guide](docs/release-0.4.0-en.md) before upgrading from `0.3.1` / `local-draft-1`.
|
|
57
|
+
|
|
58
|
+
The `reactive-md` entry provides the local compiler, expressions and runtime; `reactive-md/react` provides the React renderer. Import component styles from `reactive-md/styles.css`. The `reactive-md/editor` entry provides the source editor with its own stylesheet at `reactive-md/editor/styles.css`. Existing renderer and style imports are unchanged in 0.5.0.
|
|
59
|
+
|
|
60
|
+
The core `reactive-md` entry does not depend on React:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
64
|
+
|
|
65
|
+
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
66
|
+
if (result.ok) {
|
|
67
|
+
const runtime = createLocalRuntime(result.document);
|
|
68
|
+
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
69
|
+
finally { runtime.dispose(); }
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
See [Local mode integration](docs/local-integration-en.md) for the full compile and runtime APIs, host URL policy, lifecycle and style overrides.
|
|
74
|
+
|
|
75
|
+
0.x minor releases may contain breaking changes. Before upgrading, read the [changelog](CHANGELOG.md) and [compatibility rules](docs/compatibility-en.md), and keep the original `.reactive.md` sources.
|
|
76
|
+
|
|
77
|
+
## Use with React
|
|
78
|
+
|
|
79
|
+
The React entry requires React 19:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
npm install react@19 react-dom@19
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
87
|
+
import 'reactive-md/styles.css';
|
|
88
|
+
|
|
89
|
+
export function Article({ source }: { source: string }) {
|
|
90
|
+
return <LocalReactiveDocument source={source} />;
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`LocalReactiveDocument` compiles and manages the runtime for you. To control compilation, lifecycle or URL policy yourself, use `LocalDocumentView` as described in [Local mode integration](docs/local-integration-en.md).
|
|
95
|
+
|
|
96
|
+
## Edit source with React
|
|
97
|
+
|
|
98
|
+
The 0.5.0 preview adds a reusable source editor at `reactive-md/editor`, with its own stylesheet at `reactive-md/editor/styles.css`. The component is controlled and requires React 19:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { useState } from 'react';
|
|
102
|
+
import { ReactiveMarkdownEditor } from 'reactive-md/editor';
|
|
103
|
+
import 'reactive-md/editor/styles.css';
|
|
104
|
+
|
|
105
|
+
export function Editor() {
|
|
106
|
+
const [source, setSource] = useState('# Notes');
|
|
107
|
+
return <ReactiveMarkdownEditor value={source} onChange={setSource} />;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The editor handles highlighting, formatting and insertion tools, completion, binding tools, undo and redo, and line numbers. It does not compile or render a preview; keep the source in your app and render it with `reactive-md/react`. See [React source editor](docs/editor-en.md) for the props, ref handle, diagnostics, themes, locales and history.
|
|
112
|
+
|
|
113
|
+
## Share documents
|
|
114
|
+
|
|
115
|
+
Build a self-contained HTML file that readers can open offline, or a script-free static snapshot:
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
npm run build
|
|
119
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter.html
|
|
120
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter-static.html --mode static
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The interactive file embeds the original source, React 19, the runtime, styles and any verified local images. It hydrates a static first screen, so it remains readable with JavaScript disabled. Use `--state-file doc.state.json` to export a saved `reactive-md-state/v1` baseline; without it, the author initial values are used and become the reader's reset baseline. The demo export dialog can save the current preview parameters as such a file.
|
|
124
|
+
|
|
125
|
+
See [Shareable documents and static export](docs/shareable-export-en.md) for image limits, CSP/security, printing, exit codes, `ReactiveMD.mount`/`mountAll` and `<reactive-md-doc>`.
|
|
126
|
+
|
|
127
|
+
## Try the demo
|
|
128
|
+
|
|
129
|
+
```sh
|
|
130
|
+
npm ci
|
|
131
|
+
npm run dev
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The command builds the language package first, then starts the standalone `demo/` app at `http://127.0.0.1:5173`. `/embed.html` demonstrates the embedding approach. The masthead language toggle switches the demo between English and Chinese, and the choice is saved in the browser. The demo pages, editor, demo server, assets and browser checks all live in `demo/` and integrate through the package's public entries.
|
|
135
|
+
|
|
136
|
+
## Repository layout
|
|
137
|
+
|
|
138
|
+
```text
|
|
139
|
+
src/ Local syntax compilation, expressions, runtime and React renderer
|
|
140
|
+
examples/ Copyable local interactive examples, independent of the demo app
|
|
141
|
+
docs/ Local syntax specification, integration and release documentation
|
|
142
|
+
tests/ Language and renderer tests
|
|
143
|
+
demo/ Standalone Playground app
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Documentation
|
|
147
|
+
|
|
148
|
+
- [Beginner guide](docs/local-guide-en.md) and [local interaction syntax specification](docs/local-interaction-syntax-en.md).
|
|
149
|
+
- [Local mode integration](docs/local-integration-en.md): core and React API, URL policy, lifecycle, styling and version pinning.
|
|
150
|
+
- [Shareable documents and static export](docs/shareable-export-en.md): CLI build/lint, state files, local image inlining, printing and the standalone browser runtime.
|
|
151
|
+
- [Feature tours and examples](examples/local/README.md) and [standalone integrations](examples/integration/README.md).
|
|
152
|
+
- [React source editor](docs/editor-en.md): controlled editor for `.reactive.md` source, with its own stylesheet.
|
|
153
|
+
- [Versions and compatibility](docs/compatibility-en.md): 0.x rules, migration, diagnostics and supported platforms.
|
|
154
|
+
- [0.5.0 release notes](docs/release-0.5.0-en.md): the editor entry and document rendering fixes.
|
|
155
|
+
- [0.4.0 release and migration](docs/release-0.4.0-en.md): the upgrade checklist for that minor series.
|
|
156
|
+
- [Component protocol](docs/component-protocol-en.md) and [component development guide](docs/component-development-en.md): contribution contracts, a proposal template and acceptance cases.
|
|
157
|
+
- [Performance measurements](docs/performance-en.md) and [release checklist](docs/releasing-en.md).
|
|
158
|
+
|
|
159
|
+
See the [contributing guide](CONTRIBUTING.md) for development and test commands.
|
|
160
|
+
|
|
161
|
+
## Support and status
|
|
162
|
+
|
|
163
|
+
- CI targets Node 22.12 and Node 24 with Playwright Chromium; local browser checks use Microsoft Edge. The packed check covers static SSR, and `npm run test:shareable` covers the single-file export's static-first hydration. General SSR hydration outside that path, Firefox and WebKit remain unverified.
|
|
164
|
+
- 0.x minor releases may contain breaking changes. Persist the original `.reactive.md` source, not the runtime AST or in-memory state.
|
|
165
|
+
- `latest` is `0.4.0`; the `0.5.0` preview targets `next`. Security fixes may ship in minor releases.
|
|
166
|
+
|
|
167
|
+
## Contributing and security
|
|
168
|
+
|
|
169
|
+
- [Contributing guide](CONTRIBUTING.md): environment, check commands and change requirements.
|
|
170
|
+
- [Security policy](SECURITY.md): threat boundary, resource limits, host responsibilities and vulnerability reporting.
|
|
171
|
+
- [Changelog](CHANGELOG.md).
|
|
172
|
+
- [Release checklist](docs/releasing-en.md): the verification gate, notices, tarball and the manual release flow for maintainers.
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
[MIT](LICENSE)
|