@xiongtao.xt/tau-plugins 0.33.0 → 0.35.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 +50 -0
- package/client/{chunk-SVY5LBAT.js → chunk-FZTR4KOY.js} +10 -0
- package/docs/README.md +18 -17
- package/docs/editor.md +47 -1
- package/docs/excerpts.md +1 -1
- package/docs/plugin-basics.md +3 -0
- package/docs/storage-and-network.md +1 -1
- package/docs/ui.md +229 -1
- package/docs/user-data.md +395 -72
- package/package.js +1 -1
- package/package.json +1 -1
- package/publish-artifacts.js +29 -2
- package/publish-client.js +2 -2
- package/types/packages/editor/src/core/api/extension.d.ts +3 -0
- package/types/packages/editor/src/core/api/index.d.ts +1 -0
- package/types/packages/editor/src/core/api/inputRules.d.ts +37 -0
- package/types/packages/plugins/src/actions.d.ts +61 -0
- package/types/packages/plugins/src/app.d.ts +106 -8
- package/types/packages/plugins/src/components.d.ts +22 -0
- package/types/packages/plugins/src/content-input.d.ts +45 -0
- package/types/packages/plugins/src/contract.d.ts +18 -0
- package/types/packages/plugins/src/data.d.ts +179 -11
- package/types/packages/plugins/src/editor-fields.d.ts +10 -0
- package/types/packages/plugins/src/editor.d.ts +2 -1
- package/types/packages/plugins/src/entities.d.ts +28 -3
- package/types/packages/plugins/src/events.d.ts +9 -3
- package/types/packages/plugins/src/excerpts.d.ts +1 -1
- package/types/packages/plugins/src/home.d.ts +20 -0
- package/types/packages/plugins/src/index.d.ts +17 -5
- package/types/packages/plugins/src/links.d.ts +39 -0
- package/types/packages/plugins/src/pages.d.ts +12 -0
- package/types/packages/plugins/src/permissions.d.ts +1 -1
- package/types/packages/plugins/src/publish-data.d.ts +6 -62
- package/types/packages/plugins/src/query.d.ts +64 -0
- package/types/packages/plugins/src/records.d.ts +50 -0
- package/types/packages/plugins/src/sidebar.d.ts +63 -1
- package/types/packages/plugins/src/transaction.d.ts +40 -0
- package/types/packages/plugins/src/views.d.ts +26 -0
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* 每次调用前宿主按 manifest.permissions 与用户授权校验,未获准抛出 PluginPermissionError。
|
|
4
4
|
* 修改与删除要传读到的 revision,数据已被别处修改时抛出 PluginConflictError。
|
|
5
5
|
*/
|
|
6
|
+
import type { Descendant } from "slate";
|
|
7
|
+
import type { PluginContentInput } from "./content-input";
|
|
8
|
+
import type { PluginEntityRef } from "./app";
|
|
6
9
|
/** 一份正文的句柄,从实体上取得,传给 context.content 读取 */
|
|
7
10
|
export type PluginContentRef = string;
|
|
8
11
|
export interface PluginPage<T> {
|
|
@@ -51,6 +54,136 @@ export interface PluginDocument extends PluginEntityBase {
|
|
|
51
54
|
contentRef: PluginContentRef | null;
|
|
52
55
|
projectIds: string[];
|
|
53
56
|
}
|
|
57
|
+
export interface PluginWhiteboard {
|
|
58
|
+
id: string;
|
|
59
|
+
/** 白板信息(标题、说明、标签)的版本;画板内容的编辑不改变它 */
|
|
60
|
+
revision: string;
|
|
61
|
+
title: string;
|
|
62
|
+
description: string;
|
|
63
|
+
tags: string[];
|
|
64
|
+
/** 画板页数 */
|
|
65
|
+
pageCount: number;
|
|
66
|
+
createdAt: number;
|
|
67
|
+
updatedAt: number;
|
|
68
|
+
}
|
|
69
|
+
export interface PluginWhiteboardInput {
|
|
70
|
+
title: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
tags?: string[];
|
|
73
|
+
}
|
|
74
|
+
export type PluginWhiteboardPatch = Partial<PluginWhiteboardInput>;
|
|
75
|
+
export interface PluginProject {
|
|
76
|
+
id: string;
|
|
77
|
+
/** 项目的版本:改名、归档、置顶以及文档目录的变化都会改变它 */
|
|
78
|
+
revision: string;
|
|
79
|
+
title: string;
|
|
80
|
+
archived: boolean;
|
|
81
|
+
pinned: boolean;
|
|
82
|
+
/** 根目录下的文档数 */
|
|
83
|
+
documentCount: number;
|
|
84
|
+
createdAt: number;
|
|
85
|
+
updatedAt: number;
|
|
86
|
+
}
|
|
87
|
+
export interface PluginProjectInput {
|
|
88
|
+
title: string;
|
|
89
|
+
}
|
|
90
|
+
export interface PluginProjectPatch {
|
|
91
|
+
title?: string;
|
|
92
|
+
archived?: boolean;
|
|
93
|
+
pinned?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 项目目录中的一处。同一篇文档可以挂在多处,这时会在目录里出现多次,documentId 相同。
|
|
97
|
+
*/
|
|
98
|
+
export interface PluginProjectNode {
|
|
99
|
+
documentId: string;
|
|
100
|
+
/** 文档的版本,documents.move 时作为 expectedRevision 传回 */
|
|
101
|
+
revision: string;
|
|
102
|
+
title: string;
|
|
103
|
+
/** document(富文本)、white-board 等 */
|
|
104
|
+
kind: string;
|
|
105
|
+
/** 引用卡片或文章的条目:正文归被引用的内容,documents.get 读不到这一项 */
|
|
106
|
+
ref?: PluginEntityRef;
|
|
107
|
+
children: PluginProjectNode[];
|
|
108
|
+
}
|
|
109
|
+
export interface PluginDocumentInput {
|
|
110
|
+
projectId: string;
|
|
111
|
+
/** 挂在哪篇文档下;省略时挂在项目根目录末尾 */
|
|
112
|
+
parentId?: string;
|
|
113
|
+
title: string;
|
|
114
|
+
/** 正文;省略时为空 */
|
|
115
|
+
content?: PluginContentInput;
|
|
116
|
+
tags?: string[];
|
|
117
|
+
}
|
|
118
|
+
/** 在同一项目内移动文档的一处位置;from / to 为父文档 ID,null 表示项目根目录 */
|
|
119
|
+
export interface PluginDocumentMove {
|
|
120
|
+
projectId: string;
|
|
121
|
+
from: string | null;
|
|
122
|
+
to: string | null;
|
|
123
|
+
/** 移动后在新位置中的序号,从 0 开始;省略时放在末尾 */
|
|
124
|
+
index?: number;
|
|
125
|
+
}
|
|
126
|
+
export interface PluginNotebook {
|
|
127
|
+
id: string;
|
|
128
|
+
title: string;
|
|
129
|
+
archived: boolean;
|
|
130
|
+
pinned: boolean;
|
|
131
|
+
/** 资料数 */
|
|
132
|
+
resourceCount: number;
|
|
133
|
+
createdAt: number;
|
|
134
|
+
updatedAt: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Notebook 里的一份资料。只给清单信息:不含本机文件路径与资料转换后的文字。
|
|
138
|
+
* source:local 本机文件、remote 网络链接、note 加入时的笔记快照、material 材料快照、
|
|
139
|
+
* online-video 在线视频。
|
|
140
|
+
*/
|
|
141
|
+
export interface PluginNotebookResource {
|
|
142
|
+
id: string;
|
|
143
|
+
name: string;
|
|
144
|
+
/** 文件类型:pdf、video、audio、image、md、html、docx 等,无法识别时为 other */
|
|
145
|
+
type: string;
|
|
146
|
+
source: "local" | "remote" | "note" | "material" | "online-video";
|
|
147
|
+
/** remote 的网址 */
|
|
148
|
+
url?: string;
|
|
149
|
+
/** note / material:快照来自哪些内容,原内容可能已删除 */
|
|
150
|
+
from?: PluginEntityRef[];
|
|
151
|
+
/** 字节数,未知时为 null */
|
|
152
|
+
size: number | null;
|
|
153
|
+
/** 音视频时长(秒),未知时为 null */
|
|
154
|
+
duration: number | null;
|
|
155
|
+
createdAt: number;
|
|
156
|
+
}
|
|
157
|
+
/** 划线(excerpt)、PDF 标注(pdf-annotation)与剪藏(web-clip) */
|
|
158
|
+
export type PluginMaterialKind = "excerpt" | "pdf-annotation" | "web-clip";
|
|
159
|
+
export interface PluginMaterial {
|
|
160
|
+
/** 与 PluginEntityRef 的 material 引用 ID 相同 */
|
|
161
|
+
id: string;
|
|
162
|
+
kind: PluginMaterialKind;
|
|
163
|
+
title: string;
|
|
164
|
+
/** 划下或标注的原文;剪藏为空 */
|
|
165
|
+
quote: string;
|
|
166
|
+
/** 用户写下的想法 */
|
|
167
|
+
note: string;
|
|
168
|
+
/** 出处说明,如「PDF · 文件名 · 第 3 页」 */
|
|
169
|
+
source: string;
|
|
170
|
+
/** 原处的网址:划线的外部链接、剪藏的网页 */
|
|
171
|
+
url?: string;
|
|
172
|
+
createdAt: number;
|
|
173
|
+
updatedAt: number;
|
|
174
|
+
}
|
|
175
|
+
/** 对话的信息;消息内容不开放 */
|
|
176
|
+
export interface PluginChatSession {
|
|
177
|
+
id: string;
|
|
178
|
+
/** 未命名的对话为空字符串 */
|
|
179
|
+
title: string;
|
|
180
|
+
/** main 主对话、pdf PDF 对话、video-note 视频笔记对话、notebook Notebook 对话 */
|
|
181
|
+
scene: "main" | "pdf" | "video-note" | "notebook";
|
|
182
|
+
messageCount: number;
|
|
183
|
+
archived: boolean;
|
|
184
|
+
createdAt: number;
|
|
185
|
+
updatedAt: number;
|
|
186
|
+
}
|
|
54
187
|
export interface PluginEntityReader<T> {
|
|
55
188
|
get(id: string): Promise<T | null>;
|
|
56
189
|
query(query?: PluginEntityQuery): Promise<PluginPage<T>>;
|
|
@@ -60,8 +193,8 @@ export interface PluginWriteOptions {
|
|
|
60
193
|
expectedRevision: string;
|
|
61
194
|
}
|
|
62
195
|
export interface PluginCardInput {
|
|
63
|
-
/**
|
|
64
|
-
|
|
196
|
+
/** 正文;省略时为空卡片 */
|
|
197
|
+
content?: PluginContentInput;
|
|
65
198
|
tags?: string[];
|
|
66
199
|
pinned?: boolean;
|
|
67
200
|
}
|
|
@@ -71,7 +204,8 @@ export interface PluginCardPatch {
|
|
|
71
204
|
}
|
|
72
205
|
export interface PluginArticleInput {
|
|
73
206
|
title: string;
|
|
74
|
-
|
|
207
|
+
/** 正文;省略时为空文章 */
|
|
208
|
+
content?: PluginContentInput;
|
|
75
209
|
tags?: string[];
|
|
76
210
|
}
|
|
77
211
|
export interface PluginArticlePatch {
|
|
@@ -157,10 +291,41 @@ export type PluginCalendarPatch = Partial<PluginCalendarInput>;
|
|
|
157
291
|
export interface PluginData {
|
|
158
292
|
readonly cards: PluginEntityWriter<PluginCard, PluginCardInput, PluginCardPatch>;
|
|
159
293
|
readonly articles: PluginEntityWriter<PluginArticle, PluginArticleInput, PluginArticlePatch>;
|
|
160
|
-
/**
|
|
294
|
+
/** 白板的信息;画板内容不开放读写,用户在 Tau 中编辑 */
|
|
295
|
+
readonly whiteboards: PluginEntityWriter<PluginWhiteboard, PluginWhiteboardInput, PluginWhiteboardPatch>;
|
|
296
|
+
/** 项目本身;query 不支持 tag。项目里的文档见 documents */
|
|
297
|
+
readonly projects: PluginEntityReader<PluginProject> & {
|
|
298
|
+
/** 新建一个空项目 */
|
|
299
|
+
create(input: PluginProjectInput): Promise<PluginProject>;
|
|
300
|
+
/** 项目的文档目录;项目不存在时为 null */
|
|
301
|
+
tree(id: string): Promise<PluginProjectNode[] | null>;
|
|
302
|
+
update(id: string, patch: PluginProjectPatch, options: PluginWriteOptions): Promise<PluginProject>;
|
|
303
|
+
/** 只能删除空项目:项目里还有文档时拒绝 */
|
|
304
|
+
delete(id: string, options: PluginWriteOptions): Promise<void>;
|
|
305
|
+
};
|
|
306
|
+
/** 项目文档:新建、修改标题与标签、在项目内移动与删除 */
|
|
161
307
|
readonly documents: PluginEntityReader<PluginDocument> & {
|
|
308
|
+
create(input: PluginDocumentInput): Promise<PluginDocument>;
|
|
162
309
|
update(id: string, patch: PluginDocumentPatch, options: PluginWriteOptions): Promise<PluginDocument>;
|
|
310
|
+
/** 移动挂在 from 下的那一处;不能移到自己或自己的子文档下。返回文档的新版本 */
|
|
311
|
+
move(id: string, move: PluginDocumentMove, options: PluginWriteOptions): Promise<{
|
|
312
|
+
revision: string;
|
|
313
|
+
}>;
|
|
314
|
+
/**
|
|
315
|
+
* 从所有挂载处删除这篇文档。有子文档时拒绝;视频笔记不能由插件删除。
|
|
316
|
+
* 用户可在插件详情页 7 天内恢复,恢复后挂回仍存在的原位置。
|
|
317
|
+
*/
|
|
318
|
+
delete(id: string, options: PluginWriteOptions): Promise<void>;
|
|
163
319
|
};
|
|
320
|
+
/** Notebook 的信息与资料清单;query 不支持 tag */
|
|
321
|
+
readonly notebooks: PluginEntityReader<PluginNotebook> & {
|
|
322
|
+
/** 按 Notebook 中的顺序;Notebook 不存在时为 null */
|
|
323
|
+
resources(id: string): Promise<PluginNotebookResource[] | null>;
|
|
324
|
+
};
|
|
325
|
+
/** 划线、PDF 标注与剪藏;query 不支持 tag,已删除的不返回 */
|
|
326
|
+
readonly materials: PluginEntityReader<PluginMaterial>;
|
|
327
|
+
/** AI 对话的信息,不含消息内容;query 不支持 tag */
|
|
328
|
+
readonly chats: PluginEntityReader<PluginChatSession>;
|
|
164
329
|
readonly todos: {
|
|
165
330
|
query(query?: PluginTodoQuery): Promise<PluginPage<PluginTodo>>;
|
|
166
331
|
create(input: PluginTodoInput): Promise<PluginTodo>;
|
|
@@ -182,21 +347,24 @@ export interface PluginContentSnapshot {
|
|
|
182
347
|
revision: string;
|
|
183
348
|
/** format 为 markdown(默认)时给出 */
|
|
184
349
|
markdown?: string;
|
|
185
|
-
/** format 为 nodes
|
|
186
|
-
nodes?:
|
|
350
|
+
/** format 为 nodes 时给出编辑器节点,可原样作为 PluginContentInput 的 nodes 写回 */
|
|
351
|
+
nodes?: Descendant[];
|
|
352
|
+
/** format 为 nodes 时给出节点结构版本,见 EDITOR_NODE_SCHEMA_VERSION */
|
|
353
|
+
schemaVersion?: number;
|
|
187
354
|
wordCount: number;
|
|
188
355
|
updatedAt: number;
|
|
189
356
|
}
|
|
190
357
|
/**
|
|
191
|
-
* 正文修改。append / prepend
|
|
192
|
-
*
|
|
358
|
+
* 正文修改。append / prepend 只加入新内容(不能为空),原有内容保持不变;replaceAll 用新内容替换
|
|
359
|
+
* 整篇(可以为空)。replaceText 在 Markdown 文本上查找替换,会把整篇经 Markdown 重建,
|
|
360
|
+
* Markdown 无法表达的格式可能简化。
|
|
193
361
|
*/
|
|
194
362
|
export type PluginContentEdit = {
|
|
195
363
|
op: "append";
|
|
196
|
-
|
|
364
|
+
content: PluginContentInput;
|
|
197
365
|
} | {
|
|
198
366
|
op: "prepend";
|
|
199
|
-
|
|
367
|
+
content: PluginContentInput;
|
|
200
368
|
}
|
|
201
369
|
/** find 必须在当前 Markdown 中恰好出现一次 */
|
|
202
370
|
| {
|
|
@@ -205,7 +373,7 @@ export type PluginContentEdit = {
|
|
|
205
373
|
markdown: string;
|
|
206
374
|
} | {
|
|
207
375
|
op: "replaceAll";
|
|
208
|
-
|
|
376
|
+
content: PluginContentInput;
|
|
209
377
|
};
|
|
210
378
|
export interface PluginContent {
|
|
211
379
|
/** 需要拥有该正文所属实体的读取权限;正文不存在时返回 null */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PluginEditorExtension } from "./editor";
|
|
2
|
+
/** 向插件开放的编辑器扩展字段;类型与运行时校验共用这一份,新增开放须同时评估宿主隔离。 */
|
|
3
|
+
declare const OPEN_EXTENSION_FIELDS: readonly ["id", "apiVersion", "elements", "commands", "hotkeys", "menu", "blockPanel", "behaviorsFor"];
|
|
4
|
+
export type OpenEditorExtensionField = (typeof OPEN_EXTENSION_FIELDS)[number];
|
|
5
|
+
/**
|
|
6
|
+
* 运行时按白名单校验插件给的编辑器扩展:编辑器装配直接读取属性,类型约束拦不住纯 JS 插件,
|
|
7
|
+
* 继承或不可枚举的属性同样会被读到,所以要求普通对象且自有键全部开放。
|
|
8
|
+
*/
|
|
9
|
+
export declare function assertPluginEditorExtension(extension: unknown): asserts extension is PluginEditorExtension;
|
|
10
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EditorExtension as InternalExtension } from "../../editor/contracts";
|
|
2
2
|
import type { MarkdownCodec } from "../../markdown/src/index";
|
|
3
3
|
import type { Disposable } from "./index";
|
|
4
|
+
import { type OpenEditorExtensionField } from "./editor-fields";
|
|
4
5
|
export { defineElement as defineEditorElement } from "../../editor/contracts";
|
|
5
6
|
export type { ElementRenderProps as EditorElementRenderProps } from "../../editor/contracts";
|
|
6
7
|
export type { MarkdownCodec as EditorMarkdownCodec } from "../../markdown/src/index";
|
|
@@ -22,7 +23,7 @@ declare module "../../editor/api" {
|
|
|
22
23
|
[inlineMapBrand]: never;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
export type PluginEditorExtension = Pick<InternalExtension,
|
|
26
|
+
export type PluginEditorExtension = Pick<InternalExtension, OpenEditorExtensionField> & {
|
|
26
27
|
plugins?: never;
|
|
27
28
|
/** 发布时从节点字段收集 Tailwind 源码,复用宿主编译器。 */
|
|
28
29
|
styleSources?: readonly {
|
|
@@ -8,6 +8,8 @@ import type { JsonValue } from "./json";
|
|
|
8
8
|
import type { PluginPageParams } from "./pages";
|
|
9
9
|
import type { PluginEntityRef } from "./app";
|
|
10
10
|
import type { PluginIcon } from "./icons";
|
|
11
|
+
import type { PluginContentInput } from "./content-input";
|
|
12
|
+
import type { PluginIndexes, PluginOrderBy, PluginWhere } from "./query";
|
|
11
13
|
export type PluginOwnEntityMeta = Record<string, JsonValue>;
|
|
12
14
|
export interface PluginOwnEntity {
|
|
13
15
|
id: string;
|
|
@@ -42,19 +44,40 @@ export interface PluginOwnEntityKind {
|
|
|
42
44
|
};
|
|
43
45
|
/** 是否可在正文中用 @ 引用,默认 false */
|
|
44
46
|
mentionable?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 可用于 query 筛选与排序的 meta 字段及类型,如 `{ status: "string", sortIndex: "number" }`。
|
|
49
|
+
* 最多 16 个;写入时这些字段的值必须是声明的类型或 null。只在插件运行时生效。
|
|
50
|
+
*/
|
|
51
|
+
indexes?: PluginIndexes;
|
|
45
52
|
}
|
|
46
53
|
export interface PluginOwnEntityInput {
|
|
47
54
|
kind: string;
|
|
48
55
|
key: string;
|
|
49
56
|
title?: string;
|
|
50
57
|
meta?: PluginOwnEntityMeta;
|
|
58
|
+
/** 初始正文;省略时为空 */
|
|
59
|
+
content?: PluginContentInput;
|
|
51
60
|
}
|
|
52
61
|
export interface PluginOwnEntityPatch {
|
|
53
62
|
title?: string;
|
|
54
63
|
meta?: PluginOwnEntityMeta;
|
|
55
64
|
}
|
|
56
|
-
|
|
65
|
+
/** 实体自带的排序列;其余排序字段取 registerKind 声明的 indexes */
|
|
66
|
+
export type PluginOwnEntitySortField = "createdAt" | "updatedAt" | "title";
|
|
67
|
+
export interface PluginOwnEntityFilter {
|
|
57
68
|
kind?: string;
|
|
69
|
+
/** 按 indexes 中的字段筛选,需同时给出 kind */
|
|
70
|
+
where?: PluginWhere;
|
|
71
|
+
/** 标题包含这段文字(英文字母不区分大小写) */
|
|
72
|
+
titleContains?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface PluginOwnEntityQuery extends PluginOwnEntityFilter {
|
|
75
|
+
/**
|
|
76
|
+
* 最多两项,ID 兜底保证顺序稳定;默认按创建时间倒序。字段为 createdAt、updatedAt、title,
|
|
77
|
+
* 或 kind 的 indexes 中声明的字段。
|
|
78
|
+
*/
|
|
79
|
+
orderBy?: PluginOrderBy | PluginOrderBy[];
|
|
80
|
+
/** 原样传回上一页的 cursor;换了筛选或排序后不能再用 */
|
|
58
81
|
cursor?: string;
|
|
59
82
|
/** 默认 50,最多 200 */
|
|
60
83
|
limit?: number;
|
|
@@ -74,12 +97,14 @@ export interface PluginOwnEntityBacklink {
|
|
|
74
97
|
export interface PluginOwnEntities {
|
|
75
98
|
/** 声明一种内容类型;create 只接受已声明的类型 */
|
|
76
99
|
registerKind(definition: PluginOwnEntityKind): Disposable;
|
|
77
|
-
/**
|
|
100
|
+
/** 新建一项,content 为初始正文(缺省为空)。同一类型下 key 已存在时抛出 PluginConflictError */
|
|
78
101
|
create(input: PluginOwnEntityInput): Promise<PluginOwnEntity>;
|
|
79
102
|
get(id: string): Promise<PluginOwnEntity | null>;
|
|
80
103
|
find(kind: string, key: string): Promise<PluginOwnEntity | null>;
|
|
81
|
-
/**
|
|
104
|
+
/** 分页查询,默认按创建时间倒序 */
|
|
82
105
|
query(query?: PluginOwnEntityQuery): Promise<PluginPage<PluginOwnEntity>>;
|
|
106
|
+
/** 符合条件的数量 */
|
|
107
|
+
count(filter?: PluginOwnEntityFilter): Promise<number>;
|
|
83
108
|
/** 修改标题或 meta;revision 不是最新时抛出 PluginConflictError */
|
|
84
109
|
update(id: string, patch: PluginOwnEntityPatch, options: PluginWriteOptions): Promise<PluginOwnEntity>;
|
|
85
110
|
/**
|
|
@@ -2,9 +2,11 @@ import type { Disposable } from "./contract";
|
|
|
2
2
|
import type { PluginPermission } from "./permissions";
|
|
3
3
|
/**
|
|
4
4
|
* 业务数据变更事件。事件只说明「哪一项变了」,不携带数据:需要时用 context.data 重新读取。
|
|
5
|
-
*
|
|
5
|
+
* 正文修改计入所属卡片、文章、项目文档或插件实体的 updated;Notebook 资料的增删改计入所属
|
|
6
|
+
* Notebook 的 updated;待办与日程只给出集合级变化。entity.* 与 record.* 是本插件实体
|
|
7
|
+
* (context.entities)与记录(context.records)的变化,只发给拥有它的插件。
|
|
6
8
|
*/
|
|
7
|
-
export declare const PLUGIN_EVENT_TYPES: readonly ["card.created", "card.updated", "card.deleted", "article.created", "article.updated", "article.deleted", "document.created", "document.updated", "document.deleted", "todos.changed", "calendar.changed", "workspace.reset"];
|
|
9
|
+
export declare const PLUGIN_EVENT_TYPES: readonly ["card.created", "card.updated", "card.deleted", "article.created", "article.updated", "article.deleted", "document.created", "document.updated", "document.deleted", "whiteboard.created", "whiteboard.updated", "whiteboard.deleted", "project.created", "project.updated", "project.deleted", "notebook.created", "notebook.updated", "notebook.deleted", "material.created", "material.updated", "material.deleted", "chat.created", "chat.updated", "chat.deleted", "entity.created", "entity.updated", "entity.deleted", "record.created", "record.updated", "record.deleted", "todos.changed", "calendar.changed", "workspace.reset"];
|
|
8
10
|
export type PluginEventType = (typeof PLUGIN_EVENT_TYPES)[number];
|
|
9
11
|
/** 变化来自哪里:插件经 context.data / context.content 写入时为 plugin,其余(用户、同步、AI 等)为 app */
|
|
10
12
|
export type PluginEventOrigin = {
|
|
@@ -15,8 +17,12 @@ export type PluginEventOrigin = {
|
|
|
15
17
|
};
|
|
16
18
|
export interface PluginDomainEvent {
|
|
17
19
|
type: PluginEventType;
|
|
18
|
-
/** 实体事件给出与 context.data 相同的 ID;集合级事件没有 */
|
|
20
|
+
/** 实体事件给出与 context.data / context.entities 相同的 ID;集合级事件没有 */
|
|
19
21
|
id?: string;
|
|
22
|
+
/** entity.* 事件给出实体类型(registerKind 声明的 kind);删除后读不到实体时据此区分 */
|
|
23
|
+
kind?: string;
|
|
24
|
+
/** record.* 事件给出记录所在的集合 */
|
|
25
|
+
collection?: string;
|
|
20
26
|
/** 宿主发出事件的时间(毫秒) */
|
|
21
27
|
at: number;
|
|
22
28
|
/** 用来忽略自己写入引起的事件;待办与日程的集合级事件恒为 app */
|
|
@@ -86,6 +86,6 @@ export interface PluginMaterialAction {
|
|
|
86
86
|
run(): Promise<void>;
|
|
87
87
|
}
|
|
88
88
|
export interface PluginMaterials {
|
|
89
|
-
/**
|
|
89
|
+
/** 客户端对该材料当前可执行的动作(转为卡片…),不含其他插件注册的对象动作;动作随客户端增加 */
|
|
90
90
|
actions(ref: PluginMaterialRef): Promise<PluginMaterialAction[]>;
|
|
91
91
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { Disposable, PluginContext } from "./contract";
|
|
3
|
+
/** compact:有最小宽度、可伸展,宽度足够时与其他紧凑面板并排;wide:占整行 */
|
|
4
|
+
export type PluginHomePanelSize = "compact" | "wide";
|
|
5
|
+
export interface PluginHomePanelProps {
|
|
6
|
+
readonly context: PluginContext;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginHomePanelDefinition {
|
|
9
|
+
id: string;
|
|
10
|
+
/** 面板标题,也是「显示已隐藏的面板」里的名称 */
|
|
11
|
+
title: string;
|
|
12
|
+
/** 面板正文;返回 null 时整块不显示 */
|
|
13
|
+
component: ComponentType<PluginHomePanelProps>;
|
|
14
|
+
/** 缺省为 wide */
|
|
15
|
+
size?: PluginHomePanelSize;
|
|
16
|
+
}
|
|
17
|
+
export interface PluginHome {
|
|
18
|
+
/** 面板出现在首页:新面板排在末尾,位置由用户调整;插件停用后消失,重新启用回到原位置 */
|
|
19
|
+
registerPanel(definition: PluginHomePanelDefinition): Disposable;
|
|
20
|
+
}
|
|
@@ -11,21 +11,33 @@ export * from "./editor";
|
|
|
11
11
|
export { SourceBlockEditor, useSourceBlock, useReportPreviewError, insertSourceBlock, sourceBlockParagraphBehavior, } from "./source-editor";
|
|
12
12
|
export type { SourceBlockEditorProps, PluginRuntimeStyleCompiler } from "./source-editor";
|
|
13
13
|
export { useInlineSource, insertInlineSource, InlineSourceBoundary } from "./inline-source";
|
|
14
|
-
export { ContentEditor, ContentPreview } from "./components";
|
|
14
|
+
export { ContentEditor, ContentPreview, EntityRef } from "./components";
|
|
15
15
|
export { useElement, useMediaViewer, BlockToolbar, BlockToolbarButton, BlockToolbarGap, } from "./element";
|
|
16
16
|
export type { ElementAccess, BlockToolbarProps, BlockToolbarButtonProps, EditorElementFrame, } from "./element";
|
|
17
17
|
export { MediaImage, MediaVideo, MediaAudio, useResource, useResourceUpload, useMediaAppearance, } from "./media";
|
|
18
18
|
export type { ResourceKind, ResourceState, ResourceUpload, MediaAppearance, MediaAppearancePreset, MediaImageProps, MediaVideoProps, MediaAudioProps, MediaRuntime, } from "./media";
|
|
19
|
-
export type { ContentEditorProps, ContentPreviewProps } from "./components";
|
|
20
|
-
export * from "./sidebar";
|
|
19
|
+
export type { ContentEditorKit, ContentEditorProps, ContentPreviewProps, EntityRefProps, } from "./components";
|
|
20
|
+
export type * from "./sidebar";
|
|
21
|
+
export { SIDEBAR_GROUPS } from "./sidebar";
|
|
21
22
|
export type * from "./icons";
|
|
23
|
+
export type * from "./home";
|
|
24
|
+
export type * from "./actions";
|
|
25
|
+
export { PLUGIN_ACTION_TARGET_KINDS } from "./actions";
|
|
26
|
+
export type * from "./views";
|
|
27
|
+
export { PLUGIN_ENTITY_PANEL_KINDS } from "./views";
|
|
22
28
|
export type * from "./excerpts";
|
|
23
29
|
export type * from "./data";
|
|
30
|
+
export type { PluginContentInput } from "./content-input";
|
|
31
|
+
export { EDITOR_NODE_SCHEMA_VERSION, CONTENT_INPUT_LIMITS } from "./content-input";
|
|
24
32
|
export type * from "./entities";
|
|
33
|
+
export type * from "./records";
|
|
34
|
+
export type * from "./links";
|
|
35
|
+
export type * from "./transaction";
|
|
36
|
+
export type { PluginFieldCondition, PluginIndexes, PluginIndexType, PluginIndexValue, PluginOrderBy, PluginWhere, } from "./query";
|
|
25
37
|
export { PluginConflictError } from "./errors";
|
|
26
|
-
export { PLUGIN_ENTITY_KINDS, PLUGIN_APP_ACTIONS, PLUGIN_EXPORT_FORMATS } from "./app";
|
|
38
|
+
export { PLUGIN_ENTITY_KINDS, PLUGIN_ENTITY_READ_PERMISSIONS, PLUGIN_APP_ACTIONS, PLUGIN_EXPORT_FORMATS, PLUGIN_NOTEBOOK_FROM_KINDS, PLUGIN_CHAT_CONTEXT_KINDS, } from "./app";
|
|
27
39
|
export type { PluginNotifications, PluginNotificationOptions, PluginNotificationMode, PluginNotificationAction, } from "./notifications";
|
|
28
|
-
export type { PluginApp, PluginAppAction, PluginAppActions, PluginExportFormat, PluginEntityKind, PluginEntityRef, PluginPickOptions, PluginPickedEntity, } from "./app";
|
|
40
|
+
export type { PluginApp, PluginAppAction, PluginAppActions, PluginAppActionResults, PluginContentLocation, PluginOpenOptions, PluginExportFormat, PluginEntityKind, PluginEntityRef, PluginEntityDescription, PluginPickOptions, PluginPickedEntity, } from "./app";
|
|
29
41
|
export { PLUGIN_EVENT_TYPES } from "./events";
|
|
30
42
|
export type { PluginDomainEvent, PluginEventOrigin, PluginEventType, PluginEvents } from "./events";
|
|
31
43
|
export { PLUGIN_PERMISSIONS, PluginPermissionError, isPluginPermission } from "./permissions";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件关联:从本插件的内容(context.entities)指向任意可引用内容的有序关联,如「问题 → 探究材料」。
|
|
3
|
+
* 关联随笔记库保存;目标被删除时关联保留,由 describe / EntityRef 显示为已删除。
|
|
4
|
+
*/
|
|
5
|
+
import type { PluginEntityRef } from "./app";
|
|
6
|
+
import type { JsonValue } from "./json";
|
|
7
|
+
export type PluginLinkData = Record<string, JsonValue>;
|
|
8
|
+
export interface PluginLink {
|
|
9
|
+
/** 宿主生成的不透明 ID */
|
|
10
|
+
id: string;
|
|
11
|
+
/** 来源:本插件内容的 ID */
|
|
12
|
+
from: string;
|
|
13
|
+
to: PluginEntityRef;
|
|
14
|
+
/** 插件定义的关联角色,如 material、answer;缺省为空字符串 */
|
|
15
|
+
role: string;
|
|
16
|
+
/** 少量附加数据(不超过 4 KB),如对话里的消息位置 */
|
|
17
|
+
data: PluginLinkData;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PluginLinkOptions {
|
|
21
|
+
role?: string;
|
|
22
|
+
data?: PluginLinkData;
|
|
23
|
+
}
|
|
24
|
+
export interface PluginLinks {
|
|
25
|
+
/**
|
|
26
|
+
* 添加一条关联,排在同一角色的末尾;同一来源、目标与角色已关联时返回已有的那条,不修改 data。
|
|
27
|
+
* 目标须是插件能看到的内容:用户选择过或请 Tau 新建的、本插件自己的内容,或已获准读取的类型;
|
|
28
|
+
* 否则抛错,且不透露目标是否存在。
|
|
29
|
+
*/
|
|
30
|
+
add(from: string, to: PluginEntityRef, options?: PluginLinkOptions): Promise<PluginLink>;
|
|
31
|
+
/** 按角色与顺序列出来源的关联;给出 role 时只列这一角色 */
|
|
32
|
+
list(from: string, options?: {
|
|
33
|
+
role?: string;
|
|
34
|
+
}): Promise<PluginLink[]>;
|
|
35
|
+
/** 删除一条关联;已不存在时不报错 */
|
|
36
|
+
remove(id: string): Promise<void>;
|
|
37
|
+
/** 重排同一来源、同一角色的全部关联:ids 须恰好是这一角色当前的全部关联 */
|
|
38
|
+
reorder(from: string, ids: readonly string[]): Promise<void>;
|
|
39
|
+
}
|
|
@@ -5,6 +5,18 @@ export type PluginPageParams = Record<string, string | number | boolean>;
|
|
|
5
5
|
export interface PluginPageContext {
|
|
6
6
|
/** 在组件 effect 中登记当前状态提供器;返回值的形状由插件决定。 */
|
|
7
7
|
register(provider: () => JsonValue): Disposable;
|
|
8
|
+
/**
|
|
9
|
+
* 本页是否为当前显示的页面(在页面栈顶);页面隐藏、卸载或插件停用后为 false。
|
|
10
|
+
* 页面隐藏时组件的 effect 会被清理、显示时重新执行,订阅与键盘监听放在 effect 里即可随之暂停;
|
|
11
|
+
* 这里供命令等 effect 之外的回调判断。
|
|
12
|
+
*/
|
|
13
|
+
isActive(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 登记一个浮层(抽屉、弹出面板)的关闭函数:用户按 Esc 时 Tau 先关最后登记的浮层,
|
|
16
|
+
* 不会后退页面。只在本页显示时生效。@tau/ui 的模态 Dialog / Drawer 已自带,不必登记;
|
|
17
|
+
* 插件不要自己监听 Esc。
|
|
18
|
+
*/
|
|
19
|
+
registerDismiss(dismiss: () => void): Disposable;
|
|
8
20
|
}
|
|
9
21
|
export interface PluginPageProps {
|
|
10
22
|
readonly context: PluginContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const PLUGIN_PERMISSIONS: readonly ["cards:read", "cards:write", "cards:delete", "articles:read", "articles:write", "articles:delete", "documents:read", "documents:write", "todos:read", "todos:write", "todos:delete", "calendar:read", "calendar:write", "calendar:delete", "flashcards:read", "flashcards:write", ...("ai:chat" | "ai:titleSummary" | "ai:webClip" | "ai:podcastGeneration" | "ai:flashcardGeneration" | "ai:aiJudgement" | "ai:transcriptionOptimization" | "ai:videoSummary" | "ai:videoEbookRewrite" | "ai:vibeLearningImageDescription" | "ai:contentMetadata" | "ai:contentInsights")[]];
|
|
1
|
+
export declare const PLUGIN_PERMISSIONS: readonly ["cards:read", "cards:write", "cards:delete", "articles:read", "articles:write", "articles:delete", "documents:read", "documents:write", "documents:delete", "whiteboards:read", "whiteboards:write", "whiteboards:delete", "projects:read", "projects:write", "projects:delete", "todos:read", "todos:write", "todos:delete", "calendar:read", "calendar:write", "calendar:delete", "notebooks:read", "materials:read", "chats:read", "flashcards:read", "flashcards:write", ...("ai:chat" | "ai:titleSummary" | "ai:webClip" | "ai:podcastGeneration" | "ai:flashcardGeneration" | "ai:aiJudgement" | "ai:transcriptionOptimization" | "ai:videoSummary" | "ai:videoEbookRewrite" | "ai:vibeLearningImageDescription" | "ai:contentMetadata" | "ai:contentInsights")[]];
|
|
2
2
|
export type PluginPermission = (typeof PLUGIN_PERMISSIONS)[number];
|
|
3
3
|
export declare const isPluginPermission: (value: unknown) => value is PluginPermission;
|
|
4
4
|
/** granted:可直接调用;prompt:调用时会询问用户;denied:本次运行已拒绝或已被阻止 */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** 发布数据协议不包含公开路由、DOM、组件或宿主生命周期。 */
|
|
2
|
-
export type DataKind = "home" | "card" | "article" | "doc" | "
|
|
2
|
+
export type DataKind = "home" | "card" | "article" | "doc" | "list";
|
|
3
3
|
export interface ContentRef {
|
|
4
4
|
key: string;
|
|
5
5
|
type: DataKind;
|
|
@@ -10,7 +10,7 @@ export interface ResourceRef {
|
|
|
10
10
|
integrity: string;
|
|
11
11
|
}
|
|
12
12
|
export interface ManifestItem extends ContentRef {
|
|
13
|
-
collectionType?: "card" | "article" | "doc"
|
|
13
|
+
collectionType?: "card" | "article" | "doc";
|
|
14
14
|
title: string;
|
|
15
15
|
projectId?: number;
|
|
16
16
|
data: string;
|
|
@@ -123,58 +123,8 @@ export interface DocData {
|
|
|
123
123
|
createTime: number;
|
|
124
124
|
updateTime: number;
|
|
125
125
|
}
|
|
126
|
-
export type QuestStatus = "not_started" | "in_progress" | "resolved";
|
|
127
|
-
export interface QuestAnswer {
|
|
128
|
-
id: number;
|
|
129
|
-
createTime: number;
|
|
130
|
-
updateTime: number;
|
|
131
|
-
content?: ContentNode[];
|
|
132
|
-
source?: {
|
|
133
|
-
type: "card" | "article" | "project-item" | "custom";
|
|
134
|
-
id?: number;
|
|
135
|
-
contentId: number;
|
|
136
|
-
target?: ContentRef;
|
|
137
|
-
title?: string;
|
|
138
|
-
published: boolean;
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
export interface QuestMaterial {
|
|
142
|
-
index: number;
|
|
143
|
-
kind: string;
|
|
144
|
-
group: "external" | "note" | "discussion";
|
|
145
|
-
title: string;
|
|
146
|
-
meta: string;
|
|
147
|
-
excerpt: string;
|
|
148
|
-
note?: string;
|
|
149
|
-
target?: ContentRef;
|
|
150
|
-
url?: string;
|
|
151
|
-
citeKey?: string;
|
|
152
|
-
}
|
|
153
|
-
export interface QuestTrail {
|
|
154
|
-
time: number;
|
|
155
|
-
tone: "start" | "milestone" | "plain" | "note" | "done";
|
|
156
|
-
text: string;
|
|
157
|
-
refs: number[];
|
|
158
|
-
}
|
|
159
|
-
export interface QuestData {
|
|
160
|
-
id: number;
|
|
161
|
-
title: string;
|
|
162
|
-
summary: string;
|
|
163
|
-
target: ContentRef;
|
|
164
|
-
groupId: number;
|
|
165
|
-
groupTitle: string;
|
|
166
|
-
groupColor?: string;
|
|
167
|
-
status: QuestStatus;
|
|
168
|
-
answers: QuestAnswer[];
|
|
169
|
-
materials: QuestMaterial[];
|
|
170
|
-
trail: QuestTrail[];
|
|
171
|
-
description?: ContentNode[];
|
|
172
|
-
createTime: number;
|
|
173
|
-
updateTime: number;
|
|
174
|
-
resolvedTime?: number | null;
|
|
175
|
-
}
|
|
176
126
|
export interface TimelineItem {
|
|
177
|
-
type: "card" | "article" | "doc"
|
|
127
|
+
type: "card" | "article" | "doc";
|
|
178
128
|
id: number;
|
|
179
129
|
title?: string;
|
|
180
130
|
summary: string;
|
|
@@ -199,15 +149,10 @@ export interface ListItem {
|
|
|
199
149
|
target: ContentRef;
|
|
200
150
|
tags: string[];
|
|
201
151
|
createTime: number;
|
|
202
|
-
updateTime?: number;
|
|
203
|
-
groupId?: number;
|
|
204
|
-
groupTitle?: string;
|
|
205
|
-
status?: QuestStatus;
|
|
206
|
-
answerCount?: number;
|
|
207
152
|
}
|
|
208
153
|
export interface ListData {
|
|
209
154
|
title: string;
|
|
210
|
-
type: "card" | "article" | "doc"
|
|
155
|
+
type: "card" | "article" | "doc";
|
|
211
156
|
items: ListItem[];
|
|
212
157
|
tags?: {
|
|
213
158
|
name: string;
|
|
@@ -228,7 +173,7 @@ export interface CardTagTree {
|
|
|
228
173
|
export interface PublishedCommon {
|
|
229
174
|
version: 1;
|
|
230
175
|
key: string;
|
|
231
|
-
/**
|
|
176
|
+
/** 本文正文里已发布的站内链接目标,键为 `${contentType}:${refId}`;未发布的链接不在其中。 */
|
|
232
177
|
links?: Record<string, ContentRef>;
|
|
233
178
|
pluginRenderers?: import("./render-artifact").PublishedPluginRender[];
|
|
234
179
|
contentStyles?: ResourceRef[];
|
|
@@ -244,7 +189,6 @@ export type PublishedData = {
|
|
|
244
189
|
card: CardData;
|
|
245
190
|
article: ArticleData;
|
|
246
191
|
doc: DocData;
|
|
247
|
-
quest: QuestData;
|
|
248
192
|
list: ListData;
|
|
249
193
|
}[K];
|
|
250
194
|
};
|
|
@@ -256,7 +200,7 @@ export interface DataResult {
|
|
|
256
200
|
settings?: PublishSettings;
|
|
257
201
|
}
|
|
258
202
|
export interface SearchDocument extends ContentRef {
|
|
259
|
-
type: "card" | "article" | "doc"
|
|
203
|
+
type: "card" | "article" | "doc";
|
|
260
204
|
title: string;
|
|
261
205
|
summary: string;
|
|
262
206
|
content: string;
|