@8btc/whiteboard 0.0.20-alpha.28 → 0.0.20-alpha.29

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.
@@ -1,5 +1,5 @@
1
1
  import { v4 as _ } from "uuid";
2
- import { N as M } from "../const-CNw7pZuI.js";
2
+ import { N as M } from "../const-BJHbPsA9.js";
3
3
  async function N(t) {
4
4
  return new Promise((r, n) => {
5
5
  const e = new Image();
@@ -7,15 +7,19 @@ const i = {
7
7
  html: "html_intrinsic",
8
8
  text: "text_intrinsic",
9
9
  richText: "rich_text_intrinsic",
10
- video: "video_intrinsic"
10
+ video: "video_intrinsic",
11
+ star: "star_intrinsic",
12
+ ellipse: "ellipse_intrinsic",
13
+ polygon: "polygon_intrinsic",
14
+ arrow: "arrow_intrinsic"
11
15
  }, t = {
12
16
  CORNER_RADIUS: 6,
13
17
  MIN_SIZE: 10
14
- }, e = {
18
+ }, n = {
15
19
  MIN_SIZE: 10
16
20
  };
17
21
  export {
18
- e as I,
22
+ n as I,
19
23
  i as N,
20
24
  t as R
21
25
  };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,13 @@ import { Editor } from '@tiptap/core';
3
3
  import { JSX } from 'react/jsx-runtime';
4
4
  import { Transformer as Transformer_2 } from 'konva/lib/shapes/Transformer';
5
5
 
6
+ /**
7
+ * 箭头节点配置
8
+ */
9
+ declare type ArrowNodeConfig = BaseNodeConfig & default_2.ArrowConfig & Partial<NodeStyle> & {
10
+ $_type: "arrow";
11
+ };
12
+
6
13
  declare interface BaseNodeConfig {
7
14
  id: string;
8
15
  x: number;
@@ -19,11 +26,10 @@ export declare class CanvasApi extends CanvasCore {
19
26
  /**
20
27
  * 获取所有可用的工具类型
21
28
  */
22
- getAvailableTools(): ToolType[];
23
- /**
24
- * 设置当前工具类型
25
- */
26
- setToolType(type: ToolType): void;
29
+ getAvailableTools(): Array<{
30
+ type: ToolType;
31
+ meta?: Record<string, any>;
32
+ }>;
27
33
  /**
28
34
  * 手动创建多个节点
29
35
  * 如果你不知道自己在干什么,请使用更高层的封装方法,如 createImageNode
@@ -206,10 +212,18 @@ declare class CanvasCore extends CanvasStore {
206
212
  * 获取当前工具类型
207
213
  */
208
214
  getToolType(): ToolType;
215
+ /**
216
+ * 获取当前工具的元数据
217
+ */
218
+ getToolMeta(): Record<string, any> | undefined;
209
219
  /**
210
220
  * 设置当前工具类型(内部使用)
221
+ *
222
+ * toolMeta 是一个可选的对象,可以包含与当前工具相关的任何额外信息。例如,在绘制图形时,toolMeta 可以包含初始位置、颜色、线条样式等信息。这样,在处理工具逻辑时,就可以访问这些元数据来实现更复杂的行为。
223
+ *
224
+ * - polygon 工具可以在 toolMeta 中包含一个 $_shape 字段,指示要绘制的多边形形状(如 triangle、rectangle、pentagon 等),以便在创建草稿节点时生成对应形状的点数据。
211
225
  */
212
- setToolType(type: ToolType): void;
226
+ setToolType(type: ToolType, toolMeta?: any): void;
213
227
  /**
214
228
  * 根据 ID 获取 Canvas 节点实例
215
229
  */
@@ -287,7 +301,10 @@ declare type CanvasEvents = {
287
301
  "viewport:change": CanvasSnapshot["viewport"];
288
302
  "viewport:scale:change": number;
289
303
  "transformer:positionChange": TransformerPosition | null;
290
- "toolType:change": CanvasSnapshot["toolType"];
304
+ "toolType:change": {
305
+ type: CanvasSnapshot["toolType"];
306
+ meta?: Record<string, any>;
307
+ };
291
308
  "theme:change": Theme;
292
309
  "nodes:created": NodeConfig[];
293
310
  "nodes:deleted": NodeConfig[];
@@ -316,6 +333,7 @@ export declare interface CanvasNode {
316
333
  export declare interface CanvasSnapshot {
317
334
  viewport: Viewport;
318
335
  toolType: ToolType;
336
+ toolMeta?: any;
319
337
  selectedNodeIds?: string[];
320
338
  nodes?: NodeConfig[];
321
339
  }
@@ -470,6 +488,13 @@ export declare const DARK_THEME: Theme;
470
488
 
471
489
  export declare const DEFAULT_THEME: Theme;
472
490
 
491
+ /**
492
+ * 椭圆节点配置
493
+ */
494
+ declare type EllipseNodeConfig = BaseNodeConfig & default_2.EllipseConfig & Partial<NodeStyle> & {
495
+ $_type: "ellipse";
496
+ };
497
+
473
498
  declare type HistoryState<T> = {
474
499
  past: T[];
475
500
  present: T;
@@ -531,13 +556,17 @@ export declare const NODE_NAMES: {
531
556
  text: string;
532
557
  richText: string;
533
558
  video: string;
559
+ star: string;
560
+ ellipse: string;
561
+ polygon: string;
562
+ arrow: string;
534
563
  };
535
564
 
536
565
  /**
537
566
  * 节点配置联合类型(判别联合)
538
567
  * 根据 $_type 字段可以自动推断出对应节点的特定字段
539
568
  */
540
- export declare type NodeConfig = RectangleNodeConfig | ImageNodeConfig | ImageMarkerNodeConfig | HtmlNodeConfig | TextNodeConfig | RichTextNodeConfig | VideoNodeConfig;
569
+ export declare type NodeConfig = RectangleNodeConfig | ImageNodeConfig | ImageMarkerNodeConfig | HtmlNodeConfig | TextNodeConfig | RichTextNodeConfig | VideoNodeConfig | StarNodeConfig | EllipseNodeConfig | PolygonNodeConfig | ArrowNodeConfig;
541
570
 
542
571
  /**
543
572
  * 根据节点类型获取对应的配置类型
@@ -552,7 +581,15 @@ declare interface NodeStyle {
552
581
  $_fillColor: ThemeKeysStartingWith<"theme.fill-color."> | string;
553
582
  }
554
583
 
555
- export declare type NodeType = "rectangle" | "image" | "image-marker" | "html" | "text" | "rich-text" | "video";
584
+ export declare type NodeType = "rectangle" | "image" | "image-marker" | "html" | "text" | "rich-text" | "video" | "star" | "ellipse" | "polygon" | "arrow";
585
+
586
+ /**
587
+ * 多边形节点配置
588
+ */
589
+ declare type PolygonNodeConfig = BaseNodeConfig & default_2.LineConfig & Partial<NodeStyle> & {
590
+ $_type: "polygon";
591
+ $_shape: "triangle" | "diamond" | "hexagon";
592
+ };
556
593
 
557
594
  /**
558
595
  * 矩形节点配置
@@ -576,6 +613,13 @@ declare type StageConfig = {
576
613
  className?: string;
577
614
  };
578
615
 
616
+ /**
617
+ * 星形节点配置
618
+ */
619
+ export declare type StarNodeConfig = BaseNodeConfig & default_2.StarConfig & Partial<NodeStyle> & {
620
+ $_type: "star";
621
+ };
622
+
579
623
  declare type TextNodeConfig = BaseNodeConfig & default_2.TextConfig & Partial<NodeStyle> & {
580
624
  $_type: "text";
581
625
  text: string;
@@ -614,7 +658,7 @@ declare interface TipTapBubbleMenuProps {
614
658
  api: CanvasApi | null;
615
659
  }
616
660
 
617
- export declare type ToolType = "select" | "hand" | "rectangle" | "image-marker" | "text" | "rich-text";
661
+ export declare type ToolType = "select" | "hand" | "rectangle" | "star" | "image-marker" | "text" | "rich-text" | "ellipse" | "polygon" | "arrow";
618
662
 
619
663
  declare type TransformerConfig = {
620
664
  rotateEnabled?: boolean;