@airalogy/aimd-renderer 2.6.0 → 2.8.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.
Files changed (41) hide show
  1. package/README.md +38 -0
  2. package/README.zh-CN.md +38 -0
  3. package/dist/aimd-renderer.css +1 -1
  4. package/dist/common/assetUrls.d.ts +8 -0
  5. package/dist/common/assetUrls.d.ts.map +1 -0
  6. package/dist/common/citationNumbering.d.ts +11 -0
  7. package/dist/common/citationNumbering.d.ts.map +1 -0
  8. package/dist/common/criticMarkup.d.ts +10 -0
  9. package/dist/common/criticMarkup.d.ts.map +1 -0
  10. package/dist/common/processor.d.ts +2 -0
  11. package/dist/common/processor.d.ts.map +1 -1
  12. package/dist/html/index.d.ts +1 -0
  13. package/dist/html/index.d.ts.map +1 -1
  14. package/dist/html.js +1 -1
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +80 -73
  18. package/dist/locales.d.ts +3 -0
  19. package/dist/locales.d.ts.map +1 -1
  20. package/dist/{processor-CHbNEcN8.js → processor-C_zN3-hL.js} +3454 -2534
  21. package/dist/readonly-record-renderer-G9xOkOFe.js +711 -0
  22. package/dist/vue/index.d.ts +2 -0
  23. package/dist/vue/index.d.ts.map +1 -1
  24. package/dist/vue/readonly-record-renderer.d.ts +42 -0
  25. package/dist/vue/readonly-record-renderer.d.ts.map +1 -0
  26. package/dist/vue/vue-renderer.d.ts +7 -1
  27. package/dist/vue/vue-renderer.d.ts.map +1 -1
  28. package/dist/vue.js +20 -13
  29. package/package.json +2 -2
  30. package/src/__tests__/renderer.test.ts +536 -1
  31. package/src/common/assetUrls.ts +22 -0
  32. package/src/common/citationNumbering.ts +265 -0
  33. package/src/common/criticMarkup.ts +97 -0
  34. package/src/common/processor.ts +206 -25
  35. package/src/html/index.ts +4 -0
  36. package/src/index.ts +23 -0
  37. package/src/locales.ts +9 -0
  38. package/src/styles/katex.css +213 -0
  39. package/src/vue/index.ts +22 -0
  40. package/src/vue/readonly-record-renderer.ts +747 -0
  41. package/src/vue/vue-renderer.ts +183 -9
package/README.md CHANGED
@@ -30,6 +30,20 @@ console.log(html)
30
30
  console.log(fields)
31
31
  ```
32
32
 
33
+ ## Review Marks
34
+
35
+ Renderer output supports CriticMarkup-style review marks in normal Markdown text:
36
+
37
+ | Purpose | AIMD source |
38
+ | --- | --- |
39
+ | Addition | `{++added text++}` |
40
+ | Deletion | `{--deleted text--}` |
41
+ | Substitution | `{~~old wording~>new wording~~}` |
42
+ | Comment | `{>>review note<<}` |
43
+ | Highlight | `{==important text==}` |
44
+
45
+ These marks render through `renderToHtml`, `renderToVue`, and readonly `AiralogyMarkdown` fields. Inline code and fenced code blocks keep the source text literal.
46
+
33
47
  ## Assigner Visibility
34
48
 
35
49
  ```ts
@@ -96,6 +110,30 @@ const { nodes } = await renderToVue(content, {
96
110
 
97
111
  Use this when you want a ready-made Vue step-card surface without first mapping AIMD nodes into your own custom elements.
98
112
 
113
+ ## Readonly Record Rendering
114
+
115
+ ```ts
116
+ import { renderReadonlyRecordToVue } from "@airalogy/aimd-renderer"
117
+
118
+ const { nodes } = await renderReadonlyRecordToVue(protocolContent, {
119
+ data: {
120
+ var: {
121
+ sample_id: { value: "S-001" },
122
+ site_photo: "airalogy.id.file.site-photo.png",
123
+ },
124
+ check: { prepared: { checked: true } },
125
+ },
126
+ }, {
127
+ resolveAsset: ({ fileId, fieldPath }) => assets.get(fileId ?? "") ?? assets.get(fieldPath) ?? null,
128
+ })
129
+ ```
130
+
131
+ Use this when a host app needs to show a completed AIMD protocol as a static document. The helper accepts either a Record payload wrapper with `data` or the `data` object itself, then renders the protocol in a readonly field context.
132
+
133
+ `resolveAsset` lets the host map Record file ids, field paths, or archive manifest entries to `ReadonlyRecordAsset` objects. The renderer uses that mapping to show image/audio/video fields inline, render ordinary files as readonly links, and resolve Markdown image `src` values that point at Airalogy file ids. Archive readers should keep storage-specific work, such as building `blob:` URLs from `.aira` payloads, in the host app and pass only display-ready URLs into the renderer.
134
+
135
+ Readonly `AiralogyMarkdown` values are rendered through the AIMD Vue renderer, so headings, lists, nested AIMD preview tokens, and resolved Markdown image assets appear as document content instead of raw Markdown source.
136
+
99
137
  Math styles are loaded automatically when calling async render APIs (`renderToHtml` / `renderToVue`) in browser environments.
100
138
  Use `@airalogy/aimd-renderer/styles` only if you want to preload styles manually.
101
139
 
package/README.zh-CN.md CHANGED
@@ -30,6 +30,20 @@ console.log(html)
30
30
  console.log(fields)
31
31
  ```
32
32
 
33
+ ## 审阅标记
34
+
35
+ Renderer 输出支持普通 Markdown 文本中的 CriticMarkup 风格审阅标记:
36
+
37
+ | 用途 | AIMD 源码 |
38
+ | --- | --- |
39
+ | 添加 | `{++新增文字++}` |
40
+ | 删除 | `{--删除文字--}` |
41
+ | 替换 | `{~~旧表述~>新表述~~}` |
42
+ | 注释 | `{>>审阅备注<<}` |
43
+ | 高亮 | `{==重点文字==}` |
44
+
45
+ 这些标记会通过 `renderToHtml`、`renderToVue` 和只读 `AiralogyMarkdown` 字段渲染出来。行内代码和 fenced 代码块会保留原始文本。
46
+
33
47
  ## Assigner 可见性
34
48
 
35
49
  ```ts
@@ -96,6 +110,30 @@ const { nodes } = await renderToVue(content, {
96
110
 
97
111
  当你想直接得到现成的 Vue 步骤卡片渲染,而不是先把 AIMD 节点映射到自定义元素时,可以使用这组 API。
98
112
 
113
+ ## 只读 Record 渲染
114
+
115
+ ```ts
116
+ import { renderReadonlyRecordToVue } from "@airalogy/aimd-renderer"
117
+
118
+ const { nodes } = await renderReadonlyRecordToVue(protocolContent, {
119
+ data: {
120
+ var: {
121
+ sample_id: { value: "S-001" },
122
+ site_photo: "airalogy.id.file.site-photo.png",
123
+ },
124
+ check: { prepared: { checked: true } },
125
+ },
126
+ }, {
127
+ resolveAsset: ({ fileId, fieldPath }) => assets.get(fileId ?? "") ?? assets.get(fieldPath) ?? null,
128
+ })
129
+ ```
130
+
131
+ 当宿主应用需要把已完成的 AIMD Protocol 展示为静态文档时,可以使用这个 helper。它既接受带 `data` 的 Record payload,也接受 `data` 对象本身,然后在只读字段上下文中渲染协议内容。
132
+
133
+ `resolveAsset` 由宿主应用负责把 Record 文件 id、字段路径或 archive manifest 条目映射成 `ReadonlyRecordAsset`。renderer 会基于这个映射把图片、音频、视频字段内嵌渲染,把普通文件渲染为只读链接,并解析指向 Airalogy file id 的 Markdown 图片 `src`。`.aira` 读取、`blob:` URL 创建、对象存储签名 URL 等存储细节应留在宿主应用中,renderer 只接收可显示的 URL。
134
+
135
+ 只读 `AiralogyMarkdown` 值会通过 AIMD Vue renderer 渲染,因此标题、列表、嵌套 AIMD 预览 token,以及已解析的 Markdown 图片资源都会作为文档内容显示,而不是显示原始 Markdown 文本。
136
+
99
137
  在浏览器环境中调用异步渲染 API(`renderToHtml` / `renderToVue`)时,会自动加载公式样式。
100
138
  只有在你希望手动预加载样式时,才需要引入 `@airalogy/aimd-renderer/styles`。
101
139