@logicflow/extension 2.0.0-beta.3 → 2.0.0-beta.4

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 (39) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/dist/index.min.js +2 -2
  3. package/es/components/menu/index.d.ts +1 -1
  4. package/es/components/menu/index.js +9 -10
  5. package/es/components/menu/index.js.map +1 -1
  6. package/es/index.d.ts +1 -0
  7. package/es/index.js +1 -0
  8. package/es/index.js.map +1 -1
  9. package/es/materials/node-selection/index.d.ts +2 -1
  10. package/es/materials/node-selection/index.js +64 -56
  11. package/es/materials/node-selection/index.js.map +1 -1
  12. package/es/tools/snapshot/index.d.ts +101 -11
  13. package/es/tools/snapshot/index.js +331 -147
  14. package/es/tools/snapshot/index.js.map +1 -1
  15. package/es/tools/snapshot/utils.d.ts +35 -0
  16. package/es/tools/snapshot/utils.js +238 -0
  17. package/es/tools/snapshot/utils.js.map +1 -0
  18. package/lib/components/menu/index.d.ts +1 -1
  19. package/lib/components/menu/index.js +9 -10
  20. package/lib/components/menu/index.js.map +1 -1
  21. package/lib/index.d.ts +1 -0
  22. package/lib/index.js +1 -0
  23. package/lib/index.js.map +1 -1
  24. package/lib/materials/node-selection/index.d.ts +2 -1
  25. package/lib/materials/node-selection/index.js +63 -55
  26. package/lib/materials/node-selection/index.js.map +1 -1
  27. package/lib/tools/snapshot/index.d.ts +101 -11
  28. package/lib/tools/snapshot/index.js +331 -147
  29. package/lib/tools/snapshot/index.js.map +1 -1
  30. package/lib/tools/snapshot/utils.d.ts +35 -0
  31. package/lib/tools/snapshot/utils.js +247 -0
  32. package/lib/tools/snapshot/utils.js.map +1 -0
  33. package/package.json +3 -3
  34. package/src/components/menu/index.ts +16 -13
  35. package/src/index.ts +1 -0
  36. package/src/materials/node-selection/index.ts +72 -69
  37. package/src/tools/snapshot/README.md +130 -5
  38. package/src/tools/snapshot/index.ts +264 -98
  39. package/src/tools/snapshot/utils.ts +163 -0
@@ -1,25 +1,115 @@
1
+ import LogicFlow from '@logicflow/core';
2
+ export type ToImageOptions = {
3
+ /**
4
+ * 导出图片的格式,可选值为:`png`、`webp`、`gif`、`jpeg`、`svg`,默认值为 `png`
5
+ */
6
+ fileType?: string;
7
+ /**
8
+ * 导出图片的宽度,通常无需设置,设置后可能会拉伸图形
9
+ */
10
+ width?: number;
11
+ /**
12
+ * 导出图片的高度,通常无需设置,设置后可能会拉伸图形
13
+ */
14
+ height?: number;
15
+ /**
16
+ * 导出图片的背景色,默认为透明
17
+ */
18
+ backgroundColor?: string;
19
+ /**
20
+ * 导出图片的质量。
21
+ *
22
+ * 在指定图片格式为 `jpeg` 或 `webp` 的情况下,可以从 0 到 1 的区间内选择图片的质量,如果超出取值范围,将会使用默认值 0.92。导出为其他格式的图片时,该参数会被忽略。
23
+ */
24
+ quality?: number;
25
+ /**
26
+ * 导出图片的内边距,即元素内容所在区域边界与图片边界的距离,单位为像素,默认为 40
27
+ */
28
+ padding?: number;
29
+ /**
30
+ * 导出图片时是否开启局部渲染
31
+ * - `false`:将导出画布上所有的元素
32
+ * - `true`:只导出画面区域内的可见元素
33
+ */
34
+ partial?: boolean;
35
+ };
36
+ export type SnapshotResponse = {
37
+ data: Blob | string;
38
+ width: number;
39
+ height: number;
40
+ };
1
41
  /**
2
42
  * 快照插件,生成视图
3
43
  */
4
44
  export declare class Snapshot {
5
45
  static pluginName: string;
6
- lf: any;
46
+ lf: LogicFlow;
7
47
  offsetX?: number;
8
48
  offsetY?: number;
9
- fileName: string;
49
+ fileName?: string;
10
50
  customCssRules: string;
11
51
  useGlobalRules: boolean;
12
52
  constructor({ lf }: {
13
53
  lf: any;
14
54
  });
15
- getSvgRootElement(lf: any): any;
16
- triggerDownload(imgURI: string): void;
17
- removeAnchor(element: any): void;
18
- removeRotateControl(element: any): void;
19
- getSnapshot(fileName: string, backgroundColor: string): void;
20
- getSnapshotBase64(backgroundColor: string): Promise<unknown>;
21
- getSnapshotBlob(backgroundColor: string): Promise<unknown>;
22
- getClassRules(): string;
23
- getCanvasData(svg: SVGGraphicsElement, backgroundColor: string): Promise<any>;
55
+ /**
56
+ * 获取svgRoot对象dom: 画布元素(不包含grid背景)
57
+ * @param lf LogicFlow
58
+ * @returns
59
+ */
60
+ getSvgRootElement(lf: LogicFlow): Element;
61
+ /**
62
+ * 通过 imgUrl 下载图片
63
+ * @param imgUrl
64
+ */
65
+ triggerDownload(imgUrl: string): void;
66
+ /**
67
+ * 删除锚点
68
+ * @param element ChildNode
69
+ */
70
+ private removeAnchor;
71
+ /**
72
+ * 删除旋转按钮
73
+ * @param element
74
+ */
75
+ private removeRotateControl;
76
+ /**
77
+ * 下载图片
78
+ * @param fileName string
79
+ * @param toImageOptions
80
+ */
81
+ private getSnapshot;
82
+ /**
83
+ * 获取base64对象
84
+ * @param backgroundColor string | undefined
85
+ * @param fileType string | undefined
86
+ * @returns Promise<SnapshotResponse>
87
+ */
88
+ private getSnapshotBase64;
89
+ /**
90
+ * 获取Blob对象
91
+ * @param backgroundColor string | undefined
92
+ * @param fileType string | undefined
93
+ * @returns
94
+ */
95
+ private getSnapshotBlob;
96
+ /**
97
+ * 获取脚本css样式
98
+ * @returns rules string
99
+ */
100
+ private getClassRules;
101
+ /**
102
+ * 获取图片生成中间产物canvas对象,用户转换为其他需要的格式
103
+ * @param svg Element
104
+ * @param toImageOptions ToImageOptions
105
+ * @returns Promise<HTMLCanvasElement>
106
+ */
107
+ private getCanvasData;
108
+ /**
109
+ * 克隆并处理画布节点
110
+ * @param svg Node
111
+ * @returns
112
+ */
113
+ private cloneSvg;
24
114
  }
25
115
  export default Snapshot;