@xiongtao.xt/tau-plugins 0.58.0 → 0.60.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 (123) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/docs/editor-interactions.md +55 -0
  3. package/docs/pages.md +71 -2
  4. package/docs/portability.md +2 -0
  5. package/docs/references.md +2 -0
  6. package/docs/settings-and-commands.md +3 -0
  7. package/docs/whiteboard.md +1 -1
  8. package/package.json +1 -1
  9. package/publish-artifacts.js +35 -26
  10. package/tailwind.css +3 -3
  11. package/types/packages/collaboration/src/document-history-edit.d.ts +11 -0
  12. package/types/packages/collaboration/src/document-history.d.ts +91 -0
  13. package/types/packages/collaboration/src/index.d.ts +2 -0
  14. package/types/packages/collaboration/src/node-document.d.ts +1 -1
  15. package/types/packages/collaboration/src/node-tree.d.ts +7 -0
  16. package/types/packages/collaboration/src/whiteboard-model.d.ts +33 -2
  17. package/types/packages/db-schema/content-identities.d.ts +1 -1
  18. package/types/packages/editor/src/core/CoreEditor.d.ts +10 -1
  19. package/types/packages/editor/src/core/api/extension.d.ts +0 -1
  20. package/types/packages/editor/src/core/api/index.d.ts +3 -1
  21. package/types/packages/editor/src/core/utils/nodeOperations.d.ts +1 -0
  22. package/types/packages/editor/src/core/utils/undoStep.d.ts +6 -0
  23. package/types/packages/editor/src/core/utils/wrapInlineText.d.ts +4 -0
  24. package/types/packages/editor/src/extensions/kbd/src/types.d.ts +2 -2
  25. package/types/packages/editor/src/extensions/link/src/types.d.ts +2 -2
  26. package/types/packages/editor/src/extensions/styled-text/src/types.d.ts +2 -2
  27. package/types/packages/editor/src/extensions/underline/src/types.d.ts +2 -2
  28. package/types/packages/markdown/src/codec.d.ts +6 -2
  29. package/types/packages/markdown/src/markdown.d.ts +2 -1
  30. package/types/packages/markdown/src/positionMapper.d.ts +7 -1
  31. package/types/packages/plugins/src/app.d.ts +2 -0
  32. package/types/packages/plugins/src/contract.d.ts +2 -0
  33. package/types/packages/plugins/src/index.d.ts +2 -1
  34. package/types/packages/plugins/src/pages.d.ts +8 -2
  35. package/types/packages/plugins/src/text-decorations.d.ts +68 -0
  36. package/types/packages/shared/src/chat-core/aiRunProtocol.d.ts +1 -1
  37. package/types/packages/shared/src/chat-core/messages.d.ts +13 -4
  38. package/types/packages/themes/src/themes/ink.theme.d.ts +1 -2
  39. package/types/packages/themes/src/themes/mint.theme.d.ts +1 -2
  40. package/types/packages/themes/src/themes/ocean.theme.d.ts +1 -2
  41. package/types/packages/themes/src/themes/paper.theme.d.ts +1 -2
  42. package/types/packages/themes/src/themes/sakura.theme.d.ts +1 -2
  43. package/types/packages/themes/src/themes/wisteria.theme.d.ts +1 -2
  44. package/types/packages/ui/src/cn.d.ts +1 -1
  45. package/types/packages/ui/src/primitives/AnchoredPanel.d.ts +3 -3
  46. package/types/packages/ui/src/primitives/Button.d.ts +4 -4
  47. package/types/packages/ui/src/primitives/Checkbox.d.ts +2 -2
  48. package/types/packages/ui/src/primitives/ConfirmDialog.d.ts +3 -3
  49. package/types/packages/ui/src/primitives/Dialog.d.ts +4 -4
  50. package/types/packages/ui/src/primitives/Loading.d.ts +1 -1
  51. package/types/packages/ui/src/primitives/Menu.d.ts +1 -1
  52. package/types/packages/ui/src/primitives/Notification.d.ts +2 -2
  53. package/types/packages/ui/src/primitives/Popover.d.ts +3 -3
  54. package/types/packages/ui/src/primitives/Radio.d.ts +2 -3
  55. package/types/packages/ui/src/primitives/RadioGroup.d.ts +1 -1
  56. package/types/packages/ui/src/primitives/Segmented.d.ts +3 -3
  57. package/types/packages/ui/src/primitives/Select.d.ts +6 -6
  58. package/types/packages/ui/src/primitives/Switch.d.ts +2 -2
  59. package/types/packages/ui/src/primitives/Tag.d.ts +2 -3
  60. package/types/packages/ui/src/primitives/Toast.d.ts +1 -1
  61. package/types/packages/ui/src/primitives/Tooltip.d.ts +5 -5
  62. package/types/packages/ui/src/primitives/ValueDisplay.d.ts +2 -3
  63. package/types/packages/ui/src/primitives/anchoredPosition.d.ts +1 -2
  64. package/types/packages/ui/src/primitives/datepicker/DatePicker.d.ts +2 -2
  65. package/types/packages/ui/src/primitives/datepicker/DateRangePicker.d.ts +1 -1
  66. package/types/packages/ui/src/primitives/input/Input.d.ts +4 -4
  67. package/types/packages/ui/src/primitives/input/NumberInput.d.ts +2 -2
  68. package/types/packages/ui/src/primitives/input/Textarea.d.ts +1 -1
  69. package/types/packages/whiteboard/src/Board.d.ts +28 -12
  70. package/types/packages/whiteboard/src/{WhiteBoard.d.ts → Whiteboard.d.ts} +6 -6
  71. package/types/packages/whiteboard/src/chrome/index.d.ts +4 -2
  72. package/types/packages/whiteboard/src/components/ArrowConnectPoint/index.d.ts +26 -0
  73. package/types/packages/whiteboard/src/components/ArrowConnectPointGroup/index.d.ts +3 -0
  74. package/types/packages/whiteboard/src/components/DocumentElement/index.d.ts +2 -0
  75. package/types/packages/whiteboard/src/components/ExcerptElement/index.d.ts +13 -0
  76. package/types/packages/whiteboard/src/components/SketchPopover.d.ts +1 -1
  77. package/types/packages/whiteboard/src/constants/arrow.d.ts +0 -2
  78. package/types/packages/whiteboard/src/constants/mind.d.ts +0 -13
  79. package/types/packages/whiteboard/src/constants/text-style.d.ts +1 -1
  80. package/types/packages/whiteboard/src/constants/tools.d.ts +3 -0
  81. package/types/packages/whiteboard/src/context.d.ts +1 -2
  82. package/types/packages/whiteboard/src/extensions/api.d.ts +6 -1
  83. package/types/packages/whiteboard/src/extensions/authorApi.d.ts +0 -1
  84. package/types/packages/whiteboard/src/extensions/events.d.ts +0 -1
  85. package/types/packages/whiteboard/src/hooks/useDropArrow.d.ts +1 -1
  86. package/types/packages/whiteboard/src/hooks/useReadonly.d.ts +1 -0
  87. package/types/packages/whiteboard/src/hooks/useSelectState.d.ts +0 -1
  88. package/types/packages/whiteboard/src/hooks/useZoom.d.ts +6 -0
  89. package/types/packages/whiteboard/src/index.d.ts +11 -6
  90. package/types/packages/whiteboard/src/interactions/InteractionManager.d.ts +1 -0
  91. package/types/packages/whiteboard/src/plugins/ArrowPlugin.d.ts +1 -1
  92. package/types/packages/whiteboard/src/plugins/ColumnPlugin.d.ts +1 -1
  93. package/types/packages/whiteboard/src/plugins/CommonPlugin.d.ts +10 -10
  94. package/types/packages/whiteboard/src/plugins/DocumentPlugin.d.ts +36 -3
  95. package/types/packages/whiteboard/src/plugins/ExcerptPlugin.d.ts +48 -0
  96. package/types/packages/whiteboard/src/plugins/FramePlugin.d.ts +1 -1
  97. package/types/packages/whiteboard/src/plugins/GeometryPlugin.d.ts +5 -2
  98. package/types/packages/whiteboard/src/plugins/MindPlugin.d.ts +2 -2
  99. package/types/packages/whiteboard/src/plugins/WebviewPlugin.d.ts +1 -1
  100. package/types/packages/whiteboard/src/plugins/{WhiteBoardPlugin.d.ts → WhiteboardPlugin.d.ts} +8 -5
  101. package/types/packages/whiteboard/src/plugins/index.d.ts +2 -1
  102. package/types/packages/whiteboard/src/public.d.ts +23 -1
  103. package/types/packages/whiteboard/src/types/board.d.ts +12 -10
  104. package/types/packages/whiteboard/src/types/element.d.ts +6 -1
  105. package/types/packages/whiteboard/src/types/operation.d.ts +1 -1
  106. package/types/packages/whiteboard/src/types/selection.d.ts +1 -1
  107. package/types/packages/whiteboard/src/types/sketch.d.ts +2 -2
  108. package/types/packages/whiteboard/src/types/viewport.d.ts +1 -1
  109. package/types/packages/whiteboard/src/utils/ArrowStyleUtil.d.ts +0 -1
  110. package/types/packages/whiteboard/src/utils/CanvasUtil.d.ts +0 -1
  111. package/types/packages/whiteboard/src/utils/ClipboardUtil.d.ts +0 -5
  112. package/types/packages/whiteboard/src/utils/GeometryUtil.d.ts +1 -1
  113. package/types/packages/whiteboard/src/utils/HandwriteUtil.d.ts +0 -1
  114. package/types/packages/whiteboard/src/utils/MindUtil.d.ts +0 -3
  115. package/types/packages/whiteboard/src/utils/PathUtil.d.ts +1 -1
  116. package/types/packages/whiteboard/src/utils/PointUtil.d.ts +0 -1
  117. package/types/packages/whiteboard/src/utils/PresentationManager.d.ts +1 -1
  118. package/types/packages/whiteboard/src/utils/TextStyleStore.d.ts +2 -1
  119. package/types/packages/whiteboard/src/utils/index.d.ts +0 -1
  120. package/types/packages/whiteboard/src/utils/sketch/handText.d.ts +1 -1
  121. package/types/packages/whiteboard/src/utils/sketch/index.d.ts +4 -5
  122. package/types/packages/whiteboard/src/utils/sketch/shape.d.ts +1 -2
  123. package/types/packages/whiteboard/src/utils/ViewportUtil.d.ts +0 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.60.0
4
+
5
+ - 桌面主窗口新增可选的 `context.textDecorations`。插件可以在已获读取权限的卡片、文章和项目文档中标出文字范围。提供方支持异步计算、取消请求、按来源刷新和主动注销。
6
+ - 支持六种主题外观、语义色调和悬停提示。点击回调可以返回候选列表,用户选择后由同一回调接收 `choice`。
7
+ - `getPreview` 可为命中或候选返回内容引用和可选块位置。宿主在悬停时核验目标读取权限并展示只读预览。接口与示例见随包的 `docs/editor-interactions.md`。
8
+ - 随包类型声明同步当前白板和协作实现,包括画布视口、文本编辑与笔迹更新相关类型;博客发布辅助模块也按当前源码重新构建。
9
+
10
+ ## 0.59.0
11
+
12
+ - 插件页面可声明 `dockable`,通过页面句柄选择完整页或右栏,组件从 `placement` 读取展示位置。桌面主窗口支持 `context.app.openWeb(url)` 查看网页。
13
+
3
14
  ## 0.58.0
4
15
 
5
16
  - 插件通知按钮新增可选字段 `reveal`。Tau 桌面端 0.64.1 起,点击通知正文也会执行该按钮的回调,独立通知会先唤起来源窗口。每条通知至多指定一个查看动作。
@@ -248,6 +248,61 @@ export default definePlugin({
248
248
 
249
249
  `editor` 上的 `string`、`removeNodes`、`insertNodes`、`setNodes` 等方法直接可用,不需要另外安装或打包编辑器库。
250
250
 
251
+ ## 在正文中标出文字
252
+
253
+ 桌面主窗口提供 `context.textDecorations`。在插件的 `activate(context)` 中注册,旧版或其他宿主可用可选链判断支持情况。下面的示例把文章里的「回顾」标出来,点击后打开最近更新的一篇带「复盘」标签的文章。先在 manifest 的 `permissions` 声明 `articles:read`。
254
+
255
+ ```ts
256
+ if (!context.textDecorations) return;
257
+ const { items } = await context.data.articles.query({ tag: "复盘", limit: 1 });
258
+ const target = items[0];
259
+ if (!target) return;
260
+
261
+ const marks = await context.textDecorations.register({
262
+ sources: ["article"],
263
+ getDecorations({ text, source }) {
264
+ if (source.id === target.id) return [];
265
+ return Array.from(text.matchAll(/回顾/g), hit => ({
266
+ start: hit.index, end: hit.index + hit[0].length,
267
+ appearance: "reference" as const, key: target.id, label: `打开文章《${target.title}》`,
268
+ }));
269
+ },
270
+ getPreview({ key }) {
271
+ return { ref: { kind: "article", id: key } };
272
+ },
273
+ async onActivate({ key }) {
274
+ await context.app.open({ kind: "article", id: key });
275
+ },
276
+ });
277
+ ```
278
+
279
+ 在 `sources` 里选择卡片(`card`)、文章(`article`)、项目文档(`document`),并声明各来源的读取权限。每个返回项用 `appearance` 选择外观,按打扰程度从低到高:
280
+
281
+ | 外观 | 样子 | 适合 |
282
+ | --- | --- | --- |
283
+ | `dot` | 文字不变,末尾一个小圆点 | 极简、行距紧 |
284
+ | `ghost` | 点线很淡,悬停或按住 ⌘/Ctrl 才显出 | 识别量很大、不想打扰阅读 |
285
+ | `reference` | 正文色文字加点线,悬停变成实线 | 引用、跳转,推荐默认 |
286
+ | `tint` | 只改字色 | 表格、密集文本 |
287
+ | `marker` | 文字下沿的荧光笔底色,悬停铺满 | 想一眼扫出结果 |
288
+ | `wavy` | 波浪下划线 | 提醒、待确认 |
289
+
290
+ `dot`、`ghost`、`reference` 表示可以点击,必须提供字符串 `key` 和 `onActivate`,否则不显示。其余外观省略 `key` 即可只用于阅读。外观都用背景或伪元素绘制,用户自己加的下划线、删除线保持不变(`wavy` 除外)。
291
+
292
+ `tone` 选择颜色:`accent`(默认,跟随主题强调色)、`info`、`warn`、`muted`。颜色取自当前主题,深浅模式自动适配,不能传自定义颜色。`label` 是悬停约 0.4 秒后出现的提示,Tau 会在后面附上插件名。
293
+
294
+ 可选的 `getPreview({ key, source, choice }, signal)` 在指针停留约 450 毫秒后调用,可以同步或异步返回 `{ ref: { kind, id }, at?: { block } }`。其中 `kind` 支持 `card`、`article` 和 `document`。Tau 校验目标读取权限并显示与内容引用相同的只读预览卡;提供 `at` 时从该顶层块开始预览,「打开」也会定位到它。插件需要预先声明并获得目标类型的读取权限。
295
+
296
+ 单一目标可直接返回。命中多个目标时,首次悬停返回 `undefined`,使用 `label` 提示;用户点击打开候选菜单,再悬停某一项时,`choice` 是该项的 key。离开、切换目标、注销或内容失效会取消旧请求。悬停与点击分别处理,预览不会执行 `onActivate`。
297
+
298
+ `onActivate` 返回候选数组 `[{ key, title, description? }]` 时,Tau 在文字旁弹出菜单。用户选中后再次调用 `onActivate`,并在 `choice` 中传入选中的 `key`。处理中文字会变淡,抛出的错误以提示条显示。
299
+
300
+ `getDecorations({ source, blockType, text }, signal)` 可以返回范围数组或 Promise。偏移按 JavaScript 字符串下标计算,包含起点、排除终点。同一块内相邻的普通文字与粗体连续传入,链接、行内代码、嵌套块等会切断文本。请自行消解本次结果中的重叠;同一批存在重叠时,这个提供方的该批结果会被忽略。不同插件发生冲突时优先起点较前的范围,同起点按注册顺序。
301
+
302
+ 主窗口按需计算靠近视口的正文并在编辑停顿后更新,移动光标和普通重绘复用结果。可以直接返回与当前来源、正文和配置一致的预计算结果,或在 Worker 中匹配并响应取消信号。文字变化、资料库切换和插件停用会使旧请求失效。
303
+
304
+ 插件的匹配规则、词表或外观设置变化时,调用 `marks.invalidate()`;只影响一篇时调用 `marks.invalidate({ source })`。主动移除这组装饰用 `marks.dispose()`。
305
+
251
306
  ## 下一步
252
307
 
253
308
  - [源码块与媒体块](editor-source-media.md):做「源码 + 预览」的块,或在块里显示图片、视频、音频。
package/docs/pages.md CHANGED
@@ -39,11 +39,12 @@ export default definePlugin({
39
39
  | ----------- | -------------------------------------------------------------------------- |
40
40
  | `id` | 局部 ID,见 [ID 规则](plugin-basics.md#id-规则) |
41
41
  | `title` | 页面标题 |
42
- | `component` | React 组件,收到 `context`、`params`、`pageContext` 三个属性 |
42
+ | `component` | React 组件,收到 `context`、`params`、`pageContext` 和 `placement` |
43
+ | `dockable` | 可选。设为 `true` 后,桌面主窗口支持在右栏打开此页 |
43
44
  | `match` | 可选。默认 `"single"`,页面只有一个实例;`"params"` 表示按参数区分多个实例 |
44
45
  | `getId` | 可选。`match: "params"` 时,用它从参数算出实例身份;默认按全部参数区分 |
45
46
 
46
- `register` 返回页面句柄,提供 `open(params?)` 和 `dispose()`。在命令、按钮或其他页面里用 `shelf.open()` 打开页面,不要自己操作浏览器地址或历史记录。
47
+ `register` 返回页面句柄,提供 `open(params?, options?)` 和 `dispose()`。在命令、按钮或其他页面里用 `shelf.open()` 打开页面,不要自己操作浏览器地址或历史记录。
47
48
 
48
49
  只是从别的页面打开的详情页可以不注册入口;用户要能直接找到的页面,注册一个[功能入口](#功能入口)。
49
50
 
@@ -190,6 +191,74 @@ function BookPage({ pageContext }: PluginPageProps) {
190
191
  - 只在页面显示时生效:页面切走后,它登记的浮层不会响应 Esc;回来后自动恢复。插件停用时全部清除。
191
192
  - `@tau/ui` 的模态 `Dialog`、`Drawer` 和 `Popover`、`Select`、`Menu` 已经自己处理 Esc,不需要登记。
192
193
 
194
+ ## 在右栏打开页面和网页
195
+
196
+ 要让用户边看正文边用插件,在页面定义里加 `dockable: true`。用户点击按钮、菜单或执行命令时,调用自己登记的页面句柄。下面的桌面插件提供一条「在右栏打开资料来源」命令;把示例放进模板的 `src/index.tsx`,构建并启用后,按 ⌘K(Windows / Linux 用 Ctrl+K)搜索这条命令。
197
+
198
+ ```tsx
199
+ import { useState } from "react";
200
+ import { definePlugin, type PluginPageProps } from "@tau/plugins";
201
+ import { Button } from "@tau/ui";
202
+
203
+ declare const __PLUGIN_META__: { id: string; name: string; version: string };
204
+
205
+ function Sources({ context, placement }: PluginPageProps) {
206
+ const [url, setUrl] = useState("");
207
+ const [error, setError] = useState("");
208
+ async function viewSource() {
209
+ try {
210
+ setError("");
211
+ await context.app.openWeb(url);
212
+ } catch (cause) {
213
+ setError(cause instanceof Error ? cause.message : "无法打开网页");
214
+ }
215
+ }
216
+ return (
217
+ <section>
218
+ {placement === "page" && <h1>资料来源</h1>}
219
+ <label>
220
+ 来源网址
221
+ <input type="url" value={url} onChange={e => setUrl(e.target.value)} />
222
+ </label>
223
+ <Button disabled={!url} onClick={viewSource}>
224
+ 查看来源
225
+ </Button>
226
+ {error && <p role="alert">{error}</p>}
227
+ </section>
228
+ );
229
+ }
230
+
231
+ export default definePlugin({
232
+ ...__PLUGIN_META__,
233
+ create: () => ({
234
+ activate(ctx) {
235
+ const sources = ctx.pages.register({
236
+ id: "sources",
237
+ title: "资料来源",
238
+ component: Sources,
239
+ dockable: true,
240
+ });
241
+ ctx.commands.register({
242
+ id: "open-sources",
243
+ title: "在右栏打开资料来源",
244
+ async run() {
245
+ await sources.open({}, { placement: "dock" });
246
+ return null;
247
+ },
248
+ });
249
+ },
250
+ }),
251
+ });
252
+ ```
253
+
254
+ 输入完整网址,点击「查看来源」,网页会暂时盖住插件。点网页栏左上角的「资料来源」回到刚才的输入框。右上角可以放大、收回或关闭;放大往返时组件保留状态。
255
+
256
+ - `sources.open()` 和 `sources.open(params)` 仍打开完整页。已有参数放在第一项,例如 `sources.open({ sourceId: 12 }, { placement: "dock" })`。同一右栏实例接收新参数,身份由 `match` 与 `getId` 决定。完整页与右栏各有自己的组件状态。
257
+ - 组件收到的 `placement` 为 `"page"` 或 `"dock"`。放大右栏时它仍是 `"dock"`。页面自己的浮层和未保存修改继续通过 `pageContext.registerDismiss` 与 `registerLeaveGuard` 登记。被网页盖住时页面暂停 effect,返回时恢复。右栏登记的上下文只属于右栏,AI 查询当前页仍读取正文页。
258
+ - 只需打开网址时,直接在点击回调里调用 `await ctx.app.openWeb(url)`,无需注册页面或申请数据权限。只接受绝对 HTTP(S) 地址。Promise 在宿主接受打开请求后完成,后续网络错误由网页栏显示。未保存修改阻止切换、网址不合法、句柄已注销或宿主不支持时,调用会拒绝。
259
+ - 停靠和打开网页都需要桌面主窗口里的用户操作。移动端使用 `sources.open()` 打开完整页。依赖桌面右栏的插件在 manifest 的 `targets.desktop.minAppVersion` 填写实际验证过且包含此能力的客户端版本。
260
+
261
+
193
262
  ## 功能入口
194
263
 
195
264
  功能入口让用户找到你的页面。桌面上它出现在侧边栏的「插件」分组,手机上出现在「我的」顶部的功能宫格,和任务、文章等内置功能放在一起;同一份代码,位置由 Tau 决定。开头例子里的 `registerEntry` 就是它,加上图标:
@@ -28,6 +28,7 @@
28
28
  | 接口 | 桌面 | Android / iOS | 说明 |
29
29
  | -------------------------------------------------------------- | ---- | ------------- | ------------------------------------------------------------------------------------------------------------------------- |
30
30
  | `pages`、`navigation` | ✓ | ✓ | 桌面的功能入口在侧边栏,手机在「我的」顶部功能宫格,见[页面与入口](pages.md) |
31
+ | 页面右栏、`app.openWeb` | ✓ | | 主窗口用户操作可打开停靠页面或 HTTP(S) 网页,见[在右栏打开页面和网页](pages.md#在右栏打开页面和网页) |
31
32
  | `windows` | ✓ | | 独立窗口、自动外观与同插件跨窗口通信,见[桌面插件窗口](windows.md) |
32
33
  | `settings`、`storage`、`fetch`、`websocket` | ✓ | ✓ | |
33
34
  | `environment`、`register`、`signal`、`pluginId`、`workspaceId` | ✓ | ✓ | |
@@ -38,6 +39,7 @@
38
39
  | `speech` | | ✓ | 见[通知、语音输入与朗读 · 语音输入](notifications-and-voice.md#语音输入) |
39
40
  | `tts.open` | ✓ | | 见[通知、语音输入与朗读 · 朗读](notifications-and-voice.md#朗读) |
40
41
  | `upload.save` | ✓ | | 见[插件内容与记录 · 保存资源文件](plugin-content.md#保存资源文件) |
42
+ | 正文文字装饰(`textDecorations`) | ✓ | | 桌面主窗口可以标记词语、选择目标并悬停预览,见[编辑器交互](editor-interactions.md#在正文中标出文字) |
41
43
  | 编辑器块(`editorExtensions`、`editorCodecs`) | ✓ | ✓ | 见[编辑器块](#编辑器块) |
42
44
  | `sync`、`upload`、`tts`、`asr`、`images` 提供方 | ✓ | ✓ | 见[服务提供方](#服务提供方) |
43
45
  | `embeddings`、`video`、`publish` 提供方 | ✓ | | |
@@ -115,6 +115,8 @@ await context.app.open(ref, { at: { block: 3 } }); // 打开并滚动到第 4
115
115
  - 不支持的组合直接抛错,不会悄悄改用别的位置。手机上只有 `page`。
116
116
  - 打开插件内容并定位时,你的插件页面会收到页面参数 `at`,原样传给 `<ContentEditor at={params.at}>` 即可,见[嵌入正文编辑器](document-body.md#嵌入正文编辑器)。
117
117
 
118
+ 要打开普通网址,在用户点击时调用 `await context.app.openWeb(url)`。要打开插件自己的页面,使用页面句柄。两种用法见[在右栏打开页面和网页](pages.md#在右栏打开页面和网页)。
119
+
118
120
  ### 显示引用
119
121
 
120
122
  清单里直接放 `<EntityRef>`:图标、类型名、最新标题与「已删除」都由 Tau 显示,同一次渲染的引用会合并成一次查询。需要自己排版或排序,例如把已删除的项排到最后时,用 `describe` 批量读取当前状态,每次最多 200 项:
@@ -152,6 +152,9 @@ function ProfileSettings({ context, saved }: PluginSettingsProps & { saved: Prof
152
152
 
153
153
  ## 命令
154
154
 
155
+ 要把插件页面作为一条右栏命令,在 `run` 中调用 `await page.open({}, { placement: "dock" })` 并返回 `null`。注册和调用的完整示例见[在右栏打开页面和网页](pages.md#在右栏打开页面和网页)。
156
+
157
+
155
158
  命令是一个有名字的操作,开头例子里的「重置计数」就是一条命令:
156
159
 
157
160
  | 字段 | 说明 |
@@ -262,7 +262,7 @@ panel: ({ run }) => (
262
262
 
263
263
  - 每块画布的状态放在 `create` 的闭包里,不要放在模块顶层,否则会在多块画布之间共享。
264
264
  - `elements` 必须写在扩展顶层,不能放进 `create` 的返回值。
265
- - `mod+k`、`mod+p`、`mod+j`、Alt+方向键和 Esc 由 Tau 保留,不能声明。
265
+ - `mod+k`、`mod+p`、`mod+j`、`mod+shift+j`、Alt+方向键和 Esc 由 Tau 保留,不能声明。
266
266
 
267
267
  ### 修改画布
268
268
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiongtao.xt/tau-plugins",
3
- "version": "0.58.0",
3
+ "version": "0.60.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1629,7 +1629,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
1629
1629
  },
1630
1630
  [subscribe, value, getSnapshot]
1631
1631
  );
1632
- useEffect24(
1632
+ useEffect25(
1633
1633
  function() {
1634
1634
  checkIfSnapshotChanged(inst) && forceUpdate({ inst });
1635
1635
  return subscribe(function() {
@@ -1655,7 +1655,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
1655
1655
  return getSnapshot();
1656
1656
  }
1657
1657
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1658
- var React6 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState34 = React6.useState, useEffect24 = React6.useEffect, useLayoutEffect9 = React6.useLayoutEffect, useDebugValue2 = React6.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
1658
+ var React6 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState34 = React6.useState, useEffect25 = React6.useEffect, useLayoutEffect9 = React6.useLayoutEffect, useDebugValue2 = React6.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
1659
1659
  exports.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim;
1660
1660
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1661
1661
  })();
@@ -1683,7 +1683,7 @@ var require_with_selector_development = __commonJS({
1683
1683
  return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
1684
1684
  }
1685
1685
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1686
- var React6 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef34 = React6.useRef, useEffect24 = React6.useEffect, useMemo8 = React6.useMemo, useDebugValue2 = React6.useDebugValue;
1686
+ var React6 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef34 = React6.useRef, useEffect25 = React6.useEffect, useMemo8 = React6.useMemo, useDebugValue2 = React6.useDebugValue;
1687
1687
  exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual2) {
1688
1688
  var instRef = useRef34(null);
1689
1689
  if (null === instRef.current) {
@@ -1726,7 +1726,7 @@ var require_with_selector_development = __commonJS({
1726
1726
  [getSnapshot, getServerSnapshot, selector, isEqual2]
1727
1727
  );
1728
1728
  var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]);
1729
- useEffect24(
1729
+ useEffect25(
1730
1730
  function() {
1731
1731
  inst.hasValue = true;
1732
1732
  inst.value = value;
@@ -1833,8 +1833,10 @@ function assertDataVersions(spec, validate) {
1833
1833
  if (!previous || previous.element === spec || previous.element?.type !== spec.type || !["read", "edit", "none"].includes(previous.access))
1834
1834
  throw new Error("\u5386\u53F2\u8282\u70B9\u58F0\u660E\u65E0\u6548");
1835
1835
  validate(previous.element);
1836
- if (versions.has(previous.element.dataVersion)) throw new Error("\u8282\u70B9\u6570\u636E\u7248\u672C\u91CD\u590D");
1837
- versions.add(previous.element.dataVersion);
1836
+ const previousVersion = previous.element.dataVersion;
1837
+ if (previousVersion === void 0) throw new Error("\u5386\u53F2\u8282\u70B9\u7F3A\u5C11 dataVersion");
1838
+ if (versions.has(previousVersion)) throw new Error("\u8282\u70B9\u6570\u636E\u7248\u672C\u91CD\u590D");
1839
+ versions.add(previousVersion);
1838
1840
  }
1839
1841
  }
1840
1842
 
@@ -1985,9 +1987,11 @@ function assertWhiteboardElementVersions(element) {
1985
1987
  throw new Error("\u65B0\u5951\u7EA6\u4E0D\u80FD\u6DF7\u7528 schemaVersion");
1986
1988
  assertDataVersions(element, (value) => {
1987
1989
  if (value.schemaVersion !== void 0) throw new Error("\u5386\u53F2\u5B9A\u4E49\u4E0D\u80FD\u6DF7\u7528\u65E7\u7248\u672C\u5B57\u6BB5");
1990
+ const { dataVersion } = value;
1991
+ if (dataVersion === void 0) throw new Error(`\u767D\u677F\u5951\u7EA6 ${value.type} \u7F3A\u5C11 dataVersion`);
1988
1992
  return normalizeWhiteboardContract("validation", {
1989
1993
  type: value.type,
1990
- dataVersion: value.dataVersion,
1994
+ dataVersion,
1991
1995
  collaboration: value.collaboration,
1992
1996
  resources: value.resources,
1993
1997
  structure: {
@@ -5344,7 +5348,7 @@ var SCALE_WORDS = {
5344
5348
  radius: ["tau-sm", "tau-md", "tau-lg"],
5345
5349
  shadow: ["card", "lift", "float", "paper"],
5346
5350
  ease: ["tau-out"],
5347
- animate: ["hm-pulse"]
5351
+ animate: ["hm-pulse", "aurora-1", "aurora-2", "aurora-3"]
5348
5352
  };
5349
5353
  var twMerge = extendTailwindMerge({
5350
5354
  extend: {
@@ -5911,9 +5915,7 @@ var EditText = (0, import_react19.memo)(
5911
5915
  style: {
5912
5916
  ...style,
5913
5917
  ...placeholder && !style?.position ? { position: "relative" } : {},
5914
- ...placeholderStyle?.color ? {
5915
- ["--placeholder-color"]: placeholderStyle.color
5916
- } : {}
5918
+ ...placeholderStyle?.color ? { "--placeholder-color": placeholderStyle.color } : {}
5917
5919
  },
5918
5920
  "data-placeholder": placeholder,
5919
5921
  "data-empty": isEmpty ? "true" : "false",
@@ -5966,7 +5968,7 @@ function getTheme(key) {
5966
5968
  }
5967
5969
 
5968
5970
  // packages/themes/src/themes/paper.theme.ts
5969
- var paper_theme_default = defineTheme({
5971
+ defineTheme({
5970
5972
  key: "paper",
5971
5973
  name: "\u6696\u7EB8",
5972
5974
  light: {
@@ -5976,7 +5978,7 @@ var paper_theme_default = defineTheme({
5976
5978
  surface: "#fffdf9",
5977
5979
  // 卡片/面板
5978
5980
  sunken: "#e7dbc8",
5979
- // 轨道/凹槽专档:进度轨道、波形未播放段、时间轴(对 page 1.181);输入框/代码块禁用本档——走 surface 亮底 + line-1 描边(D-007/D-009/D-032)
5981
+ // 轨道/凹槽专档:进度轨道、波形未播放段、时间轴(对 page 1.181);输入框/代码块禁用本档——走 surface 亮底 + line-1 描边
5980
5982
  track: "#e0d6c3",
5981
5983
  // 控件轨道(开关/滑杆槽):米灰,与 thumb(surface) 拉开
5982
5984
  ink1: "#43392c",
@@ -6121,7 +6123,7 @@ var paper_theme_default = defineTheme({
6121
6123
  });
6122
6124
 
6123
6125
  // packages/themes/src/themes/ocean.theme.ts
6124
- var ocean_theme_default = defineTheme({
6126
+ defineTheme({
6125
6127
  key: "ocean",
6126
6128
  name: "\u6D77\u76D0",
6127
6129
  light: {
@@ -6133,7 +6135,7 @@ var ocean_theme_default = defineTheme({
6133
6135
  // 实底控件 hover 档:bg-hover 5% 石板墨叠 surface 的不透明合成(同暖纸口径)
6134
6136
  surfaceHover: "#f2f3f6",
6135
6137
  sunken: "#d6e0ec",
6136
- // 轨道/凹槽专档:page 之下一档;输入框/代码块禁用本档(D-007/D-009/D-032)
6138
+ // 轨道/凹槽专档:page 之下一档;输入框/代码块禁用本档
6137
6139
  track: "#d3dce8",
6138
6140
  // 控件轨道:灰蓝,与 thumb(surface) 拉开
6139
6141
  ink1: "#2d3644",
@@ -6276,7 +6278,7 @@ var ocean_theme_default = defineTheme({
6276
6278
  });
6277
6279
 
6278
6280
  // packages/themes/src/themes/mint.theme.ts
6279
- var mint_theme_default = defineTheme({
6281
+ defineTheme({
6280
6282
  key: "mint",
6281
6283
  name: "\u8584\u8377",
6282
6284
  light: {
@@ -6422,7 +6424,7 @@ var mint_theme_default = defineTheme({
6422
6424
  });
6423
6425
 
6424
6426
  // packages/themes/src/themes/wisteria.theme.ts
6425
- var wisteria_theme_default = defineTheme({
6427
+ defineTheme({
6426
6428
  key: "wisteria",
6427
6429
  name: "\u7D2B\u85E4",
6428
6430
  light: {
@@ -6567,7 +6569,7 @@ var wisteria_theme_default = defineTheme({
6567
6569
  });
6568
6570
 
6569
6571
  // packages/themes/src/themes/sakura.theme.ts
6570
- var sakura_theme_default = defineTheme({
6572
+ defineTheme({
6571
6573
  key: "sakura",
6572
6574
  name: "\u6A31\u82B1",
6573
6575
  light: {
@@ -6714,7 +6716,7 @@ var sakura_theme_default = defineTheme({
6714
6716
  });
6715
6717
 
6716
6718
  // packages/themes/src/themes/ink.theme.ts
6717
- var ink_theme_default = defineTheme({
6719
+ defineTheme({
6718
6720
  key: "ink",
6719
6721
  name: "\u6C34\u58A8",
6720
6722
  // 素色主题收尾:设置页始终排在所有彩色主题之后(新增主题无需关心顺序)
@@ -6863,7 +6865,7 @@ var ink_theme_default = defineTheme({
6863
6865
  // packages/themes/src/tokenContract.ts
6864
6866
  var tokenContract = {
6865
6867
  surface: ["bg-page", "bg-surface", "bg-surface-hover", "bg-sunken"],
6866
- // 控件部件色(不在表面阶梯里——不受 D-006「沉到 page 之下」约束):开关/滑杆轨道
6868
+ // 控件部件色(不在表面阶梯里——不受「沉到 page 之下」约束):开关/滑杆轨道
6867
6869
  control: ["bg-track"],
6868
6870
  interaction: ["bg-hover", "bg-press", "bg-selected"],
6869
6871
  ink: ["ink-1", "ink-2", "ink-3", "ink-inverse"],
@@ -7869,7 +7871,7 @@ function MenuSeparator() {
7869
7871
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { role: "separator", className: "bg-line-1 mx-1 my-1.5 h-px" });
7870
7872
  }
7871
7873
  function MenuGroup({ children }) {
7872
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "text-ink-3 text-tau-tiny px-2.5 pb-1 pt-2 font-semibold tracking-[0.03em] first:pt-1", children });
7874
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "text-ink-3 text-tau-tiny px-2.5 pt-2 pb-1 font-semibold tracking-[0.03em] first:pt-1", children });
7873
7875
  }
7874
7876
  function Menu({
7875
7877
  trigger,
@@ -8106,10 +8108,17 @@ function Popover({
8106
8108
  const card = cardRef.current;
8107
8109
  if (!card) return;
8108
8110
  const target = card.querySelector("[data-autofocus]") ?? card;
8109
- try {
8110
- target.focus({ preventScroll: true });
8111
- } catch {
8112
- }
8111
+ const focus = () => {
8112
+ try {
8113
+ target.focus({ preventScroll: true });
8114
+ } catch {
8115
+ }
8116
+ };
8117
+ focus();
8118
+ const raf = requestAnimationFrame(() => {
8119
+ if (card.ownerDocument.activeElement !== target) focus();
8120
+ });
8121
+ return () => cancelAnimationFrame(raf);
8113
8122
  }, [open]);
8114
8123
  const hasHeader = import_react36.Children.toArray(children).some(
8115
8124
  (c2) => (0, import_react36.isValidElement)(c2) && c2.type === PopoverHeader
@@ -8187,7 +8196,7 @@ function Popover({
8187
8196
  }
8188
8197
  function PopoverHeader({ icon, children }) {
8189
8198
  const root = usePopoverRoot();
8190
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-2.5 px-4 pb-1 pt-3.5", children: [
8199
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-2.5 px-4 pt-3.5 pb-1", children: [
8191
8200
  icon && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "bg-accent-soft text-accent-text flex size-[26px] shrink-0 items-center justify-center rounded-[8px] [&>svg]:size-3.5", children: icon }),
8192
8201
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h4", { id: root.headerId, className: "text-ink-1 flex-1 truncate text-[13.5px] font-[600]", children }),
8193
8202
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
package/tailwind.css CHANGED
@@ -3,7 +3,7 @@
3
3
  * 取值来自 tokens.css 的 --tau-*,使用方需同时引入 @tau/themes/tokens.css。
4
4
  *
5
5
  * Tailwind 词一律用 tau 命名空间(rounded-tau-* / text-tau-*),不覆盖
6
- * legacy 页面在用的 Tailwind 默认刻度(D-001);一次性展示字号允许
6
+ * legacy 页面在用的 Tailwind 默认刻度;一次性展示字号允许
7
7
  * text-[24px] 类任意值。
8
8
  */
9
9
  @theme inline {
@@ -55,9 +55,9 @@
55
55
  --font-tau-mono: var(--tau-font-mono);
56
56
  --font-tau-hand: var(--tau-font-hand);
57
57
 
58
- /* ── 尺度词(D-001,tau 命名空间,见 02 规范 §3/§4)── */
58
+ /* ── 尺度词(tau 命名空间,见 02 规范 §3/§4)── */
59
59
 
60
- /* 字号:A2 定稿取值(经 :root 字面值层 --tau-text-* 桥接,支持运行时整体缩放——
60
+ /* 字号:A2 取值(经 :root 字面值层 --tau-text-* 桥接,支持运行时整体缩放——
61
61
  @theme inline 对字面值会内联进工具类导致不可覆盖,必须走 var 引用) */
62
62
  --text-tau-hero: var(--tau-text-hero);
63
63
  --text-tau-title-lg: var(--tau-text-title-lg);
@@ -0,0 +1,11 @@
1
+ import * as Y from "yjs";
2
+ import { type NodeDocumentOptions } from "./node-document";
3
+ import { type DocumentHistoryReader } from "./document-history";
4
+ export interface DocumentHistoryAction {
5
+ operationId: string;
6
+ kind: "restore" | "undo";
7
+ sequence: number;
8
+ expectedRevision?: string;
9
+ }
10
+ export declare function validateDocumentHistoryAction(action: DocumentHistoryAction): void;
11
+ export declare function buildDocumentHistoryUpdate(history: DocumentHistoryReader, id: string, current: Y.Doc, action: DocumentHistoryAction, currentRevision: string, actorId: string, owner: boolean, options?: NodeDocumentOptions): Promise<Uint8Array>;
@@ -0,0 +1,91 @@
1
+ import * as Y from "yjs";
2
+ import { type ContentNode, type SharedContent } from "./protocol";
3
+ import type { ContentContractDictionary } from "../../db-schema/content-contracts";
4
+ export interface DocumentHistoryEntry {
5
+ sequence: number;
6
+ operationId: string;
7
+ actorId: string;
8
+ actorName: string;
9
+ time: number;
10
+ kind: "baseline" | "edit" | "undo" | "restore";
11
+ target?: number;
12
+ source?: string;
13
+ sourceRevision?: string;
14
+ }
15
+ export type DocumentHistoryActor = Pick<DocumentHistoryEntry, "actorId" | "actorName" | "source">;
16
+ export interface DocumentHistoryChange {
17
+ blockId: string;
18
+ kind: "insert" | "delete" | "modify" | "move";
19
+ before?: ContentNode;
20
+ after?: ContentNode;
21
+ }
22
+ export interface DocumentHistoryPreview {
23
+ entry: DocumentHistoryEntry;
24
+ value: SharedContent;
25
+ contracts: ContentContractDictionary;
26
+ changes: DocumentHistoryChange[];
27
+ previousTitle?: string;
28
+ headRevision: string;
29
+ canRestore: boolean;
30
+ canUndo: boolean;
31
+ }
32
+ export interface DocumentHistoryReader {
33
+ entry(id: string, sequence: number): DocumentHistoryEntry;
34
+ replay(id: string, sequence: number): Y.Doc;
35
+ undone(id: string, sequence: number): boolean;
36
+ }
37
+ type SqlValue = string | number | Uint8Array;
38
+ export interface DocumentHistorySql {
39
+ exec(sql: string, ...values: SqlValue[]): void;
40
+ all<Row>(sql: string, ...values: SqlValue[]): Row[];
41
+ }
42
+ interface HistoryRow {
43
+ sequence: number;
44
+ revision: string;
45
+ checkpoint: number;
46
+ byte_count: number;
47
+ metadata: string;
48
+ }
49
+ export interface TransferredDocumentHistoryVersion {
50
+ entry: DocumentHistoryEntry;
51
+ revision: string;
52
+ checkpoint: number;
53
+ storage: string[];
54
+ }
55
+ export interface DocumentHistoryWrite {
56
+ operationId: string;
57
+ actor: DocumentHistoryActor;
58
+ kind?: "edit" | "restore" | "undo";
59
+ target?: number;
60
+ time?: number;
61
+ sourceRevision?: string;
62
+ previousRevision: string;
63
+ revision: string;
64
+ update: Uint8Array;
65
+ before: () => Uint8Array;
66
+ after: () => Uint8Array;
67
+ checkBytes?: (bytes: number) => void;
68
+ }
69
+ export declare const documentHistorySchema = "\nCREATE TABLE IF NOT EXISTS document_history_entries (\n document_id TEXT NOT NULL,\n sequence INTEGER NOT NULL,\n operation_id TEXT NOT NULL,\n revision TEXT NOT NULL,\n checkpoint INTEGER NOT NULL,\n byte_count INTEGER NOT NULL,\n metadata TEXT NOT NULL,\n PRIMARY KEY(document_id,sequence),\n UNIQUE(document_id,operation_id)\n);\nCREATE TABLE IF NOT EXISTS document_history_payloads (\n document_id TEXT NOT NULL,\n sequence INTEGER NOT NULL,\n part INTEGER NOT NULL,\n state BLOB NOT NULL,\n PRIMARY KEY(document_id,sequence,part)\n);\n";
70
+ export declare function assertHistorySequence(sequence: number): void;
71
+ /** 正文提交方持有事务和逐文档写入权,历史随同一提交落盘。 */
72
+ export declare class DocumentHistoryStore {
73
+ private readonly sql;
74
+ constructor(sql: DocumentHistorySql);
75
+ head(id: string): HistoryRow | undefined;
76
+ list(id: string, before?: number): DocumentHistoryEntry[];
77
+ entriesAfter(id: string, sequence: number): DocumentHistoryEntry[];
78
+ entry(id: string, sequence: number): DocumentHistoryEntry;
79
+ operation(id: string, operationId: string): DocumentHistoryEntry | undefined;
80
+ undone(id: string, sequence: number): boolean;
81
+ remove(id: string): void;
82
+ exportVersion(id: string, sequence: number): TransferredDocumentHistoryVersion;
83
+ importVersion(id: string, value: TransferredDocumentHistoryVersion): void;
84
+ append(id: string, write: DocumentHistoryWrite): void;
85
+ private insert;
86
+ replay(id: string, sequence: number): Y.Doc;
87
+ preview(id: string, sequence: number, headRevision: string, actorId: string, owner: boolean, comparison?: Y.Doc): DocumentHistoryPreview;
88
+ }
89
+ export declare function readDocumentHistoryPreview(history: DocumentHistoryReader, id: string, sequence: number, headRevision: string, actorId: string, owner: boolean, comparison?: Y.Doc): DocumentHistoryPreview;
90
+ export declare function documentHistoryChanges(before: ContentNode[], after: ContentNode[]): DocumentHistoryChange[];
91
+ export {};
@@ -20,6 +20,8 @@ export * from "./document-adapter";
20
20
  export * from "./document-operations";
21
21
  export * from "./scoped-content-edit";
22
22
  export * from "./document-sync";
23
+ export * from "./document-history";
24
+ export * from "./document-history-edit";
23
25
  export { exportWhiteboardTransfer, prepareWhiteboardTransfer, whiteboardTransferResources, } from "./whiteboard-transfer";
24
26
  export type { WhiteboardTransfer } from "./whiteboard-types";
25
27
  export { isSafeResource, isVideoResource, imageMimeFromBytes, collaborationAssetMime, } from "./resource-policy";
@@ -19,7 +19,7 @@ export declare function createNodeDocument(identity: NodeDocumentIdentity, conte
19
19
  export declare function validateNodeDocument(doc: Y.Doc, identity?: NodeDocumentIdentity, previous?: Y.Doc, options?: NodeDocumentOptions): Promise<void>;
20
20
  /** 正文与白板富文本根共用候选校验,不依赖任何渲染或插件代码。 */
21
21
  export declare function validateNodeTree(doc: Y.Doc, rootId?: string, previous?: Y.Doc, options?: NodeDocumentOptions): Promise<void>;
22
- export declare function applyNodeDocumentUpdate(current: Y.Doc, update: Uint8Array, identity: NodeDocumentIdentity, options?: NodeDocumentOptions): Promise<Y.Doc>;
22
+ export declare function applyNodeDocumentUpdate(current: Y.Doc, update: Uint8Array, identity: NodeDocumentIdentity, options?: NodeDocumentOptions, onUpdate?: (update: Uint8Array) => void): Promise<Y.Doc>;
23
23
  export declare function readNodeDocument(doc: Y.Doc): SharedContent;
24
24
  /** 保留记录也可能被撤销重新显示;只读取各自契约声明的资源位置。 */
25
25
  export declare function collectNodeDocumentResources(doc: Y.Doc): string[];
@@ -27,6 +27,13 @@ export interface TreeSpan {
27
27
  source: string | null;
28
28
  segment?: string;
29
29
  }
30
+ export interface NodeTextEdit {
31
+ nodeId: string;
32
+ offset: number;
33
+ text: string;
34
+ action: "insert" | "remove";
35
+ marks: Record<string, unknown>;
36
+ }
30
37
  export interface NodeTreeOptions {
31
38
  rootId?: string;
32
39
  }