@duxweb/dvha-pro 1.0.23 → 1.0.25
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/cjs/component.cjs +1 -1
- package/dist/cjs/components/card/card.cjs +1 -1
- package/dist/cjs/components/card/store.cjs +1 -1
- package/dist/cjs/components/carousel/carousel.cjs +1 -1
- package/dist/cjs/components/chart/echart.cjs +1 -1
- package/dist/cjs/components/crop/imageCrop.cjs +1 -1
- package/dist/cjs/components/crop/imageCropModal.cjs +1 -1
- package/dist/cjs/components/dashboard/hello.cjs +1 -1
- package/dist/cjs/components/dashboard/helloBig.cjs +1 -1
- package/dist/cjs/components/dashboard/quick.cjs +1 -1
- package/dist/cjs/components/data/dynamicData.cjs +1 -1
- package/dist/cjs/components/data/dynamicSelect.cjs +1 -1
- package/dist/cjs/components/data/selectModal.cjs +1 -1
- package/dist/cjs/components/dialog/dialog.cjs +1 -1
- package/dist/cjs/components/drawer/drawer.cjs +1 -1
- package/dist/cjs/components/drawer/drawerPage.cjs +1 -1
- package/dist/cjs/components/editor/aiEditor.cjs +1 -1
- package/dist/cjs/components/form/drawerForm.cjs +1 -1
- package/dist/cjs/components/form/formItem.cjs +1 -1
- package/dist/cjs/components/form/formLayout.cjs +1 -1
- package/dist/cjs/components/form/modalForm.cjs +1 -1
- package/dist/cjs/components/form/pageForm.cjs +1 -1
- package/dist/cjs/components/form/settingForm.cjs +1 -1
- package/dist/cjs/components/icon/icon.cjs +1 -1
- package/dist/cjs/components/icon/iconPicker.cjs +1 -1
- package/dist/cjs/components/image/components/CanvasRuler.cjs +1 -0
- package/dist/cjs/components/image/elements/circle.cjs +1 -0
- package/dist/cjs/components/image/elements/image.cjs +1 -0
- package/dist/cjs/components/image/elements/index.cjs +1 -0
- package/dist/cjs/components/image/elements/rect.cjs +1 -0
- package/dist/cjs/components/image/elements/text.cjs +1 -0
- package/dist/cjs/components/image/hooks/usePosterEditor.cjs +1 -0
- package/dist/cjs/components/image/pages/LeftToolbar.cjs +1 -0
- package/dist/cjs/components/image/pages/Panel.cjs +1 -0
- package/dist/cjs/components/image/pages/PanelItem.cjs +1 -0
- package/dist/cjs/components/image/pages/RightPanel.cjs +1 -0
- package/dist/cjs/components/image/posterEditor.cjs +1 -0
- package/dist/cjs/components/layout/filter.cjs +1 -1
- package/dist/cjs/components/layout/filterLayout.cjs +1 -1
- package/dist/cjs/components/layout/list.cjs +1 -1
- package/dist/cjs/components/layout/table.cjs +1 -1
- package/dist/cjs/components/layout/tools.cjs +1 -1
- package/dist/cjs/components/level/level.cjs +1 -1
- package/dist/cjs/components/list/card.cjs +1 -1
- package/dist/cjs/components/list/list.cjs +1 -1
- package/dist/cjs/components/media/media.cjs +1 -1
- package/dist/cjs/components/modal/modal.cjs +1 -1
- package/dist/cjs/components/modal/modalPage.cjs +1 -1
- package/dist/cjs/components/modal/modalTab.cjs +1 -1
- package/dist/cjs/components/panel/alert.cjs +1 -1
- package/dist/cjs/components/panel/collapse.cjs +1 -1
- package/dist/cjs/components/panel/setting.cjs +1 -1
- package/dist/cjs/components/select/cardSelect.cjs +1 -1
- package/dist/cjs/components/status/listEmpty.cjs +1 -1
- package/dist/cjs/components/table/table.cjs +1 -1
- package/dist/cjs/components/table/tablePage.cjs +1 -1
- package/dist/cjs/components/tree/treeFilter.cjs +1 -1
- package/dist/cjs/components/upload/config.cjs +1 -1
- package/dist/cjs/components/upload/file.cjs +1 -1
- package/dist/cjs/components/upload/image.cjs +1 -1
- package/dist/cjs/components/upload/manage/item.cjs +1 -1
- package/dist/cjs/components/upload/manager.cjs +1 -1
- package/dist/cjs/components/widget/connect.cjs +1 -1
- package/dist/cjs/dvha-pro.css +1 -1
- package/dist/cjs/hooks/action.cjs +1 -1
- package/dist/cjs/hooks/dialog.cjs +1 -1
- package/dist/cjs/hooks/download.cjs +1 -1
- package/dist/cjs/hooks/drawer.cjs +1 -1
- package/dist/cjs/hooks/echart.cjs +1 -1
- package/dist/cjs/hooks/image.cjs +1 -1
- package/dist/cjs/hooks/level.cjs +1 -1
- package/dist/cjs/hooks/modal.cjs +1 -1
- package/dist/cjs/hooks/table/color.cjs +1 -0
- package/dist/cjs/hooks/table/column.cjs +1 -1
- package/dist/cjs/hooks/table/image.cjs +1 -1
- package/dist/cjs/hooks/table/input.cjs +1 -1
- package/dist/cjs/hooks/table/map.cjs +1 -1
- package/dist/cjs/hooks/table/media.cjs +1 -1
- package/dist/cjs/hooks/table/status.cjs +1 -1
- package/dist/cjs/hooks/table/switch.cjs +1 -1
- package/dist/cjs/hooks/table.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/pages/authLayout.cjs +1 -1
- package/dist/cjs/pages/layout/global.cjs +1 -1
- package/dist/cjs/pages/layout/page.cjs +1 -1
- package/dist/cjs/pages/layout/tab.cjs +1 -1
- package/dist/cjs/pages/layout.cjs +1 -1
- package/dist/cjs/pages/login.cjs +1 -1
- package/dist/cjs/pages/menu/avatar.cjs +1 -1
- package/dist/cjs/pages/menu/button.cjs +1 -1
- package/dist/cjs/pages/menu/cmd.cjs +1 -1
- package/dist/cjs/pages/menu/main.cjs +1 -1
- package/dist/cjs/pages/menu/mobile.cjs +1 -1
- package/dist/cjs/pages/page.cjs +1 -1
- package/dist/cjs/pages/page404.cjs +1 -1
- package/dist/cjs/pages/pageStatus.cjs +1 -1
- package/dist/cjs/stores/ui.cjs +1 -1
- package/dist/cjs/theme/uno.css.cjs +26 -1
- package/dist/esm/component.js +49 -47
- package/dist/esm/components/card/card.js +24 -27
- package/dist/esm/components/card/store.js +33 -39
- package/dist/esm/components/carousel/carousel.js +16 -19
- package/dist/esm/components/chart/echart.js +15 -13
- package/dist/esm/components/crop/imageCrop.js +45 -46
- package/dist/esm/components/crop/imageCropModal.js +36 -37
- package/dist/esm/components/dashboard/hello.js +27 -30
- package/dist/esm/components/dashboard/helloBig.js +328 -331
- package/dist/esm/components/dashboard/quick.js +30 -33
- package/dist/esm/components/data/dynamicData.js +86 -98
- package/dist/esm/components/data/dynamicSelect.js +42 -42
- package/dist/esm/components/data/selectModal.js +58 -60
- package/dist/esm/components/dialog/dialog.js +54 -55
- package/dist/esm/components/drawer/drawer.js +23 -23
- package/dist/esm/components/drawer/drawerPage.js +39 -49
- package/dist/esm/components/editor/aiEditor.js +64 -70
- package/dist/esm/components/form/drawerForm.js +61 -59
- package/dist/esm/components/form/formItem.js +45 -51
- package/dist/esm/components/form/formLayout.js +7 -10
- package/dist/esm/components/form/modalForm.js +63 -61
- package/dist/esm/components/form/pageForm.js +56 -57
- package/dist/esm/components/form/settingForm.js +43 -44
- package/dist/esm/components/icon/icon.js +15 -13
- package/dist/esm/components/icon/iconPicker.js +54 -58
- package/dist/esm/components/image/components/CanvasRuler.js +113 -0
- package/dist/esm/components/image/elements/circle.js +127 -0
- package/dist/esm/components/image/elements/image.js +131 -0
- package/dist/esm/components/image/elements/index.js +46 -0
- package/dist/esm/components/image/elements/rect.js +171 -0
- package/dist/esm/components/image/elements/text.js +206 -0
- package/dist/esm/components/image/hooks/usePosterEditor.js +434 -0
- package/dist/esm/components/image/pages/LeftToolbar.js +40 -0
- package/dist/esm/components/image/pages/Panel.js +31 -0
- package/dist/esm/components/image/pages/PanelItem.js +22 -0
- package/dist/esm/components/image/pages/RightPanel.js +421 -0
- package/dist/esm/components/image/posterEditor.js +227 -0
- package/dist/esm/components/layout/filter.js +13 -16
- package/dist/esm/components/layout/filterLayout.js +7 -10
- package/dist/esm/components/layout/list.js +312 -337
- package/dist/esm/components/layout/table.js +281 -294
- package/dist/esm/components/layout/tools.js +38 -41
- package/dist/esm/components/level/level.js +15 -13
- package/dist/esm/components/list/card.js +35 -38
- package/dist/esm/components/list/list.js +15 -18
- package/dist/esm/components/media/media.js +35 -36
- package/dist/esm/components/modal/modal.js +10 -10
- package/dist/esm/components/modal/modalPage.js +32 -36
- package/dist/esm/components/modal/modalTab.js +39 -45
- package/dist/esm/components/panel/alert.js +19 -22
- package/dist/esm/components/panel/collapse.js +33 -36
- package/dist/esm/components/panel/setting.js +25 -31
- package/dist/esm/components/select/cardSelect.js +27 -28
- package/dist/esm/components/status/listEmpty.js +13 -13
- package/dist/esm/components/table/table.js +15 -13
- package/dist/esm/components/table/tablePage.js +25 -25
- package/dist/esm/components/tree/treeFilter.js +137 -147
- package/dist/esm/components/upload/config.js +15 -27
- package/dist/esm/components/upload/file.js +115 -109
- package/dist/esm/components/upload/image.js +135 -130
- package/dist/esm/components/upload/manage/item.js +59 -60
- package/dist/esm/components/upload/manager.js +203 -218
- package/dist/esm/components/widget/connect.js +103 -106
- package/dist/esm/dvha-pro.css +1 -1
- package/dist/esm/hooks/action.js +115 -131
- package/dist/esm/hooks/dialog.js +15 -13
- package/dist/esm/hooks/download.js +55 -56
- package/dist/esm/hooks/drawer.js +15 -13
- package/dist/esm/hooks/echart.js +156 -179
- package/dist/esm/hooks/image.js +14 -15
- package/dist/esm/hooks/level.js +7 -7
- package/dist/esm/hooks/modal.js +15 -13
- package/dist/esm/hooks/table/color.js +19 -0
- package/dist/esm/hooks/table/column.js +25 -23
- package/dist/esm/hooks/table/image.js +17 -15
- package/dist/esm/hooks/table/input.js +28 -28
- package/dist/esm/hooks/table/map.js +7 -7
- package/dist/esm/hooks/table/media.js +15 -13
- package/dist/esm/hooks/table/status.js +8 -9
- package/dist/esm/hooks/table/switch.js +19 -19
- package/dist/esm/hooks/table.js +27 -31
- package/dist/esm/index.js +213 -200
- package/dist/esm/pages/authLayout.js +15 -13
- package/dist/esm/pages/layout/global.js +12 -15
- package/dist/esm/pages/layout/page.js +15 -13
- package/dist/esm/pages/layout/tab.js +58 -71
- package/dist/esm/pages/layout.js +7 -6
- package/dist/esm/pages/login.js +95 -98
- package/dist/esm/pages/menu/avatar.js +151 -162
- package/dist/esm/pages/menu/button.js +29 -31
- package/dist/esm/pages/menu/cmd.js +83 -87
- package/dist/esm/pages/menu/main.js +25 -23
- package/dist/esm/pages/menu/mobile.js +15 -13
- package/dist/esm/pages/page.js +21 -25
- package/dist/esm/pages/page404.js +13 -11
- package/dist/esm/pages/pageStatus.js +33 -34
- package/dist/esm/stores/ui.js +15 -15
- package/dist/esm/theme/uno.css.js +26 -1
- package/dist/types/components/form/drawerForm.d.ts +6 -0
- package/dist/types/components/form/modalForm.d.ts +6 -0
- package/dist/types/components/form/pageForm.d.ts +6 -0
- package/dist/types/components/form/settingForm.d.ts +6 -0
- package/dist/types/components/image/components/CanvasRuler.d.ts +43 -0
- package/dist/types/components/image/components/index.d.ts +1 -0
- package/dist/types/components/image/elements/circle.d.ts +3 -0
- package/dist/types/components/image/elements/image.d.ts +3 -0
- package/dist/types/components/image/elements/index.d.ts +15 -0
- package/dist/types/components/image/elements/rect.d.ts +3 -0
- package/dist/types/components/image/elements/text.d.ts +3 -0
- package/dist/types/components/image/elements/types.d.ts +51 -0
- package/dist/types/components/image/hooks/index.d.ts +1 -0
- package/dist/types/components/image/hooks/usePosterEditor.d.ts +48 -0
- package/dist/types/components/image/index.d.ts +4 -0
- package/dist/types/components/image/pages/LeftToolbar.d.ts +33 -0
- package/dist/types/components/image/pages/Panel.d.ts +11 -0
- package/dist/types/components/image/pages/PanelItem.d.ts +11 -0
- package/dist/types/components/image/pages/RightPanel.d.ts +208 -0
- package/dist/types/components/image/pages/index.d.ts +4 -0
- package/dist/types/components/image/posterEditor.d.ts +61 -0
- package/dist/types/components/image/types/editor.d.ts +47 -0
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/components/layout/table.d.ts +9 -0
- package/dist/types/components/stats/number.d.ts +1 -1
- package/dist/types/components/table/tablePage.d.ts +9 -0
- package/dist/types/components/upload/file.d.ts +5 -3
- package/dist/types/hooks/table/color.d.ts +13 -0
- package/dist/types/hooks/table/column.d.ts +1 -0
- package/dist/types/hooks/table/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/pages/layout/global.d.ts +0 -1
- package/package.json +6 -3
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Circle as c } from "fabric";
|
|
2
|
+
const r = {
|
|
3
|
+
type: "circle",
|
|
4
|
+
name: "圆形",
|
|
5
|
+
icon: "i-tabler:circle",
|
|
6
|
+
category: "basic",
|
|
7
|
+
defaultProps: {
|
|
8
|
+
type: "circle",
|
|
9
|
+
left: 100,
|
|
10
|
+
top: 100,
|
|
11
|
+
width: 100,
|
|
12
|
+
height: 100,
|
|
13
|
+
angle: 0,
|
|
14
|
+
scaleX: 1,
|
|
15
|
+
scaleY: 1,
|
|
16
|
+
visible: !0,
|
|
17
|
+
locked: !1,
|
|
18
|
+
radius: 50,
|
|
19
|
+
fill: "#00ff00",
|
|
20
|
+
stroke: "",
|
|
21
|
+
strokeWidth: 0,
|
|
22
|
+
strokeDashArray: null,
|
|
23
|
+
opacity: 1,
|
|
24
|
+
label: ""
|
|
25
|
+
},
|
|
26
|
+
createFabricObject: (e) => {
|
|
27
|
+
const l = new c({
|
|
28
|
+
left: e.left,
|
|
29
|
+
top: e.top,
|
|
30
|
+
radius: e.radius,
|
|
31
|
+
fill: e.fill,
|
|
32
|
+
stroke: e.stroke || void 0,
|
|
33
|
+
strokeWidth: e.strokeWidth,
|
|
34
|
+
strokeDashArray: e.strokeDashArray,
|
|
35
|
+
angle: e.angle,
|
|
36
|
+
scaleX: e.scaleX,
|
|
37
|
+
scaleY: e.scaleY,
|
|
38
|
+
opacity: e.opacity,
|
|
39
|
+
visible: e.visible,
|
|
40
|
+
selectable: !e.locked,
|
|
41
|
+
evented: !e.locked,
|
|
42
|
+
strokeUniform: !0,
|
|
43
|
+
lockUniScaling: !0
|
|
44
|
+
// 强制等比例缩放,确保圆形始终占满容器
|
|
45
|
+
});
|
|
46
|
+
return l.label = e.label, l;
|
|
47
|
+
},
|
|
48
|
+
getPropsFromFabricObject: (e) => {
|
|
49
|
+
const l = e, t = l.scaleX || 1, i = l.scaleY || 1, a = Math.round((l.radius || 50) * Math.max(t, i));
|
|
50
|
+
return {
|
|
51
|
+
type: "circle",
|
|
52
|
+
left: Math.round(l.left || 0),
|
|
53
|
+
top: Math.round(l.top || 0),
|
|
54
|
+
width: a * 2,
|
|
55
|
+
height: a * 2,
|
|
56
|
+
angle: Math.round(l.angle || 0),
|
|
57
|
+
scaleX: 1,
|
|
58
|
+
// 始终重置为1,将缩放应用到实际尺寸
|
|
59
|
+
scaleY: 1,
|
|
60
|
+
// 始终重置为1,将缩放应用到实际尺寸
|
|
61
|
+
visible: l.visible !== !1,
|
|
62
|
+
locked: !l.selectable,
|
|
63
|
+
radius: a,
|
|
64
|
+
fill: l.fill || "#00ff00",
|
|
65
|
+
stroke: l.stroke || "",
|
|
66
|
+
strokeWidth: Math.round(l.strokeWidth || 0),
|
|
67
|
+
strokeDashArray: l.strokeDashArray || null,
|
|
68
|
+
opacity: l.opacity || 1,
|
|
69
|
+
label: l.label || ""
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
getToolbarControls: (e) => [
|
|
73
|
+
{
|
|
74
|
+
key: "label",
|
|
75
|
+
label: "标签",
|
|
76
|
+
type: "text",
|
|
77
|
+
value: e.label,
|
|
78
|
+
options: { placeholder: "请输入标签" }
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
key: "radius",
|
|
82
|
+
label: "半径",
|
|
83
|
+
type: "number",
|
|
84
|
+
value: e.radius,
|
|
85
|
+
options: { min: 1, max: 1e3, step: 1 }
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
key: "fill",
|
|
89
|
+
label: "填充颜色",
|
|
90
|
+
type: "color",
|
|
91
|
+
value: e.fill
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: "stroke",
|
|
95
|
+
label: "边框颜色",
|
|
96
|
+
type: "color",
|
|
97
|
+
value: e.stroke
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
key: "strokeWidth",
|
|
101
|
+
label: "边框宽度",
|
|
102
|
+
type: "number",
|
|
103
|
+
value: e.strokeWidth,
|
|
104
|
+
options: { min: 0, max: 50, step: 1 }
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
key: "opacity",
|
|
108
|
+
label: "透明度",
|
|
109
|
+
type: "slider",
|
|
110
|
+
value: e.opacity,
|
|
111
|
+
options: { min: 0, max: 1, step: 0.01 }
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
onPropsChange: (e, l) => {
|
|
115
|
+
const t = l;
|
|
116
|
+
t.set({
|
|
117
|
+
radius: e.radius,
|
|
118
|
+
fill: e.fill,
|
|
119
|
+
stroke: e.stroke || void 0,
|
|
120
|
+
strokeWidth: e.strokeWidth,
|
|
121
|
+
opacity: e.opacity
|
|
122
|
+
}), t.label = e.label;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
export {
|
|
126
|
+
r as default
|
|
127
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { FabricImage as u } from "fabric";
|
|
2
|
+
const y = {
|
|
3
|
+
type: "image",
|
|
4
|
+
name: "图片",
|
|
5
|
+
icon: "i-tabler:photo",
|
|
6
|
+
category: "basic",
|
|
7
|
+
defaultProps: {
|
|
8
|
+
id: "",
|
|
9
|
+
type: "image",
|
|
10
|
+
left: 100,
|
|
11
|
+
top: 100,
|
|
12
|
+
width: 200,
|
|
13
|
+
height: 200,
|
|
14
|
+
angle: 0,
|
|
15
|
+
scaleX: 1,
|
|
16
|
+
scaleY: 1,
|
|
17
|
+
visible: !0,
|
|
18
|
+
locked: !1,
|
|
19
|
+
src: "",
|
|
20
|
+
opacity: 1
|
|
21
|
+
},
|
|
22
|
+
createFabricObject: (e) => u.fromURL(e.src || "", {
|
|
23
|
+
crossOrigin: "anonymous"
|
|
24
|
+
}).then((a) => (a.set({
|
|
25
|
+
left: e.left,
|
|
26
|
+
top: e.top,
|
|
27
|
+
width: e.width,
|
|
28
|
+
height: e.height,
|
|
29
|
+
angle: e.angle,
|
|
30
|
+
opacity: e.opacity,
|
|
31
|
+
visible: e.visible,
|
|
32
|
+
selectable: !e.locked,
|
|
33
|
+
evented: !e.locked
|
|
34
|
+
}), a)),
|
|
35
|
+
getPropsFromFabricObject: (e) => {
|
|
36
|
+
const a = e, t = (a.width || 200) * (a.scaleX || 1), i = (a.height || 200) * (a.scaleY || 1);
|
|
37
|
+
return {
|
|
38
|
+
type: "image",
|
|
39
|
+
left: Math.round(a.left || 0),
|
|
40
|
+
top: Math.round(a.top || 0),
|
|
41
|
+
width: Math.round(t),
|
|
42
|
+
height: Math.round(i),
|
|
43
|
+
angle: Math.round(a.angle || 0),
|
|
44
|
+
scaleX: a.scaleX || 1,
|
|
45
|
+
scaleY: a.scaleY || 1,
|
|
46
|
+
visible: a.visible !== !1,
|
|
47
|
+
locked: !a.selectable,
|
|
48
|
+
src: a.getSrc() || "",
|
|
49
|
+
opacity: a.opacity || 1,
|
|
50
|
+
cropX: 0,
|
|
51
|
+
cropY: 0,
|
|
52
|
+
borderRadius: 0
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
getToolbarControls: (e) => [
|
|
56
|
+
{
|
|
57
|
+
key: "src",
|
|
58
|
+
label: "选择图片",
|
|
59
|
+
type: "image",
|
|
60
|
+
value: e.src,
|
|
61
|
+
options: { placeholder: "点击选择图片文件" }
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: "width",
|
|
65
|
+
label: "宽度",
|
|
66
|
+
type: "number",
|
|
67
|
+
value: e.width,
|
|
68
|
+
options: { min: 10, max: 2e3, step: 1 }
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
key: "height",
|
|
72
|
+
label: "高度",
|
|
73
|
+
type: "number",
|
|
74
|
+
value: e.height,
|
|
75
|
+
options: { min: 10, max: 2e3, step: 1 }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: "opacity",
|
|
79
|
+
label: "透明度",
|
|
80
|
+
type: "slider",
|
|
81
|
+
value: e.opacity,
|
|
82
|
+
options: { min: 0, max: 1, step: 0.01 }
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
onPropsChange: (e, a) => {
|
|
86
|
+
const t = a;
|
|
87
|
+
if (e.src && e.src !== (t.getSrc() || "")) {
|
|
88
|
+
t.setSrc(e.src, { crossOrigin: "anonymous" }).then(() => {
|
|
89
|
+
const c = t.getElement().width, l = t.getElement().height, n = t.canvas, g = n?.width || 800, r = n?.height || 600, b = g / c, m = r / l, s = Math.min(b, m, 1);
|
|
90
|
+
t.set({
|
|
91
|
+
left: e.left,
|
|
92
|
+
top: e.top,
|
|
93
|
+
width: c,
|
|
94
|
+
height: l,
|
|
95
|
+
scaleX: s,
|
|
96
|
+
scaleY: s,
|
|
97
|
+
angle: e.angle,
|
|
98
|
+
opacity: e.opacity,
|
|
99
|
+
visible: e.visible,
|
|
100
|
+
selectable: !e.locked,
|
|
101
|
+
evented: !e.locked
|
|
102
|
+
}), t.setCoords(), t.canvas?.renderAll(), t.canvas?.fire("object:modified", { target: t });
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!e.src) {
|
|
107
|
+
t.setSrc("").then(() => {
|
|
108
|
+
t.set({
|
|
109
|
+
width: 200,
|
|
110
|
+
height: 200
|
|
111
|
+
}), t.setCoords(), t.canvas?.renderAll(), t.canvas?.fire("object:modified", { target: t });
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const i = t.width || 200, o = t.height || 200, h = e.width / i, d = e.height / o;
|
|
116
|
+
t.set({
|
|
117
|
+
left: e.left,
|
|
118
|
+
top: e.top,
|
|
119
|
+
scaleX: h,
|
|
120
|
+
scaleY: d,
|
|
121
|
+
angle: e.angle,
|
|
122
|
+
opacity: e.opacity,
|
|
123
|
+
visible: e.visible,
|
|
124
|
+
selectable: !e.locked,
|
|
125
|
+
evented: !e.locked
|
|
126
|
+
}), t.setCoords(), t.canvas?.renderAll(), t.canvas?.fire("object:modified", { target: t });
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
export {
|
|
130
|
+
y as default
|
|
131
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import s from "./circle.js";
|
|
2
|
+
import g from "./image.js";
|
|
3
|
+
import n from "./rect.js";
|
|
4
|
+
import m from "./text.js";
|
|
5
|
+
class o {
|
|
6
|
+
elements = /* @__PURE__ */ new Map();
|
|
7
|
+
// 注册元素
|
|
8
|
+
register(e) {
|
|
9
|
+
this.elements.set(e.type, e);
|
|
10
|
+
}
|
|
11
|
+
// 批量注册元素
|
|
12
|
+
registerAll(e) {
|
|
13
|
+
e.forEach((t) => this.register(t));
|
|
14
|
+
}
|
|
15
|
+
// 获取元素配置
|
|
16
|
+
get(e) {
|
|
17
|
+
return this.elements.get(e) || null;
|
|
18
|
+
}
|
|
19
|
+
// 获取所有元素配置
|
|
20
|
+
getAll() {
|
|
21
|
+
return Array.from(this.elements.values());
|
|
22
|
+
}
|
|
23
|
+
// 根据分类获取元素配置
|
|
24
|
+
getByCategory(e) {
|
|
25
|
+
return this.getAll().filter((t) => t.category === e);
|
|
26
|
+
}
|
|
27
|
+
// 获取所有分类
|
|
28
|
+
getCategories() {
|
|
29
|
+
const e = new Set(this.getAll().map((t) => t.category));
|
|
30
|
+
return Array.from(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const l = new o();
|
|
34
|
+
l.registerAll([
|
|
35
|
+
m,
|
|
36
|
+
n,
|
|
37
|
+
s,
|
|
38
|
+
g
|
|
39
|
+
]);
|
|
40
|
+
const f = l.getAll(), p = (r) => l.get(r), A = (r) => l.getByCategory(r);
|
|
41
|
+
export {
|
|
42
|
+
f as elementConfigs,
|
|
43
|
+
l as elementRegistry,
|
|
44
|
+
p as getElementConfig,
|
|
45
|
+
A as getElementsByCategory
|
|
46
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Rect as i } from "fabric";
|
|
2
|
+
const o = {
|
|
3
|
+
type: "rect",
|
|
4
|
+
name: "矩形",
|
|
5
|
+
icon: "i-tabler:square",
|
|
6
|
+
category: "basic",
|
|
7
|
+
defaultProps: {
|
|
8
|
+
id: "",
|
|
9
|
+
type: "rect",
|
|
10
|
+
left: 100,
|
|
11
|
+
top: 100,
|
|
12
|
+
width: 100,
|
|
13
|
+
height: 100,
|
|
14
|
+
angle: 0,
|
|
15
|
+
scaleX: 1,
|
|
16
|
+
scaleY: 1,
|
|
17
|
+
visible: !0,
|
|
18
|
+
locked: !1,
|
|
19
|
+
fill: "#ff0000",
|
|
20
|
+
stroke: "",
|
|
21
|
+
strokeWidth: 0,
|
|
22
|
+
strokeDashArray: null,
|
|
23
|
+
rx: 0,
|
|
24
|
+
ry: 0,
|
|
25
|
+
opacity: 1,
|
|
26
|
+
label: ""
|
|
27
|
+
},
|
|
28
|
+
createFabricObject: (e) => {
|
|
29
|
+
const t = new i({
|
|
30
|
+
left: e.left,
|
|
31
|
+
top: e.top,
|
|
32
|
+
width: e.width,
|
|
33
|
+
height: e.height,
|
|
34
|
+
fill: e.fill,
|
|
35
|
+
stroke: e.stroke || void 0,
|
|
36
|
+
strokeWidth: e.strokeWidth,
|
|
37
|
+
strokeDashArray: e.strokeDashArray,
|
|
38
|
+
rx: e.rx,
|
|
39
|
+
ry: e.ry,
|
|
40
|
+
angle: e.angle,
|
|
41
|
+
scaleX: e.scaleX,
|
|
42
|
+
scaleY: e.scaleY,
|
|
43
|
+
opacity: e.opacity,
|
|
44
|
+
visible: e.visible,
|
|
45
|
+
selectable: !e.locked,
|
|
46
|
+
evented: !e.locked,
|
|
47
|
+
strokeUniform: !0,
|
|
48
|
+
// 支持等比例缩放:用户可以按住Shift键进行等比例缩放
|
|
49
|
+
uniformScaling: !1
|
|
50
|
+
// 默认不强制等比例,但支持Shift键等比例缩放
|
|
51
|
+
});
|
|
52
|
+
return t.setControlsVisibility({
|
|
53
|
+
mtr: !0,
|
|
54
|
+
// 旋转控制点
|
|
55
|
+
mt: !0,
|
|
56
|
+
// 顶部中间
|
|
57
|
+
mb: !0,
|
|
58
|
+
// 底部中间
|
|
59
|
+
ml: !0,
|
|
60
|
+
// 左侧中间
|
|
61
|
+
mr: !0,
|
|
62
|
+
// 右侧中间
|
|
63
|
+
tl: !0,
|
|
64
|
+
// 左上角 - 支持等比例缩放
|
|
65
|
+
tr: !0,
|
|
66
|
+
// 右上角 - 支持等比例缩放
|
|
67
|
+
bl: !0,
|
|
68
|
+
// 左下角 - 支持等比例缩放
|
|
69
|
+
br: !0
|
|
70
|
+
// 右下角 - 支持等比例缩放
|
|
71
|
+
}), t.label = e.label, t;
|
|
72
|
+
},
|
|
73
|
+
getPropsFromFabricObject: (e) => {
|
|
74
|
+
const t = e, l = t.scaleX || 1, a = t.scaleY || 1;
|
|
75
|
+
return {
|
|
76
|
+
type: "rect",
|
|
77
|
+
left: Math.round(t.left || 0),
|
|
78
|
+
top: Math.round(t.top || 0),
|
|
79
|
+
width: Math.round((t.width || 100) * l),
|
|
80
|
+
height: Math.round((t.height || 100) * a),
|
|
81
|
+
angle: Math.round(t.angle || 0),
|
|
82
|
+
scaleX: 1,
|
|
83
|
+
// 始终重置为1,将缩放应用到实际尺寸
|
|
84
|
+
scaleY: 1,
|
|
85
|
+
// 始终重置为1,将缩放应用到实际尺寸
|
|
86
|
+
visible: t.visible !== !1,
|
|
87
|
+
locked: !t.selectable,
|
|
88
|
+
fill: t.fill || "#ff0000",
|
|
89
|
+
stroke: t.stroke || "",
|
|
90
|
+
strokeWidth: Math.round(t.strokeWidth || 0),
|
|
91
|
+
strokeDashArray: t.strokeDashArray || null,
|
|
92
|
+
rx: Math.round(t.rx || 0),
|
|
93
|
+
ry: Math.round(t.ry || 0),
|
|
94
|
+
opacity: t.opacity || 1,
|
|
95
|
+
label: t.label || ""
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
getToolbarControls: (e) => [
|
|
99
|
+
{
|
|
100
|
+
key: "label",
|
|
101
|
+
label: "标签",
|
|
102
|
+
type: "text",
|
|
103
|
+
value: e.label,
|
|
104
|
+
options: { placeholder: "请输入标签" }
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
key: "width",
|
|
108
|
+
label: "宽度",
|
|
109
|
+
type: "number",
|
|
110
|
+
value: e.width,
|
|
111
|
+
options: { min: 1, max: 2e3, step: 1 }
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: "height",
|
|
115
|
+
label: "高度",
|
|
116
|
+
type: "number",
|
|
117
|
+
value: e.height,
|
|
118
|
+
options: { min: 1, max: 2e3, step: 1 }
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
key: "fill",
|
|
122
|
+
label: "填充颜色",
|
|
123
|
+
type: "color",
|
|
124
|
+
value: e.fill
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
key: "stroke",
|
|
128
|
+
label: "边框颜色",
|
|
129
|
+
type: "color",
|
|
130
|
+
value: e.stroke
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
key: "strokeWidth",
|
|
134
|
+
label: "边框宽度",
|
|
135
|
+
type: "number",
|
|
136
|
+
value: e.strokeWidth,
|
|
137
|
+
options: { min: 0, max: 50, step: 1 }
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
key: "rx",
|
|
141
|
+
label: "圆角半径",
|
|
142
|
+
type: "number",
|
|
143
|
+
value: e.rx,
|
|
144
|
+
options: { min: 0, max: 100, step: 1 }
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
key: "opacity",
|
|
148
|
+
label: "透明度",
|
|
149
|
+
type: "slider",
|
|
150
|
+
value: e.opacity,
|
|
151
|
+
options: { min: 0, max: 1, step: 0.01 }
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
onPropsChange: (e, t) => {
|
|
155
|
+
const l = t;
|
|
156
|
+
l.set({
|
|
157
|
+
width: e.width,
|
|
158
|
+
height: e.height,
|
|
159
|
+
fill: e.fill,
|
|
160
|
+
stroke: e.stroke || void 0,
|
|
161
|
+
strokeWidth: e.strokeWidth,
|
|
162
|
+
rx: e.rx,
|
|
163
|
+
ry: e.rx,
|
|
164
|
+
// 让ry跟随rx
|
|
165
|
+
opacity: e.opacity
|
|
166
|
+
}), l.label = e.label;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
export {
|
|
170
|
+
o as default
|
|
171
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { Textbox as o } from "fabric";
|
|
2
|
+
const c = {
|
|
3
|
+
type: "text",
|
|
4
|
+
name: "文本",
|
|
5
|
+
icon: "i-tabler:typography",
|
|
6
|
+
category: "basic",
|
|
7
|
+
defaultProps: {
|
|
8
|
+
id: "",
|
|
9
|
+
type: "text",
|
|
10
|
+
left: 100,
|
|
11
|
+
top: 100,
|
|
12
|
+
width: 200,
|
|
13
|
+
angle: 0,
|
|
14
|
+
scaleX: 1,
|
|
15
|
+
scaleY: 1,
|
|
16
|
+
visible: !0,
|
|
17
|
+
locked: !1,
|
|
18
|
+
text: "双击编辑文本",
|
|
19
|
+
fontSize: 20,
|
|
20
|
+
fontFamily: "Arial",
|
|
21
|
+
fill: "#000000",
|
|
22
|
+
textAlign: "left",
|
|
23
|
+
fontWeight: "normal",
|
|
24
|
+
fontStyle: "normal",
|
|
25
|
+
underline: !1,
|
|
26
|
+
linethrough: !1
|
|
27
|
+
},
|
|
28
|
+
createFabricObject: (e) => {
|
|
29
|
+
const t = new o(e.text, {
|
|
30
|
+
left: e.left,
|
|
31
|
+
top: e.top,
|
|
32
|
+
width: e.width,
|
|
33
|
+
angle: e.angle,
|
|
34
|
+
scaleX: e.scaleX,
|
|
35
|
+
scaleY: e.scaleY,
|
|
36
|
+
visible: e.visible,
|
|
37
|
+
selectable: !e.locked,
|
|
38
|
+
evented: !e.locked,
|
|
39
|
+
fontSize: e.fontSize,
|
|
40
|
+
fontFamily: e.fontFamily,
|
|
41
|
+
fill: e.fill,
|
|
42
|
+
textAlign: e.textAlign,
|
|
43
|
+
fontWeight: e.fontWeight,
|
|
44
|
+
fontStyle: e.fontStyle,
|
|
45
|
+
underline: e.underline,
|
|
46
|
+
linethrough: e.linethrough,
|
|
47
|
+
// 启用自动换行的关键配置
|
|
48
|
+
splitByGrapheme: !0,
|
|
49
|
+
// 锁定高度缩放,只允许宽度缩放
|
|
50
|
+
lockScalingY: !0,
|
|
51
|
+
// 禁用高度手柄
|
|
52
|
+
setControlsVisibility: {
|
|
53
|
+
mt: !1,
|
|
54
|
+
// 顶部中间
|
|
55
|
+
mb: !1
|
|
56
|
+
// 底部中间
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
let l = e.fontSize;
|
|
60
|
+
return t.on("mousedown", () => {
|
|
61
|
+
l = t.fontSize || 20;
|
|
62
|
+
}), t.on("scaling", () => {
|
|
63
|
+
const n = t.scaleX || 1, i = Math.round(l * n), a = Math.max(8, Math.min(200, i));
|
|
64
|
+
t.set({
|
|
65
|
+
fontSize: a,
|
|
66
|
+
scaleX: 1,
|
|
67
|
+
scaleY: 1
|
|
68
|
+
}), t.canvas?.requestRenderAll();
|
|
69
|
+
}), t.on("mousedblclick", () => {
|
|
70
|
+
t.enterEditing(), t.selectAll();
|
|
71
|
+
}), t;
|
|
72
|
+
},
|
|
73
|
+
getPropsFromFabricObject: (e) => {
|
|
74
|
+
const t = e;
|
|
75
|
+
return {
|
|
76
|
+
left: Math.round(t.left || 0),
|
|
77
|
+
top: Math.round(t.top || 0),
|
|
78
|
+
width: Math.round(t.width || 0),
|
|
79
|
+
angle: Math.round(t.angle || 0),
|
|
80
|
+
scaleX: t.scaleX || 1,
|
|
81
|
+
scaleY: t.scaleY || 1,
|
|
82
|
+
visible: t.visible !== !1,
|
|
83
|
+
locked: !t.selectable,
|
|
84
|
+
text: t.text || "",
|
|
85
|
+
fontSize: Math.round(t.fontSize || 20),
|
|
86
|
+
fontFamily: t.fontFamily || "Arial",
|
|
87
|
+
fill: t.fill,
|
|
88
|
+
textAlign: t.textAlign || "left",
|
|
89
|
+
fontWeight: t.fontWeight || "normal",
|
|
90
|
+
fontStyle: t.fontStyle || "normal",
|
|
91
|
+
underline: t.underline || !1,
|
|
92
|
+
linethrough: t.linethrough || !1
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
onPropsChange: (e, t) => {
|
|
96
|
+
t.set({
|
|
97
|
+
left: e.left,
|
|
98
|
+
top: e.top,
|
|
99
|
+
width: e.width,
|
|
100
|
+
angle: e.angle,
|
|
101
|
+
visible: e.visible,
|
|
102
|
+
selectable: !e.locked,
|
|
103
|
+
evented: !e.locked,
|
|
104
|
+
text: e.text,
|
|
105
|
+
fontSize: e.fontSize,
|
|
106
|
+
fontFamily: e.fontFamily,
|
|
107
|
+
fill: e.fill,
|
|
108
|
+
textAlign: e.textAlign,
|
|
109
|
+
fontWeight: e.fontWeight,
|
|
110
|
+
fontStyle: e.fontStyle,
|
|
111
|
+
underline: e.underline,
|
|
112
|
+
linethrough: e.linethrough
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
getToolbarControls: (e) => [
|
|
116
|
+
{
|
|
117
|
+
key: "text",
|
|
118
|
+
label: "文本内容",
|
|
119
|
+
type: "text",
|
|
120
|
+
value: e.text
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
key: "fontSize",
|
|
124
|
+
label: "字体大小",
|
|
125
|
+
type: "number",
|
|
126
|
+
value: e.fontSize,
|
|
127
|
+
options: {
|
|
128
|
+
min: 8,
|
|
129
|
+
max: 200,
|
|
130
|
+
step: 1
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
key: "fontFamily",
|
|
135
|
+
label: "字体",
|
|
136
|
+
type: "select",
|
|
137
|
+
value: e.fontFamily,
|
|
138
|
+
options: {
|
|
139
|
+
choices: [
|
|
140
|
+
{ label: "Arial", value: "Arial" },
|
|
141
|
+
{ label: "微软雅黑", value: "Microsoft YaHei" },
|
|
142
|
+
{ label: "宋体", value: "SimSun" },
|
|
143
|
+
{ label: "黑体", value: "SimHei" }
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
key: "fill",
|
|
149
|
+
label: "颜色",
|
|
150
|
+
type: "color",
|
|
151
|
+
value: e.fill
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
key: "textAlign",
|
|
155
|
+
label: "对齐",
|
|
156
|
+
type: "select",
|
|
157
|
+
value: e.textAlign,
|
|
158
|
+
options: {
|
|
159
|
+
choices: [
|
|
160
|
+
{ label: "左对齐", value: "left" },
|
|
161
|
+
{ label: "居中", value: "center" },
|
|
162
|
+
{ label: "右对齐", value: "right" }
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: "fontWeight",
|
|
168
|
+
label: "粗体",
|
|
169
|
+
type: "select",
|
|
170
|
+
value: e.fontWeight,
|
|
171
|
+
options: {
|
|
172
|
+
choices: [
|
|
173
|
+
{ label: "正常", value: "normal" },
|
|
174
|
+
{ label: "粗体", value: "bold" }
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
key: "fontStyle",
|
|
180
|
+
label: "斜体",
|
|
181
|
+
type: "select",
|
|
182
|
+
value: e.fontStyle,
|
|
183
|
+
options: {
|
|
184
|
+
choices: [
|
|
185
|
+
{ label: "正常", value: "normal" },
|
|
186
|
+
{ label: "斜体", value: "italic" }
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
key: "underline",
|
|
192
|
+
label: "下划线",
|
|
193
|
+
type: "switch",
|
|
194
|
+
value: e.underline
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
key: "linethrough",
|
|
198
|
+
label: "删除线",
|
|
199
|
+
type: "switch",
|
|
200
|
+
value: e.linethrough
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
};
|
|
204
|
+
export {
|
|
205
|
+
c as default
|
|
206
|
+
};
|