@xiongtao.xt/tau-plugins 0.58.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/docs/editor-interactions.md +55 -0
  3. package/docs/pages.md +71 -2
  4. package/docs/portability.md +2 -0
  5. package/docs/references.md +2 -0
  6. package/docs/settings-and-commands.md +3 -0
  7. package/docs/whiteboard.md +1 -1
  8. package/package.json +1 -1
  9. package/publish-artifacts.js +35 -26
  10. package/tailwind.css +3 -3
  11. package/types/packages/collaboration/src/document-history-edit.d.ts +11 -0
  12. package/types/packages/collaboration/src/document-history.d.ts +91 -0
  13. package/types/packages/collaboration/src/index.d.ts +2 -0
  14. package/types/packages/collaboration/src/node-document.d.ts +1 -1
  15. package/types/packages/collaboration/src/node-tree.d.ts +7 -0
  16. package/types/packages/collaboration/src/whiteboard-model.d.ts +33 -2
  17. package/types/packages/db-schema/content-identities.d.ts +1 -1
  18. package/types/packages/editor/src/core/CoreEditor.d.ts +10 -1
  19. package/types/packages/editor/src/core/api/extension.d.ts +0 -1
  20. package/types/packages/editor/src/core/api/index.d.ts +3 -1
  21. package/types/packages/editor/src/core/utils/nodeOperations.d.ts +1 -0
  22. package/types/packages/editor/src/core/utils/undoStep.d.ts +6 -0
  23. package/types/packages/editor/src/core/utils/wrapInlineText.d.ts +4 -0
  24. package/types/packages/editor/src/extensions/kbd/src/types.d.ts +2 -2
  25. package/types/packages/editor/src/extensions/link/src/types.d.ts +2 -2
  26. package/types/packages/editor/src/extensions/styled-text/src/types.d.ts +2 -2
  27. package/types/packages/editor/src/extensions/underline/src/types.d.ts +2 -2
  28. package/types/packages/markdown/src/codec.d.ts +6 -2
  29. package/types/packages/markdown/src/markdown.d.ts +2 -1
  30. package/types/packages/markdown/src/positionMapper.d.ts +7 -1
  31. package/types/packages/plugins/src/app.d.ts +2 -0
  32. package/types/packages/plugins/src/contract.d.ts +2 -0
  33. package/types/packages/plugins/src/index.d.ts +2 -1
  34. package/types/packages/plugins/src/pages.d.ts +8 -2
  35. package/types/packages/plugins/src/text-decorations.d.ts +68 -0
  36. package/types/packages/shared/src/chat-core/aiRunProtocol.d.ts +1 -1
  37. package/types/packages/shared/src/chat-core/messages.d.ts +13 -4
  38. package/types/packages/themes/src/themes/ink.theme.d.ts +1 -2
  39. package/types/packages/themes/src/themes/mint.theme.d.ts +1 -2
  40. package/types/packages/themes/src/themes/ocean.theme.d.ts +1 -2
  41. package/types/packages/themes/src/themes/paper.theme.d.ts +1 -2
  42. package/types/packages/themes/src/themes/sakura.theme.d.ts +1 -2
  43. package/types/packages/themes/src/themes/wisteria.theme.d.ts +1 -2
  44. package/types/packages/ui/src/cn.d.ts +1 -1
  45. package/types/packages/ui/src/primitives/AnchoredPanel.d.ts +3 -3
  46. package/types/packages/ui/src/primitives/Button.d.ts +4 -4
  47. package/types/packages/ui/src/primitives/Checkbox.d.ts +2 -2
  48. package/types/packages/ui/src/primitives/ConfirmDialog.d.ts +3 -3
  49. package/types/packages/ui/src/primitives/Dialog.d.ts +4 -4
  50. package/types/packages/ui/src/primitives/Loading.d.ts +1 -1
  51. package/types/packages/ui/src/primitives/Menu.d.ts +1 -1
  52. package/types/packages/ui/src/primitives/Notification.d.ts +2 -2
  53. package/types/packages/ui/src/primitives/Popover.d.ts +3 -3
  54. package/types/packages/ui/src/primitives/Radio.d.ts +2 -3
  55. package/types/packages/ui/src/primitives/RadioGroup.d.ts +1 -1
  56. package/types/packages/ui/src/primitives/Segmented.d.ts +3 -3
  57. package/types/packages/ui/src/primitives/Select.d.ts +6 -6
  58. package/types/packages/ui/src/primitives/Switch.d.ts +2 -2
  59. package/types/packages/ui/src/primitives/Tag.d.ts +2 -3
  60. package/types/packages/ui/src/primitives/Toast.d.ts +1 -1
  61. package/types/packages/ui/src/primitives/Tooltip.d.ts +5 -5
  62. package/types/packages/ui/src/primitives/ValueDisplay.d.ts +2 -3
  63. package/types/packages/ui/src/primitives/anchoredPosition.d.ts +1 -2
  64. package/types/packages/ui/src/primitives/datepicker/DatePicker.d.ts +2 -2
  65. package/types/packages/ui/src/primitives/datepicker/DateRangePicker.d.ts +1 -1
  66. package/types/packages/ui/src/primitives/input/Input.d.ts +4 -4
  67. package/types/packages/ui/src/primitives/input/NumberInput.d.ts +2 -2
  68. package/types/packages/ui/src/primitives/input/Textarea.d.ts +1 -1
  69. package/types/packages/whiteboard/src/Board.d.ts +28 -12
  70. package/types/packages/whiteboard/src/{WhiteBoard.d.ts → Whiteboard.d.ts} +6 -6
  71. package/types/packages/whiteboard/src/chrome/index.d.ts +4 -2
  72. package/types/packages/whiteboard/src/components/ArrowConnectPoint/index.d.ts +26 -0
  73. package/types/packages/whiteboard/src/components/ArrowConnectPointGroup/index.d.ts +3 -0
  74. package/types/packages/whiteboard/src/components/DocumentElement/index.d.ts +2 -0
  75. package/types/packages/whiteboard/src/components/ExcerptElement/index.d.ts +13 -0
  76. package/types/packages/whiteboard/src/components/SketchPopover.d.ts +1 -1
  77. package/types/packages/whiteboard/src/constants/arrow.d.ts +0 -2
  78. package/types/packages/whiteboard/src/constants/mind.d.ts +0 -13
  79. package/types/packages/whiteboard/src/constants/text-style.d.ts +1 -1
  80. package/types/packages/whiteboard/src/constants/tools.d.ts +3 -0
  81. package/types/packages/whiteboard/src/context.d.ts +1 -2
  82. package/types/packages/whiteboard/src/extensions/api.d.ts +6 -1
  83. package/types/packages/whiteboard/src/extensions/authorApi.d.ts +0 -1
  84. package/types/packages/whiteboard/src/extensions/events.d.ts +0 -1
  85. package/types/packages/whiteboard/src/hooks/useDropArrow.d.ts +1 -1
  86. package/types/packages/whiteboard/src/hooks/useReadonly.d.ts +1 -0
  87. package/types/packages/whiteboard/src/hooks/useSelectState.d.ts +0 -1
  88. package/types/packages/whiteboard/src/hooks/useZoom.d.ts +6 -0
  89. package/types/packages/whiteboard/src/index.d.ts +11 -6
  90. package/types/packages/whiteboard/src/interactions/InteractionManager.d.ts +1 -0
  91. package/types/packages/whiteboard/src/plugins/ArrowPlugin.d.ts +1 -1
  92. package/types/packages/whiteboard/src/plugins/ColumnPlugin.d.ts +1 -1
  93. package/types/packages/whiteboard/src/plugins/CommonPlugin.d.ts +10 -10
  94. package/types/packages/whiteboard/src/plugins/DocumentPlugin.d.ts +36 -3
  95. package/types/packages/whiteboard/src/plugins/ExcerptPlugin.d.ts +48 -0
  96. package/types/packages/whiteboard/src/plugins/FramePlugin.d.ts +1 -1
  97. package/types/packages/whiteboard/src/plugins/GeometryPlugin.d.ts +5 -2
  98. package/types/packages/whiteboard/src/plugins/MindPlugin.d.ts +2 -2
  99. package/types/packages/whiteboard/src/plugins/WebviewPlugin.d.ts +1 -1
  100. package/types/packages/whiteboard/src/plugins/{WhiteBoardPlugin.d.ts → WhiteboardPlugin.d.ts} +8 -5
  101. package/types/packages/whiteboard/src/plugins/index.d.ts +2 -1
  102. package/types/packages/whiteboard/src/public.d.ts +23 -1
  103. package/types/packages/whiteboard/src/types/board.d.ts +12 -10
  104. package/types/packages/whiteboard/src/types/element.d.ts +6 -1
  105. package/types/packages/whiteboard/src/types/operation.d.ts +1 -1
  106. package/types/packages/whiteboard/src/types/selection.d.ts +1 -1
  107. package/types/packages/whiteboard/src/types/sketch.d.ts +2 -2
  108. package/types/packages/whiteboard/src/types/viewport.d.ts +1 -1
  109. package/types/packages/whiteboard/src/utils/ArrowStyleUtil.d.ts +0 -1
  110. package/types/packages/whiteboard/src/utils/CanvasUtil.d.ts +0 -1
  111. package/types/packages/whiteboard/src/utils/ClipboardUtil.d.ts +0 -5
  112. package/types/packages/whiteboard/src/utils/GeometryUtil.d.ts +1 -1
  113. package/types/packages/whiteboard/src/utils/HandwriteUtil.d.ts +0 -1
  114. package/types/packages/whiteboard/src/utils/MindUtil.d.ts +0 -3
  115. package/types/packages/whiteboard/src/utils/PathUtil.d.ts +1 -1
  116. package/types/packages/whiteboard/src/utils/PointUtil.d.ts +0 -1
  117. package/types/packages/whiteboard/src/utils/PresentationManager.d.ts +1 -1
  118. package/types/packages/whiteboard/src/utils/TextStyleStore.d.ts +2 -1
  119. package/types/packages/whiteboard/src/utils/index.d.ts +0 -1
  120. package/types/packages/whiteboard/src/utils/sketch/handText.d.ts +1 -1
  121. package/types/packages/whiteboard/src/utils/sketch/index.d.ts +4 -5
  122. package/types/packages/whiteboard/src/utils/sketch/shape.d.ts +1 -2
  123. package/types/packages/whiteboard/src/utils/ViewportUtil.d.ts +0 -10
@@ -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, ViewPort } from "./types/index";
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("tau.select" 表示非创建模式) */
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;
@@ -2,7 +2,6 @@ import type { WhiteboardAPI as HostAPI, WhiteboardExtension as HostExtension } f
2
2
  import type { WhiteboardAPI, WhiteboardAuthorBridge, WhiteboardElementDefinition, WhiteboardExtension } from "./authorTypes";
3
3
  export declare const whiteboardAuthorOwner: (extension: object) => string | undefined;
4
4
  export declare function bindWhiteboardAuthorAPI(base: HostAPI, owner: string, get: () => WhiteboardAuthorBridge | undefined, active: () => boolean): () => void;
5
- export declare function authorAPI(base: HostAPI): WhiteboardAPI;
6
5
  export declare function useWhiteboardAPI(): WhiteboardAPI;
7
6
  export declare function defineElement<TData = unknown>(definition: WhiteboardElementDefinition<TData>): WhiteboardElementDefinition<TData>;
8
7
  /** 作者工厂及回调始终收到受控外观,宿主旧能力不进入作者对象原型。 */
@@ -40,7 +40,6 @@ export type KernelEventName = keyof WhiteboardKernelEvents;
40
40
  export declare const KERNEL_EVENT_NAMES: readonly KernelEventName[];
41
41
  /** 扩展事件名:`<命名空间>.<名称>`,命名空间取扩展 id 第一段 */
42
42
  export type ExtensionEventName = `${string}.${string}`;
43
- export declare function isKernelEventName(event: string): event is KernelEventName;
44
43
  /** api.on 允许的事件:内核事件 + 任意命名空间的扩展事件(扩展间通信) */
45
44
  export declare function assertSubscribableEventName(event: string): void;
46
45
  /**
@@ -7,7 +7,7 @@ interface DropArrowOptions {
7
7
  container?: boolean;
8
8
  }
9
9
  /** 注册元素为箭头连接目标(悬停连接点与拖动落点共用一份候选),并在拖动箭头时判定自己是否为落点 */
10
- export declare const useDropArrow: (element: CommonElement & any, { container }?: DropArrowOptions) => {
10
+ export declare const useDropArrow: (element: CommonElement, { container }?: DropArrowOptions) => {
11
11
  isMoveArrowClosing: boolean;
12
12
  activeConnectId: string;
13
13
  arrowConnectPoints: ({
@@ -0,0 +1 @@
1
+ export declare const useReadonly: () => boolean;
@@ -7,4 +7,3 @@ export declare const useSelectState: (elementId: string) => {
7
7
  isSelected: boolean;
8
8
  isSelecting: boolean;
9
9
  };
10
- export default useSelectState;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 缩放值订阅。只关心 zoom 的组件(低缩放降级渲染、连接点尺寸换算)不要订阅
3
+ * 完整视口——平移每帧都会换 viewPort 对象(minX/minY 变),那会让全部
4
+ * 订阅者重渲;这里订阅 viewport:change 并在通知侧短路,zoom 不变(纯平移)零重渲。
5
+ */
6
+ export declare const useZoom: () => number;
@@ -1,5 +1,5 @@
1
- export { default, default as WhiteBoard } from "./WhiteBoard";
2
- export type { WhiteBoardProps, WhiteBoardRef } from "./WhiteBoard";
1
+ export { default, default as Whiteboard } from "./Whiteboard";
2
+ export type { WhiteboardProps, WhiteboardRef } from "./Whiteboard";
3
3
  export * from "./extensions/api";
4
4
  export type { WhiteboardKernelEvents, KernelEventName, ExtensionEventName, } from "./extensions/events";
5
5
  export { KERNEL_EVENT_NAMES } from "./extensions/events";
@@ -25,11 +25,13 @@ export { SELECT_TOOL_ID } from "./constants/tools";
25
25
  export type { BoardElement, ElementBounds, BoardContextMenuPayload, ContextMenuModalPayload, } from "./types/board";
26
26
  export type { WhiteboardAPI as Board } from "./extensions/api";
27
27
  export type { Path } from "./types/index";
28
- export { BoardUtil, PathUtil, ViewPortTransforms, ImageUtil, VideoUtil, AudioUtil, createWhiteboardSession, FrameUtil, PointUtil, MindUtil, } from "./public";
28
+ export { BoardUtil, PathUtil, ViewPortTransforms, ImageUtil, VideoUtil, AudioUtil, createWhiteboardSession, FrameUtil, PointUtil, MindUtil, placeDocuments, placeExcerpt, } from "./public";
29
29
  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";
34
+ export { useReadonly } from "./hooks/useReadonly";
33
35
  export { useBoardState } from "./hooks/useBoardState";
34
36
  export { useDropArrow } from "./hooks/useDropArrow";
35
37
  export { useSelectState } from "./hooks/useSelectState";
@@ -38,9 +40,12 @@ export { useSketch } from "./hooks/useSketch";
38
40
  export { RESIZE_CIRCLE_FILL, RESIZE_CIRCLE_RADIUS } from "./constants/resize";
39
41
  export { SELECT_RECT_STROKE, SELECT_RECT_STROKE_WIDTH, SELECT_RECT_FILL_OPACITY, } from "./constants/select";
40
42
  export { SKETCH_MEDIA_FRAME } from "./constants/sketch";
41
- export { DOCUMENT_OPEN_EVENT, DOCUMENT_DEFAULT_SIZE, isDocumentElement, } from "./plugins/DocumentPlugin";
42
- export type { DocumentElement, DocumentKind } from "./plugins/DocumentPlugin";
43
- export type { WhiteBoardElement } from "./plugins/WhiteBoardPlugin";
43
+ export { DOCUMENT_OPEN_EVENT, DOCUMENT_INSERT_EVENT, DOCUMENT_RELATED_EVENT, DOCUMENT_PEEK_EVENT, DOCUMENT_TURN_PAGE_EVENT, DOCUMENT_DEFAULT_SIZE, isDocumentElement, } from "./plugins/DocumentPlugin";
44
+ export type { DocumentElement, DocumentKind, DocumentInsertRequest, } from "./plugins/DocumentPlugin";
45
+ export type { WhiteboardElement } from "./plugins/WhiteboardPlugin";
46
+ export { EXCERPT_OPEN_SOURCE_EVENT, EXCERPT_DEFAULT_SIZE, isExcerptElement, } from "./plugins/ExcerptPlugin";
47
+ export type { ExcerptElement, ExcerptSource } from "./plugins/ExcerptPlugin";
48
+ export { EXCERPT_CARD_RADIUS } from "./components/ExcerptElement/index";
44
49
  export * from "./chrome/index";
45
50
  export { PageSchematic } from "./schematic/PageSchematic";
46
51
  export { default as ResizeCircle } from "./components/ResizeCircle/index";
@@ -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;
@@ -30,7 +30,7 @@ export declare class ArrowPlugin implements IBoardPlugin {
30
30
  children?: import("../index").BoardElement[];
31
31
  resizable?: boolean;
32
32
  autoHeight?: boolean;
33
- entityRef?: import("../../../shared/entity-ref").EntityRef;
33
+ entityRef?: import("../types/element").BoardEntityRef;
34
34
  entity?: import("../../../db-schema/content-identities").ContentEntityReference;
35
35
  sketch?: import("../index").ElementSketch;
36
36
  schemaVersion?: number;
@@ -76,6 +76,6 @@ export declare class ColumnPlugin extends CommonPlugin implements IBoardPlugin {
76
76
  protected onResizeEnd(board: Board): void;
77
77
  render(board: Board, { element, children }: {
78
78
  element: ColumnElement;
79
- children?: any;
79
+ children?: React.ReactNode;
80
80
  }): import("react/jsx-runtime").JSX.Element;
81
81
  }
@@ -88,17 +88,17 @@ export declare abstract class CommonPlugin implements IBoardPlugin {
88
88
  })[];
89
89
  static getCustomBindPoint(element: CommonElement, customOffset: CustomOffset): Point;
90
90
  getArrowBindPoint(_board: Board, element: CommonElement, connectId: string, customOffset?: CustomOffset): Point | null;
91
- isHit(_board: Board, element: CommonElement & any, x: number, y: number): boolean;
92
- moveElement(_board: Board, element: CommonElement & any, dx: number, dy: number): any;
93
- getBounds(_board: Board, element: CommonElement & any): {
94
- minX: any;
95
- minY: any;
96
- maxX: any;
97
- maxY: any;
91
+ isHit(_board: Board, element: CommonElement, x: number, y: number): boolean;
92
+ moveElement(_board: Board, element: CommonElement, dx: number, dy: number): BoardElement | null;
93
+ getBounds(_board: Board, element: CommonElement): {
94
+ minX: number;
95
+ minY: number;
96
+ maxX: number;
97
+ maxY: number;
98
98
  };
99
- isElementSelected(board: Board, element: CommonElement & any, selectArea?: Selection["selectArea"]): boolean;
100
- protected onResizeStart(element: CommonElement & any): void;
101
- protected onResize(board: Board, element: CommonElement & any, position: EHandlerPosition, startPoint: Point, endPoint: Point, isPreserveRatio?: boolean, isAdsorb?: boolean): any;
99
+ isElementSelected(board: Board, element: CommonElement, selectArea?: Selection["selectArea"]): boolean;
100
+ protected onResizeStart(element: CommonElement): void;
101
+ protected onResize(board: Board, element: CommonElement, position: EHandlerPosition, startPoint: Point, endPoint: Point, isPreserveRatio?: boolean, isAdsorb?: boolean): void | CommonElement;
102
102
  protected onResizeEnd(board: Board): void;
103
103
  }
104
104
  export default CommonPlugin;
@@ -1,9 +1,10 @@
1
1
  import { Board, BoardElement, IBoardPlugin, EHandlerPosition, Point, ContextMenuContext, PluginContextMenuItem, IElementCapabilities } from "../types/index";
2
+ import type { ViewPort } from "../types/viewport";
2
3
  import { CommonPlugin, CommonElement } from "./CommonPlugin";
3
- /** 文档卡可指向的正文实体,写法同 EntityRefKind */
4
- export type DocumentKind = "card" | "article" | "project-item" | "diary-moment";
4
+ /** 文档卡可指向的实体:正文实体写法同 EntityRefKind;pdf 是一整份 PDF(pdfs.id),没有正文 */
5
+ export type DocumentKind = "card" | "article" | "project-item" | "diary-moment" | "pdf";
5
6
  /**
6
- * 文档卡:引用一篇库里的正文(卡片 / 文章 / 项目文档 / 日记里的一条碎碎念)。画布上只读预览,展开后编辑;
7
+ * 文档卡:引用一篇库里的正文(卡片 / 文章 / 项目文档 / 日记里的一条碎碎念),或一整份 PDF。画布上只读预览,展开后编辑;
7
8
  * 正文不存在元素上,删除元素不影响原文。只存 entityRef,不存 contentId——白板保存按 contentId 计引用。
8
9
  */
9
10
  export interface DocumentElement extends CommonElement {
@@ -23,8 +24,40 @@ export declare const DOCUMENT_DEFAULT_SIZE: Record<DocumentKind, {
23
24
  width: number;
24
25
  height: number;
25
26
  }>;
27
+ /**
28
+ * 放入请求:`/`、工具栏、右键「文档」、从文档卡拖出到空白处都只发这个请求,宿主的检索面板响应。
29
+ * - at:放入位置(画布坐标),一行内容从这里向右展开;
30
+ * - screen:面板贴在哪里(client 坐标),缺省放在视口中央;
31
+ * - linkFrom:放入后从这个元素连一条箭头到每个新元素。
32
+ */
33
+ export declare const DOCUMENT_INSERT_EVENT = "tau.document.insert";
34
+ export interface DocumentInsertRequest {
35
+ at: Point;
36
+ /** at 是行的左缘还是中心,缺省左缘 */
37
+ align?: "start" | "center";
38
+ screen?: Point;
39
+ linkFrom?: string;
40
+ /** 拖出时画着的临时连线:面板关闭(放入或取消)时由宿主调用移除 */
41
+ release?(): void;
42
+ }
43
+ /**
44
+ * 速览:按住文档卡 250ms,或选中后按住空格,卡面原位放大到能读,松开落回。
45
+ * 载荷为元素 id(开始)或 null(结束);宿主的速览层响应,只读画布同样可用。
46
+ */
47
+ export declare const DOCUMENT_PEEK_EVENT = "tau.document.peek";
48
+ export declare const DOCUMENT_PEEK_DELAY = 250;
49
+ export declare const requestPeekDocument: (board: Board, elementId: string | null) => void;
50
+ /** PDF 文档卡翻页:选中 PDF 卡按 [ / ],载荷 { id, delta };宿主写回全局「上次读到的页」 */
51
+ export declare const DOCUMENT_TURN_PAGE_EVENT = "tau.document.turn-page";
52
+ /** 长出相关请求:选中文档卡按 R 或点属性条「相关」,载荷为元素 id;宿主在卡旁浮出建议 */
53
+ export declare const DOCUMENT_RELATED_EVENT = "tau.document.related";
26
54
  export declare const isDocumentElement: (element: BoardElement | null | undefined) => boolean;
27
55
  export declare const requestOpenDocument: (board: Board, elementId: string) => void;
56
+ export declare const requestInsertDocument: (board: Board, request: DocumentInsertRequest) => void;
57
+ /** 视口中央的放入请求(工具栏按钮、没有光标位置时) */
58
+ export declare function viewportInsertRequest(source: {
59
+ viewPort: ViewPort;
60
+ }): DocumentInsertRequest;
28
61
  export declare class DocumentPlugin extends CommonPlugin implements IBoardPlugin {
29
62
  private readonly actions;
30
63
  name: string;
@@ -0,0 +1,48 @@
1
+ import { Board, BoardElement, IBoardPlugin, EHandlerPosition, Point, IElementCapabilities } from "../types/index";
2
+ import { CommonPlugin, CommonElement } from "./CommonPlugin";
3
+ /** 摘录的来源:PDF 里的一处标注,或一篇正文 */
4
+ export type ExcerptSource = {
5
+ kind: "pdf";
6
+ entity: import("../../../db-schema/content-identities").ContentEntityReference & {
7
+ kind: "pdf";
8
+ };
9
+ annotationObjectId: string;
10
+ page: number;
11
+ } | {
12
+ kind: "pdf";
13
+ pdfId: number;
14
+ annotationId: number | null;
15
+ page: number;
16
+ } | {
17
+ kind: "card" | "article" | "project-item";
18
+ id: number;
19
+ };
20
+ /**
21
+ * 摘录:从阅读纸里摘下的一段原文,带来源。原文与笔记存快照(来源删除后照样显示),不进库、不建索引;
22
+ * 回到原文由来源条发 EXCERPT_OPEN_SOURCE_EVENT,宿主打开来源并定位。
23
+ */
24
+ export interface ExcerptElement extends CommonElement {
25
+ type: "excerpt";
26
+ source?: ExcerptSource;
27
+ quote?: string;
28
+ note?: string;
29
+ /** 高亮色(EHighlightColor 的值),卡片左侧色条 */
30
+ color?: string;
31
+ /** 来源标题快照:来源条显示 */
32
+ sourceTitle?: string;
33
+ }
34
+ export declare const EXCERPT_OPEN_SOURCE_EVENT = "tau.excerpt.open-source";
35
+ export declare const EXCERPT_DEFAULT_SIZE: {
36
+ width: number;
37
+ height: number;
38
+ };
39
+ export declare const isExcerptElement: (element: BoardElement | null | undefined) => boolean;
40
+ export declare class ExcerptPlugin extends CommonPlugin implements IBoardPlugin {
41
+ name: string;
42
+ constructor();
43
+ getCapabilities(): IElementCapabilities;
44
+ onResize(board: Board, element: ExcerptElement, position: EHandlerPosition, startPoint: Point, endPoint: Point, isPreserveRatio?: boolean, isAdsorb?: boolean): void;
45
+ render(_board: Board, { element }: {
46
+ element: ExcerptElement;
47
+ }): import("react/jsx-runtime").JSX.Element;
48
+ }
@@ -9,6 +9,6 @@ export declare class FramePlugin extends CommonPlugin implements IBoardPlugin {
9
9
  protected onResizeEnd(board: Board): void;
10
10
  render(_board: Board, { element, children }: {
11
11
  element: FrameElement;
12
- children?: any;
12
+ children?: React.ReactNode;
13
13
  }): import("react/jsx-runtime").JSX.Element;
14
14
  }
@@ -11,10 +11,13 @@ export interface GeometryElement extends CommonElement {
11
11
  stroke?: string;
12
12
  strokeWidth?: number;
13
13
  strokeOpacity?: number;
14
- /** 手绘模式下的填充样式(D-107);普通模式一律按实色渲染,缺省 solid */
14
+ /** 手绘模式下的填充样式;普通模式一律按实色渲染,缺省 solid */
15
15
  fillStyle?: SketchFillStyle;
16
16
  paths: string[];
17
- extraInfo?: Record<string, any>;
17
+ /** 渲染器按图形类型读取附加参数(如矩形圆角);未知键原样保留 */
18
+ extraInfo?: {
19
+ cornerRadius?: number;
20
+ } & Record<string, unknown>;
18
21
  text: {
19
22
  align: "left" | "center" | "right";
20
23
  content: Descendant[];
@@ -2,14 +2,14 @@ import { type TextExtensionOptions } from "../extensions/text";
2
2
  import { type ReactNode } from "react";
3
3
  import { Board, IBoardPlugin, MindNodeElement, Selection, MindDragState, ContextMenuContext, PluginContextMenuItem, IElementCapabilities, BoardElement } from "../types/index";
4
4
  import type { InteractionState } from "../interactions/InteractionState";
5
- export declare const EMPTY_MIND_DRAG_STATE: MindDragState;
6
5
  export declare class MindPlugin implements IBoardPlugin {
7
6
  private readonly text;
8
7
  name: string;
8
+ readonly claimPointerButton = 0;
9
9
  constructor(text?: TextExtensionOptions);
10
10
  getCapabilities(): IElementCapabilities;
11
11
  private dragState;
12
- private dragAnimationFrame;
12
+ private cancelDragPreviewFrame;
13
13
  private pendingPointerMove;
14
14
  private listeners;
15
15
  getContextMenu(context: ContextMenuContext): PluginContextMenuItem[];
@@ -4,7 +4,7 @@ export declare class WebviewPlugin extends CommonPlugin implements IBoardPlugin
4
4
  name: string;
5
5
  constructor();
6
6
  getContextMenu(context: ContextMenuContext): PluginContextMenuItem[];
7
- isHit(_board: Board, element: CommonElement & any, x: number, y: number): boolean;
7
+ isHit(_board: Board, element: CommonElement, x: number, y: number): boolean;
8
8
  render(_board: Board, { element }: {
9
9
  element: WebviewElement;
10
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,13 @@
1
1
  import { Board, IBoardPlugin, EHandlerPosition, Point, ContextMenuContext, PluginContextMenuItem, IElementCapabilities } from "../types/index";
2
2
  import { CommonPlugin, CommonElement } from "./CommonPlugin";
3
- export interface WhiteBoardElement extends CommonElement {
3
+ export interface WhiteboardElement extends CommonElement {
4
4
  type: "whiteboard";
5
5
  /** 引用的整块白板 */
6
- whiteBoardId?: number;
6
+ whiteboardId?: number;
7
7
  /** 旧元素:只引用了某一页(新元素不再写入) */
8
+ whiteboardContentId?: number;
9
+ /** 旧画布元素的误拼 key,读取兼容 */
10
+ whiteBoardId?: number;
8
11
  whiteBoardContentId?: number;
9
12
  /** 插入时的白板标题(白板读取失败时兜底显示) */
10
13
  name: string;
@@ -18,14 +21,14 @@ export interface WhiteBoardElement extends CommonElement {
18
21
  theme?: "light" | "dark";
19
22
  resizable?: boolean;
20
23
  }
21
- export declare class WhiteBoardPlugin extends CommonPlugin implements IBoardPlugin {
24
+ export declare class WhiteboardPlugin extends CommonPlugin implements IBoardPlugin {
22
25
  private readonly canCreate;
23
26
  name: string;
24
27
  constructor(canCreate?: boolean);
25
28
  getCapabilities(): IElementCapabilities;
26
29
  getContextMenu(context: ContextMenuContext): PluginContextMenuItem[];
27
- onResize(board: Board, element: WhiteBoardElement, position: EHandlerPosition, startPoint: Point, endPoint: Point, _isPreserveRatio?: boolean, isAdsorb?: boolean): void;
30
+ onResize(board: Board, element: WhiteboardElement, position: EHandlerPosition, startPoint: Point, endPoint: Point, _isPreserveRatio?: boolean, isAdsorb?: boolean): void;
28
31
  render(board: Board, { element }: {
29
- element: WhiteBoardElement;
32
+ element: WhiteboardElement;
30
33
  }): import("react/jsx-runtime").JSX.Element;
31
34
  }
@@ -4,6 +4,7 @@ export * from "./RichTextPlugin";
4
4
  export * from "./GeometryPlugin";
5
5
  export * from "./HandwritePlugin";
6
6
  export * from "./DocumentPlugin";
7
+ export * from "./ExcerptPlugin";
7
8
  export * from "./CommonPlugin";
8
9
  export * from "./ArrowPlugin";
9
10
  export * from "./ImagePlugin";
@@ -13,7 +14,7 @@ export * from "./MindPlugin";
13
14
  export * from "./PresentationPlugin";
14
15
  export * from "./WebviewPlugin";
15
16
  export * from "./FramePlugin";
16
- export * from "./WhiteBoardPlugin";
17
+ export * from "./WhiteboardPlugin";
17
18
  export * from "./ColumnPlugin";
18
19
  export * from "./FileDragDropPlugin";
19
20
  export * from "./ExportImagePlugin";
@@ -2,7 +2,9 @@ import type { WhiteboardAPI, WhiteboardExtension, WhiteboardSnapshot } from "./e
2
2
  import { BoardUtil as InternalBoardUtil } from "./utils/BoardUtil";
3
3
  import { ViewPortTransforms as InternalViewport } from "./transforms/index";
4
4
  import { VideoUtil as InternalVideo } from "./utils/VideoUtil";
5
- import type { BoardElement } from "./types/index";
5
+ import type { BoardElement, Point } from "./types/index";
6
+ import { type DocumentElement } from "./plugins/DocumentPlugin";
7
+ import { type ExcerptElement } from "./plugins/ExcerptPlugin";
6
8
  import type { MediaCapabilities } from "./extensions/media";
7
9
  import { FrameUtil as InternalFrame } from "./utils/FrameUtil";
8
10
  import { PointUtil as InternalPoint } from "./utils/PointUtil";
@@ -52,3 +54,23 @@ export declare const AudioUtil: {
52
54
  insertAudioFromUrl: (url: string, api: WhiteboardAPI) => Promise<void>;
53
55
  insertAudioFromTTS: (blob: Blob, text: string, api: WhiteboardAPI, media: MediaCapabilities) => Promise<void>;
54
56
  };
57
+ /**
58
+ * 把一组文档放到白板:从 at 起排成一行(align 为 center 时以 at 为中心),可选从 linkFrom 连箭头,选中新卡。
59
+ * 插入、连线与选中是一次 apply(一步撤销)。返回新元素;linkFrom 已不存在时不连线。
60
+ */
61
+ export declare function placeDocuments(api: WhiteboardAPI, documents: readonly Pick<DocumentElement, "entityRef" | "entity" | "title">[], options: {
62
+ at: Point;
63
+ align?: "start" | "center";
64
+ linkFrom?: string;
65
+ /** 保留当前选中(长出相关:放入建议后还要继续看这张卡的其他建议) */
66
+ keepSelection?: boolean;
67
+ }): DocumentElement[];
68
+ /**
69
+ * 放一张摘录:at 为左缘中点(align center 时为中心);linkFrom 存在时从来源卡画一条虚线箭头。
70
+ * 插入、连线与选中是一次 apply。返回新元素。
71
+ */
72
+ export declare function placeExcerpt(api: WhiteboardAPI, excerpt: Pick<ExcerptElement, "source" | "quote" | "note" | "color" | "sourceTitle">, options: {
73
+ at: Point;
74
+ align?: "start" | "center";
75
+ linkFrom?: string;
76
+ }): ExcerptElement;
@@ -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
  * 在广播前调用,返回手势状态则由内核接管路由(取代通用选择/拖拽并消费
@@ -60,20 +62,20 @@ export interface IBoardPlugin {
60
62
  onDragOver?: EventHandler;
61
63
  onDragEnter?: EventHandler;
62
64
  onDragLeave?: EventHandler;
63
- getArrowBindPoint?: (board: Board, element: BoardElement & any, connectId: string, customOffset?: CustomOffset) => Point | null;
64
- isElementSelected?: (board: Board, element: BoardElement & any, selectArea?: Selection["selectArea"]) => boolean;
65
- moveElement?: (board: Board, element: BoardElement & any, offsetX: number, offsetY: number) => BoardElement | null;
66
- isHit?(board: Board, element: BoardElement & any, x: number, y: number): boolean;
67
- render?: (board: Board, value: {
68
- element: BoardElement & any;
69
- children?: React.ReactElement[];
70
- }) => React.ReactElement;
71
- getBounds?: (board: Board, element: BoardElement & any) => ElementBounds | null;
65
+ getArrowBindPoint?(board: Board, element: BoardElement, connectId: string, customOffset?: CustomOffset): Point | null;
66
+ isElementSelected?(board: Board, element: BoardElement, selectArea?: Selection["selectArea"]): boolean;
67
+ moveElement?(board: Board, element: BoardElement, offsetX: number, offsetY: number): BoardElement | null;
68
+ isHit?(board: Board, element: BoardElement, x: number, y: number): boolean;
69
+ render?(board: Board, value: {
70
+ element: BoardElement;
71
+ children?: React.ReactNode;
72
+ }): React.ReactElement;
73
+ getBounds?(board: Board, element: BoardElement): ElementBounds | null;
72
74
  getContextMenu?: (context: ContextMenuContext) => PluginContextMenuItem[];
73
75
  getCapabilities?: () => IElementCapabilities;
74
76
  }
75
77
  export interface ContextMenuModalPayload {
76
- type: "document" | "image" | "video" | "audio" | "webview" | "whiteboard" | "export-image";
78
+ type: "image" | "video" | "audio" | "webview" | "whiteboard" | "export-image";
77
79
  action?: string;
78
80
  selectedElementIds?: string[];
79
81
  }
@@ -1,4 +1,9 @@
1
1
  import type { EntityRef } from "../../../shared/entity-ref";
2
+ /** 元素指向的库内实体:正文实体(EntityRef),或一整份 PDF(文档卡) */
3
+ export type BoardEntityRef = EntityRef | {
4
+ kind: "pdf";
5
+ id: number;
6
+ };
2
7
  import type { ElementSketch } from "./sketch";
3
8
  import type { Point } from "./point";
4
9
  /** 白板持久化元素;不依赖 Board 或内部插件实例。 */
@@ -10,7 +15,7 @@ export interface BoardElement {
10
15
  children?: BoardElement[];
11
16
  resizable?: boolean;
12
17
  autoHeight?: boolean;
13
- entityRef?: EntityRef;
18
+ entityRef?: BoardEntityRef;
14
19
  entity?: import("../../../db-schema/content-identities").ContentEntityReference;
15
20
  sketch?: ElementSketch;
16
21
  schemaVersion?: number;
@@ -37,7 +37,7 @@ export type SetViewportOperation = {
37
37
  properties: Partial<ViewPort>;
38
38
  newProperties: Partial<ViewPort>;
39
39
  };
40
- /** 页级画风(D-107),进撤销历史 */
40
+ /** 页级画风,进撤销历史 */
41
41
  export type SetSketchOperation = {
42
42
  type: "set_sketch";
43
43
  properties: Partial<PageSketch>;
@@ -7,5 +7,5 @@ export interface SelectArea {
7
7
  export interface Selection {
8
8
  selectArea: SelectArea | null;
9
9
  selectedElements: BoardElement[];
10
- [key: string]: any;
10
+ [key: string]: unknown;
11
11
  }
@@ -1,10 +1,10 @@
1
- /** 页面画风:手绘 / 普通(D-107) */
1
+ /** 页面画风:手绘 / 普通 */
2
2
  export type SketchMode = "sketch" | "normal";
3
3
  /** 笔触档位:工整 / 自然 / 潦草 */
4
4
  export type SketchLevel = "neat" | "natural" | "loose";
5
5
  /** 形状填充样式;普通模式下一律按实色渲染 */
6
6
  export type SketchFillStyle = "solid" | "hatch" | "cross" | "scribble";
7
- /** 页级画风,存在 WhiteBoardContent.data.sketch,缺省为 DEFAULT_PAGE_SKETCH */
7
+ /** 页级画风,存在 WhiteboardContent.data.sketch,缺省为 DEFAULT_PAGE_SKETCH */
8
8
  export interface PageSketch {
9
9
  mode: SketchMode;
10
10
  level: SketchLevel;
@@ -4,5 +4,5 @@ export interface ViewPort {
4
4
  width: number;
5
5
  height: number;
6
6
  zoom: number;
7
- [key: string]: any;
7
+ [key: string]: unknown;
8
8
  }
@@ -10,6 +10,5 @@ export interface ArrowStylePreset {
10
10
  animated: boolean;
11
11
  animationSpeed: number;
12
12
  }
13
- export declare const getDefaultArrowStylePreset: () => ArrowStylePreset;
14
13
  export declare const getPrevArrowStylePreset: () => ArrowStylePreset;
15
14
  export declare const saveArrowStylePresetFromElement: (element: ArrowElement) => void;
@@ -2,4 +2,3 @@ export declare class CanvasUtil {
2
2
  static isPointInPath(path: Path2D, x: number, y: number): boolean;
3
3
  static isPointInStroke(path: Path2D, lineWidth: number, x: number, y: number): boolean;
4
4
  }
5
- export default CanvasUtil;
@@ -1,8 +1,3 @@
1
1
  import { Board, BoardElement } from "../types/index";
2
2
  export declare const buildClipboardPayload: (board: Board, elements: BoardElement[]) => string | null;
3
3
  export declare const writeClipboardPayload: (payload: string) => Promise<boolean>;
4
- declare const _default: {
5
- buildClipboardPayload: (board: Board, elements: BoardElement[]) => string | null;
6
- writeClipboardPayload: (payload: string) => Promise<boolean>;
7
- };
8
- export default _default;
@@ -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: "dark" | "light" | undefined;
13
+ readonly theme: "light" | "dark" | undefined;
14
14
  readonly cornerRadius: number;
15
15
  readonly textAlign: "center" | "left" | "right";
16
16
  readonly fillStyle: SketchFillStyle | undefined;
@@ -1,4 +1,3 @@
1
- export declare const HANDWRITE_STYLE_STORAGE_KEY = "whiteboard-handwrite-style-v1";
2
1
  export interface HandwriteStyle {
3
2
  themeColorId: string;
4
3
  opacity: number;
@@ -1,7 +1,4 @@
1
1
  import { Board, ElementBounds, MindNodeElement, MindDragTarget } from "../types/index";
2
- export declare const MIND_DRAG_HORIZONTAL_THRESHOLD_PX = 120;
3
- export declare const MIND_DRAG_VERTICAL_THRESHOLD_PX = 80;
4
- export declare const MIND_DRAG_TARGET_RETENTION_SCALE = 1.2;
5
2
  export declare class MindUtil {
6
3
  static isRoot(node: MindNodeElement): boolean;
7
4
  static layout(node: MindNodeElement): MindNodeElement;
@@ -1,7 +1,7 @@
1
1
  import { BoardElement, Board, Operation } from "../types/index";
2
2
  export type Path = number[];
3
3
  export declare class PathUtil {
4
- static getPathByElement(board: Board, element: BoardElement & any): Path | null;
4
+ static getPathByElement(board: Board, element: BoardElement): Path | null;
5
5
  static getElementByPath(board: Board, path: number[]): BoardElement;
6
6
  static getElement(children: BoardElement[], path: Path): BoardElement | null;
7
7
  static getParentByPath(board: Board, path: Path): Board | BoardElement | null;
@@ -47,4 +47,3 @@ export declare class PointUtil {
47
47
  static getResizedBBox(bbox: BBox, position: EHandlerPosition, anchor: Point, focus: Point): BBox;
48
48
  static getResizeCursor(position: EHandlerPosition): "move" | "e-resize" | "n-resize" | "ne-resize" | "nw-resize" | "s-resize" | "se-resize" | "sw-resize" | "w-resize";
49
49
  }
50
- export default PointUtil;
@@ -11,7 +11,7 @@ export declare class PresentationManager {
11
11
  constructor(board: Board, initialSequences?: PresentationSequence[]);
12
12
  on(event: string, listener: (...args: any[]) => void): void;
13
13
  off(event: string, listener: (...args: any[]) => void): void;
14
- emit(event: string, ...args: any[]): void;
14
+ emit(event: string, ...args: unknown[]): void;
15
15
  once(event: string, listener: (...args: any[]) => void): void;
16
16
  get isPresentationMode(): boolean;
17
17
  set isPresentationMode(value: boolean);