reactive-md 0.5.3 → 0.6.1

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.
Files changed (141) hide show
  1. package/CHANGELOG-ch.md +195 -165
  2. package/CHANGELOG.md +195 -165
  3. package/CONTRIBUTING-ch.md +67 -62
  4. package/CONTRIBUTING.md +69 -64
  5. package/README-ch.md +157 -155
  6. package/README-en.md +184 -181
  7. package/README.md +184 -181
  8. package/SECURITY-ch.md +81 -81
  9. package/SECURITY.md +81 -81
  10. package/THIRD_PARTY_NOTICES.md +585 -1
  11. package/bin/reactive-md.mjs +39 -39
  12. package/cli/args.mjs +181 -181
  13. package/cli/assets.mjs +390 -390
  14. package/cli/build.mjs +268 -268
  15. package/cli/document.mjs +130 -130
  16. package/cli/errors.mjs +61 -61
  17. package/cli/fs-utils.mjs +133 -133
  18. package/cli/glob.mjs +203 -203
  19. package/cli/help.mjs +138 -138
  20. package/cli/lint.mjs +177 -177
  21. package/cli/main.mjs +55 -55
  22. package/cli/migrate.mjs +368 -368
  23. package/cli/package.mjs +210 -210
  24. package/dist-library/{authoring-DJJjKYg9.js → authoring-BEVyth5X.js} +58 -58
  25. package/dist-library/compiler-Cm3ppMxG.js +46044 -0
  26. package/dist-library/react-Bh7_oxZp.js +59655 -0
  27. package/dist-library/reactive-md-authoring.js +2 -2
  28. package/dist-library/reactive-md-editor.js +13 -0
  29. package/dist-library/reactive-md-print.css +284 -284
  30. package/dist-library/reactive-md-react-unstyled.js +1 -1
  31. package/dist-library/reactive-md-react.js +1 -1
  32. package/dist-library/reactive-md.css +1 -1
  33. package/dist-library/reactive-md.js +123 -123
  34. package/dist-library/{runtime-DXtle_6c.js → runtime-DlFYQ4s_.js} +151 -151
  35. package/dist-library/types/editor/types.d.ts +2 -0
  36. package/dist-library/types/local/code-block.d.ts +3 -1
  37. package/dist-library/types/local/code-languages.d.ts +7 -0
  38. package/dist-library/types/local/compiled-data.d.ts +6 -0
  39. package/dist-library/types/local/compiler.d.ts +1 -0
  40. package/dist-library/types/local/diagnostics.d.ts +31 -0
  41. package/dist-library/types/local/diagram-layout.d.ts +69 -0
  42. package/dist-library/types/local/html-names.d.ts +6 -0
  43. package/dist-library/types/local/html-table.d.ts +25 -0
  44. package/dist-library/types/local/math-display.d.ts +22 -22
  45. package/dist-library/types/local/math-view.d.ts +6 -7
  46. package/dist-library/types/local/table-surface.d.ts +10 -0
  47. package/dist-library/types/local/types.d.ts +2 -0
  48. package/dist-library/types/local/visuals.d.ts +9 -0
  49. package/dist-standalone/reactive-md-standalone.css +1 -1
  50. package/dist-standalone/reactive-md-standalone.js +331 -51
  51. package/docs/README.md +84 -0
  52. package/docs/{compatibility-ch.md → compatibility/compatibility-ch.md} +121 -109
  53. package/docs/{compatibility-en.md → compatibility/compatibility-en.md} +121 -109
  54. package/docs/{source-versioning-ch.md → compatibility/source-versioning-ch.md} +159 -159
  55. package/docs/{source-versioning-en.md → compatibility/source-versioning-en.md} +159 -159
  56. package/docs/{component-development-ch.md → development/component-development-ch.md} +210 -210
  57. package/docs/{component-development-en.md → development/component-development-en.md} +210 -210
  58. package/docs/{component-protocol-ch.md → development/component-protocol-ch.md} +747 -747
  59. package/docs/{component-protocol-en.md → development/component-protocol-en.md} +747 -747
  60. package/docs/{performance-ch.md → development/performance-ch.md} +76 -76
  61. package/docs/{performance-en.md → development/performance-en.md} +76 -76
  62. package/docs/{releasing-ch.md → development/releasing-ch.md} +108 -108
  63. package/docs/{releasing-en.md → development/releasing-en.md} +108 -108
  64. package/docs/guides/local-guide-ch.md +513 -0
  65. package/docs/guides/local-guide-en.md +513 -0
  66. package/docs/{author-tools-ch.md → integration/author-tools-ch.md} +57 -57
  67. package/docs/{author-tools-en.md → integration/author-tools-en.md} +57 -57
  68. package/docs/{editor-ch.md → integration/editor-ch.md} +7 -6
  69. package/docs/{editor-en.md → integration/editor-en.md} +7 -6
  70. package/docs/{local-integration-ch.md → integration/local-integration-ch.md} +33 -15
  71. package/docs/{local-integration-en.md → integration/local-integration-en.md} +33 -15
  72. package/docs/{shareable-export-ch.md → integration/shareable-export-ch.md} +221 -209
  73. package/docs/{shareable-export-en.md → integration/shareable-export-en.md} +223 -211
  74. package/docs/{computations-formatting-ch.md → reference/computations-formatting-ch.md} +87 -87
  75. package/docs/{computations-formatting-en.md → reference/computations-formatting-en.md} +87 -87
  76. package/docs/{constraints-collections-ch.md → reference/constraints-collections-ch.md} +84 -84
  77. package/docs/{constraints-collections-en.md → reference/constraints-collections-en.md} +84 -84
  78. package/docs/{diagnostics-counting-ch.md → reference/diagnostics-counting-ch.md} +104 -84
  79. package/docs/{diagnostics-counting-en.md → reference/diagnostics-counting-en.md} +104 -84
  80. package/docs/{html-compatibility-ch.md → reference/html-compatibility-ch.md} +42 -4
  81. package/docs/{html-compatibility-en.md → reference/html-compatibility-en.md} +42 -4
  82. package/docs/{local-components-v2-ch.md → reference/local-components-v2-ch.md} +138 -138
  83. package/docs/{local-components-v2-en.md → reference/local-components-v2-en.md} +104 -104
  84. package/docs/{local-interaction-syntax-ch.md → reference/local-interaction-syntax-ch.md} +515 -492
  85. package/docs/{local-interaction-syntax-en.md → reference/local-interaction-syntax-en.md} +511 -488
  86. package/docs/{theme-protocol-ch.md → reference/theme-protocol-ch.md} +107 -107
  87. package/docs/{theme-protocol-en.md → reference/theme-protocol-en.md} +107 -107
  88. package/docs/{release-0.4.0-ch.md → releases/release-0.4.0-ch.md} +89 -89
  89. package/docs/{release-0.4.0-en.md → releases/release-0.4.0-en.md} +89 -89
  90. package/docs/{release-0.4.1-ch.md → releases/release-0.4.1-ch.md} +23 -23
  91. package/docs/{release-0.4.1-en.md → releases/release-0.4.1-en.md} +23 -23
  92. package/docs/{release-0.5.0-ch.md → releases/release-0.5.0-ch.md} +4 -4
  93. package/docs/{release-0.5.0-en.md → releases/release-0.5.0-en.md} +4 -4
  94. package/docs/{release-0.5.1-ch.md → releases/release-0.5.1-ch.md} +4 -4
  95. package/docs/{release-0.5.1-en.md → releases/release-0.5.1-en.md} +4 -4
  96. package/docs/{release-0.5.2-ch.md → releases/release-0.5.2-ch.md} +3 -3
  97. package/docs/{release-0.5.2-en.md → releases/release-0.5.2-en.md} +3 -3
  98. package/docs/{release-0.5.3-ch.md → releases/release-0.5.3-ch.md} +1 -1
  99. package/docs/{release-0.5.3-en.md → releases/release-0.5.3-en.md} +1 -1
  100. package/docs/releases/release-0.6.0-ch.md +57 -0
  101. package/docs/releases/release-0.6.0-en.md +57 -0
  102. package/docs/releases/release-0.6.1-ch.md +27 -0
  103. package/docs/releases/release-0.6.1-en.md +27 -0
  104. package/examples/conformance/README.md +53 -53
  105. package/examples/conformance/component-protocol-1.json +482 -482
  106. package/examples/conformance/component-protocol-1.schema.json +76 -76
  107. package/examples/conformance/local-draft-1.json +50 -50
  108. package/examples/conformance/local-draft-2.json +212 -212
  109. package/examples/integration/README.md +47 -45
  110. package/examples/integration/core/index.mjs +32 -32
  111. package/examples/integration/worker/index.html +19 -19
  112. package/examples/integration/worker/main.js +61 -61
  113. package/examples/integration/worker/package.json +13 -13
  114. package/examples/integration/worker/worker.js +3 -3
  115. package/examples/local/README.md +74 -74
  116. package/examples/local/charts.reactive.md +73 -73
  117. package/examples/local/html-compat.reactive.md +19 -0
  118. package/examples/local/recipes/invoice-zh.reactive.md +36 -36
  119. package/examples/local/recipes/invoice.reactive.md +36 -36
  120. package/examples/local/recipes/workshop-zh.reactive.md +33 -33
  121. package/examples/local/recipes/workshop.reactive.md +33 -33
  122. package/examples/local/showcase/README.md +25 -25
  123. package/examples/local/showcase/explore.reactive.md +102 -102
  124. package/examples/local/showcase/flow.reactive.md +86 -86
  125. package/examples/local/showcase/forms.reactive.md +126 -126
  126. package/examples/local/showcase/functions.reactive.md +119 -119
  127. package/examples/local/showcase/layout.reactive.md +100 -100
  128. package/examples/local/showcase/statistics.reactive.md +108 -108
  129. package/examples/local/showcase/tasks.reactive.md +89 -89
  130. package/examples/local/showcase/zh/explore.reactive.md +102 -102
  131. package/examples/local/showcase/zh/flow.reactive.md +86 -86
  132. package/examples/local/showcase/zh/forms.reactive.md +126 -126
  133. package/examples/local/showcase/zh/functions.reactive.md +119 -119
  134. package/examples/local/showcase/zh/layout.reactive.md +100 -100
  135. package/examples/local/showcase/zh/statistics.reactive.md +108 -108
  136. package/examples/local/showcase/zh/tasks.reactive.md +89 -89
  137. package/package.json +152 -145
  138. package/dist-library/compiler-UyPwGzJZ.js +0 -22109
  139. package/dist-library/react-fizgU3i8.js +0 -12764
  140. package/docs/local-guide-ch.md +0 -967
  141. package/docs/local-guide-en.md +0 -967
@@ -65,25 +65,63 @@ React 快捷组件通过 `compileOptions` 接收同样的设置:
65
65
  | 代码 | `code`、`pre`、`pre` 内的 `code` |
66
66
  | 列表 | `ul`、`ol`、`li`,含 `ol[start]` |
67
67
  | 链接与图片 | `a`、`img`,沿用默认路径的 URL 策略 |
68
+ | 原生表格 | `table`、`caption`、`colgroup`、`col`、`thead`、`tbody`、`tfoot`、`tr`、`th`、`td`,按正文结构与 ReactiveMD 表格区分 |
68
69
  | 其他写法 | HTML 注释、命名及数字字符引用、HTML 大小写和空元素写法 |
69
70
 
70
71
  容器中的正文继续解析 Markdown、公式、插值和 ReactiveMD 控件;`code`、`pre` 中的内容按字面显示。`details` 复用现有折叠组件的主题和交互,支持富文本标题、嵌套和 `open`,静态模式展开正文。HTML 布尔属性按存在与否判断,因此 `open="false"` 仍表示展开;现有 ReactiveMD 组件的布尔值规则保持不变。
71
72
 
72
- 可运行示例见 [HTML 与 ReactiveMD](../examples/local/html-compat.reactive.md)。
73
+ 可运行示例见 [HTML 与 ReactiveMD](../../examples/local/html-compat.reactive.md)。
74
+
75
+ `div`、`p` 和 `h1` 至 `h6` 支持静态 `align` 属性,取值为 `left`、`center`、`right` 或 `justify`,忽略大小写和首尾空白。例如:
76
+
77
+ ```html
78
+ <div align="center">你好</div>
79
+ <p align="right">右对齐的 **Markdown** 段落。</p>
80
+ ```
81
+
82
+ 对齐不需要开启 CSS 或扩展 HTML,容器内的 Markdown 和绑定继续生效;嵌套元素可以设置自己的对齐。原生 HTML 路径同样接受这些限定值。
73
83
 
74
84
  通用属性按允许列表接收,支持文档标识、标题、语言、方向和可访问性属性。默认模式中的作者 `style`、事件处理属性及不支持的标签保持惰性源码或产生定位诊断。图片仍需宿主明确允许后才加载。代码与不支持区域不执行脚本。
75
85
 
86
+ `a` 支持静态 `target`、`rel` 属性,例如 `<a href="https://example.com" target="_self" rel="nofollow">当前页面打开</a>`。显式 `target` 覆盖默认打开方式,`rel` 支持多个空白分隔的关系词。默认混排模式中,未指定属性的 HTTP(S) 链接仍使用 `_blank` 和 `noopener noreferrer`;相对链接仍在当前页面打开。`target="_blank"` 会保留作者关系词、合并 `noopener noreferrer` 并移除冲突的 `opener`。沙箱 HTML 路径也支持这两个属性,且继续限制 `_top`、`_parent` 导航及弹窗权限。
87
+
88
+ ## 两种表格写法
89
+
90
+ `<table>` 的正文是 Markdown 表格时,继续使用 ReactiveMD 表格组件,保留搜索、排序、分页和行选择。正文出现原生表格结构时,解析为 HTML 表格,无需开启扩展 HTML,也不切换整篇文档的模式:
91
+
92
+ ```html
93
+ <table>
94
+ <caption>价格表</caption>
95
+ <tr><th scope="col">商品</th><th scope="col">价格</th></tr>
96
+ <tr><td>苹果</td><td>5</td></tr>
97
+ <tr><td colspan="2">**说明**:价格可随参数更新。</td></tr>
98
+ </table>
99
+ ```
100
+
101
+ 两种写法共用表格框架、标题、单元格样式和窄屏滚动。普通数字列使用相同的自动对齐规则;合并单元格保留其结构,单元格可用 `align` 明确设置对齐。原生表格默认不添加搜索、排序、分页或选择控件。
102
+
103
+ 支持 `colspan`、`rowspan`、`scope`、`headers` 和 `col` / `colgroup` 的 `span`。`colspan` 与 `span` 为 1–1000;`rowspan` 为 0–65534,其中 0 表示延伸到当前行组末尾。单元格和标题内继续解析 Markdown、公式、插值、图片及控件;省略的行组、行和单元格结束标签按 HTML 规则补齐,原始源码位置保持不变。
104
+
105
+ 同一表格混用 Markdown 表格行与 HTML 表格结构会产生诊断,并将该表格按原文显示。原生表格不接受 `bind`、`key`、`label`、`searchable`、`sortable`、`page-size` 等组件属性;标题用 `caption`,无障碍名称也可用 `aria-label`。代码示例中的结构标签不参与类型判断。
106
+
107
+ ### 原文回退
108
+
109
+ 成功转为惰性源码时发出 `local.html.fallback` 警告。未知 ReactiveMD 组件继续使用 `local.component.unknown`;致命编译失败仍返回 `ok: false`。宿主可以单独放行回退警告,同时保留对组件拼写错误的检查。详见[诊断契约](diagnostics-counting-ch.md#原生-html-安全回退)。
110
+
111
+ 无法编译的局部原生 HTML 按原文显示,其余 Markdown、公式和控件继续工作。回退覆盖不支持的标签或属性、无效的原生表格,以及缺少完整结束标记的 HTML 片段。无法找到结束标签时,片段截至当前段落或外层 ReactiveMD 容器的结束标签。回退片段中的 Markdown、`{{ 表达式 }}`、组件和脚本均保留为文本。
112
+
113
+ 原生 HTML 路径中,不支持的属性会使所在元素回退为原文;相邻元素继续渲染。整篇解析、序列化或编译预算检查失败时,React 预览和 standalone 挂载显示完整源码,保留换行并转义标签。`compileLocal` 的错误结果、资源限制和 `onDiagnostics` 诊断仍保留;配置错误及 ReactiveMD 组件语法错误继续按原规则处理。
114
+
76
115
  ## 扩展 HTML
77
116
 
78
117
  `enableExtendedHtml` 管理以下作者语法:
79
118
 
80
- - 表格及结构:`table`、`caption`、`thead`、`tbody`、`tfoot`、`tr`、`th`、`td`。
81
119
  - 定义列表:`dl`、`dt`、`dd`。
82
120
  - 补充文字语义:`small`、`kbd`、`samp`、`var`、`abbr`、`q`、`cite`、`ins`。
83
121
  - 图文和结构:`figure`、`figcaption`、`article`、`section`、`aside`、`header`、`footer`、`ruby`、`rt`、`rp`、`wbr`。
84
122
  - 原生表单、`iframe`、`object`、`embed`、`dialog`、任意 SVG/MathML 和整页 HTML 功能。
85
123
 
86
- 在默认模式中,已有的 ReactiveMD `<table>`、`<section>`、`<input>`、`<select>` 等组件继续采用当前语义。在原生 HTML 模式中,同名元素采用浏览器语义。
124
+ 在默认模式中,ReactiveMD `<table>` 按正文结构与原生表格区分;`<section>`、`<input>`、`<select>` 等同名组件继续采用当前语义。在原生 HTML 模式中,同名元素采用浏览器语义。
87
125
 
88
126
  ## 隔离与导出
89
127
 
@@ -95,4 +133,4 @@ React 快捷组件通过 `compileOptions` 接收同样的设置:
95
133
 
96
134
  交互导出保留本次编译选项和文档路径。原生 HTML 的静态导出保留浏览器内建的折叠和表单行为,并禁用作者 JavaScript。这类文档没有可保存的 ReactiveMD 参数。旧导出载荷省略编译选项时采用三个开关全部关闭的默认行为。
97
135
 
98
- 相关规则见[集成说明](local-integration-ch.md)、[可分享导出](shareable-export-ch.md)和[安全约定](../SECURITY-ch.md)。
136
+ 相关规则见[集成说明](../integration/local-integration-ch.md)、[可分享导出](../integration/shareable-export-ch.md)和[安全约定](../../SECURITY-ch.md)。
@@ -65,25 +65,63 @@ Lower-level hosts pass the compiled document to `LocalDocumentView`. Native HTML
65
65
  | Code | `code`, `pre`, and `code` inside `pre` |
66
66
  | Lists | `ul`, `ol`, `li`, including `ol[start]` |
67
67
  | Links and images | `a`, `img`, using the default path's URL policy |
68
+ | Native tables | `table`, `caption`, `colgroup`, `col`, `thead`, `tbody`, `tfoot`, `tr`, `th`, `td`; distinguished from ReactiveMD tables by their body structure |
68
69
  | Other forms | HTML comments, named and numeric character references, case-insensitive HTML names and void-element spelling |
69
70
 
70
71
  Container bodies continue to parse Markdown, formulas, interpolation and ReactiveMD controls. Code elements preserve literal content. `details` reuses the existing disclosure theme and interaction, with rich summaries, nesting and the `open` attribute. Static rendering expands the body. HTML boolean attributes use presence semantics, so `open="false"` still means open. Existing ReactiveMD component boolean rules stay unchanged.
71
72
 
72
- See the runnable [HTML and ReactiveMD example](../examples/local/html-compat.reactive.md).
73
+ See the runnable [HTML and ReactiveMD example](../../examples/local/html-compat.reactive.md).
74
+
75
+ `div`, `p` and `h1` through `h6` accept a static `align` attribute with `left`, `center`, `right` or `justify`. Values ignore case and surrounding whitespace. For example:
76
+
77
+ ```html
78
+ <div align="center">Hello</div>
79
+ <p align="right">A right-aligned **Markdown** paragraph.</p>
80
+ ```
81
+
82
+ Alignment works without enabling CSS or extended HTML. Markdown and bindings inside the container remain active, and nested elements can override the inherited alignment. The native HTML route accepts the same bounded values.
73
83
 
74
84
  Common attributes use an allowlist for document identifiers, titles, language, direction and accessibility. Author styles, event-handler attributes and unsupported elements in the default mode remain inert source or produce positioned diagnostics. Images still require explicit host approval. Code and unsupported regions execute no scripts.
75
85
 
86
+ Anchors accept static `target` and `rel` attributes, for example `<a href="https://example.com" target="_self" rel="nofollow">Open here</a>`. An explicit `target` overrides the default opening behavior; `rel` accepts whitespace-separated relationship tokens. In the default mixed mode, HTTP(S) links without these attributes retain `_blank` and `noopener noreferrer`, while relative links open in the current page. A `_blank` target preserves author relationship tokens, merges `noopener noreferrer` and removes the conflicting `opener` token. The sandboxed HTML route also accepts these attributes, retaining its restrictions on `_top`, `_parent` navigation and popups.
87
+
88
+ ## Two table syntaxes
89
+
90
+ A `<table>` containing a Markdown table remains a ReactiveMD component, with its existing search, sorting, pagination and row selection. A body with native table structure is parsed as an HTML table without enabling extended HTML or changing the whole document's mode:
91
+
92
+ ```html
93
+ <table>
94
+ <caption>Prices</caption>
95
+ <tr><th scope="col">Item</th><th scope="col">Price</th></tr>
96
+ <tr><td>Apple</td><td>5</td></tr>
97
+ <tr><td colspan="2">**Note**: prices can follow document parameters.</td></tr>
98
+ </table>
99
+ ```
100
+
101
+ Both syntaxes share the table frame, title, cell styles and narrow-screen scrolling. Plain numeric columns use the same automatic alignment rules. Merged cells preserve their structure; cells can set `align` explicitly. Native tables add no search, sorting, pagination or selection controls by default.
102
+
103
+ Supported attributes include `colspan`, `rowspan`, `scope`, `headers` and `span` on `col` / `colgroup`. `colspan` and `span` accept 1–1000; `rowspan` accepts 0–65534, with 0 extending to the end of the current row group. Cells and captions support Markdown, formulas, interpolation, images and controls. Omitted row groups, row ends and cell ends are normalized using HTML rules, while source locations retain their original offsets.
104
+
105
+ Mixing Markdown table rows and HTML table structure in one table produces a diagnostic and displays that table as source. Native tables reject component attributes such as `bind`, `key`, `label`, `searchable`, `sortable` and `page-size`; use `caption` for a title or `aria-label` for an accessible name. Structural tags inside code examples never determine the table type.
106
+
107
+ ### Source fallback
108
+
109
+ Successful conversion to inert source emits a `local.html.fallback` warning. Unknown ReactiveMD components retain `local.component.unknown`; fatal compilation still returns `ok: false`. Hosts can explicitly allow the fallback warning without allowing component spelling errors. See the [diagnostic contract](diagnostics-counting-en.md#safe-native-html-fallback).
110
+
111
+ Native HTML fragments that cannot compile are displayed as their original text, while surrounding Markdown, formulas and controls continue to work. This covers unsupported tags or attributes, invalid native tables and incomplete HTML fragments. An unclosed fragment ends at the current paragraph boundary or the enclosing ReactiveMD container's closing tag. Markdown, `{{ expressions }}`, components and scripts inside a fallback fragment stay literal.
112
+
113
+ In the native HTML route, an unsupported attribute makes its element fall back to source while neighboring elements continue to render. If whole-document parsing, serialization or compilation budget checks fail, React previews and standalone mounts display the complete source with preserved line breaks and escaped tags. Error results from `compileLocal`, resource limits and `onDiagnostics` reports are retained. Invalid host options and ReactiveMD component syntax errors keep their existing behavior.
114
+
76
115
  ## Extended HTML
77
116
 
78
117
  `enableExtendedHtml` controls the following author syntax:
79
118
 
80
- - Tables and their structure: `table`, `caption`, `thead`, `tbody`, `tfoot`, `tr`, `th`, `td`.
81
119
  - Definition lists: `dl`, `dt`, `dd`.
82
120
  - Additional text semantics: `small`, `kbd`, `samp`, `var`, `abbr`, `q`, `cite`, `ins`.
83
121
  - Figures and structure: `figure`, `figcaption`, `article`, `section`, `aside`, `header`, `footer`, `ruby`, `rt`, `rp`, `wbr`.
84
122
  - Native forms, `iframe`, `object`, `embed`, `dialog`, arbitrary SVG/MathML and whole-page HTML features.
85
123
 
86
- In the default mode, existing ReactiveMD components such as `table`, `section`, `input` and `select` retain their current meanings. In native HTML mode, these names use browser semantics.
124
+ In the default mode, `table` distinguishes native and ReactiveMD syntax by its body; existing components such as `section`, `input` and `select` retain their current meanings. In native HTML mode, these names use browser semantics.
87
125
 
88
126
  ## Isolation and export
89
127
 
@@ -95,4 +133,4 @@ Once arbitrary JavaScript is enabled, scripts can create elements and styles dyn
95
133
 
96
134
  Interactive export preserves compile options and the selected rendering path. Native HTML static export retains built-in browser disclosure and form behavior while disabling author JavaScript. These documents have no ReactiveMD parameters to save. Older export payloads without compile options use the default with all three capabilities off.
97
135
 
98
- See [integration](local-integration-en.md), [shareable export](shareable-export-en.md) and [security](../SECURITY.md).
136
+ See [integration](../integration/local-integration-en.md), [shareable export](../integration/shareable-export-en.md) and [security](../../SECURITY.md).
@@ -1,138 +1,138 @@
1
- # 新增组块与迁移:local-draft-2
2
-
3
- 本页说明 `0.4.0` 的新增组块与 `local-draft-2` 语法。它是[本地交互语法规范](local-interaction-syntax-ch.md)的补充。贡献与验收继续使用 `component-protocol-1`,机器格式保持不变。
4
-
5
- ## 跳转与正文颜色
6
-
7
- ```markdown
8
- <jump to="result" appearance="button" color="#2563eb">查看结果</jump>
9
-
10
- <section color="#45536f">
11
- 普通正文,<text color="#a2273a">**重点提醒**</text>。
12
-
13
- 第二段继承外层颜色,支持 {{ count }} 等插值。
14
- </section>
15
-
16
- <anchor id="result">
17
-
18
- ## 结果
19
-
20
- 结果显示在这里。
21
- ```
22
-
23
- 本例中的 `count` 需由一个控件声明,例如 `<counter bind="count" label="数量">`。
24
-
25
- | 组块 | 形态 | 属性与规则 |
26
- | --- | --- | --- |
27
- | jump | 行内、成对标签 | `to` 必填,为静态文档内目标名;`appearance=link/button`,默认 link;可选 color;正文为行内 Markdown |
28
- | anchor | 无正文标签 | `id` 必填,匹配 `[A-Za-z_][A-Za-z0-9_-]*`,当前文档内唯一 |
29
- | text | 行内、成对标签 | color 必填,正文为行内 Markdown 与插值 |
30
- | section | 块容器、成对标签 | color 必填,内部继续解析 Markdown;不添加边框和背景 |
31
-
32
- jump 可以指向自动生成的标题锚点或显式 anchor,不写前导 `#`。普通 Markdown 链接仍使用 `[结果](#result)`。实际 DOM ID 按文档实例隔离;显式 ID 与标题锚点冲突、跳转目标不存在时编译失败。点击后滚动并移动焦点,隐藏目标显示局部提示,保留读者已填写的参数。
33
-
34
- color 是静态颜色名或 `#RGB`、`#RRGGBB`。它不接受表达式、CSS 函数、变量或声明。颜色名由共享校验表限定;无效值给出编译诊断。text/section 的 color 控制文字,内层显式颜色覆盖继承;链接和交互控件保留自身配色。jump/badge 使用文字或强调色;progress 使用填充色;slider、toggle、checkbox、select、choices、radio-group、checklist 以及新输入组块使用激活色。省略时沿用主题。tone 的语义保持不变。
35
-
36
- ## 待办与多选
37
-
38
- checklist 继续接受原有 Markdown 任务列表。勾选后仅该项正文加删除线并变淡,取消勾选后恢复;初始 `[x]` 也呈现完成样式。绑定、隐藏与面板重置保持原有规则。
39
-
40
- ```markdown
41
- <multi-select bind="subjects" label="主题" max-selected="2" initial="math">
42
- <option value="math">数学</option>
43
- <option value="physics">物理</option>
44
- <option value="chemistry">化学</option>
45
- </multi-select>
46
-
47
- 已选择 {{ len(subjects) }} 项。
48
- ```
49
-
50
- multi-select 是有正文容器,只接受 option 子项,label 必填;bind 可省略。公开值为按源码顺序排列的字符串数组,默认空数组;initial 为逗号分隔的静态 value。value 非空、唯一,且不含逗号。max-selected 为非负整数,默认选项数。组件内置搜索、清空,达到上限仍可取消已选项;disabled 可以使用布尔表达式。该绑定为独占 family,保留已有数组大小和字符串预算。
51
-
52
- ## 区间与二维坐标
53
-
54
- ```markdown
55
- <range-slider label="观察区间" bind-start="low" bind-end="high"
56
- initial-start="20" initial-end="80" min="0" max="100" step="1">
57
-
58
- 区间宽度:{{ high - low }}。
59
-
60
- <coordinate label="坐标点" bind-x="px" bind-y="py"
61
- initial-x="1" initial-y="2"
62
- x-min="-5" x-max="5" y-min="-5" y-max="5" step="1">
63
-
64
- 坐标:({{ px }}, {{ py }})。
65
- ```
66
-
67
- 这两个组块均为无正文标签,label 必填,支持 color 与动态 disabled。范围和步长都是静态有限数,step 必须为正。
68
-
69
- - range-slider 默认 min=0、max=100、step=1;起点默认 min,终点默认不超过 max 的最大合法步长值。始终满足起点不大于终点,交叉写入被拒绝,不交换端点。
70
- - coordinate 默认两个轴范围均为 -5 到 5,step=1;各轴初值取最接近零的合法值。支持拖动、键盘和数值输入,指针输入吸附到合法步长。
71
- - 每个绑定名独立可选,省略时仍有内部状态;首版各槽位独占拥有绑定,不能与其他控件共享。`x`、`y` 仍是保留名,示例使用 px、py。
72
- - 所有槽位在编译时初始化;多值写入和重置均为原子更新,拒绝写入时状态与 revision 保持不变。
73
-
74
- 宿主 API 扩展:`runtime.get(node, slot?)`、`runtime.set(node, value, slot?)` 保留原调用方式,新增 `runtime.setMany(node, values)`。range-slider 的 slot 为 start/end,coordinate 为 x/y;setMany 使用 slot 名作为对象键。运行时根据已登记的节点和槽位校验,调用方提供的伪造属性不改变权限或约束。
75
-
76
- ## 练习与分步阅读
77
-
78
- ```markdown
79
- <quiz type="choice" label="2 + 3 等于多少?" answer="b" explanation="相加得到 5。">
80
- <option value="a">4</option>
81
- <option value="b">5</option>
82
- </quiz>
83
-
84
- <quiz type="number" label="圆周率近似值" answer="3.14" tolerance="0.01">
85
- </quiz>
86
-
87
- <steps label="学习路线" bind="lesson">
88
- <step label="观察" value="observe">
89
- 调整参数,观察结果。
90
- </step>
91
- <step label="练习" value="practice">
92
- 检查一道练习题。
93
- </step>
94
- </steps>
95
- ```
96
-
97
- quiz 的 type 默认 choice,label/answer 必填;choice 接受 option,answer 必须是现有 value。number 的正文为空,answer 为有限数,tolerance 默认为 0 且非负。explanation 可选,可含文本插值。组件内置检查答案、反馈与重试,首版不公开 bind;答案随源码提供,适合自学练习。隐藏后保留草稿与反馈,面板重置清除它们。
98
-
99
- steps 只接受一个或多个 step。steps.label 可选,bind 可选且独占;initial 默认第一步 value。step.label 必填,value 可省略,按顺序生成 step-1、step-2 等,同组唯一。组件提供上一步、下一步和当前位置;仅当前内容显示,所有子控件仍参与编译和初始化。切换保留内容状态,隐藏计时器暂停;面板重置恢复初始步骤和子内容。
100
-
101
- ## 表格与图表选择
102
-
103
- ```markdown
104
- <table bind="project" key="项目" initial="内容">
105
- | 项目 | 费用 |
106
- | --- | ---: |
107
- | 内容 | 120 |
108
- | 视觉 | 230 |
109
- </table>
110
-
111
- <chart bind="project" key="项目">
112
- | 项目 | 费用 |
113
- | --- | ---: |
114
- | 内容 | 120 |
115
- | 视觉 | 230 |
116
- </chart>
117
-
118
- 当前项目:{{ project }}。
119
- ```
120
-
121
- key 指定静态标识列,值必须非空、唯一且没有插值。提供 key 才启用选择状态,bind/initial 要求同时提供 key。默认空字符串表示未选;显式 initial 必须是现有标识。表格和图表可以共享 selection family,前提是标识集合与顺序一致,且最多一处显式 initial。
122
-
123
- 点击或键盘选择写入稳定标识,排序、搜索、分页和隐藏图例都保留选择。表格搜索仍只影响该表。省略 key 的旧文档保持原行为,不增加隐含绑定。
124
-
125
- ## 兼容、迁移与验收
126
-
127
- local-draft-1 中已支持的写法继续有效。本扩展引入 10 个新组块名:jump、anchor、text、section、multi-select、range-slider、coordinate、quiz、steps、step。同一版本还增加声明标签 computed、const、validation 和结构标签 data-table、column,`local-draft-2` 的完整集合为 48 个标签名;开头的 `<theme>` 声明是元数据,不计入组块。新名称以前会作为未知源码惰性显示,现在开始解释其中的受支持内容;若原文用于演示标签,放进代码围栏或行内代码。checklist 的完成样式是可见变化。
128
-
129
- 机器验收沿用 component-protocol-1 的格式,syntaxVersion 更新为 local-draft-2;旧 local-draft-1.json 留作历史数据,新构建运行 local-draft-2.json。新组件另有核心、渲染和可视化用例。错误仍使用带源码位置的 Diagnostic,未知标签、脚注、安全与资源预算保持已有契约。同一版本还新增表达式函数保留名;完整重命名清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。
130
-
131
- | 协议条款 | 实现与证据入口 |
132
- | --- | --- |
133
- | CP-SYNTAX、CP-DIAG、CP-SEC | parser/schema/compiler/colors;local-v2-core 与 local-v2-acceptance 测试 |
134
- | CP-STATE、CP-LIFE、CP-VIS | runtime 的规范槽位、数组校验、原子写入与重置;核心测试、浏览器检查 |
135
- | CP-A11Y、CP-STYLE | LocalDocumentView、visuals 及相应样式;SSR 与浏览器检查 |
136
- | CP-CORE、CP-COMPAT、CP-ACCEPT | 独立 core/React 构建、机器验收、打包和本页迁移说明 |
137
-
138
- 双语可运行示例分布在[六个场景](../examples/local/showcase/README.md):函数场景包含区间、坐标与数值题;表单场景包含多选;统计场景包含表格与图表选择联动;布局场景包含跳转与正文颜色;流程场景包含分步阅读与选择题;清单场景包含待办与计时。自动检查命令为 `npm test`、`npm run test:components`、`npm run build:demo`、`npm run test:docs`;浏览器检查和完整发布门禁使用 `npm run verify:release`,见[贡献指南](../CONTRIBUTING-ch.md)。实际结果以该门禁的执行记录为准,不要沿用旧脚本名。
1
+ # 新增组块与迁移:local-draft-2
2
+
3
+ 本页说明 `0.4.0` 的新增组块与 `local-draft-2` 语法。它是[本地交互语法规范](local-interaction-syntax-ch.md)的补充。贡献与验收继续使用 `component-protocol-1`,机器格式保持不变。
4
+
5
+ ## 跳转与正文颜色
6
+
7
+ ```markdown
8
+ <jump to="result" appearance="button" color="#2563eb">查看结果</jump>
9
+
10
+ <section color="#45536f">
11
+ 普通正文,<text color="#a2273a">**重点提醒**</text>。
12
+
13
+ 第二段继承外层颜色,支持 {{ count }} 等插值。
14
+ </section>
15
+
16
+ <anchor id="result">
17
+
18
+ ## 结果
19
+
20
+ 结果显示在这里。
21
+ ```
22
+
23
+ 本例中的 `count` 需由一个控件声明,例如 `<counter bind="count" label="数量">`。
24
+
25
+ | 组块 | 形态 | 属性与规则 |
26
+ | --- | --- | --- |
27
+ | jump | 行内、成对标签 | `to` 必填,为静态文档内目标名;`appearance=link/button`,默认 link;可选 color;正文为行内 Markdown |
28
+ | anchor | 无正文标签 | `id` 必填,匹配 `[A-Za-z_][A-Za-z0-9_-]*`,当前文档内唯一 |
29
+ | text | 行内、成对标签 | color 必填,正文为行内 Markdown 与插值 |
30
+ | section | 块容器、成对标签 | color 必填,内部继续解析 Markdown;不添加边框和背景 |
31
+
32
+ jump 可以指向自动生成的标题锚点或显式 anchor,不写前导 `#`。普通 Markdown 链接仍使用 `[结果](#result)`。实际 DOM ID 按文档实例隔离;显式 ID 与标题锚点冲突、跳转目标不存在时编译失败。点击后滚动并移动焦点,隐藏目标显示局部提示,保留读者已填写的参数。
33
+
34
+ color 是静态颜色名或 `#RGB`、`#RRGGBB`。它不接受表达式、CSS 函数、变量或声明。颜色名由共享校验表限定;无效值给出编译诊断。text/section 的 color 控制文字,内层显式颜色覆盖继承;链接和交互控件保留自身配色。jump/badge 使用文字或强调色;progress 使用填充色;slider、toggle、checkbox、select、choices、radio-group、checklist 以及新输入组块使用激活色。省略时沿用主题。tone 的语义保持不变。
35
+
36
+ ## 待办与多选
37
+
38
+ checklist 继续接受原有 Markdown 任务列表。勾选后仅该项正文加删除线并变淡,取消勾选后恢复;初始 `[x]` 也呈现完成样式。绑定、隐藏与面板重置保持原有规则。
39
+
40
+ ```markdown
41
+ <multi-select bind="subjects" label="主题" max-selected="2" initial="math">
42
+ <option value="math">数学</option>
43
+ <option value="physics">物理</option>
44
+ <option value="chemistry">化学</option>
45
+ </multi-select>
46
+
47
+ 已选择 {{ len(subjects) }} 项。
48
+ ```
49
+
50
+ multi-select 是有正文容器,只接受 option 子项,label 必填;bind 可省略。公开值为按源码顺序排列的字符串数组,默认空数组;initial 为逗号分隔的静态 value。value 非空、唯一,且不含逗号。max-selected 为非负整数,默认选项数。组件内置搜索、清空,达到上限仍可取消已选项;disabled 可以使用布尔表达式。该绑定为独占 family,保留已有数组大小和字符串预算。
51
+
52
+ ## 区间与二维坐标
53
+
54
+ ```markdown
55
+ <range-slider label="观察区间" bind-start="low" bind-end="high"
56
+ initial-start="20" initial-end="80" min="0" max="100" step="1">
57
+
58
+ 区间宽度:{{ high - low }}。
59
+
60
+ <coordinate label="坐标点" bind-x="px" bind-y="py"
61
+ initial-x="1" initial-y="2"
62
+ x-min="-5" x-max="5" y-min="-5" y-max="5" step="1">
63
+
64
+ 坐标:({{ px }}, {{ py }})。
65
+ ```
66
+
67
+ 这两个组块均为无正文标签,label 必填,支持 color 与动态 disabled。范围和步长都是静态有限数,step 必须为正。
68
+
69
+ - range-slider 默认 min=0、max=100、step=1;起点默认 min,终点默认不超过 max 的最大合法步长值。始终满足起点不大于终点,交叉写入被拒绝,不交换端点。
70
+ - coordinate 默认两个轴范围均为 -5 到 5,step=1;各轴初值取最接近零的合法值。支持拖动、键盘和数值输入,指针输入吸附到合法步长。
71
+ - 每个绑定名独立可选,省略时仍有内部状态;首版各槽位独占拥有绑定,不能与其他控件共享。`x`、`y` 仍是保留名,示例使用 px、py。
72
+ - 所有槽位在编译时初始化;多值写入和重置均为原子更新,拒绝写入时状态与 revision 保持不变。
73
+
74
+ 宿主 API 扩展:`runtime.get(node, slot?)`、`runtime.set(node, value, slot?)` 保留原调用方式,新增 `runtime.setMany(node, values)`。range-slider 的 slot 为 start/end,coordinate 为 x/y;setMany 使用 slot 名作为对象键。运行时根据已登记的节点和槽位校验,调用方提供的伪造属性不改变权限或约束。
75
+
76
+ ## 练习与分步阅读
77
+
78
+ ```markdown
79
+ <quiz type="choice" label="2 + 3 等于多少?" answer="b" explanation="相加得到 5。">
80
+ <option value="a">4</option>
81
+ <option value="b">5</option>
82
+ </quiz>
83
+
84
+ <quiz type="number" label="圆周率近似值" answer="3.14" tolerance="0.01">
85
+ </quiz>
86
+
87
+ <steps label="学习路线" bind="lesson">
88
+ <step label="观察" value="observe">
89
+ 调整参数,观察结果。
90
+ </step>
91
+ <step label="练习" value="practice">
92
+ 检查一道练习题。
93
+ </step>
94
+ </steps>
95
+ ```
96
+
97
+ quiz 的 type 默认 choice,label/answer 必填;choice 接受 option,answer 必须是现有 value。number 的正文为空,answer 为有限数,tolerance 默认为 0 且非负。explanation 可选,可含文本插值。组件内置检查答案、反馈与重试,首版不公开 bind;答案随源码提供,适合自学练习。隐藏后保留草稿与反馈,面板重置清除它们。
98
+
99
+ steps 只接受一个或多个 step。steps.label 可选,bind 可选且独占;initial 默认第一步 value。step.label 必填,value 可省略,按顺序生成 step-1、step-2 等,同组唯一。组件提供上一步、下一步和当前位置;仅当前内容显示,所有子控件仍参与编译和初始化。切换保留内容状态,隐藏计时器暂停;面板重置恢复初始步骤和子内容。
100
+
101
+ ## 表格与图表选择
102
+
103
+ ```markdown
104
+ <table bind="project" key="项目" initial="内容">
105
+ | 项目 | 费用 |
106
+ | --- | ---: |
107
+ | 内容 | 120 |
108
+ | 视觉 | 230 |
109
+ </table>
110
+
111
+ <chart bind="project" key="项目">
112
+ | 项目 | 费用 |
113
+ | --- | ---: |
114
+ | 内容 | 120 |
115
+ | 视觉 | 230 |
116
+ </chart>
117
+
118
+ 当前项目:{{ project }}。
119
+ ```
120
+
121
+ key 指定静态标识列,值必须非空、唯一且没有插值。提供 key 才启用选择状态,bind/initial 要求同时提供 key。默认空字符串表示未选;显式 initial 必须是现有标识。表格和图表可以共享 selection family,前提是标识集合与顺序一致,且最多一处显式 initial。
122
+
123
+ 点击或键盘选择写入稳定标识,排序、搜索、分页和隐藏图例都保留选择。表格搜索仍只影响该表。省略 key 的旧文档保持原行为,不增加隐含绑定。
124
+
125
+ ## 兼容、迁移与验收
126
+
127
+ local-draft-1 中已支持的写法继续有效。本扩展引入 10 个新组块名:jump、anchor、text、section、multi-select、range-slider、coordinate、quiz、steps、step。同一版本还增加声明标签 computed、const、validation 和结构标签 data-table、column,`local-draft-2` 的完整集合为 48 个标签名;开头的 `<theme>` 声明是元数据,不计入组块。新名称以前会作为未知源码惰性显示,现在开始解释其中的受支持内容;若原文用于演示标签,放进代码围栏或行内代码。checklist 的完成样式是可见变化。
128
+
129
+ 机器验收沿用 component-protocol-1 的格式,syntaxVersion 更新为 local-draft-2;旧 local-draft-1.json 留作历史数据,新构建运行 local-draft-2.json。新组件另有核心、渲染和可视化用例。错误仍使用带源码位置的 Diagnostic,未知标签、脚注、安全与资源预算保持已有契约。同一版本还新增表达式函数保留名;完整重命名清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
130
+
131
+ | 协议条款 | 实现与证据入口 |
132
+ | --- | --- |
133
+ | CP-SYNTAX、CP-DIAG、CP-SEC | parser/schema/compiler/colors;local-v2-core 与 local-v2-acceptance 测试 |
134
+ | CP-STATE、CP-LIFE、CP-VIS | runtime 的规范槽位、数组校验、原子写入与重置;核心测试、浏览器检查 |
135
+ | CP-A11Y、CP-STYLE | LocalDocumentView、visuals 及相应样式;SSR 与浏览器检查 |
136
+ | CP-CORE、CP-COMPAT、CP-ACCEPT | 独立 core/React 构建、机器验收、打包和本页迁移说明 |
137
+
138
+ 双语可运行示例分布在[六个场景](../../examples/local/showcase/README.md):函数场景包含区间、坐标与数值题;表单场景包含多选;统计场景包含表格与图表选择联动;布局场景包含跳转与正文颜色;流程场景包含分步阅读与选择题;清单场景包含待办与计时。自动检查命令为 `npm test`、`npm run test:components`、`npm run build:demo`、`npm run test:docs`;浏览器检查和完整发布门禁使用 `npm run verify:release`,见[贡献指南](../../CONTRIBUTING-ch.md)。实际结果以该门禁的执行记录为准,不要沿用旧脚本名。