@8btc/whiteboard 0.0.20-alpha.39 → 0.0.20-alpha.40

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/dist/maze.d.ts CHANGED
@@ -562,6 +562,25 @@ declare class CanvasApi extends CanvasCore {
562
562
  destroy(): void;
563
563
  }
564
564
 
565
+ /**
566
+ * 根据字体识别结果在选区附近创建可编辑的 rich-text 节点
567
+ */
568
+ export declare function createRichTextFromFontReplace(api: CanvasApi | null | undefined, params: {
569
+ text: string;
570
+ fontFamily: string;
571
+ fontId: string;
572
+ fontSize: number;
573
+ letterSpacing: number;
574
+ fontWeight: number;
575
+ fontColor: string;
576
+ lineHeight: number;
577
+ position: {
578
+ x: number;
579
+ y: number;
580
+ };
581
+ width: number;
582
+ }): string | undefined;
583
+
565
584
  /**
566
585
  * 图片裁剪变换数据
567
586
  * 描述图像位图在裁剪区域内的位置、缩放和旋转
@@ -583,6 +602,11 @@ declare class CanvasApi extends CanvasCore {
583
602
  $_type: "ellipse";
584
603
  };
585
604
 
605
+ /**
606
+ * 导出 font-replace 选区数据,用于发送到后端
607
+ */
608
+ export declare function exportFontReplaceRegion(api: CanvasApi | null | undefined, fontReplaceNodeId: string): Promise<FontReplaceObj | null>;
609
+
586
610
  /**
587
611
  * 根据图片标注裁剪图片并返回 base64 字符串
588
612
  * @param api Canvas API 实例
@@ -604,6 +628,64 @@ declare class CanvasApi extends CanvasCore {
604
628
  padding?: number;
605
629
  }): string | null;
606
630
 
631
+ /**
632
+ * 字体替换选区节点配置
633
+ */
634
+ declare type FontReplaceNodeConfig = BaseNodeConfig & default_2.RectConfig & Partial<NodeStyle> & {
635
+ $_type: "font-replace";
636
+ width: number;
637
+ height: number;
638
+ $_parentId: string;
639
+ $_relativeBox: {
640
+ start: {
641
+ ratioX: number;
642
+ ratioY: number;
643
+ };
644
+ end: {
645
+ ratioX: number;
646
+ ratioY: number;
647
+ };
648
+ };
649
+ $_status: "selecting" | "confirming" | "processing" | "done" | "error";
650
+ $_bounds?: {
651
+ x: number;
652
+ y: number;
653
+ width: number;
654
+ height: number;
655
+ };
656
+ };
657
+
658
+ /**
659
+ * Font-Replace 选区数据结构(前端 → 后端)
660
+ */
661
+ export declare interface FontReplaceObj {
662
+ /** 选区裁剪后的 base64 图片 */
663
+ region_image: string;
664
+ /** 原图完整 URL(含标注框,用于 NanoBanana 擦除) */
665
+ edit_urls: string[];
666
+ /** 擦除提示词 */
667
+ prompt: string;
668
+ /** 选区在原图中的相对位置 */
669
+ relative_box: {
670
+ start: {
671
+ ratioX: number;
672
+ ratioY: number;
673
+ };
674
+ end: {
675
+ ratioX: number;
676
+ ratioY: number;
677
+ };
678
+ };
679
+ /** 原图节点 ID */
680
+ image_node_id: string;
681
+ /** font-replace 节点 ID */
682
+ font_replace_node_id: string;
683
+ /** 原图真实像素宽度 */
684
+ natural_width?: number;
685
+ /** 原图真实像素高度 */
686
+ natural_height?: number;
687
+ }
688
+
607
689
  declare type HistoryState<T> = {
608
690
  past: T[];
609
691
  present: T;
@@ -668,6 +750,16 @@ declare class CanvasApi extends CanvasCore {
668
750
  $_type: "image";
669
751
  $_imageUrl: string;
670
752
  $_cropTransform?: CropTransform | null;
753
+ $_applyBlurFilter?: boolean;
754
+ $_applyBrightnessFilter?: boolean;
755
+ $_applyRGBFilter?: boolean;
756
+ $_applyHSLFilter?: boolean;
757
+ red?: number;
758
+ green?: number;
759
+ blue?: number;
760
+ hue?: number;
761
+ saturation?: number;
762
+ luminance?: number;
671
763
  image?: CanvasImageSource | undefined;
672
764
  };
673
765
 
@@ -719,14 +811,14 @@ declare class CanvasApi extends CanvasCore {
719
811
  * 节点配置联合类型(判别联合)
720
812
  * 根据 $_type 字段可以自动推断出对应节点的特定字段
721
813
  */
722
- declare type NodeConfig = RectangleNodeConfig | ImageNodeConfig | ImageMarkerNodeConfig | HtmlNodeConfig | TextNodeConfig | RichTextNodeConfig | VideoNodeConfig | StarNodeConfig | EllipseNodeConfig | PolygonNodeConfig | ArrowNodeConfig | BrushNodeConfig | ImageBrushNodeConfig;
814
+ declare type NodeConfig = RectangleNodeConfig | ImageNodeConfig | ImageMarkerNodeConfig | HtmlNodeConfig | TextNodeConfig | RichTextNodeConfig | VideoNodeConfig | StarNodeConfig | EllipseNodeConfig | PolygonNodeConfig | ArrowNodeConfig | BrushNodeConfig | ImageBrushNodeConfig | FontReplaceNodeConfig;
723
815
 
724
816
  declare interface NodeStyle {
725
817
  $_strokeColor: ThemeKeysStartingWith<"theme.stroke-color."> | string;
726
818
  $_fillColor: ThemeKeysStartingWith<"theme.fill-color."> | string;
727
819
  }
728
820
 
729
- declare type NodeType = "rectangle" | "image" | "image-marker" | "html" | "text" | "rich-text" | "video" | "star" | "ellipse" | "polygon" | "arrow" | "brush" | "image-brush";
821
+ declare type NodeType = "rectangle" | "image" | "image-marker" | "html" | "text" | "rich-text" | "video" | "star" | "ellipse" | "polygon" | "arrow" | "brush" | "image-brush" | "font-replace";
730
822
 
731
823
  /**
732
824
  * 多边形节点配置
@@ -745,6 +837,11 @@ declare class CanvasApi extends CanvasCore {
745
837
  height: number;
746
838
  };
747
839
 
840
+ /**
841
+ * 替换图片节点的图片 URL(用擦除后的图片替换原图)
842
+ */
843
+ export declare function replaceImageUrl(api: CanvasApi | null | undefined, imageNodeId: string, newImageUrl: string): void;
844
+
748
845
  export declare function replaceLoadingImageNode(api: CanvasApi | null | undefined, loadingNodeId: string, imageUrls: string | string[]): void;
749
846
 
750
847
  declare type RichTextNodeConfig = BaseNodeConfig & default_2.ImageConfig & Partial<NodeStyle> & {
@@ -792,7 +889,7 @@ declare class CanvasApi extends CanvasCore {
792
889
 
793
890
  declare type ThemeKeysStartingWith<Prefix extends string> = Extract<keyof Theme, `${Prefix}${string}`>;
794
891
 
795
- declare type ToolType = "select" | "hand" | "rectangle" | "star" | "image-marker" | "text" | "rich-text" | "ellipse" | "polygon" | "arrow" | "brush" | "image-brush";
892
+ declare type ToolType = "select" | "hand" | "rectangle" | "star" | "image-marker" | "text" | "rich-text" | "ellipse" | "polygon" | "arrow" | "brush" | "image-brush" | "font-replace";
796
893
 
797
894
  declare type TransformerConfig = {
798
895
  rotateEnabled?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8btc/whiteboard",
3
3
  "private": false,
4
- "version": "0.0.20-alpha.39",
4
+ "version": "0.0.20-alpha.40",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
7
7
  "module": "./dist/index.js",