@xiongtao.xt/tau-plugins 0.59.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.
- package/CHANGELOG.md +7 -0
- package/docs/editor-interactions.md +55 -0
- package/docs/portability.md +1 -0
- package/docs/whiteboard.md +1 -1
- package/package.json +1 -1
- package/publish-artifacts.js +15 -8
- package/types/packages/collaboration/src/node-tree.d.ts +7 -0
- package/types/packages/collaboration/src/whiteboard-model.d.ts +33 -2
- package/types/packages/plugins/src/contract.d.ts +2 -0
- package/types/packages/plugins/src/index.d.ts +1 -0
- package/types/packages/plugins/src/text-decorations.d.ts +68 -0
- package/types/packages/whiteboard/src/Board.d.ts +20 -6
- package/types/packages/whiteboard/src/chrome/index.d.ts +3 -1
- package/types/packages/whiteboard/src/constants/tools.d.ts +3 -0
- package/types/packages/whiteboard/src/context.d.ts +1 -2
- package/types/packages/whiteboard/src/extensions/api.d.ts +6 -1
- package/types/packages/whiteboard/src/hooks/useZoom.d.ts +6 -0
- package/types/packages/whiteboard/src/index.d.ts +1 -0
- package/types/packages/whiteboard/src/interactions/InteractionManager.d.ts +1 -0
- package/types/packages/whiteboard/src/plugins/MindPlugin.d.ts +1 -0
- package/types/packages/whiteboard/src/types/board.d.ts +2 -0
- package/types/packages/whiteboard/src/utils/GeometryUtil.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 0.60.0
|
|
4
|
+
|
|
5
|
+
- 桌面主窗口新增可选的 `context.textDecorations`。插件可以在已获读取权限的卡片、文章和项目文档中标出文字范围。提供方支持异步计算、取消请求、按来源刷新和主动注销。
|
|
6
|
+
- 支持六种主题外观、语义色调和悬停提示。点击回调可以返回候选列表,用户选择后由同一回调接收 `choice`。
|
|
7
|
+
- `getPreview` 可为命中或候选返回内容引用和可选块位置。宿主在悬停时核验目标读取权限并展示只读预览。接口与示例见随包的 `docs/editor-interactions.md`。
|
|
8
|
+
- 随包类型声明同步当前白板和协作实现,包括画布视口、文本编辑与笔迹更新相关类型;博客发布辅助模块也按当前源码重新构建。
|
|
9
|
+
|
|
3
10
|
## 0.59.0
|
|
4
11
|
|
|
5
12
|
- 插件页面可声明 `dockable`,通过页面句柄选择完整页或右栏,组件从 `placement` 读取展示位置。桌面主窗口支持 `context.app.openWeb(url)` 查看网页。
|
|
@@ -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/portability.md
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
| `speech` | | ✓ | 见[通知、语音输入与朗读 · 语音输入](notifications-and-voice.md#语音输入) |
|
|
40
40
|
| `tts.open` | ✓ | | 见[通知、语音输入与朗读 · 朗读](notifications-and-voice.md#朗读) |
|
|
41
41
|
| `upload.save` | ✓ | | 见[插件内容与记录 · 保存资源文件](plugin-content.md#保存资源文件) |
|
|
42
|
+
| 正文文字装饰(`textDecorations`) | ✓ | | 桌面主窗口可以标记词语、选择目标并悬停预览,见[编辑器交互](editor-interactions.md#在正文中标出文字) |
|
|
42
43
|
| 编辑器块(`editorExtensions`、`editorCodecs`) | ✓ | ✓ | 见[编辑器块](#编辑器块) |
|
|
43
44
|
| `sync`、`upload`、`tts`、`asr`、`images` 提供方 | ✓ | ✓ | 见[服务提供方](#服务提供方) |
|
|
44
45
|
| `embeddings`、`video`、`publish` 提供方 | ✓ | | |
|
package/docs/whiteboard.md
CHANGED
|
@@ -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
package/publish-artifacts.js
CHANGED
|
@@ -1629,7 +1629,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
|
|
|
1629
1629
|
},
|
|
1630
1630
|
[subscribe, value, getSnapshot]
|
|
1631
1631
|
);
|
|
1632
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
1729
|
+
useEffect25(
|
|
1730
1730
|
function() {
|
|
1731
1731
|
inst.hasValue = true;
|
|
1732
1732
|
inst.value = value;
|
|
@@ -8108,10 +8108,17 @@ function Popover({
|
|
|
8108
8108
|
const card = cardRef.current;
|
|
8109
8109
|
if (!card) return;
|
|
8110
8110
|
const target = card.querySelector("[data-autofocus]") ?? card;
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
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);
|
|
8115
8122
|
}, [open]);
|
|
8116
8123
|
const hasHeader = import_react36.Children.toArray(children).some(
|
|
8117
8124
|
(c2) => (0, import_react36.isValidElement)(c2) && c2.type === PopoverHeader
|
|
@@ -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
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WhiteboardPresentations } from "./whiteboard-presentation";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
import { type PreparedWhiteboardContract, type PreparedContentContract, type ContentContractDictionary, type DataContract } from "../../db-schema/content-contracts";
|
|
4
|
-
import { NodeTree } from "./node-tree";
|
|
4
|
+
import { NodeTree, type NodeTextEdit } from "./node-tree";
|
|
5
5
|
import { NodeTreeHistory, type NodeTreeHistoryOptions } from "./node-tree-history";
|
|
6
|
-
import type { WhiteboardModelCommand, WhiteboardReference, WhiteboardSnapshot } from "./whiteboard-types";
|
|
6
|
+
import type { WhiteboardElementSnapshot, WhiteboardGeometry, WhiteboardModelCommand, WhiteboardReference, WhiteboardSnapshot } from "./whiteboard-types";
|
|
7
7
|
/** 纯协作模型;宿主负责权限、耐久会话和插件版本保护,模型不连接画布。 */
|
|
8
8
|
export declare class WhiteboardModel {
|
|
9
9
|
readonly doc: Y.Doc;
|
|
@@ -21,7 +21,10 @@ export declare class WhiteboardModel {
|
|
|
21
21
|
private readonly histories;
|
|
22
22
|
private disposed;
|
|
23
23
|
private revision;
|
|
24
|
+
private translationBudget?;
|
|
24
25
|
private pending?;
|
|
26
|
+
/** 缺依赖期间复用已提交状态的编码,每份输入仍在独立候选上校验。 */
|
|
27
|
+
private pendingBase?;
|
|
25
28
|
private queuedBytes;
|
|
26
29
|
private incoming;
|
|
27
30
|
private readonly changed;
|
|
@@ -48,15 +51,28 @@ export declare class WhiteboardModel {
|
|
|
48
51
|
preflightHistory(history: NodeTreeHistory, direction: "undo" | "redo"): void;
|
|
49
52
|
private preparedAdditions;
|
|
50
53
|
withPreparedContracts(prepared: readonly (PreparedWhiteboardContract | PreparedContentContract)[], write: (model: WhiteboardModel) => void, origin: unknown): void;
|
|
54
|
+
/** 普通文本只修改已有段落的字符;结构变更、复杂标记与容量临界由完整候选处理。 */
|
|
55
|
+
tryLocalBodyEdit(target: string, edit: NodeTextEdit, origin: object): {
|
|
56
|
+
isolated: boolean;
|
|
57
|
+
} | undefined;
|
|
51
58
|
/** 大批导入分段预检,最终以一个增量进入当前视图历史。 */
|
|
52
59
|
submitChunks(commands: readonly WhiteboardModelCommand[], origin: unknown, prepared?: readonly (PreparedWhiteboardContract | PreparedContentContract)[], initialBodies?: readonly {
|
|
53
60
|
id: string;
|
|
54
61
|
preserveIds?: boolean;
|
|
55
62
|
body: readonly import("./protocol").ContentNode[];
|
|
56
63
|
}[]): void;
|
|
64
|
+
/** 为已打开的画布准备位置提交。无法证明基线有效时,调用方仍使用完整的隔离候选。 */
|
|
65
|
+
prepareLocalTranslations(): void;
|
|
66
|
+
/** 仅平移一个现有标量几何。返回 undefined 时没有写入,由调用方执行原有预检。 */
|
|
67
|
+
tryLocalTranslation(target: string, value: WhiteboardGeometry, origin: unknown): {
|
|
68
|
+
isolated: boolean;
|
|
69
|
+
} | undefined;
|
|
70
|
+
/** 笔迹只在页根创建父笔与分段。用同契约、同父级的小候选预演原命令。 */
|
|
71
|
+
private strokeTrial;
|
|
57
72
|
/** 在隔离副本中验证整批及编码大小,失败不改变真实文档或撤销栈。 */
|
|
58
73
|
submit(commands: readonly WhiteboardModelCommand[], origin: unknown, prepared?: readonly (PreparedWhiteboardContract | PreparedContentContract)[]): {
|
|
59
74
|
readonly createdIds: readonly string[];
|
|
75
|
+
readonly isolatedStroke?: true;
|
|
60
76
|
};
|
|
61
77
|
private execute;
|
|
62
78
|
private initialize;
|
|
@@ -69,8 +85,21 @@ export declare class WhiteboardModel {
|
|
|
69
85
|
private erase;
|
|
70
86
|
private edit;
|
|
71
87
|
private executeOne;
|
|
88
|
+
private elementUsage;
|
|
72
89
|
private assertBudget;
|
|
73
90
|
private validateState;
|
|
91
|
+
private visiblePageReferences;
|
|
92
|
+
readElementIdentity(target: string): {
|
|
93
|
+
type: string;
|
|
94
|
+
contractId: string;
|
|
95
|
+
} | undefined;
|
|
96
|
+
readSummary(): {
|
|
97
|
+
title: string;
|
|
98
|
+
pageCount: number;
|
|
99
|
+
};
|
|
100
|
+
private snapshotElement;
|
|
101
|
+
/** 绑定在已隔离的追加事务后复用同一笔的前缀。 */
|
|
102
|
+
readAppendedStroke(id: string, segmentId: string, prefix: readonly WhiteboardElementSnapshot[]): WhiteboardElementSnapshot;
|
|
74
103
|
read(): WhiteboardSnapshot;
|
|
75
104
|
/** 服务端校验完整候选,已有记录的物理身份不能被普通更新替换。 */
|
|
76
105
|
validate(previous?: WhiteboardModel): Promise<void>;
|
|
@@ -80,6 +109,8 @@ export declare class WhiteboardModel {
|
|
|
80
109
|
}>;
|
|
81
110
|
/** 将未接纳的缺依赖材料交还宿主保全;不能在接收仍进行时清空。 */
|
|
82
111
|
takePendingUpdate(): Uint8Array | undefined;
|
|
112
|
+
/** 已有结构和删除均被覆盖时,增量不会改变文档。需要打开富文本根的校验仍使用隔离候选。 */
|
|
113
|
+
private isReadOnlyReplay;
|
|
83
114
|
private receiveNow;
|
|
84
115
|
private assertStableRecords;
|
|
85
116
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PluginTextDecorations } from "./text-decorations";
|
|
1
2
|
import type { PluginWindowDefinition, PluginWindows } from "./windows";
|
|
2
3
|
import type { PluginPages } from "./pages";
|
|
3
4
|
import type { PluginEnvironment } from "./environment";
|
|
@@ -83,6 +84,7 @@ export interface PluginContext {
|
|
|
83
84
|
readonly home: PluginHome;
|
|
84
85
|
/** 对象动作:卡片、文章、项目文档「⋯」菜单里的条目 */
|
|
85
86
|
readonly actions: PluginActions;
|
|
87
|
+
readonly textDecorations?: PluginTextDecorations;
|
|
86
88
|
/** 卡片、文章、项目文档详情里的区块 */
|
|
87
89
|
readonly views: PluginViews;
|
|
88
90
|
/** Notebook 的生成菜单里加产物;只在桌面主窗口 */
|
|
@@ -28,6 +28,7 @@ export type * from "./sidebar";
|
|
|
28
28
|
export { SIDEBAR_GROUPS } from "./sidebar";
|
|
29
29
|
export type * from "./icons";
|
|
30
30
|
export type * from "./home";
|
|
31
|
+
export type * from "./text-decorations";
|
|
31
32
|
export type * from "./actions";
|
|
32
33
|
export { PLUGIN_ACTION_TARGET_KINDS } from "./actions";
|
|
33
34
|
export type * from "./views";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { PluginContentLocation } from "./app";
|
|
2
|
+
import type { Disposable } from "./contract";
|
|
3
|
+
export interface PluginDecorationSource {
|
|
4
|
+
readonly kind: "card" | "article" | "document";
|
|
5
|
+
readonly id: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PluginDecorationBlock {
|
|
8
|
+
readonly source: PluginDecorationSource;
|
|
9
|
+
readonly blockType: string;
|
|
10
|
+
readonly text: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 外观按打扰程度从低到高:
|
|
14
|
+
* - `dot`:文字不变,末尾一个小圆点
|
|
15
|
+
* - `ghost`:静止时点线极淡,悬停或按住 ⌘/Ctrl 才显出
|
|
16
|
+
* - `reference`:正文色文字 + 点线,悬停变实线
|
|
17
|
+
* - `tint`:只改字色
|
|
18
|
+
* - `marker`:下沿荧光笔底色
|
|
19
|
+
* - `wavy`:波浪下划线,适合提醒或待确认
|
|
20
|
+
*
|
|
21
|
+
* `dot`、`ghost`、`reference` 表示可以点击,必须提供 `key` 和 `onActivate`。
|
|
22
|
+
*/
|
|
23
|
+
export type PluginTextDecorationAppearance = "reference" | "ghost" | "marker" | "tint" | "wavy" | "dot";
|
|
24
|
+
/** 主题里的语义色,深浅主题由宿主适配。 */
|
|
25
|
+
export type PluginTextDecorationTone = "accent" | "info" | "warn" | "muted";
|
|
26
|
+
export interface PluginTextDecoration {
|
|
27
|
+
/** 当前连续文本内的 UTF-16 偏移,左闭右开。 */
|
|
28
|
+
start: number;
|
|
29
|
+
end: number;
|
|
30
|
+
appearance: PluginTextDecorationAppearance;
|
|
31
|
+
/** 默认 `accent`。 */
|
|
32
|
+
tone?: PluginTextDecorationTone;
|
|
33
|
+
/** 有 key 的结果可以触发 onActivate。 */
|
|
34
|
+
key?: string;
|
|
35
|
+
/** 悬停提示,例如「打开文章《遗忘曲线》」。 */
|
|
36
|
+
label?: string;
|
|
37
|
+
}
|
|
38
|
+
/** onActivate 返回候选时,宿主在文字旁弹出菜单让用户选择。 */
|
|
39
|
+
export interface PluginTextDecorationCandidate {
|
|
40
|
+
key: string;
|
|
41
|
+
title: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PluginTextDecorationActivation {
|
|
45
|
+
key: string;
|
|
46
|
+
source: PluginDecorationSource;
|
|
47
|
+
/** 用户在候选菜单里选中的 `candidate.key`;首次点击时为空。 */
|
|
48
|
+
choice?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface PluginDecorationPreviewTarget {
|
|
51
|
+
ref: PluginDecorationSource;
|
|
52
|
+
at?: PluginContentLocation;
|
|
53
|
+
}
|
|
54
|
+
export interface PluginTextDecorationProvider {
|
|
55
|
+
sources: readonly PluginDecorationSource["kind"][];
|
|
56
|
+
getDecorations(block: PluginDecorationBlock, signal: AbortSignal): readonly PluginTextDecoration[] | Promise<readonly PluginTextDecoration[]>;
|
|
57
|
+
/** 停留在命中或候选上时解析目标;宿主负责授权检查和只读预览。 */
|
|
58
|
+
getPreview?(hit: PluginTextDecorationActivation, signal: AbortSignal): PluginDecorationPreviewTarget | undefined | Promise<PluginDecorationPreviewTarget | undefined>;
|
|
59
|
+
onActivate?(action: PluginTextDecorationActivation): void | readonly PluginTextDecorationCandidate[] | Promise<void | readonly PluginTextDecorationCandidate[]>;
|
|
60
|
+
}
|
|
61
|
+
export interface PluginTextDecorationHandle extends Disposable {
|
|
62
|
+
invalidate(scope?: {
|
|
63
|
+
source: PluginDecorationSource;
|
|
64
|
+
}): void;
|
|
65
|
+
}
|
|
66
|
+
export interface PluginTextDecorations {
|
|
67
|
+
register(provider: PluginTextDecorationProvider): Promise<PluginTextDecorationHandle>;
|
|
68
|
+
}
|
|
@@ -19,7 +19,10 @@ declare class Board {
|
|
|
19
19
|
private disconnectDocument?;
|
|
20
20
|
private projectingDocument;
|
|
21
21
|
attachDocument(document: WhiteboardDocumentBinding): void;
|
|
22
|
-
publishDocument(children: BoardElement[], sketch?: PageSketch, sequences?: PresentationSequence[]
|
|
22
|
+
publishDocument(children: BoardElement[], sketch?: PageSketch, sequences?: PresentationSequence[], body?: {
|
|
23
|
+
previous: BoardElement;
|
|
24
|
+
next: BoardElement;
|
|
25
|
+
}): void;
|
|
23
26
|
private plugins;
|
|
24
27
|
/** 指针在画布上的最近位置(画布坐标);指针离开画布为 null。`/` 放入等需要光标处的入口读取 */
|
|
25
28
|
pointer: Point | null;
|
|
@@ -66,8 +69,6 @@ declare class Board {
|
|
|
66
69
|
y: number;
|
|
67
70
|
} | null;
|
|
68
71
|
invalidateContainerRect(): void;
|
|
69
|
-
/** 剔除滞回的上一轮保留集合(见 filterElementsInViewport 的宽退出盒说明) */
|
|
70
|
-
private cullRetainedIds;
|
|
71
72
|
private snapshot;
|
|
72
73
|
/** 当前工具("tau.select" 表示非创建模式) */
|
|
73
74
|
private _activeTool;
|
|
@@ -130,6 +131,7 @@ declare class Board {
|
|
|
130
131
|
*/
|
|
131
132
|
private exitCreateToolOnEscape;
|
|
132
133
|
onKeyUp(event: KeyboardEvent): void;
|
|
134
|
+
canClaimPointer(button: number): boolean;
|
|
133
135
|
onPointerDown(event: PointerEvent): void;
|
|
134
136
|
onPointerUp(event: PointerEvent): void;
|
|
135
137
|
onPointerMove(event: PointerEvent): void;
|
|
@@ -157,6 +159,15 @@ declare class Board {
|
|
|
157
159
|
undo(): void;
|
|
158
160
|
redo(): void;
|
|
159
161
|
subscribe(callback: () => void): () => void;
|
|
162
|
+
private bodyLayout?;
|
|
163
|
+
getCanvasSnapshot(): {
|
|
164
|
+
children: BoardElement[];
|
|
165
|
+
viewPort: ViewPort;
|
|
166
|
+
selection: Selection;
|
|
167
|
+
presentationSequences: PresentationSequence[];
|
|
168
|
+
sketch: PageSketch;
|
|
169
|
+
version: number;
|
|
170
|
+
};
|
|
160
171
|
getSnapshot(): {
|
|
161
172
|
children: BoardElement[];
|
|
162
173
|
viewPort: ViewPort;
|
|
@@ -168,7 +179,7 @@ declare class Board {
|
|
|
168
179
|
getElementVersion(): number;
|
|
169
180
|
get activeTool(): string;
|
|
170
181
|
get activeToolOptions(): Readonly<Record<string, unknown>> | null;
|
|
171
|
-
/**
|
|
182
|
+
/** 当前工具是否用于创建元素。 */
|
|
172
183
|
isCreating(): boolean;
|
|
173
184
|
/**
|
|
174
185
|
* 设置当前工具;id 必须是已注册工具 id 或 "tau.select",否则抛错。
|
|
@@ -178,7 +189,10 @@ declare class Board {
|
|
|
178
189
|
/** 写齐字段后统一发事件 */
|
|
179
190
|
private applyToolChange;
|
|
180
191
|
getPlugin<T extends IBoardPlugin>(name: string): T | undefined;
|
|
181
|
-
filterElementsInViewport(elements: BoardElement[], expandPixels?: number
|
|
182
|
-
|
|
192
|
+
filterElementsInViewport(elements: BoardElement[], expandPixels?: number, vp?: ViewPort, retention?: {
|
|
193
|
+
previous: ReadonlySet<string>;
|
|
194
|
+
current: Set<string>;
|
|
195
|
+
}): VisibleElementTree[];
|
|
196
|
+
renderVisibleElements(elements?: VisibleElementTree[], liveText?: boolean): Array<React.ReactElement | null | undefined>;
|
|
183
197
|
}
|
|
184
198
|
export default Board;
|
|
@@ -45,12 +45,14 @@ export interface ChromeButtonProps extends ComponentProps<"button"> {
|
|
|
45
45
|
sub?: boolean;
|
|
46
46
|
kbd?: string;
|
|
47
47
|
tooltipPlacement?: TooltipPlacement;
|
|
48
|
+
/** 不显示悬停提示(按钮下方紧贴着自己的浮动件时,提示会把它挡住) */
|
|
49
|
+
hideTooltip?: boolean;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* 浮动件图标按钮:30px,Tooltip 包在 button 外、ref 与注入的 props 透传到 button——
|
|
51
53
|
* 所以可以直接作为 Menu / Popover 的 trigger。展开时(aria-expanded)按下态、并暂停提示。
|
|
52
54
|
*/
|
|
53
|
-
export declare function ChromeButton({ label, active, sub, kbd, tooltipPlacement, className, children, ref, ...rest }: ChromeButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
export declare function ChromeButton({ label, active, sub, kbd, tooltipPlacement, hideTooltip, className, children, ref, ...rest }: ChromeButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
54
56
|
/** 属性条的弹层方向:条在元素上方 → 向上展开;翻到元素下方 → 向下展开 */
|
|
55
57
|
export declare const AttrBarContext: import("react").Context<{
|
|
56
58
|
side: "top" | "bottom";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** 内置"选择"工具 id(非创建模式的哨兵值) */
|
|
2
2
|
export declare const SELECT_TOOL_ID = "tau.select";
|
|
3
|
+
export declare const HAND_TOOL_ID = "tau.hand";
|
|
3
4
|
/** 内置创建工具 id(工具按钮、右键菜单与扩展装配共用同一常量) */
|
|
4
5
|
export declare const GEOMETRY_TOOL_ID = "tau.geometry.create";
|
|
5
6
|
export declare const ARROW_TOOL_ID = "tau.arrow.create";
|
|
@@ -8,4 +9,6 @@ export declare const RICHTEXT_TOOL_ID = "tau.richtext.create";
|
|
|
8
9
|
export declare const MIND_TOOL_ID = "tau.mind.create";
|
|
9
10
|
export declare const FRAME_TOOL_ID = "tau.frame.create";
|
|
10
11
|
export declare const COLUMN_TOOL_ID = "tau.column.create";
|
|
12
|
+
/** 指针和文本模式都把已有对象的操作交还给元素。 */
|
|
13
|
+
export declare const allowsElementInteraction: (toolId: string) => toolId is "tau.select" | "tau.richtext.create";
|
|
11
14
|
export declare const builtinCreateToolIds: Set<string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
import { Board, Point, Selection
|
|
2
|
+
import { Board, Point, Selection } from "./types/index";
|
|
3
3
|
import { MovingElementsStore } from "./hooks/useElementsMoving";
|
|
4
4
|
import type { ConnectPointOwnerStore } from "./utils/ConnectPointOwner";
|
|
5
5
|
export interface PointerViewportStore {
|
|
@@ -11,7 +11,6 @@ export declare const BoardContext: import("react").Context<Board | null>;
|
|
|
11
11
|
export declare const SelectionContext: import("react").Context<Selection | null>;
|
|
12
12
|
/** 静态元素层(选中的箭头/内部连接元素已提升到交互层时)强制无选区;元素级选中订阅据此短路 */
|
|
13
13
|
export declare const StaticSelectionContext: import("react").Context<boolean>;
|
|
14
|
-
export declare const ViewPortContext: import("react").Context<ViewPort>;
|
|
15
14
|
export declare const BoardStateContext: import("react").Context<{
|
|
16
15
|
isMoving: boolean;
|
|
17
16
|
movingStore: MovingElementsStore;
|
|
@@ -31,7 +31,7 @@ export interface WhiteboardAPI {
|
|
|
31
31
|
/** 只读原因:文档版本高于当前应用时为 "document-too-new",普通只读为 null */
|
|
32
32
|
readonly readonlyReason: "document-too-new" | null;
|
|
33
33
|
readonly isDestroyed: boolean;
|
|
34
|
-
/** 当前激活工具 id
|
|
34
|
+
/** 当前激活工具 id(默认指针为 "tau.select",抓手为 "tau.hand") */
|
|
35
35
|
readonly activeTool: string;
|
|
36
36
|
/** 当前工具参数(如 geometry 的形状参数);无参数为 null */
|
|
37
37
|
readonly activeToolOptions: Readonly<Record<string, unknown>> | null;
|
|
@@ -333,6 +333,11 @@ export interface WhiteboardExtensionError {
|
|
|
333
333
|
}
|
|
334
334
|
export declare function defineWhiteboardExtension(definition: Omit<WhiteboardExtension, "apiVersion">): WhiteboardExtension;
|
|
335
335
|
export interface WhiteboardOutline {
|
|
336
|
+
/** 省略时显示内置元素树。 */
|
|
337
|
+
panel?: {
|
|
338
|
+
label: string;
|
|
339
|
+
content: ReactNode;
|
|
340
|
+
};
|
|
336
341
|
open: boolean;
|
|
337
342
|
width: number;
|
|
338
343
|
onWidthChange(width: number): void;
|
|
@@ -30,6 +30,7 @@ export { default as MindThemeUtil } from "./utils/MindThemeUtil";
|
|
|
30
30
|
export type { MindMode, MindNodeVisual } from "./utils/MindThemeUtil";
|
|
31
31
|
export { useWhiteboardAPI as useBoard } from "./extensions/context";
|
|
32
32
|
export { useSelection, useViewPort } from "./extensions/publicHooks";
|
|
33
|
+
export { useZoom } from "./hooks/useZoom";
|
|
33
34
|
export { useReadonly } from "./hooks/useReadonly";
|
|
34
35
|
export { useBoardState } from "./hooks/useBoardState";
|
|
35
36
|
export { useDropArrow } from "./hooks/useDropArrow";
|
|
@@ -49,6 +49,7 @@ export declare class InteractionManager {
|
|
|
49
49
|
* 拖拽仍可独立开启;右键按下进入平移手势兜底。
|
|
50
50
|
*/
|
|
51
51
|
tryStartPointerGesture(event: PointerEvent): void;
|
|
52
|
+
tryStartPanning(event: PointerEvent): boolean;
|
|
52
53
|
routePointerMove(event: PointerEvent): boolean;
|
|
53
54
|
routePointerUp(event: PointerEvent): boolean;
|
|
54
55
|
routeGlobalPointerMove(event: PointerEvent): boolean;
|
|
@@ -5,6 +5,7 @@ import type { InteractionState } from "../interactions/InteractionState";
|
|
|
5
5
|
export declare class MindPlugin implements IBoardPlugin {
|
|
6
6
|
private readonly text;
|
|
7
7
|
name: string;
|
|
8
|
+
readonly claimPointerButton = 0;
|
|
8
9
|
constructor(text?: TextExtensionOptions);
|
|
9
10
|
getCapabilities(): IElementCapabilities;
|
|
10
11
|
private dragState;
|
|
@@ -27,6 +27,8 @@ export type Events = "onMouseDown" | "onMouseMove" | "onMouseUp" | "onMouseEnter
|
|
|
27
27
|
export interface IBoardPlugin {
|
|
28
28
|
dispose?(): void;
|
|
29
29
|
name: string;
|
|
30
|
+
/** 限定命中查询的按键;未声明时保留全部按键。 */
|
|
31
|
+
claimPointerButton?: number;
|
|
30
32
|
/**
|
|
31
33
|
* 元素类型自定义指针手势声明:pointerdown 命中该类型元素时由交互内核
|
|
32
34
|
* 在广播前调用,返回手势状态则由内核接管路由(取代通用选择/拖拽并消费
|
|
@@ -10,7 +10,7 @@ export declare class GeometryUtil {
|
|
|
10
10
|
readonly strokeWidth: number;
|
|
11
11
|
readonly strokeOpacity: number;
|
|
12
12
|
readonly color: string | undefined;
|
|
13
|
-
readonly theme: "
|
|
13
|
+
readonly theme: "light" | "dark" | undefined;
|
|
14
14
|
readonly cornerRadius: number;
|
|
15
15
|
readonly textAlign: "center" | "left" | "right";
|
|
16
16
|
readonly fillStyle: SketchFillStyle | undefined;
|