@xiongtao.xt/tau-plugins 0.34.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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 0.35.0
|
|
4
|
+
|
|
5
|
+
- 插件用 `cards.create`、`articles.create`、`documents.create`、`whiteboards.create`、`projects.create` 新建的内容,之后不需要读取权限也能 `describe`、`EntityRef` 显示、`open` 与 `links.add`,与 `pick` 选择和 `app.run` 新建的结果一致。
|
|
6
|
+
- 正文输入新增 `{ shareOf: contentRef }`:与本插件的一项内容共用同一份正文,任一处的修改在另一处实时可见,删除其中一处不影响另一处。只能用于 `cards.create`、`articles.create`、`documents.create` 与 `app.run("project.insertDocument")`,来源必须是本插件内容的正文;一份正文只能有一张卡片、一篇文章,已有时报错。
|
|
7
|
+
- 发布数据不再包含求索录:数据类型 `quest` 与 `QuestData`、`QuestStatus`、`QuestAnswer`、`QuestMaterial`、`QuestTrail` 已删除,`DataKind`、`ManifestItem.collectionType`、`TimelineItem`、`ListData`、`SearchDocument` 的类型不再有 `quest`,`ListItem` 去掉了 `groupId`、`groupTitle`、`status`、`answerCount` 与 `updateTime`。博客模板不再需要问题页。
|
|
8
|
+
|
|
3
9
|
## 0.34.0
|
|
4
10
|
|
|
5
11
|
- 新增统一的正文输入 `PluginContentInput`,三选一:`{ markdown }`、`{ nodes }`(编辑器节点,格式完整保留)、`{ copyOf: contentRef }`(Tau 内部整份复制已有正文,只需要目标的写入权限)。
|
package/docs/user-data.md
CHANGED
|
@@ -259,6 +259,7 @@ try {
|
|
|
259
259
|
### 写入后
|
|
260
260
|
|
|
261
261
|
- 打开中的页面、其他窗口、搜索和云同步都会自动更新,插件不需要做任何通知。
|
|
262
|
+
- 插件新建的卡片、文章、项目文档、白板和项目,和用户在 `pick` 中选择的一样:之后不需要读取权限也能用 `describe` 读标题、用 `<EntityRef>` 显示、`open` 打开、`links.add` 关联。
|
|
262
263
|
- 插件删除的内容,用户可以在 7 天内从插件详情页的「权限 → 最近删除」中恢复。
|
|
263
264
|
- 项目只能删除空项目,里面还有文档时会被拒绝。
|
|
264
265
|
- 项目文档会从它挂载的所有位置删除,有子文档时会被拒绝,视频笔记不能由插件删除。恢复时挂回仍然存在的原位置。
|
|
@@ -266,7 +267,7 @@ try {
|
|
|
266
267
|
|
|
267
268
|
## 正文输入
|
|
268
269
|
|
|
269
|
-
新建卡片、文章、插件内容,以及修改正文时,正文都用同一种写法 `content
|
|
270
|
+
新建卡片、文章、插件内容,以及修改正文时,正文都用同一种写法 `content`,从下面几种里选一种:
|
|
270
271
|
|
|
271
272
|
```ts
|
|
272
273
|
// Markdown:适合 AI 生成或外部导入的文字
|
|
@@ -278,6 +279,9 @@ await context.data.cards.create({ content: { nodes: source!.nodes! } });
|
|
|
278
279
|
|
|
279
280
|
// 复制一份已有正文:Tau 内部整份复制,插件拿不到正文内容
|
|
280
281
|
await context.data.articles.create({ title: "副本", content: { copyOf: card.contentRef } });
|
|
282
|
+
|
|
283
|
+
// 共用本插件内容的正文:新卡片与插件内容是同一份正文,改一处另一处同步变化
|
|
284
|
+
await context.data.cards.create({ content: { shareOf: answer.contentRef } });
|
|
281
285
|
```
|
|
282
286
|
|
|
283
287
|
| 写法 | 什么时候用 | 注意 |
|
|
@@ -285,12 +289,15 @@ await context.data.articles.create({ title: "副本", content: { copyOf: card.co
|
|
|
285
289
|
| `markdown` | 写入纯文字、AI 输出、外部导入 | 高亮、颜色、白板嵌入等 Markdown 表达不了的格式会丢失 |
|
|
286
290
|
| `nodes` | 把读到的正文改写后写回,或在多份正文之间搬运内容 | 结构不对时报错并给出出错节点的路径 |
|
|
287
291
|
| `copyOf` | 把一份正文完整复制到新卡片、新文章或插件内容里,例如「把这条笔记存为卡片」 | 只需要目标的写入权限,不需要来源的读取权限 |
|
|
292
|
+
| `shareOf` | 让插件内容同时也是一张卡片、一篇文章或一篇项目文档,在哪里改都是同一份正文 | 只用于新建卡片、文章、项目文档与「插入到项目」 |
|
|
288
293
|
|
|
289
294
|
- `nodes` 只检查结构:顶层是元素,元素有 `type` 和非空的 `children`,文字节点有 `text`。Tau 不认识的节点类型(例如来自未安装的插件)原样保存,安装对应插件后即可正常显示。
|
|
290
295
|
- `content.read({ format: "nodes" })` 的结果带 `schemaVersion`。节点结构有不兼容的变化时它会增加,插件可以与 `EDITOR_NODE_SCHEMA_VERSION` 比较,判断自己是否认得这些节点。
|
|
291
296
|
- 正文中的待办勾选项由 Tau 维护身份,复制或搬运后各自独立,不需要插件处理。
|
|
292
297
|
- `copyOf` 的来源可以是卡片、文章、项目文档或任一插件内容的正文。复制的是当前内容,之后两份互不影响。
|
|
298
|
+
- `shareOf` 的来源只能是本插件内容的正文。用户在卡片、文章或项目文档里修改,插件内容同步变化,反之亦然;删除其中一处,另一处照常保留。一份正文最多是一张卡片、一篇文章,已经有了再新建会报错,可以先用 `content.read` 返回的 `owners` 判断。插件内容自己(`entities.create`)和修改正文(`content.edit`)不能用 `shareOf`。
|
|
293
299
|
- 新建时省略 `content` 得到空正文。
|
|
300
|
+
- 正文有大小上限:`markdown` 最多 200 万字;`nodes` 转成 JSON 后最多 800 万字,嵌套最多 30 层。超出时报错,上限可从 `CONTENT_INPUT_LIMITS` 读取。
|
|
294
301
|
|
|
295
302
|
## 读写正文
|
|
296
303
|
|
|
@@ -487,14 +494,14 @@ function CardRow({ card }: { card: PluginCard }) {
|
|
|
487
494
|
| `content.present` | `ref` | 全屏演示 | 无 |
|
|
488
495
|
| `content.share` | `ref` | 打开「内容协作」窗口,由用户确认发起共享 | 无 |
|
|
489
496
|
| `card.create` | `content?`(见[正文输入](#正文输入))、`tags?` | 打开新建卡片窗口并预填,用户可修改后保存 | 新卡片的引用 `{ kind: "card", id }` |
|
|
490
|
-
| `project.insertDocument` | `content`、`title?`(默认「未命名文档」) |
|
|
497
|
+
| `project.insertDocument` | `content`、`title?`(默认「未命名文档」) | 打开「插入到项目」窗口,用户选择项目与位置后新建文档 | 新文档的引用 `{ kind: "document", id }` |
|
|
491
498
|
| `notebook.create` | `title`、`sources?`(最多 200 项)、`from?` | 确认后新建 Notebook,`sources` 作为资料带入,`from` 记为来源 | Notebook 的引用 `{ kind: "notebook", id }` |
|
|
492
499
|
| `chat.start` | `prompt?`、`context?`(最多 20 项)、`placement?`:`page`(默认)、`dock` | 在对话页或右侧停靠栏开一个新对话,预填输入框与引用,由用户发送 | 对话的引用 `{ kind: "chat-session", id }` |
|
|
493
500
|
|
|
494
501
|
- 不需要数据权限:界面和确认都由 Tau 提供,用户在界面里确认即同意。插件拿不到正文。新建类返回的引用和用户在 `pick` 中选择的一样:不需要权限就能用 `describe` 读标题、用 `<EntityRef>` 显示、`open` 打开、`links.add` 关联;读取正文仍需要对应的读取权限(如 `cards:read`)。
|
|
495
502
|
- 用户关闭界面后才返回:导出、演示、协作在窗口关闭或演示结束时返回;新建类在保存后返回新内容的引用,用户取消时返回 `null`。插件停用时界面会被撤下。
|
|
496
503
|
- 只能在用户操作之后调用;同一时间只能打开一个,前一个还没关闭时抛错。内容已删除时抛出「内容不存在」。
|
|
497
|
-
- `copyOf` 只复制正文,不会改动来源。`project.insertDocument`
|
|
504
|
+
- `copyOf` 只复制正文,不会改动来源。`project.insertDocument` 的 `content` 用 `shareOf` 时,新文档与插件内容共用正文;其他写法都是新的一份正文。`card.create` 的窗口里用户可以修改预填内容,不接受 `shareOf`。
|
|
498
505
|
- `notebook.create` 的资料一次性带入,之后原内容的修改不会同步:卡片、文章、项目文档、日记和插件内容成为笔记资料;划线与 PDF 标注合并为一份,剪藏各一份;其他类型和已删除的内容不带入,确认框里会告诉用户数量。
|
|
499
506
|
- `from` 是这个 Notebook 由什么立项,显示在 Notebook 页顶部,用户点击可以打开。可以是卡片、文章、项目文档、日记、材料、对话、Notebook 或插件内容(`PLUGIN_NOTEBOOK_FROM_KINDS`),不存在时抛出「来源不存在」。
|
|
500
507
|
- `chat.start` 不会替用户发送:`prompt` 进入输入框,`context` 作为引用插在后面,用户可以修改。用户发出第一条消息后才返回对话的引用;没发送就切到别的对话、离开对话页、收起停靠栏或插件停用时返回 `null`。`context` 只支持卡片、文章、项目文档(`PLUGIN_CHAT_CONTEXT_KINDS`),其他内容请写进 `prompt`。
|
package/package.json
CHANGED
package/publish-client.js
CHANGED
|
@@ -108,7 +108,7 @@ function createClient({ manifestUrl }) {
|
|
|
108
108
|
);
|
|
109
109
|
keys.add(item.key);
|
|
110
110
|
assert(
|
|
111
|
-
["home", "card", "article", "doc", "
|
|
111
|
+
["home", "card", "article", "doc", "list"].includes(String(item.type)) && typeof item.title === "string",
|
|
112
112
|
"INVALID_DATA",
|
|
113
113
|
"\u6570\u636E\u7C7B\u578B\u6216\u6807\u9898\u65E0\u6548"
|
|
114
114
|
);
|
|
@@ -158,7 +158,7 @@ function createClient({ manifestUrl }) {
|
|
|
158
158
|
"\u641C\u7D22 key \u672A\u95ED\u5408\u6216\u91CD\u590D"
|
|
159
159
|
);
|
|
160
160
|
assert(
|
|
161
|
-
["card", "article", "doc"
|
|
161
|
+
["card", "article", "doc"].includes(String(document.type)),
|
|
162
162
|
"INVALID_DATA",
|
|
163
163
|
"\u641C\u7D22\u7C7B\u578B\u9519\u8BEF"
|
|
164
164
|
);
|
|
@@ -18,6 +18,13 @@ export type PluginContentInput =
|
|
|
18
18
|
/** 整份复制一份已有正文:只需要目标的写入权限,插件拿不到正文 */
|
|
19
19
|
| {
|
|
20
20
|
copyOf: PluginContentRef;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 与本插件的一项内容共用同一份正文,任一处的修改在另一处实时可见;只能用于新建卡片、文章、
|
|
24
|
+
* 项目文档与「插入到项目」。删除其中一处不影响另一处。
|
|
25
|
+
*/
|
|
26
|
+
| {
|
|
27
|
+
shareOf: PluginContentRef;
|
|
21
28
|
};
|
|
22
29
|
export declare const CONTENT_INPUT_LIMITS: Readonly<{
|
|
23
30
|
markdown: 2000000;
|
|
@@ -28,7 +35,11 @@ export declare const CONTENT_INPUT_LIMITS: Readonly<{
|
|
|
28
35
|
}>;
|
|
29
36
|
/** 节点结构校验:顶层为元素;元素有 type 与非空 children;文本节点有 text、没有 children。 */
|
|
30
37
|
export declare function assertContentNodes(value: unknown): asserts value is Descendant[];
|
|
31
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* 读取并复制插件传入的正文输入;allowEmpty 为 false 时拒绝空 Markdown 与空节点数组,
|
|
40
|
+
* share 为 true 时才接受 shareOf(新建宿主内容的入口)。
|
|
41
|
+
*/
|
|
32
42
|
export declare function readContentInput(value: unknown, options: {
|
|
33
43
|
allowEmpty: boolean;
|
|
44
|
+
share?: boolean;
|
|
34
45
|
}): PluginContentInput;
|
|
@@ -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;
|