@8btc/whiteboard 0.0.11 → 0.0.12
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/index.css +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +44 -0
- package/dist/index.umd.js +54 -0
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -54,6 +54,8 @@
|
|
|
54
54
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
55
55
|
--color-red-500: oklch(63.7% .237 25.331);
|
|
56
56
|
--color-red-600: oklch(57.7% .245 27.325);
|
|
57
|
+
--color-orange-500: oklch(70.5% .213 47.604);
|
|
58
|
+
--color-orange-600: oklch(64.6% .222 41.116);
|
|
57
59
|
--color-green-500: oklch(72.3% .219 149.579);
|
|
58
60
|
--color-green-600: oklch(62.7% .194 149.214);
|
|
59
61
|
--color-cyan-500: oklch(71.5% .143 215.221);
|
|
@@ -643,6 +645,10 @@
|
|
|
643
645
|
background-color: var(--color-indigo-500);
|
|
644
646
|
}
|
|
645
647
|
|
|
648
|
+
.bg-orange-500 {
|
|
649
|
+
background-color: var(--color-orange-500);
|
|
650
|
+
}
|
|
651
|
+
|
|
646
652
|
.bg-primary {
|
|
647
653
|
background-color: var(--primary);
|
|
648
654
|
}
|
|
@@ -820,6 +826,10 @@
|
|
|
820
826
|
background-color: var(--color-indigo-600);
|
|
821
827
|
}
|
|
822
828
|
|
|
829
|
+
.hover\:bg-orange-600:hover {
|
|
830
|
+
background-color: var(--color-orange-600);
|
|
831
|
+
}
|
|
832
|
+
|
|
823
833
|
.hover\:bg-primary\/90:hover {
|
|
824
834
|
background-color: var(--primary);
|
|
825
835
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export declare class CanvasApi extends CanvasCore {
|
|
|
19
19
|
* 如果你不知道自己在干什么,请使用更高层的封装方法,如 createImageNode
|
|
20
20
|
*/
|
|
21
21
|
createNodes(nodes: INode[]): void;
|
|
22
|
+
/**
|
|
23
|
+
* 根据 ID 获取节点
|
|
24
|
+
*/
|
|
25
|
+
getNodeById<T extends INode = INode>(id: string): T | null;
|
|
22
26
|
/**
|
|
23
27
|
* 更新视口位置
|
|
24
28
|
*/
|
|
@@ -51,6 +55,12 @@ export declare class CanvasApi extends CanvasCore {
|
|
|
51
55
|
quality?: number;
|
|
52
56
|
padding?: number;
|
|
53
57
|
}): string | null;
|
|
58
|
+
/**
|
|
59
|
+
* 导出带有标注的图片节点为图片
|
|
60
|
+
* @param id - 图片节点 ID
|
|
61
|
+
* @returns DataURL 格式的图片数据,如果节点不存在则返回 null
|
|
62
|
+
*/
|
|
63
|
+
exportImageWithMarker(id: string): string | null;
|
|
54
64
|
/**
|
|
55
65
|
* 删除当前选中的节点
|
|
56
66
|
* 如果删除的是 image 节点,会同步删除所有关联的 image-marker
|
package/dist/index.js
CHANGED
|
@@ -1588,6 +1588,14 @@ class CanvasApi extends CanvasCore {
|
|
|
1588
1588
|
createNodes(nodes) {
|
|
1589
1589
|
super.createNodes(nodes);
|
|
1590
1590
|
}
|
|
1591
|
+
/**
|
|
1592
|
+
* 根据 ID 获取节点
|
|
1593
|
+
*/
|
|
1594
|
+
getNodeById(id) {
|
|
1595
|
+
const nodes = this.getState().nodes || [];
|
|
1596
|
+
const node = nodes.find((n) => n.id === id);
|
|
1597
|
+
return node || null;
|
|
1598
|
+
}
|
|
1591
1599
|
/**
|
|
1592
1600
|
* 更新视口位置
|
|
1593
1601
|
*/
|
|
@@ -1672,6 +1680,42 @@ class CanvasApi extends CanvasCore {
|
|
|
1672
1680
|
transformer.visible(transformerVisible);
|
|
1673
1681
|
}
|
|
1674
1682
|
}
|
|
1683
|
+
/**
|
|
1684
|
+
* 导出带有标注的图片节点为图片
|
|
1685
|
+
* @param id - 图片节点 ID
|
|
1686
|
+
* @returns DataURL 格式的图片数据,如果节点不存在则返回 null
|
|
1687
|
+
*/
|
|
1688
|
+
exportImageWithMarker(id) {
|
|
1689
|
+
const imageShape = this.getStage().findOne(`#${id}`);
|
|
1690
|
+
if (!imageShape) {
|
|
1691
|
+
console.warn("Image shape not found on stage");
|
|
1692
|
+
return null;
|
|
1693
|
+
}
|
|
1694
|
+
const nodes = this.getState().nodes || [];
|
|
1695
|
+
const markerNodes = nodes.filter(
|
|
1696
|
+
(n) => n.type === "image-marker" && n.meta.parent === id
|
|
1697
|
+
);
|
|
1698
|
+
const tempGroup = new Konva.Group();
|
|
1699
|
+
const imageClone = imageShape.clone();
|
|
1700
|
+
tempGroup.add(imageClone);
|
|
1701
|
+
markerNodes.forEach((markerNode) => {
|
|
1702
|
+
const markerShape = this.getStage().findOne(`#${markerNode.id}`);
|
|
1703
|
+
if (markerShape) {
|
|
1704
|
+
const markerClone = markerShape.clone();
|
|
1705
|
+
tempGroup.add(markerClone);
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1708
|
+
const box = tempGroup.getClientRect();
|
|
1709
|
+
const dataURL = tempGroup.toDataURL({
|
|
1710
|
+
x: box.x,
|
|
1711
|
+
y: box.y,
|
|
1712
|
+
width: box.width,
|
|
1713
|
+
height: box.height,
|
|
1714
|
+
pixelRatio: 2
|
|
1715
|
+
});
|
|
1716
|
+
tempGroup.destroy();
|
|
1717
|
+
return dataURL;
|
|
1718
|
+
}
|
|
1675
1719
|
/**
|
|
1676
1720
|
* 删除当前选中的节点
|
|
1677
1721
|
* 如果删除的是 image 节点,会同步删除所有关联的 image-marker
|
package/dist/index.umd.js
CHANGED
|
@@ -71,6 +71,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
71
71
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
72
72
|
--color-red-500: oklch(63.7% .237 25.331);
|
|
73
73
|
--color-red-600: oklch(57.7% .245 27.325);
|
|
74
|
+
--color-orange-500: oklch(70.5% .213 47.604);
|
|
75
|
+
--color-orange-600: oklch(64.6% .222 41.116);
|
|
74
76
|
--color-green-500: oklch(72.3% .219 149.579);
|
|
75
77
|
--color-green-600: oklch(62.7% .194 149.214);
|
|
76
78
|
--color-cyan-500: oklch(71.5% .143 215.221);
|
|
@@ -660,6 +662,10 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
660
662
|
background-color: var(--color-indigo-500);
|
|
661
663
|
}
|
|
662
664
|
|
|
665
|
+
.bg-orange-500 {
|
|
666
|
+
background-color: var(--color-orange-500);
|
|
667
|
+
}
|
|
668
|
+
|
|
663
669
|
.bg-primary {
|
|
664
670
|
background-color: var(--primary);
|
|
665
671
|
}
|
|
@@ -837,6 +843,10 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
837
843
|
background-color: var(--color-indigo-600);
|
|
838
844
|
}
|
|
839
845
|
|
|
846
|
+
.hover\\:bg-orange-600:hover {
|
|
847
|
+
background-color: var(--color-orange-600);
|
|
848
|
+
}
|
|
849
|
+
|
|
840
850
|
.hover\\:bg-primary\\/90:hover {
|
|
841
851
|
background-color: var(--primary);
|
|
842
852
|
}
|
|
@@ -2899,6 +2909,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2899
2909
|
createNodes(nodes) {
|
|
2900
2910
|
super.createNodes(nodes);
|
|
2901
2911
|
}
|
|
2912
|
+
/**
|
|
2913
|
+
* 根据 ID 获取节点
|
|
2914
|
+
*/
|
|
2915
|
+
getNodeById(id) {
|
|
2916
|
+
const nodes = this.getState().nodes || [];
|
|
2917
|
+
const node = nodes.find((n) => n.id === id);
|
|
2918
|
+
return node || null;
|
|
2919
|
+
}
|
|
2902
2920
|
/**
|
|
2903
2921
|
* 更新视口位置
|
|
2904
2922
|
*/
|
|
@@ -2983,6 +3001,42 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2983
3001
|
transformer.visible(transformerVisible);
|
|
2984
3002
|
}
|
|
2985
3003
|
}
|
|
3004
|
+
/**
|
|
3005
|
+
* 导出带有标注的图片节点为图片
|
|
3006
|
+
* @param id - 图片节点 ID
|
|
3007
|
+
* @returns DataURL 格式的图片数据,如果节点不存在则返回 null
|
|
3008
|
+
*/
|
|
3009
|
+
exportImageWithMarker(id) {
|
|
3010
|
+
const imageShape = this.getStage().findOne(`#${id}`);
|
|
3011
|
+
if (!imageShape) {
|
|
3012
|
+
console.warn("Image shape not found on stage");
|
|
3013
|
+
return null;
|
|
3014
|
+
}
|
|
3015
|
+
const nodes = this.getState().nodes || [];
|
|
3016
|
+
const markerNodes = nodes.filter(
|
|
3017
|
+
(n) => n.type === "image-marker" && n.meta.parent === id
|
|
3018
|
+
);
|
|
3019
|
+
const tempGroup = new Konva.Group();
|
|
3020
|
+
const imageClone = imageShape.clone();
|
|
3021
|
+
tempGroup.add(imageClone);
|
|
3022
|
+
markerNodes.forEach((markerNode) => {
|
|
3023
|
+
const markerShape = this.getStage().findOne(`#${markerNode.id}`);
|
|
3024
|
+
if (markerShape) {
|
|
3025
|
+
const markerClone = markerShape.clone();
|
|
3026
|
+
tempGroup.add(markerClone);
|
|
3027
|
+
}
|
|
3028
|
+
});
|
|
3029
|
+
const box = tempGroup.getClientRect();
|
|
3030
|
+
const dataURL = tempGroup.toDataURL({
|
|
3031
|
+
x: box.x,
|
|
3032
|
+
y: box.y,
|
|
3033
|
+
width: box.width,
|
|
3034
|
+
height: box.height,
|
|
3035
|
+
pixelRatio: 2
|
|
3036
|
+
});
|
|
3037
|
+
tempGroup.destroy();
|
|
3038
|
+
return dataURL;
|
|
3039
|
+
}
|
|
2986
3040
|
/**
|
|
2987
3041
|
* 删除当前选中的节点
|
|
2988
3042
|
* 如果删除的是 image 节点,会同步删除所有关联的 image-marker
|