@xiongtao.xt/tau-plugins 0.33.0 → 0.34.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 (36) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/client/{chunk-SVY5LBAT.js → chunk-FZTR4KOY.js} +10 -0
  3. package/docs/README.md +18 -17
  4. package/docs/editor.md +47 -1
  5. package/docs/excerpts.md +1 -1
  6. package/docs/plugin-basics.md +3 -0
  7. package/docs/storage-and-network.md +1 -1
  8. package/docs/ui.md +229 -1
  9. package/docs/user-data.md +388 -72
  10. package/package.js +1 -1
  11. package/package.json +1 -1
  12. package/publish-artifacts.js +29 -2
  13. package/types/packages/editor/src/core/api/extension.d.ts +3 -0
  14. package/types/packages/editor/src/core/api/index.d.ts +1 -0
  15. package/types/packages/editor/src/core/api/inputRules.d.ts +37 -0
  16. package/types/packages/plugins/src/actions.d.ts +61 -0
  17. package/types/packages/plugins/src/app.d.ts +106 -8
  18. package/types/packages/plugins/src/components.d.ts +22 -0
  19. package/types/packages/plugins/src/content-input.d.ts +34 -0
  20. package/types/packages/plugins/src/contract.d.ts +18 -0
  21. package/types/packages/plugins/src/data.d.ts +179 -11
  22. package/types/packages/plugins/src/editor-fields.d.ts +10 -0
  23. package/types/packages/plugins/src/editor.d.ts +2 -1
  24. package/types/packages/plugins/src/entities.d.ts +28 -3
  25. package/types/packages/plugins/src/events.d.ts +9 -3
  26. package/types/packages/plugins/src/excerpts.d.ts +1 -1
  27. package/types/packages/plugins/src/home.d.ts +20 -0
  28. package/types/packages/plugins/src/index.d.ts +17 -5
  29. package/types/packages/plugins/src/links.d.ts +39 -0
  30. package/types/packages/plugins/src/pages.d.ts +12 -0
  31. package/types/packages/plugins/src/permissions.d.ts +1 -1
  32. package/types/packages/plugins/src/query.d.ts +64 -0
  33. package/types/packages/plugins/src/records.d.ts +50 -0
  34. package/types/packages/plugins/src/sidebar.d.ts +63 -1
  35. package/types/packages/plugins/src/transaction.d.ts +40 -0
  36. package/types/packages/plugins/src/views.d.ts +26 -0
@@ -30,7 +30,69 @@ export interface PluginSidebarItemDefinition {
30
30
  page: PluginPageHandle;
31
31
  params?: PluginPageParams;
32
32
  }
33
+ /** 子项色点,与宿主待办项目、分组同一套色板 */
34
+ export type PluginSidebarTone = "rose" | "orange" | "yellow" | "green" | "blue" | "purple" | "gray";
35
+ export interface PluginSidebarMenuEntry {
36
+ title: string;
37
+ /** 危险操作(如删除)显示为红色,并与前面的条目隔开 */
38
+ danger?: boolean;
39
+ run(): unknown;
40
+ }
41
+ export interface PluginSidebarChild {
42
+ /** 在同一条目内唯一 */
43
+ id: string;
44
+ title: string;
45
+ /** 点击后以这组参数打开条目的页面;当前页参数包含这组参数时,子项显示为选中 */
46
+ params: PluginPageParams;
47
+ tone?: PluginSidebarTone;
48
+ /** 子项右侧的计数,0 不显示 */
49
+ count?: number;
50
+ /** 右键菜单 */
51
+ menu?: readonly PluginSidebarMenuEntry[];
52
+ /** 接收拖放:type 为 dragType 的参数,run 收到拖拽数据 */
53
+ onDrop?: {
54
+ type: string;
55
+ run(data: string): unknown;
56
+ };
57
+ }
58
+ /** 子项列表末尾的动作行(如「新建分组」) */
59
+ export interface PluginSidebarAction {
60
+ title: string;
61
+ /** 缺省为加号 */
62
+ icon?: PluginSidebarIcon;
63
+ run(): unknown;
64
+ }
65
+ /** 只改传入的字段;badge 为 null 或 0 时隐藏,action 为 null 时移除 */
66
+ export interface PluginSidebarItemUpdate {
67
+ badge?: number | null;
68
+ children?: readonly PluginSidebarChild[];
69
+ action?: PluginSidebarAction | null;
70
+ }
71
+ export interface PluginSidebarItemHandle extends Disposable {
72
+ update(patch: PluginSidebarItemUpdate): void;
73
+ }
33
74
  export interface PluginSidebar {
34
75
  registerGroup(definition: PluginSidebarGroupDefinition): PluginSidebarGroupHandle;
35
- registerItem(definition: PluginSidebarItemDefinition): Disposable;
76
+ /** 条目所在页面在栈顶且侧栏展开时,子项与动作行展开在条目下方 */
77
+ registerItem(definition: PluginSidebarItemDefinition): PluginSidebarItemHandle;
78
+ /**
79
+ * 拖拽类型:插件页面拖起数据时用 dataTransfer.setData(dragType(type), data),
80
+ * 子项 onDrop 声明同一个 type 才能接收;宿主和其他插件的拖拽不会落到插件子项上。
81
+ */
82
+ dragType(type: string): string;
83
+ }
84
+ /** 侧栏条目的展示状态,宿主据此渲染;回调已由宿主包装 */
85
+ export interface PluginSidebarItemState {
86
+ badge: number;
87
+ children: readonly PluginSidebarChild[];
88
+ action: PluginSidebarAction | null;
36
89
  }
90
+ export declare function sidebarDragType(pluginId: string, type: string): string;
91
+ /**
92
+ * 校验并冻结一次 update 的结果;wrap 包装插件回调(宿主在里面核对插件仍处于启用状态),
93
+ * 拖拽类型由 dragType 加上插件命名空间。
94
+ */
95
+ export declare function snapshotSidebarUpdate(previous: PluginSidebarItemState, patch: PluginSidebarItemUpdate, options: {
96
+ wrap: <A extends unknown[]>(run: (...args: A) => unknown) => (...args: A) => unknown;
97
+ dragType: (type: string) => string;
98
+ }): PluginSidebarItemState;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 原子提交:回调里对本插件内容、记录与关联的写入先由宿主记下,回调结束后一次提交,
3
+ * 任何一条失败(revision 不符、目标不可关联等)全部不生效。
4
+ */
5
+ import type { PluginEntityRef } from "./app";
6
+ import type { PluginOwnEntityInput, PluginOwnEntityPatch } from "./entities";
7
+ import type { PluginLinkOptions } from "./links";
8
+ import type { PluginRecordData } from "./records";
9
+ /** 事务里的修改与删除可以不带 revision:带了就核对,不带即不论当前版本直接写入 */
10
+ export interface PluginTransactionWriteOptions {
11
+ expectedRevision?: string;
12
+ }
13
+ export interface PluginTransaction {
14
+ readonly entities: {
15
+ /** 立即返回新内容的 ID,同一事务里可以用它添加关联、写记录;提交失败时这个 ID 作废 */
16
+ create(input: PluginOwnEntityInput): Promise<{
17
+ id: string;
18
+ }>;
19
+ update(id: string, patch: PluginOwnEntityPatch, options?: PluginTransactionWriteOptions): Promise<void>;
20
+ delete(id: string, options?: PluginTransactionWriteOptions): Promise<void>;
21
+ };
22
+ readonly records: {
23
+ insert(collection: string, data: PluginRecordData): Promise<{
24
+ id: string;
25
+ }>;
26
+ update(collection: string, id: string, data: PluginRecordData, options?: PluginTransactionWriteOptions): Promise<void>;
27
+ delete(collection: string, id: string, options?: PluginTransactionWriteOptions): Promise<void>;
28
+ };
29
+ readonly links: {
30
+ /** 已经关联过时什么也不做;需要关联的 ID 时在提交后 list */
31
+ add(from: string, to: PluginEntityRef, options?: PluginLinkOptions): Promise<void>;
32
+ remove(id: string): Promise<void>;
33
+ reorder(from: string, ids: readonly string[]): Promise<void>;
34
+ };
35
+ }
36
+ /**
37
+ * 回调里的写入在回调结束后一次提交,返回回调的结果;回调抛错或任何一条写入失败时全部不生效。
38
+ * 回调里用 context 读到的是已提交的数据,看不到本事务尚未提交的写入。最多 500 条写入。
39
+ */
40
+ export type PluginTransactionRunner = <T>(run: (tx: PluginTransaction) => T | Promise<T>) => Promise<T>;
@@ -0,0 +1,26 @@
1
+ import type { ComponentType } from "react";
2
+ import type { Disposable, PluginContext } from "./contract";
3
+ /** 详情区块可以挂在哪类对象的详情里;document 为项目文档 */
4
+ export type PluginEntityPanelKind = "card" | "article" | "document";
5
+ /** 详情区块收到的对象:只是引用,读标题、正文仍按现有权限 */
6
+ export type PluginEntityPanelTarget = {
7
+ [K in PluginEntityPanelKind]: {
8
+ kind: K;
9
+ id: string;
10
+ };
11
+ }[PluginEntityPanelKind];
12
+ export interface PluginEntityPanelProps {
13
+ readonly context: PluginContext;
14
+ readonly target: PluginEntityPanelTarget;
15
+ }
16
+ export interface PluginEntityPanelDefinition {
17
+ id: string;
18
+ kinds: readonly PluginEntityPanelKind[];
19
+ /** 渲染在详情正文上方;返回 null 时不占位。外框与标题由插件决定,宜小而轻 */
20
+ component: ComponentType<PluginEntityPanelProps>;
21
+ }
22
+ export interface PluginViews {
23
+ /** 只在主窗口的详情页出现,独立编辑窗口不显示 */
24
+ registerEntityPanel(definition: PluginEntityPanelDefinition): Disposable;
25
+ }
26
+ export declare const PLUGIN_ENTITY_PANEL_KINDS: readonly PluginEntityPanelKind[];