reactive-md 0.3.0 → 0.4.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 +96 -0
- package/CHANGELOG.md +96 -40
- package/CONTRIBUTING-ch.md +62 -0
- package/CONTRIBUTING.md +64 -61
- package/README-ch.md +122 -0
- package/README-en.md +146 -0
- package/README.md +146 -88
- package/SECURITY-ch.md +80 -0
- package/SECURITY.md +80 -68
- package/THIRD_PARTY_NOTICES.md +85 -1
- package/bin/reactive-md.mjs +40 -0
- package/cli/args.mjs +181 -0
- package/cli/assets.mjs +390 -0
- package/cli/build.mjs +268 -0
- package/cli/document.mjs +130 -0
- package/cli/errors.mjs +61 -0
- package/cli/fs-utils.mjs +133 -0
- package/cli/glob.mjs +203 -0
- package/cli/help.mjs +138 -0
- package/cli/lint.mjs +177 -0
- package/cli/main.mjs +55 -0
- package/cli/migrate.mjs +368 -0
- package/cli/package.mjs +209 -0
- package/dist-library/reactive-md-react.js +3603 -1690
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +1798 -4
- package/dist-library/runtime-DtjdPXxJ.js +15410 -0
- package/dist-library/types/index.d.ts +1 -0
- package/dist-library/types/local/LocalDocumentView.d.ts +66 -3
- package/dist-library/types/local/authoring.d.ts +63 -0
- package/dist-library/types/local/collection-functions.d.ts +4 -0
- package/dist-library/types/local/colors.d.ts +2 -0
- package/dist-library/types/local/compiler.d.ts +3 -3
- package/dist-library/types/local/computations.d.ts +53 -0
- package/dist-library/types/local/data-functions.d.ts +22 -0
- package/dist-library/types/local/data-table.d.ts +65 -0
- package/dist-library/types/local/dates.d.ts +2 -0
- package/dist-library/types/local/dependencies.d.ts +31 -0
- package/dist-library/types/local/diagnostics.d.ts +1450 -0
- package/dist-library/types/local/expression.d.ts +13 -3
- package/dist-library/types/local/formatting.d.ts +41 -0
- package/dist-library/types/local/heading-anchors.d.ts +17 -0
- package/dist-library/types/local/i18n.d.ts +18 -0
- package/dist-library/types/local/index.d.ts +18 -1
- package/dist-library/types/local/limits.d.ts +33 -1
- package/dist-library/types/local/locale.d.ts +1 -0
- package/dist-library/types/local/math.d.ts +6 -1
- package/dist-library/types/local/parser.d.ts +10 -4
- package/dist-library/types/local/render-types.d.ts +5 -1
- package/dist-library/types/local/retention.d.ts +23 -0
- package/dist-library/types/local/schema.d.ts +25 -3
- package/dist-library/types/local/source-migration.d.ts +35 -0
- package/dist-library/types/local/state.d.ts +80 -0
- package/dist-library/types/local/text-length.d.ts +13 -0
- package/dist-library/types/local/theme.d.ts +30 -0
- package/dist-library/types/local/types.d.ts +120 -4
- package/dist-library/types/local/validation.d.ts +32 -0
- package/dist-library/types/local/version.d.ts +1 -1
- package/dist-library/types/local/worker.d.ts +82 -0
- package/dist-library/types/react/index.d.ts +4 -1
- package/dist-library/types/shareable.d.ts +64 -0
- package/dist-standalone/reactive-md-standalone.css +2 -0
- package/dist-standalone/reactive-md-standalone.js +57 -0
- package/docs/author-tools-ch.md +56 -0
- package/docs/author-tools-en.md +56 -0
- package/docs/compatibility-ch.md +103 -0
- package/docs/compatibility-en.md +103 -0
- package/docs/component-development-ch.md +210 -0
- package/docs/component-development-en.md +210 -0
- package/docs/component-protocol-ch.md +710 -0
- package/docs/component-protocol-en.md +710 -0
- package/docs/computations-formatting-ch.md +87 -0
- package/docs/computations-formatting-en.md +87 -0
- package/docs/constraints-collections-ch.md +84 -0
- package/docs/constraints-collections-en.md +84 -0
- package/docs/diagnostics-counting-ch.md +84 -0
- package/docs/diagnostics-counting-en.md +84 -0
- package/docs/local-components-v2-ch.md +138 -0
- package/docs/local-components-v2-en.md +104 -0
- package/docs/{local-guide.md → local-guide-ch.md} +961 -936
- package/docs/local-guide-en.md +961 -0
- package/docs/local-integration-ch.md +363 -0
- package/docs/local-integration-en.md +363 -0
- package/docs/{local-interaction-syntax.md → local-interaction-syntax-ch.md} +485 -437
- package/docs/local-interaction-syntax-en.md +483 -0
- package/docs/performance-ch.md +76 -0
- package/docs/performance-en.md +76 -0
- package/docs/release-0.4.0-ch.md +89 -0
- package/docs/release-0.4.0-en.md +89 -0
- package/docs/releasing-ch.md +101 -0
- package/docs/releasing-en.md +101 -0
- package/docs/shareable-export-ch.md +205 -0
- package/docs/shareable-export-en.md +207 -0
- package/docs/source-versioning-ch.md +159 -0
- package/docs/source-versioning-en.md +159 -0
- package/docs/theme-protocol-ch.md +107 -0
- package/docs/theme-protocol-en.md +107 -0
- package/examples/conformance/README.md +53 -11
- package/examples/conformance/component-protocol-1.json +482 -0
- package/examples/conformance/component-protocol-1.schema.json +76 -0
- package/examples/conformance/history/v0.3.1/catalog.reactive.md +20 -0
- package/examples/conformance/history/v0.3.1/charts.reactive.md +73 -0
- package/examples/conformance/history/v0.3.1/checklist.reactive.md +32 -0
- package/examples/conformance/history/v0.3.1/comparison.reactive.md +47 -0
- package/examples/conformance/history/v0.3.1/components.reactive.md +44 -0
- package/examples/conformance/history/v0.3.1/counter.reactive.md +7 -0
- package/examples/conformance/history/v0.3.1/diagnostics.reactive.md +54 -0
- package/examples/conformance/history/v0.3.1/diagram.reactive.md +44 -0
- package/examples/conformance/history/v0.3.1/gallery.reactive.md +61 -0
- package/examples/conformance/history/v0.3.1/local-draft-1.json +50 -0
- package/examples/conformance/history/v0.3.1/parameters.reactive.md +36 -0
- package/examples/conformance/history/v0.3.1/planning.reactive.md +24 -0
- package/examples/conformance/history/v0.3.1/pricing.reactive.md +20 -0
- package/examples/conformance/history/v0.3.1/provenance.json +72 -0
- package/examples/conformance/local-draft-1.json +50 -49
- package/examples/conformance/local-draft-2.json +212 -0
- package/examples/integration/README.md +45 -29
- package/examples/integration/core/index.mjs +32 -19
- package/examples/integration/react/index.html +1 -1
- package/examples/integration/react/main.jsx +5 -5
- package/examples/integration/worker/index.html +19 -0
- package/examples/integration/worker/main.js +61 -0
- package/examples/integration/worker/package.json +13 -0
- package/examples/integration/worker/worker.js +3 -0
- package/examples/local/README.md +72 -66
- package/examples/local/catalog.reactive.md +14 -14
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/checklist.reactive.md +19 -19
- package/examples/local/comparison.reactive.md +23 -23
- package/examples/local/components.reactive.md +20 -20
- package/examples/local/counter.reactive.md +4 -4
- package/examples/local/diagnostics.reactive.md +25 -25
- package/examples/local/diagram.reactive.md +20 -20
- package/examples/local/gallery.reactive.md +31 -31
- package/examples/local/parameters.reactive.md +19 -19
- package/examples/local/planning.reactive.md +15 -15
- package/examples/local/pricing.reactive.md +10 -10
- package/examples/local/recipes/invoice-zh.reactive.md +36 -0
- package/examples/local/recipes/invoice.reactive.md +36 -0
- package/examples/local/recipes/workshop-zh.reactive.md +33 -0
- package/examples/local/recipes/workshop.reactive.md +33 -0
- package/examples/local/showcase/README.md +25 -0
- package/examples/local/showcase/explore.reactive.md +102 -0
- package/examples/local/showcase/flow.reactive.md +86 -0
- package/examples/local/showcase/forms.reactive.md +126 -0
- package/examples/local/showcase/functions.reactive.md +119 -0
- package/examples/local/showcase/layout.reactive.md +100 -0
- package/examples/local/showcase/statistics.reactive.md +108 -0
- package/examples/local/showcase/tasks.reactive.md +89 -0
- package/examples/local/showcase/zh/explore.reactive.md +102 -0
- package/examples/local/showcase/zh/flow.reactive.md +86 -0
- package/examples/local/showcase/zh/forms.reactive.md +126 -0
- package/examples/local/showcase/zh/functions.reactive.md +119 -0
- package/examples/local/showcase/zh/layout.reactive.md +100 -0
- package/examples/local/showcase/zh/statistics.reactive.md +108 -0
- package/examples/local/showcase/zh/tasks.reactive.md +89 -0
- package/examples/local/zh/catalog.reactive.md +20 -0
- package/examples/local/zh/charts.reactive.md +73 -0
- package/examples/local/zh/checklist.reactive.md +32 -0
- package/examples/local/zh/comparison.reactive.md +47 -0
- package/examples/local/zh/components.reactive.md +44 -0
- package/examples/local/zh/counter.reactive.md +7 -0
- package/examples/local/zh/diagnostics.reactive.md +54 -0
- package/examples/local/zh/diagram.reactive.md +44 -0
- package/examples/local/zh/gallery.reactive.md +61 -0
- package/examples/local/zh/parameters.reactive.md +36 -0
- package/examples/local/zh/planning.reactive.md +24 -0
- package/examples/local/zh/pricing.reactive.md +20 -0
- package/package.json +90 -75
- package/README.en.md +0 -75
- package/dist-library/runtime-D4phFXOr.js +0 -10937
- package/docs/compatibility.md +0 -67
- package/docs/local-integration.md +0 -193
- package/docs/performance.md +0 -30
- package/docs/releasing.md +0 -92
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 放在一起,比较更清楚
|
|
2
|
+
|
|
3
|
+
<panel title="付款方式">
|
|
4
|
+
<toggle bind="annual" label="按年付款,享受八折">
|
|
5
|
+
</panel>
|
|
6
|
+
|
|
7
|
+
<grid>
|
|
8
|
+
<card title="基础方案">
|
|
9
|
+
适合个人与小型项目。
|
|
10
|
+
|
|
11
|
+
每月 **{{ annual ? 80 : 100 }} 元**。
|
|
12
|
+
|
|
13
|
+
<badge>本地文档</badge>
|
|
14
|
+
</card>
|
|
15
|
+
|
|
16
|
+
<card title="专业方案">
|
|
17
|
+
适合需要协作与扩展的团队。
|
|
18
|
+
|
|
19
|
+
每月 **{{ annual ? 160 : 200 }} 元**。
|
|
20
|
+
|
|
21
|
+
<badge tone="success">更多组件</badge>
|
|
22
|
+
</card>
|
|
23
|
+
</grid>
|
|
24
|
+
|
|
25
|
+
<tabs label="方案说明">
|
|
26
|
+
<tab label="功能比较">
|
|
27
|
+
| 能力 | 基础方案 | 专业方案 |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| 参数调整 | 支持 | 支持 |
|
|
30
|
+
| 文本联动 | 支持 | 支持 |
|
|
31
|
+
| 内容组织 | 基础排版 | 图表与图解 |
|
|
32
|
+
</tab>
|
|
33
|
+
|
|
34
|
+
<tab label="选购建议">
|
|
35
|
+
先根据实际用途选择方案,再比较付款周期带来的费用变化。
|
|
36
|
+
</tab>
|
|
37
|
+
</tabs>
|
|
38
|
+
|
|
39
|
+
<accordion>
|
|
40
|
+
<disclosure label="费用如何计算?">
|
|
41
|
+
年度付款按每月标价的八折计算,上方显示折算后的每月费用。
|
|
42
|
+
</disclosure>
|
|
43
|
+
|
|
44
|
+
<disclosure label="可以随时切换吗?">
|
|
45
|
+
切换上方开关即可比较两种付款周期。这是一份本地计算示例。
|
|
46
|
+
</disclosure>
|
|
47
|
+
</accordion>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# 用内容组织交互
|
|
2
|
+
|
|
3
|
+
将鼠标移到 <tooltip text="输入改变后,相关文字和图表自动更新。">响应式绑定</tooltip>,或使用键盘聚焦查看说明。
|
|
4
|
+
|
|
5
|
+
<panel title="阅读偏好">
|
|
6
|
+
<radio-group bind="preference" label="说明风格">
|
|
7
|
+
<option value="concise">简洁</option>
|
|
8
|
+
<option value="detailed">详细</option>
|
|
9
|
+
</radio-group>
|
|
10
|
+
</panel>
|
|
11
|
+
|
|
12
|
+
<if when="{{ preference == 'concise' }}">
|
|
13
|
+
给输入命名,在正文中引用它。
|
|
14
|
+
</if>
|
|
15
|
+
|
|
16
|
+
<if when="{{ preference == 'detailed' }}">
|
|
17
|
+
用 `bind` 为输入参数命名,用 `{{ }}` 读取参数并计算结果。读者调整控件后,相关内容立即更新。
|
|
18
|
+
</if>
|
|
19
|
+
|
|
20
|
+
## 按自己的节奏阅读
|
|
21
|
+
|
|
22
|
+
<accordion label="阅读顺序">
|
|
23
|
+
<disclosure label="理解参数" open>
|
|
24
|
+
找出读者可以改变的内容,例如人数、单价或振幅。
|
|
25
|
+
</disclosure>
|
|
26
|
+
|
|
27
|
+
<disclosure label="写下关系">
|
|
28
|
+
用算式连接输入和结果,例如 `{{ people * 100 }}`。
|
|
29
|
+
</disclosure>
|
|
30
|
+
|
|
31
|
+
<disclosure label="选择展示方式">
|
|
32
|
+
一句结果用正文,数据比较用图表,数学关系用函数曲线。
|
|
33
|
+
</disclosure>
|
|
34
|
+
</accordion>
|
|
35
|
+
|
|
36
|
+
<alert title="继续尝试">
|
|
37
|
+
切换上方选项,观察说明文字的变化。
|
|
38
|
+
</alert>
|
|
39
|
+
|
|
40
|
+
<badge tone="success">本地交互</badge>
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
> 标题、引用、链接和图片都沿用 Markdown。组件只负责需要交互的部分。
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 诊断示例
|
|
2
|
+
|
|
3
|
+
这份文档故意保留错误,用于检查诊断提示。正确示例请从同目录的其他文档开始。
|
|
4
|
+
|
|
5
|
+
## 引用拼错的参数名
|
|
6
|
+
|
|
7
|
+
<slider bind="seats" label="人数" initial="2" min="1" max="20">
|
|
8
|
+
|
|
9
|
+
当前人数:{{ seat }}。
|
|
10
|
+
|
|
11
|
+
## 重复声明初值
|
|
12
|
+
|
|
13
|
+
<number bind="seats" label="另一处人数输入" initial="3" min="1" max="20">
|
|
14
|
+
|
|
15
|
+
## 超出范围的初值
|
|
16
|
+
|
|
17
|
+
<slider bind="ratio" label="比例" initial="12" min="0" max="10">
|
|
18
|
+
|
|
19
|
+
## 条件类型错误
|
|
20
|
+
|
|
21
|
+
<if when="{{ seats }}">
|
|
22
|
+
这里需要布尔条件,例如 seats 大于 5。
|
|
23
|
+
</if>
|
|
24
|
+
|
|
25
|
+
## 未知标签
|
|
26
|
+
|
|
27
|
+
<slidr label="拼错的滑块" />
|
|
28
|
+
|
|
29
|
+
## 不属于本地交互语言的事件
|
|
30
|
+
|
|
31
|
+
<counter label="计数" on-click="increment">
|
|
32
|
+
|
|
33
|
+
## 缺少节点
|
|
34
|
+
|
|
35
|
+
<diagram label="错误连线">
|
|
36
|
+
<node id="input" label="输入">
|
|
37
|
+
只有这一个节点。
|
|
38
|
+
</node>
|
|
39
|
+
<edge from="input" to="missing">
|
|
40
|
+
</diagram>
|
|
41
|
+
|
|
42
|
+
## 不支持计算的数学结构
|
|
43
|
+
|
|
44
|
+
<plot label="积分计算尚不属于绘图语法">
|
|
45
|
+
$$ y = \int_0^x t^2\,dt $$
|
|
46
|
+
</plot>
|
|
47
|
+
|
|
48
|
+
## 无效的图表数据
|
|
49
|
+
|
|
50
|
+
<chart title="数值列中混入了单位">
|
|
51
|
+
| 项目 | 费用 |
|
|
52
|
+
| --- | ---: |
|
|
53
|
+
| 内容 | 20 元 |
|
|
54
|
+
</chart>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# 让解释可以被探索
|
|
2
|
+
|
|
3
|
+
点击节点或使用键盘选择一个环节,查看它的说明。
|
|
4
|
+
|
|
5
|
+
<diagram bind="selected" initial="input" label="响应式状态流">
|
|
6
|
+
<node id="input" label="输入">
|
|
7
|
+
读者通过滑块、开关和输入框改变参数。
|
|
8
|
+
</node>
|
|
9
|
+
|
|
10
|
+
<node id="compute" label="计算">
|
|
11
|
+
重新计算依赖这些参数的公式。
|
|
12
|
+
</node>
|
|
13
|
+
|
|
14
|
+
<node id="view" label="显示">
|
|
15
|
+
正文、图表和提示随结果更新。
|
|
16
|
+
</node>
|
|
17
|
+
|
|
18
|
+
<edge from="input" to="compute" label="参数变化">
|
|
19
|
+
<edge from="compute" to="view" label="更新结果">
|
|
20
|
+
</diagram>
|
|
21
|
+
|
|
22
|
+
当前环节:{{ selected == 'input' ? '输入' : selected == 'compute' ? '计算' : '显示' }}。
|
|
23
|
+
|
|
24
|
+
## 改变参数,观察曲线
|
|
25
|
+
|
|
26
|
+
<panel title="正弦波参数">
|
|
27
|
+
<slider bind="a" label="振幅" initial="1" min="0" max="3" step="0.5">
|
|
28
|
+
<slider bind="f" label="频率参数" initial="1" min="0.5" max="3" step="0.5">
|
|
29
|
+
</panel>
|
|
30
|
+
|
|
31
|
+
<plot min="0" max="12.56" label="正弦波" x-label="x" y-label="位移">
|
|
32
|
+
$$ y = a\sin(fx) $$
|
|
33
|
+
</plot>
|
|
34
|
+
|
|
35
|
+
<if when="{{ a == 0 }}">
|
|
36
|
+
振幅为零,曲线与横轴重合。
|
|
37
|
+
</if>
|
|
38
|
+
|
|
39
|
+
## 叠加两条曲线
|
|
40
|
+
|
|
41
|
+
<plot min="-5" max="5" label="抛物线与直线">
|
|
42
|
+
$$ y = x^2 $$
|
|
43
|
+
$$ y = 2x + 1 $$
|
|
44
|
+
</plot>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# 常用组件画廊
|
|
2
|
+
|
|
3
|
+
## 输入与实时结果
|
|
4
|
+
|
|
5
|
+
<panel title="填写你的方案">
|
|
6
|
+
<input bind="name" label="称呼" initial="小林" placeholder="请输入名字">
|
|
7
|
+
<number bind="quantity" label="数量" initial="3" min="1" max="20">
|
|
8
|
+
|
|
9
|
+
<select bind="plan" label="方案" initial="pro">
|
|
10
|
+
<option value="basic">基础版</option>
|
|
11
|
+
<option value="pro">专业版</option>
|
|
12
|
+
</select>
|
|
13
|
+
|
|
14
|
+
<toggle bind="annual" label="年度付款(八折)">
|
|
15
|
+
<toggle bind="express" label="显示加急清单" initial="true">
|
|
16
|
+
<slider bind="budgetLevel" label="预算档位" initial="50" step="10">
|
|
17
|
+
</panel>
|
|
18
|
+
|
|
19
|
+
你好,**{{ name }}**。
|
|
20
|
+
|
|
21
|
+
预估费用:**{{ round(quantity * 80 * (plan == 'pro' ? 1 : 0.8) * (annual ? 0.8 : 1)) }} 元**。
|
|
22
|
+
|
|
23
|
+
<if when="{{ quantity >= 5 }}">
|
|
24
|
+
<badge tone="success">已达到团队档</badge>
|
|
25
|
+
</if>
|
|
26
|
+
|
|
27
|
+
| 条件 | 当前选择 |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| 方案 | {{ plan == 'pro' ? '专业版' : '基础版' }} |
|
|
30
|
+
| 年度付款 | {{ annual ? '已开启' : '未开启' }} |
|
|
31
|
+
| 预算档位 | {{ budgetLevel }} |
|
|
32
|
+
|
|
33
|
+
<if when="{{ express }}">
|
|
34
|
+
<checklist label="加急准备">
|
|
35
|
+
- [x] 已选加急展示
|
|
36
|
+
- [ ] 确认交付时间
|
|
37
|
+
</checklist>
|
|
38
|
+
</if>
|
|
39
|
+
|
|
40
|
+
## 独立操作的组件
|
|
41
|
+
|
|
42
|
+
下面的组件不需要向正文公开参数,所以省略 bind。
|
|
43
|
+
|
|
44
|
+
<grid>
|
|
45
|
+
<card title="人数计数">
|
|
46
|
+
<counter label="参与人数" initial="2" min="1" max="20">
|
|
47
|
+
</card>
|
|
48
|
+
|
|
49
|
+
<card title="短时专注">
|
|
50
|
+
<timer label="一分钟倒计时">
|
|
51
|
+
</card>
|
|
52
|
+
</grid>
|
|
53
|
+
|
|
54
|
+
## 原样展示代码
|
|
55
|
+
|
|
56
|
+
```markdown
|
|
57
|
+
<slider bind="example" label="示例参数">
|
|
58
|
+
当前值:{{ example }}。
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
以上代码只作为示例显示,不会生成控件。
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"syntaxVersion": "local-draft-1",
|
|
3
|
+
"cases": [
|
|
4
|
+
{
|
|
5
|
+
"name": "shared numeric binding has one initial value and updates prose",
|
|
6
|
+
"source": "<number bind=\"n\" label=\"Count\" initial=\"2\" min=\"0\" max=\"10\">\n<slider bind=\"n\" label=\"Shared count\" min=\"0\" max=\"10\">\n\nTotal: {{ n * 2 }}",
|
|
7
|
+
"ok": true,
|
|
8
|
+
"initial": { "n": 2 },
|
|
9
|
+
"actions": [{ "bind": "n", "value": 5 }],
|
|
10
|
+
"text": "Total: {{ n * 2 }}",
|
|
11
|
+
"expectedText": "Total: 10"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "hidden controls initialize their bindings",
|
|
15
|
+
"source": "<toggle bind=\"show\" label=\"Show\">\n<if when=\"{{ show }}\">\n<number bind=\"n\" label=\"Hidden count\" initial=\"4\">\n</if>\n\n{{ n * 2 }}",
|
|
16
|
+
"ok": true,
|
|
17
|
+
"initial": { "show": false, "n": 4 },
|
|
18
|
+
"text": "{{ n * 2 }}",
|
|
19
|
+
"expectedText": "8"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "invalid state writes keep the last valid value",
|
|
23
|
+
"source": "<number bind=\"n\" label=\"Count\" initial=\"4\" min=\"0\" max=\"10\">",
|
|
24
|
+
"ok": true,
|
|
25
|
+
"initial": { "n": 4 },
|
|
26
|
+
"actions": [{ "bind": "n", "value": 11, "codes": ["local.runtime.value"] }],
|
|
27
|
+
"text": "{{ n }}",
|
|
28
|
+
"expectedText": "4"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "code fences keep controls and interpolation literal",
|
|
32
|
+
"source": "```markdown\n<counter bind=\"n\" label=\"Literal\">\n{{ missing }}\n```",
|
|
33
|
+
"ok": true,
|
|
34
|
+
"bindingNames": []
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "unknown components preserve source with a warning",
|
|
38
|
+
"source": "<slidr label=\"Typo\">\n</slidr>",
|
|
39
|
+
"ok": true,
|
|
40
|
+
"bindingNames": [],
|
|
41
|
+
"codes": ["local.component.unknown"]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "unbound expression names produce a compiler diagnostic",
|
|
45
|
+
"source": "Total: {{ missing * 2 }}",
|
|
46
|
+
"ok": false,
|
|
47
|
+
"codes": ["local.binding.unknown"]
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# 边填写,边看结果
|
|
2
|
+
|
|
3
|
+
填写你的偏好,下方说明会立即变化。
|
|
4
|
+
|
|
5
|
+
<panel title="交流准备">
|
|
6
|
+
<input bind="name" label="称呼" placeholder="怎么称呼你?">
|
|
7
|
+
|
|
8
|
+
<choices bind="role" label="使用方式">
|
|
9
|
+
<option value="personal">个人使用</option>
|
|
10
|
+
<option value="team">团队使用</option>
|
|
11
|
+
</choices>
|
|
12
|
+
|
|
13
|
+
<date bind="appointment" label="计划交流的日期" initial="2026-10-22">
|
|
14
|
+
|
|
15
|
+
<textarea bind="message" label="想做什么交互文档?" placeholder="例如:一份可以调整参数的课程讲义">
|
|
16
|
+
|
|
17
|
+
<checkbox bind="showNotes" label="显示准备清单">
|
|
18
|
+
</panel>
|
|
19
|
+
|
|
20
|
+
<card title="当前计划">
|
|
21
|
+
称呼:**{{ name == '' ? '尚未填写' : name }}**。
|
|
22
|
+
|
|
23
|
+
使用方式:{{ role == 'personal' ? '个人使用' : '团队使用' }}。
|
|
24
|
+
|
|
25
|
+
计划日期:{{ appointment }}。
|
|
26
|
+
|
|
27
|
+
想法:{{ message == '' ? '可以先从一个小计算器开始。' : message }}
|
|
28
|
+
</card>
|
|
29
|
+
|
|
30
|
+
<if when="{{ showNotes }}">
|
|
31
|
+
<checklist label="交流前准备">
|
|
32
|
+
- [ ] 想清楚读者需要调整哪些参数
|
|
33
|
+
- [ ] 准备一个具体的计算或图表示例
|
|
34
|
+
- [ ] 写出希望读者观察到的变化
|
|
35
|
+
</checklist>
|
|
36
|
+
</if>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 计划、计时和简单工具
|
|
2
|
+
|
|
3
|
+
<timeline title="45 分钟工作计划">
|
|
4
|
+
| 事项 | 开始 | 时长 | 说明 |
|
|
5
|
+
| --- | ---: | ---: | --- |
|
|
6
|
+
| 准备材料 | 0 | 10 | 先列出所需内容 |
|
|
7
|
+
| 完成主体 | 10 | 25 | 集中完成主要部分 |
|
|
8
|
+
| 整理参考 | 15 | 15 | 可以与主体阶段并行 |
|
|
9
|
+
| 检查与交付 | 35 | 10 | 留出复核时间 |
|
|
10
|
+
</timeline>
|
|
11
|
+
|
|
12
|
+
<timer label="一分钟专注计时" duration="60">
|
|
13
|
+
|
|
14
|
+
## 聚餐分账
|
|
15
|
+
|
|
16
|
+
<panel title="分账参数">
|
|
17
|
+
<number bind="total" label="账单金额" initial="240" min="0">
|
|
18
|
+
<slider bind="people" label="分账人数" initial="3" min="1" max="12">
|
|
19
|
+
<slider bind="tip" label="额外费用(%)" initial="10" min="0" max="20">
|
|
20
|
+
</panel>
|
|
21
|
+
|
|
22
|
+
每人支付 **{{ round(total * (1 + tip / 100) / people * 100) / 100 }} 元**。
|
|
23
|
+
|
|
24
|
+
金额按两位小数四舍五入显示,不补齐末尾的零。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# 方案计算器
|
|
2
|
+
|
|
3
|
+
调整人数和付款方式,比较每月平均费用。每人每月 100 元,年度付款享受八折。
|
|
4
|
+
|
|
5
|
+
<panel title="你的方案">
|
|
6
|
+
<slider bind="seats" label="人数" initial="2" min="1" max="20">
|
|
7
|
+
<toggle bind="annual" label="年度付款">
|
|
8
|
+
</panel>
|
|
9
|
+
|
|
10
|
+
当前人数:**{{ seats }}**。
|
|
11
|
+
|
|
12
|
+
每人每月:**{{ annual ? 80 : 100 }} 元**。
|
|
13
|
+
|
|
14
|
+
每月合计:**{{ seats * (annual ? 80 : 100) }} 元**。
|
|
15
|
+
|
|
16
|
+
<if when="{{ seats >= 5 }}">
|
|
17
|
+
<alert title="团队方案">
|
|
18
|
+
你选择了至少 5 人,可以继续切换付款方式比较费用。
|
|
19
|
+
</alert>
|
|
20
|
+
</if>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tag": "v0.3.1",
|
|
3
|
+
"commit": "bdfc98bd914058df5093a1c02123ad11a9ebe207",
|
|
4
|
+
"syntaxVersion": "local-draft-1",
|
|
5
|
+
"files": [
|
|
6
|
+
{
|
|
7
|
+
"file": "local-draft-1.json",
|
|
8
|
+
"sourcePath": "examples/conformance/local-draft-1.json",
|
|
9
|
+
"sha256": "7d736ebf325f2a9c392cb44fd6edd85db2b4cff91bf8999fc8f431f9f61e55eb"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"file": "catalog.reactive.md",
|
|
13
|
+
"sourcePath": "examples/local/catalog.reactive.md",
|
|
14
|
+
"sha256": "bfb6d8d29f695cb2139676f47892613003b01278e9987b145723d8150ed70b38"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"file": "charts.reactive.md",
|
|
18
|
+
"sourcePath": "examples/local/charts.reactive.md",
|
|
19
|
+
"sha256": "16f6711e3bab7b7dfe9f4ad10364b7bafca28109d7869693a331bd2f93579254"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"file": "checklist.reactive.md",
|
|
23
|
+
"sourcePath": "examples/local/checklist.reactive.md",
|
|
24
|
+
"sha256": "8f88f50c652d58e6410eab1a50885eb356219b0efe28f67e1a1fd605c12dba2c"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"file": "comparison.reactive.md",
|
|
28
|
+
"sourcePath": "examples/local/comparison.reactive.md",
|
|
29
|
+
"sha256": "a625b2b7ef1123e5a59528de3a3fd6aed87d46e5a6e55e2a5b6691644e351deb"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"file": "components.reactive.md",
|
|
33
|
+
"sourcePath": "examples/local/components.reactive.md",
|
|
34
|
+
"sha256": "b9f2e3fdc0752f8d85afafb87513eadf22fa64c3a2e504ec6ef104c310cf64a9"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"file": "counter.reactive.md",
|
|
38
|
+
"sourcePath": "examples/local/counter.reactive.md",
|
|
39
|
+
"sha256": "659955e5a3b42b8dacca4c6da9447bf6bfcb25e651496481c4855976f36b4820"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"file": "diagnostics.reactive.md",
|
|
43
|
+
"sourcePath": "examples/local/diagnostics.reactive.md",
|
|
44
|
+
"sha256": "315a65a5df2a1968cce320b1f1c096e2994c5c36a1bfd6f7bbb5ef5bec1903c5"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"file": "diagram.reactive.md",
|
|
48
|
+
"sourcePath": "examples/local/diagram.reactive.md",
|
|
49
|
+
"sha256": "7f356517d2ce13b740c46a917dac51f74471eb6e128d367f953c129958036635"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"file": "gallery.reactive.md",
|
|
53
|
+
"sourcePath": "examples/local/gallery.reactive.md",
|
|
54
|
+
"sha256": "33d854dcff496bd85454eb5fbb52f71ac2e906ef9cdedbca5abbf74d426aef5f"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"file": "parameters.reactive.md",
|
|
58
|
+
"sourcePath": "examples/local/parameters.reactive.md",
|
|
59
|
+
"sha256": "676cd75a58cfade9e265cefce204d1fd877cfcc3071d5c0b1b368eae0b0285e1"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"file": "planning.reactive.md",
|
|
63
|
+
"sourcePath": "examples/local/planning.reactive.md",
|
|
64
|
+
"sha256": "9c101147d8f0d61adbe12f422c6e2c8e141cfb8274922055cf5ebdaada329b0a"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"file": "pricing.reactive.md",
|
|
68
|
+
"sourcePath": "examples/local/pricing.reactive.md",
|
|
69
|
+
"sha256": "79746029d23a32b1eeeeffadb36aa82807fdaa7ce7808e57f3038d5616d595eb"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"syntaxVersion": "local-draft-1",
|
|
3
|
-
"cases": [
|
|
4
|
-
{
|
|
5
|
-
"name": "shared numeric binding has one initial value and updates prose",
|
|
6
|
-
"source": "<number bind=\"n\" label=\"Count\" initial=\"2\" min=\"0\" max=\"10\">\n<slider bind=\"n\" label=\"Shared count\" min=\"0\" max=\"10\">\n\nTotal: {{ n * 2 }}",
|
|
7
|
-
"ok": true,
|
|
8
|
-
"initial": { "n": 2 },
|
|
9
|
-
"actions": [{ "bind": "n", "value": 5 }],
|
|
10
|
-
"text": "Total: {{ n * 2 }}",
|
|
11
|
-
"expectedText": "Total: 10"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"name": "hidden controls initialize their bindings",
|
|
15
|
-
"source": "<toggle bind=\"show\" label=\"Show\">\n<if when=\"{{ show }}\">\n<number bind=\"n\" label=\"Hidden count\" initial=\"4\">\n</if>\n\n{{ n * 2 }}",
|
|
16
|
-
"ok": true,
|
|
17
|
-
"initial": { "show": false, "n": 4 },
|
|
18
|
-
"text": "{{ n * 2 }}",
|
|
19
|
-
"expectedText": "8"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"name": "invalid state writes keep the last valid value",
|
|
23
|
-
"source": "<number bind=\"n\" label=\"Count\" initial=\"4\" min=\"0\" max=\"10\">",
|
|
24
|
-
"ok": true,
|
|
25
|
-
"initial": { "n": 4 },
|
|
26
|
-
"actions": [{ "bind": "n", "value": 11, "codes": ["local.runtime.value"] }],
|
|
27
|
-
"text": "{{ n }}",
|
|
28
|
-
"expectedText": "4"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"name": "code fences keep controls and interpolation literal",
|
|
32
|
-
"source": "```markdown\n<counter bind=\"n\" label=\"Literal\">\n{{ missing }}\n```",
|
|
33
|
-
"ok": true,
|
|
34
|
-
"bindingNames": []
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": "unknown components
|
|
38
|
-
"source": "<slidr label=\"Typo\">\n</slidr>",
|
|
39
|
-
"ok":
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
{
|
|
2
|
+
"syntaxVersion": "local-draft-1",
|
|
3
|
+
"cases": [
|
|
4
|
+
{
|
|
5
|
+
"name": "shared numeric binding has one initial value and updates prose",
|
|
6
|
+
"source": "<number bind=\"n\" label=\"Count\" initial=\"2\" min=\"0\" max=\"10\">\n<slider bind=\"n\" label=\"Shared count\" min=\"0\" max=\"10\">\n\nTotal: {{ n * 2 }}",
|
|
7
|
+
"ok": true,
|
|
8
|
+
"initial": { "n": 2 },
|
|
9
|
+
"actions": [{ "bind": "n", "value": 5 }],
|
|
10
|
+
"text": "Total: {{ n * 2 }}",
|
|
11
|
+
"expectedText": "Total: 10"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "hidden controls initialize their bindings",
|
|
15
|
+
"source": "<toggle bind=\"show\" label=\"Show\">\n<if when=\"{{ show }}\">\n<number bind=\"n\" label=\"Hidden count\" initial=\"4\">\n</if>\n\n{{ n * 2 }}",
|
|
16
|
+
"ok": true,
|
|
17
|
+
"initial": { "show": false, "n": 4 },
|
|
18
|
+
"text": "{{ n * 2 }}",
|
|
19
|
+
"expectedText": "8"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "invalid state writes keep the last valid value",
|
|
23
|
+
"source": "<number bind=\"n\" label=\"Count\" initial=\"4\" min=\"0\" max=\"10\">",
|
|
24
|
+
"ok": true,
|
|
25
|
+
"initial": { "n": 4 },
|
|
26
|
+
"actions": [{ "bind": "n", "value": 11, "codes": ["local.runtime.value"] }],
|
|
27
|
+
"text": "{{ n }}",
|
|
28
|
+
"expectedText": "4"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "code fences keep controls and interpolation literal",
|
|
32
|
+
"source": "```markdown\n<counter bind=\"n\" label=\"Literal\">\n{{ missing }}\n```",
|
|
33
|
+
"ok": true,
|
|
34
|
+
"bindingNames": []
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "unknown components preserve source with a warning",
|
|
38
|
+
"source": "<slidr label=\"Typo\">\n</slidr>",
|
|
39
|
+
"ok": true,
|
|
40
|
+
"bindingNames": [],
|
|
41
|
+
"codes": ["local.component.unknown"]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "unbound expression names produce a compiler diagnostic",
|
|
45
|
+
"source": "Total: {{ missing * 2 }}",
|
|
46
|
+
"ok": false,
|
|
47
|
+
"codes": ["local.binding.unknown"]
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|