@xiongtao.xt/tau-plugins 0.58.0 → 0.59.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 (111) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/docs/pages.md +71 -2
  3. package/docs/portability.md +1 -0
  4. package/docs/references.md +2 -0
  5. package/docs/settings-and-commands.md +3 -0
  6. package/package.json +1 -1
  7. package/publish-artifacts.js +20 -18
  8. package/tailwind.css +3 -3
  9. package/types/packages/collaboration/src/document-history-edit.d.ts +11 -0
  10. package/types/packages/collaboration/src/document-history.d.ts +91 -0
  11. package/types/packages/collaboration/src/index.d.ts +2 -0
  12. package/types/packages/collaboration/src/node-document.d.ts +1 -1
  13. package/types/packages/db-schema/content-identities.d.ts +1 -1
  14. package/types/packages/editor/src/core/CoreEditor.d.ts +10 -1
  15. package/types/packages/editor/src/core/api/extension.d.ts +0 -1
  16. package/types/packages/editor/src/core/api/index.d.ts +3 -1
  17. package/types/packages/editor/src/core/utils/nodeOperations.d.ts +1 -0
  18. package/types/packages/editor/src/core/utils/undoStep.d.ts +6 -0
  19. package/types/packages/editor/src/core/utils/wrapInlineText.d.ts +4 -0
  20. package/types/packages/editor/src/extensions/kbd/src/types.d.ts +2 -2
  21. package/types/packages/editor/src/extensions/link/src/types.d.ts +2 -2
  22. package/types/packages/editor/src/extensions/styled-text/src/types.d.ts +2 -2
  23. package/types/packages/editor/src/extensions/underline/src/types.d.ts +2 -2
  24. package/types/packages/markdown/src/codec.d.ts +6 -2
  25. package/types/packages/markdown/src/markdown.d.ts +2 -1
  26. package/types/packages/markdown/src/positionMapper.d.ts +7 -1
  27. package/types/packages/plugins/src/app.d.ts +2 -0
  28. package/types/packages/plugins/src/index.d.ts +1 -1
  29. package/types/packages/plugins/src/pages.d.ts +8 -2
  30. package/types/packages/shared/src/chat-core/aiRunProtocol.d.ts +1 -1
  31. package/types/packages/shared/src/chat-core/messages.d.ts +13 -4
  32. package/types/packages/themes/src/themes/ink.theme.d.ts +1 -2
  33. package/types/packages/themes/src/themes/mint.theme.d.ts +1 -2
  34. package/types/packages/themes/src/themes/ocean.theme.d.ts +1 -2
  35. package/types/packages/themes/src/themes/paper.theme.d.ts +1 -2
  36. package/types/packages/themes/src/themes/sakura.theme.d.ts +1 -2
  37. package/types/packages/themes/src/themes/wisteria.theme.d.ts +1 -2
  38. package/types/packages/ui/src/cn.d.ts +1 -1
  39. package/types/packages/ui/src/primitives/AnchoredPanel.d.ts +3 -3
  40. package/types/packages/ui/src/primitives/Button.d.ts +4 -4
  41. package/types/packages/ui/src/primitives/Checkbox.d.ts +2 -2
  42. package/types/packages/ui/src/primitives/ConfirmDialog.d.ts +3 -3
  43. package/types/packages/ui/src/primitives/Dialog.d.ts +4 -4
  44. package/types/packages/ui/src/primitives/Loading.d.ts +1 -1
  45. package/types/packages/ui/src/primitives/Menu.d.ts +1 -1
  46. package/types/packages/ui/src/primitives/Notification.d.ts +2 -2
  47. package/types/packages/ui/src/primitives/Popover.d.ts +3 -3
  48. package/types/packages/ui/src/primitives/Radio.d.ts +2 -3
  49. package/types/packages/ui/src/primitives/RadioGroup.d.ts +1 -1
  50. package/types/packages/ui/src/primitives/Segmented.d.ts +3 -3
  51. package/types/packages/ui/src/primitives/Select.d.ts +6 -6
  52. package/types/packages/ui/src/primitives/Switch.d.ts +2 -2
  53. package/types/packages/ui/src/primitives/Tag.d.ts +2 -3
  54. package/types/packages/ui/src/primitives/Toast.d.ts +1 -1
  55. package/types/packages/ui/src/primitives/Tooltip.d.ts +5 -5
  56. package/types/packages/ui/src/primitives/ValueDisplay.d.ts +2 -3
  57. package/types/packages/ui/src/primitives/anchoredPosition.d.ts +1 -2
  58. package/types/packages/ui/src/primitives/datepicker/DatePicker.d.ts +2 -2
  59. package/types/packages/ui/src/primitives/datepicker/DateRangePicker.d.ts +1 -1
  60. package/types/packages/ui/src/primitives/input/Input.d.ts +4 -4
  61. package/types/packages/ui/src/primitives/input/NumberInput.d.ts +2 -2
  62. package/types/packages/ui/src/primitives/input/Textarea.d.ts +1 -1
  63. package/types/packages/whiteboard/src/Board.d.ts +8 -6
  64. package/types/packages/whiteboard/src/{WhiteBoard.d.ts → Whiteboard.d.ts} +6 -6
  65. package/types/packages/whiteboard/src/chrome/index.d.ts +1 -1
  66. package/types/packages/whiteboard/src/components/ArrowConnectPoint/index.d.ts +26 -0
  67. package/types/packages/whiteboard/src/components/ArrowConnectPointGroup/index.d.ts +3 -0
  68. package/types/packages/whiteboard/src/components/DocumentElement/index.d.ts +2 -0
  69. package/types/packages/whiteboard/src/components/ExcerptElement/index.d.ts +13 -0
  70. package/types/packages/whiteboard/src/components/SketchPopover.d.ts +1 -1
  71. package/types/packages/whiteboard/src/constants/arrow.d.ts +0 -2
  72. package/types/packages/whiteboard/src/constants/mind.d.ts +0 -13
  73. package/types/packages/whiteboard/src/constants/text-style.d.ts +1 -1
  74. package/types/packages/whiteboard/src/extensions/authorApi.d.ts +0 -1
  75. package/types/packages/whiteboard/src/extensions/events.d.ts +0 -1
  76. package/types/packages/whiteboard/src/hooks/useDropArrow.d.ts +1 -1
  77. package/types/packages/whiteboard/src/hooks/useReadonly.d.ts +1 -0
  78. package/types/packages/whiteboard/src/hooks/useSelectState.d.ts +0 -1
  79. package/types/packages/whiteboard/src/index.d.ts +10 -6
  80. package/types/packages/whiteboard/src/plugins/ArrowPlugin.d.ts +1 -1
  81. package/types/packages/whiteboard/src/plugins/ColumnPlugin.d.ts +1 -1
  82. package/types/packages/whiteboard/src/plugins/CommonPlugin.d.ts +10 -10
  83. package/types/packages/whiteboard/src/plugins/DocumentPlugin.d.ts +36 -3
  84. package/types/packages/whiteboard/src/plugins/ExcerptPlugin.d.ts +48 -0
  85. package/types/packages/whiteboard/src/plugins/FramePlugin.d.ts +1 -1
  86. package/types/packages/whiteboard/src/plugins/GeometryPlugin.d.ts +5 -2
  87. package/types/packages/whiteboard/src/plugins/MindPlugin.d.ts +1 -2
  88. package/types/packages/whiteboard/src/plugins/WebviewPlugin.d.ts +1 -1
  89. package/types/packages/whiteboard/src/plugins/{WhiteBoardPlugin.d.ts → WhiteboardPlugin.d.ts} +8 -5
  90. package/types/packages/whiteboard/src/plugins/index.d.ts +2 -1
  91. package/types/packages/whiteboard/src/public.d.ts +23 -1
  92. package/types/packages/whiteboard/src/types/board.d.ts +10 -10
  93. package/types/packages/whiteboard/src/types/element.d.ts +6 -1
  94. package/types/packages/whiteboard/src/types/operation.d.ts +1 -1
  95. package/types/packages/whiteboard/src/types/selection.d.ts +1 -1
  96. package/types/packages/whiteboard/src/types/sketch.d.ts +2 -2
  97. package/types/packages/whiteboard/src/types/viewport.d.ts +1 -1
  98. package/types/packages/whiteboard/src/utils/ArrowStyleUtil.d.ts +0 -1
  99. package/types/packages/whiteboard/src/utils/CanvasUtil.d.ts +0 -1
  100. package/types/packages/whiteboard/src/utils/ClipboardUtil.d.ts +0 -5
  101. package/types/packages/whiteboard/src/utils/HandwriteUtil.d.ts +0 -1
  102. package/types/packages/whiteboard/src/utils/MindUtil.d.ts +0 -3
  103. package/types/packages/whiteboard/src/utils/PathUtil.d.ts +1 -1
  104. package/types/packages/whiteboard/src/utils/PointUtil.d.ts +0 -1
  105. package/types/packages/whiteboard/src/utils/PresentationManager.d.ts +1 -1
  106. package/types/packages/whiteboard/src/utils/TextStyleStore.d.ts +2 -1
  107. package/types/packages/whiteboard/src/utils/index.d.ts +0 -1
  108. package/types/packages/whiteboard/src/utils/sketch/handText.d.ts +1 -1
  109. package/types/packages/whiteboard/src/utils/sketch/index.d.ts +4 -5
  110. package/types/packages/whiteboard/src/utils/sketch/shape.d.ts +1 -2
  111. package/types/packages/whiteboard/src/utils/ViewportUtil.d.ts +0 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.59.0
4
+
5
+ - 插件页面可声明 `dockable`,通过页面句柄选择完整页或右栏,组件从 `placement` 读取展示位置。桌面主窗口支持 `context.app.openWeb(url)` 查看网页。
6
+
3
7
  ## 0.58.0
4
8
 
5
9
  - 插件通知按钮新增可选字段 `reveal`。Tau 桌面端 0.64.1 起,点击通知正文也会执行该按钮的回调,独立通知会先唤起来源窗口。每条通知至多指定一个查看动作。
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` | ✓ | ✓ | |
@@ -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
  | 字段 | 说明 |
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.59.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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,
@@ -8187,7 +8189,7 @@ function Popover({
8187
8189
  }
8188
8190
  function PopoverHeader({ icon, children }) {
8189
8191
  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: [
8192
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-2.5 px-4 pt-3.5 pb-1", children: [
8191
8193
  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
8194
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h4", { id: root.headerId, className: "text-ink-1 flex-1 truncate text-[13.5px] font-[600]", children }),
8193
8195
  /* @__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[];
@@ -1,4 +1,4 @@
1
- export declare const CONTENT_ENTITY_KINDS: readonly ["whiteboard-content", "data-table", "project-item", "card", "article", "diary-moment", "whiteboard", "content", "video-note"];
1
+ export declare const CONTENT_ENTITY_KINDS: readonly ["whiteboard-content", "data-table", "project-item", "card", "article", "diary-moment", "whiteboard", "content", "video-note", "pdf"];
2
2
  export type ContentEntityKind = (typeof CONTENT_ENTITY_KINDS)[number];
3
3
  export interface ContentEntityReference {
4
4
  sourceId: string;
@@ -1,5 +1,6 @@
1
+ import { type ReactNode, type ReactElement } from "react";
1
2
  import type { Node, Path } from "slate";
2
- import { Descendant, Editor, Range } from "slate";
3
+ import { Descendant, Editor, Range, Element } from "slate";
3
4
  import type { EditorKit } from "./kit/EditorKit";
4
5
  import type { EditorDocument } from "./document/EditorDocument";
5
6
  import type { InlineSuggestionProvider } from "./inlineSuggestion/controller";
@@ -14,6 +15,7 @@ export interface IEditorProps {
14
15
  onChange?: (value: Descendant[], editor: Editor) => void;
15
16
  onSelectionChange?: () => void;
16
17
  readonly?: boolean;
18
+ ariaLabel?: string;
17
19
  /** 本编辑器的组成(扩展 + 服务 + 主题)。不传则继承外层编辑器的 kit */
18
20
  kit?: EditorKit;
19
21
  /**
@@ -35,6 +37,13 @@ export interface IEditorProps {
35
37
  decorate?: (entry: [Node, Path]) => Range[];
36
38
  /** 包装已经应用标记的内容,不接管 Slate attributes。 */
37
39
  leafWrapper?: ComponentType<MarkRenderProps>;
40
+ /** 宿主可延迟挂载顶层块的界面,节点仍属于完整编辑器。 */
41
+ renderTopLevelBlock?: (args: {
42
+ editor: Editor;
43
+ index: number;
44
+ element: Element;
45
+ children: ReactNode;
46
+ }) => ReactElement;
38
47
  /** 当前视图的行内纯文本建议来源。 */
39
48
  inlineSuggestions?: InlineSuggestionProvider;
40
49
  /**
@@ -133,6 +133,5 @@ export interface ElementContractDefinition {
133
133
  resources?: readonly ContentResourceSpec[];
134
134
  }
135
135
  export declare function assertElementVersions(spec: ElementContractDefinition): void;
136
- export declare const isEditorExtension: (value: unknown) => value is EditorExtension;
137
136
  /** 扩展贡献的元素类型 */
138
137
  export declare const elementTypesOf: (extension: EditorExtension) => string[];
@@ -36,9 +36,11 @@ export { default as InlineChromiumBugfix } from "../components/InlineChromiumBug
36
36
  export { default as useIsLastElement } from "../hooks/useIsLastElement";
37
37
  export { registerBlockNavigation, hasBlockNavigation, unregisterBlockNavigation, focusPreviousBlock, focusNextBlock, type BlockNavigationHandler, } from "../utils/blockNavigation";
38
38
  export { isCollapsed, getCurrentTextNode } from "../utils/editor";
39
- export { copyNodeToClipboard, deleteVoidBlock } from "../utils/nodeOperations";
39
+ export { copyNodeToClipboard, deleteVoidBlock, setSlateFragmentData, } from "../utils/nodeOperations";
40
40
  export { CONTENT_FRAGMENT_MIME, readContentFragment, setContentFragmentTransfer, } from "./clipboardFragment";
41
41
  export { getSelectionSnapshot, isSelectionSnapshotUnchanged } from "../utils/selectionSnapshot";
42
+ export { wrapInlineText } from "../utils/wrapInlineText";
43
+ export { withNewUndoStep } from "../utils/undoStep";
42
44
  export { createParagraph, isParagraphElement, type ParagraphElement } from "../model/paragraph";
43
45
  export { insertParagraphAndFocus } from "../utils/editor";
44
46
  export { isAtParagraphStart, isParagraphAndEmpty } from "../utils/editor";
@@ -1,5 +1,6 @@
1
1
  import { Editor, Node, Path } from "slate";
2
2
  import type { EditorFeedback } from "../services/notifier";
3
+ export declare function setSlateFragmentData(editor: Editor, data: DataTransfer, fragment: Node[], plainText: string, richContent?: DocumentFragment): void;
3
4
  /**
4
5
  * 复制节点到剪贴板
5
6
  * 支持两种格式:JSON 和纯文本;传入数组时按数组顺序作为一个 fragment,纯文本以换行连接
@@ -0,0 +1,6 @@
1
+ import type { Editor } from "slate";
2
+ export declare function registerUndoStepSplitter(editor: Editor, split: () => void): void;
3
+ /** `fn` 内的修改单独成一个撤销步,不与之前的输入合并 */
4
+ export declare function withNewUndoStep(editor: Editor, fn: () => void, { isolate }?: {
5
+ isolate?: boolean | undefined;
6
+ }): void;
@@ -0,0 +1,4 @@
1
+ import { Editor, Range } from "slate";
2
+ import type { InlineElement } from "../types/custom-element";
3
+ /** 只包裹同一父节点下连续的选中文字,避免 Slate 把部分选中的行内祖先整体移入。 */
4
+ export declare function wrapInlineText(editor: Editor, create: (range: Range) => InlineElement, at?: import("slate").BaseSelection): boolean;
@@ -1,5 +1,5 @@
1
- import { type FormattedText } from "../../../../../markdown/src/model";
1
+ import type { ParagraphElement } from "../../../../api";
2
2
  export interface KbdElement {
3
3
  type: "kbd";
4
- children: FormattedText[];
4
+ children: ParagraphElement["children"];
5
5
  }
@@ -1,6 +1,6 @@
1
- import { type FormattedText } from "../../../../../markdown/src/model";
1
+ import type { ParagraphElement } from "../../../../api";
2
2
  export interface LinkElement {
3
3
  type: "link";
4
4
  url: string;
5
- children: FormattedText[];
5
+ children: ParagraphElement["children"];
6
6
  }
@@ -1,7 +1,7 @@
1
- import { type FormattedText } from "../../../../../markdown/src/model";
1
+ import type { ParagraphElement } from "../../../../api";
2
2
  import type { EStyledColor } from "./colors";
3
3
  export interface StyledTextElement {
4
4
  type: "styled-text";
5
5
  color: EStyledColor;
6
- children: FormattedText[];
6
+ children: ParagraphElement["children"];
7
7
  }
@@ -1,8 +1,8 @@
1
- import { type FormattedText } from "../../../../../markdown/src/model";
1
+ import type { ParagraphElement } from "../../../../api";
2
2
  export interface UnderlineElement {
3
3
  type: "underline";
4
4
  color: string;
5
5
  lineType: string;
6
6
  colorSelectOpen: boolean;
7
- children: FormattedText[];
7
+ children: ParagraphElement["children"];
8
8
  }
@@ -73,6 +73,7 @@ export interface MarkdownCodec {
73
73
  nextSibling: Descendant | null;
74
74
  /** 按领域声明把块级子元素降级为行内形态,无声明则原样返回。 */
75
75
  demote: (child: Descendant) => Descendant;
76
+ isBlock: (child: Descendant) => boolean;
76
77
  }) => Descendant[] | null;
77
78
  /** 按目标类型贡献规范化,先于该类型自身 normalize;按 codec 顺序首个非 null 替换生效。 */
78
79
  normalizeFor?: Readonly<Record<string, NonNullable<MarkdownCodec["normalize"]>>>;
@@ -80,9 +81,12 @@ export interface MarkdownCodec {
80
81
  inlineForm?: (element: any) => Descendant;
81
82
  /**
82
83
  * 导入:从 code 节点(围栏或缩进代码块)认领的 void 元素,把源码区间记为
83
- * 该属性的属性级位置映射(如 code-block 的 "code");缺省只有元素级映射
84
+ * 该属性的位置映射;正文位于子节点时声明相对路径。缺省只有元素级映射。
84
85
  */
85
- fenceSourceProperty?: string;
86
+ fenceSourceProperty?: string | {
87
+ property: string;
88
+ path: readonly number[];
89
+ };
86
90
  /** 导出:子块级元素之间的接续符,默认 "\n\n";列表与表格声明 "\n" */
87
91
  childSeparator?: "\n" | "\n\n";
88
92
  }
@@ -15,6 +15,7 @@ export interface ImportConfig {
15
15
  textRegistry: MarkdownTextRegistry;
16
16
  directives: Record<string, CustomDirectiveHandler>;
17
17
  voidTypes: ReadonlySet<string>;
18
+ blockTypes: ReadonlySet<string>;
18
19
  inlineWrapperDirectives: ReadonlySet<string>;
19
20
  inlineHtmlWrappers?: ReadonlyMap<string, NonNullable<MarkdownCodec["inlineHtmlWrapper"]>>;
20
21
  fenceByLanguage: ReadonlyMap<string, {
@@ -22,7 +23,7 @@ export interface ImportConfig {
22
23
  property: string;
23
24
  }>;
24
25
  importNodes?: readonly NonNullable<MarkdownCodec["importNode"]>[];
25
- fenceSourceProperties?: ReadonlyMap<string, string>;
26
+ fenceSourceProperties?: ReadonlyMap<string, NonNullable<MarkdownCodec["fenceSourceProperty"]>>;
26
27
  normalizeHooks?: ReadonlyMap<string, NonNullable<MarkdownCodec["normalize"]>>;
27
28
  inlineForms?: ReadonlyMap<string, NonNullable<MarkdownCodec["inlineForm"]>>;
28
29
  }
@@ -27,6 +27,11 @@ export interface TextMapping {
27
27
  prefixLength: number;
28
28
  suffixLength: number;
29
29
  sourceOffsets?: readonly number[];
30
+ /** 多行导入时,正文各行在源码中的起点与文本偏移。 */
31
+ sourceLines?: readonly (MarkdownPosition & {
32
+ offset: number;
33
+ length: number;
34
+ })[];
30
35
  /** 手工改写的载体无法证明字符对应时,只提供首尾边界。 */
31
36
  opaque?: boolean;
32
37
  mdEnd?: MarkdownPosition;
@@ -39,7 +44,7 @@ export interface ElementMapping {
39
44
  type: "element";
40
45
  slateElementPath: number[];
41
46
  elementType: string;
42
- isVoid: true;
47
+ isVoid: boolean;
43
48
  mdStartLine: number;
44
49
  mdStartCh: number;
45
50
  mdEndLine: number;
@@ -50,6 +55,7 @@ export interface ElementMapping {
50
55
  mdStartCh: number;
51
56
  mdEndLine: number;
52
57
  mdEndCh: number;
58
+ mdLineColumns?: readonly number[];
53
59
  };
54
60
  };
55
61
  }
@@ -130,6 +130,8 @@ export interface PluginAppActionResults {
130
130
  export type PluginAppAction = keyof PluginAppActions;
131
131
  export declare const PLUGIN_APP_ACTIONS: readonly PluginAppAction[];
132
132
  export interface PluginApp {
133
+ /** 用户操作后在桌面主窗口的右栏查看 HTTP(S) 网页。 */
134
+ openWeb(url: string): Promise<void>;
133
135
  /**
134
136
  * 打开 Tau 的搜索选择弹窗,返回用户选中的内容;用户取消时返回空数组。
135
137
  * 用户亲手挑选即视为同意插件引用这些内容,不需要读取权限。只能在用户操作(点击、按键)后调用。