geoiq-frontend-ui-kit 2.0.2 → 2.0.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.
- package/dist/components/organisms/image-editor/components/line-session-bar.d.ts +20 -0
- package/dist/components/organisms/image-editor/components/line-session-bar.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/panel-insert.d.ts.map +1 -1
- package/dist/components/organisms/image-editor/components/panel-selected.d.ts.map +1 -1
- package/dist/components/organisms/image-editor/components/panel.d.ts.map +1 -1
- package/dist/components/organisms/image-editor/components/saved-layers-list.d.ts +9 -0
- package/dist/components/organisms/image-editor/components/saved-layers-list.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/image-editor-modal.d.ts.map +1 -1
- package/dist/components/organisms/image-editor/image-editor.types.d.ts +73 -0
- package/dist/components/organisms/image-editor/image-editor.types.d.ts.map +1 -1
- package/dist/components/organisms/image-editor/use-image-editor.d.ts.map +1 -1
- package/dist/components/ui/request-credits-view/component/request-credit-dialog.d.ts.map +1 -1
- package/dist/index.es100.js +147 -120
- package/dist/index.es100.js.map +1 -1
- package/dist/index.es101.js +16 -11
- package/dist/index.es101.js.map +1 -1
- package/dist/index.es102.js +7 -41
- package/dist/index.es102.js.map +1 -1
- package/dist/index.es103.js +21 -10
- package/dist/index.es103.js.map +1 -1
- package/dist/index.es104.js +7 -74
- package/dist/index.es104.js.map +1 -1
- package/dist/index.es105.js +177 -30
- package/dist/index.es105.js.map +1 -1
- package/dist/index.es106.js +45 -16
- package/dist/index.es106.js.map +1 -1
- package/dist/index.es107.js +42 -20
- package/dist/index.es107.js.map +1 -1
- package/dist/index.es108.js +22 -12
- package/dist/index.es108.js.map +1 -1
- package/dist/index.es109.js +122 -98
- package/dist/index.es109.js.map +1 -1
- package/dist/index.es11.js +1 -1
- package/dist/index.es110.js +33 -62
- package/dist/index.es110.js.map +1 -1
- package/dist/index.es111.js +60 -52
- package/dist/index.es111.js.map +1 -1
- package/dist/index.es112.js +10 -41
- package/dist/index.es112.js.map +1 -1
- package/dist/index.es113.js +21 -11
- package/dist/index.es113.js.map +1 -1
- package/dist/index.es114.js +42 -92
- package/dist/index.es114.js.map +1 -1
- package/dist/index.es115.js +37 -16
- package/dist/index.es115.js.map +1 -1
- package/dist/index.es116.js +12 -99
- package/dist/index.es116.js.map +1 -1
- package/dist/index.es117.js +92 -13
- package/dist/index.es117.js.map +1 -1
- package/dist/index.es118.js +13 -101
- package/dist/index.es118.js.map +1 -1
- package/dist/index.es119.js +71 -20
- package/dist/index.es119.js.map +1 -1
- package/dist/index.es12.js +1 -1
- package/dist/index.es120.js +34 -25
- package/dist/index.es120.js.map +1 -1
- package/dist/index.es121.js +20 -22
- package/dist/index.es121.js.map +1 -1
- package/dist/index.es122.js +16 -45
- package/dist/index.es122.js.map +1 -1
- package/dist/index.es123.js +11 -34
- package/dist/index.es123.js.map +1 -1
- package/dist/index.es124.js +96 -61
- package/dist/index.es124.js.map +1 -1
- package/dist/index.es125.js +57 -174
- package/dist/index.es125.js.map +1 -1
- package/dist/index.es126.js +50 -17
- package/dist/index.es126.js.map +1 -1
- package/dist/index.es127.js +2 -2
- package/dist/index.es128.js +2 -2
- package/dist/index.es129.js +1 -1
- package/dist/index.es130.js +1 -1
- package/dist/index.es131.js +2 -2
- package/dist/index.es132.js +35 -38
- package/dist/index.es132.js.map +1 -1
- package/dist/index.es133.js +41 -7
- package/dist/index.es133.js.map +1 -1
- package/dist/index.es134.js +88 -7
- package/dist/index.es134.js.map +1 -1
- package/dist/index.es135.js +14 -34
- package/dist/index.es135.js.map +1 -1
- package/dist/index.es136.js +269 -35
- package/dist/index.es136.js.map +1 -1
- package/dist/index.es137.js +7 -2
- package/dist/index.es137.js.map +1 -1
- package/dist/index.es138.js +23 -25
- package/dist/index.es138.js.map +1 -1
- package/dist/index.es139.js +169 -15
- package/dist/index.es139.js.map +1 -1
- package/dist/index.es140.js +82 -7
- package/dist/index.es140.js.map +1 -1
- package/dist/index.es141.js +73 -21
- package/dist/index.es141.js.map +1 -1
- package/dist/index.es142.js +3 -168
- package/dist/index.es142.js.map +1 -1
- package/dist/index.es143.js +56 -82
- package/dist/index.es143.js.map +1 -1
- package/dist/index.es144.js +119 -4
- package/dist/index.es144.js.map +1 -1
- package/dist/index.es145.js +405 -56
- package/dist/index.es145.js.map +1 -1
- package/dist/index.es146.js +25 -110
- package/dist/index.es146.js.map +1 -1
- package/dist/index.es147.js +60 -314
- package/dist/index.es147.js.map +1 -1
- package/dist/index.es148.js +29 -24
- package/dist/index.es148.js.map +1 -1
- package/dist/index.es149.js +21 -64
- package/dist/index.es149.js.map +1 -1
- package/dist/index.es150.js +36 -30
- package/dist/index.es150.js.map +1 -1
- package/dist/index.es151.js +211 -24
- package/dist/index.es151.js.map +1 -1
- package/dist/index.es152.js +141 -35
- package/dist/index.es152.js.map +1 -1
- package/dist/index.es153.js +141 -140
- package/dist/index.es153.js.map +1 -1
- package/dist/index.es154.js +45 -142
- package/dist/index.es154.js.map +1 -1
- package/dist/index.es155.js +353 -45
- package/dist/index.es155.js.map +1 -1
- package/dist/index.es156.js +14 -10
- package/dist/index.es156.js.map +1 -1
- package/dist/index.es157.js +10 -42
- package/dist/index.es157.js.map +1 -1
- package/dist/index.es158.js +44 -5
- package/dist/index.es158.js.map +1 -1
- package/dist/index.es159.js +5 -11
- package/dist/index.es159.js.map +1 -1
- package/dist/index.es16.js +1 -1
- package/dist/index.es160.js +10 -10
- package/dist/index.es160.js.map +1 -1
- package/dist/index.es161.js +11 -2
- package/dist/index.es161.js.map +1 -1
- package/dist/index.es162.js +2 -91
- package/dist/index.es162.js.map +1 -1
- package/dist/index.es163.js +2 -213
- package/dist/index.es163.js.map +1 -1
- package/dist/index.es164.js +23 -52
- package/dist/index.es164.js.map +1 -1
- package/dist/index.es165.js +88 -33
- package/dist/index.es165.js.map +1 -1
- package/dist/index.es166.js +52 -31
- package/dist/index.es166.js.map +1 -1
- package/dist/index.es167.js +32 -29
- package/dist/index.es167.js.map +1 -1
- package/dist/index.es168.js +26 -84
- package/dist/index.es168.js.map +1 -1
- package/dist/index.es169.js +27 -111
- package/dist/index.es169.js.map +1 -1
- package/dist/index.es170.js +97 -285
- package/dist/index.es170.js.map +1 -1
- package/dist/index.es171.js +251 -30
- package/dist/index.es171.js.map +1 -1
- package/dist/index.es172.js +63 -11
- package/dist/index.es172.js.map +1 -1
- package/dist/index.es173.js +284 -82
- package/dist/index.es173.js.map +1 -1
- package/dist/index.es174.js +29 -70
- package/dist/index.es174.js.map +1 -1
- package/dist/index.es175.js +10 -114
- package/dist/index.es175.js.map +1 -1
- package/dist/index.es176.js +23 -106
- package/dist/index.es176.js.map +1 -1
- package/dist/index.es177.js +19 -82
- package/dist/index.es177.js.map +1 -1
- package/dist/index.es178.js +63 -109
- package/dist/index.es178.js.map +1 -1
- package/dist/index.es179.js +63 -117
- package/dist/index.es179.js.map +1 -1
- package/dist/index.es180.js +112 -23
- package/dist/index.es180.js.map +1 -1
- package/dist/index.es181.js +103 -18
- package/dist/index.es181.js.map +1 -1
- package/dist/index.es182.js +86 -5
- package/dist/index.es182.js.map +1 -1
- package/dist/index.es183.js +133 -0
- package/dist/index.es183.js.map +1 -0
- package/dist/index.es184.js +133 -0
- package/dist/index.es184.js.map +1 -0
- package/dist/index.es185.js +9 -0
- package/dist/index.es185.js.map +1 -0
- package/dist/index.es19.js +1 -1
- package/dist/index.es2.js +21 -21
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es20.js +1 -1
- package/dist/index.es21.js +3 -3
- package/dist/index.es22.js +1 -1
- package/dist/index.es25.js +1 -1
- package/dist/index.es27.js +1 -1
- package/dist/index.es28.js +2 -2
- package/dist/index.es30.js +1 -1
- package/dist/index.es32.js +1 -1
- package/dist/index.es33.js +1 -1
- package/dist/index.es45.js +48 -46
- package/dist/index.es45.js.map +1 -1
- package/dist/index.es46.js +2 -2
- package/dist/index.es47.js +1 -1
- package/dist/index.es48.js +1 -1
- package/dist/index.es53.js +1 -1
- package/dist/index.es54.js +1 -1
- package/dist/index.es57.js +1 -1
- package/dist/index.es59.js +1 -1
- package/dist/index.es67.js +2 -2
- package/dist/index.es68.js +1 -1
- package/dist/index.es71.js +1 -1
- package/dist/index.es72.js +7 -7
- package/dist/index.es73.js +2 -2
- package/dist/index.es85.js +1 -1
- package/dist/index.es97.js +16 -11
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +89 -262
- package/dist/index.es98.js.map +1 -1
- package/dist/index.es99.js +13 -87
- package/dist/index.es99.js.map +1 -1
- package/dist/styles.css +55 -0
- package/package.json +2 -1
package/dist/index.es146.js
CHANGED
|
@@ -1,120 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
stickers: e.stickers || [],
|
|
11
|
-
listeners: { open: [], close: [], save: [], change: [], load: [] },
|
|
12
|
-
notify: () => {
|
|
13
|
-
},
|
|
14
|
-
sourceCanvas: o(),
|
|
15
|
-
originalCanvas: null,
|
|
16
|
-
layers: [],
|
|
17
|
-
selectedId: null,
|
|
18
|
-
nextId: 1,
|
|
19
|
-
undoStack: [],
|
|
20
|
-
redoStack: [],
|
|
21
|
-
mode: "select",
|
|
22
|
-
viewScale: 1,
|
|
23
|
-
zoom: 1,
|
|
24
|
-
fitScale: 1,
|
|
25
|
-
selectedShapeType: "rect",
|
|
26
|
-
shapeFill: "stroke",
|
|
27
|
-
shapeWidth: 6,
|
|
28
|
-
brushSize: 8,
|
|
29
|
-
brushStyle: "round",
|
|
30
|
-
textFont: a[0].value,
|
|
31
|
-
textSize: 64,
|
|
32
|
-
textColor: "#111111",
|
|
33
|
-
shapeColor: "#111111",
|
|
34
|
-
drawColor: "#111111",
|
|
35
|
-
cropRatio: "free",
|
|
36
|
-
isSaving: !1,
|
|
37
|
-
isLoadingImage: !1,
|
|
38
|
-
statusText: "Ready",
|
|
39
|
-
adj: {
|
|
40
|
-
brightness: 100,
|
|
41
|
-
contrast: 100,
|
|
42
|
-
saturate: 100,
|
|
43
|
-
sepia: 0,
|
|
44
|
-
blur: 0,
|
|
45
|
-
hue: 0,
|
|
46
|
-
filter: "none"
|
|
47
|
-
},
|
|
48
|
-
stickerImageCache: /* @__PURE__ */ new Map(),
|
|
49
|
-
canvasEl: null,
|
|
50
|
-
overlayEl: null,
|
|
51
|
-
textEditorEl: null,
|
|
52
|
-
stageEl: null,
|
|
53
|
-
ctx: null,
|
|
54
|
-
octx: null,
|
|
55
|
-
mounted: !1,
|
|
56
|
-
editingLayer: null,
|
|
57
|
-
editingSelectAll: !1,
|
|
58
|
-
dragMode: null,
|
|
59
|
-
dragStart: null,
|
|
60
|
-
dragOrig: null,
|
|
61
|
-
dragRect: null,
|
|
62
|
-
resizeCorner: null,
|
|
63
|
-
resizeAnchor: null,
|
|
64
|
-
resizeCenter: null,
|
|
65
|
-
resizeAnchorWorld: null,
|
|
66
|
-
rotateStart: null,
|
|
67
|
-
activePointerId: null,
|
|
68
|
-
pendingShape: null,
|
|
69
|
-
pendingStroke: null,
|
|
70
|
-
cropRect: null,
|
|
71
|
-
cropStart: null,
|
|
72
|
-
isOpenFlag: !1
|
|
1
|
+
import { emitChange as o, MAX_HISTORY as e } from "./index.es144.js";
|
|
2
|
+
import { syncCanvasSize as u, render as i } from "./index.es145.js";
|
|
3
|
+
function d(n) {
|
|
4
|
+
const r = document.createElement("canvas");
|
|
5
|
+
return r.width = n.sourceCanvas.width, r.height = n.sourceCanvas.height, r.getContext("2d").drawImage(n.sourceCanvas, 0, 0), {
|
|
6
|
+
raster: r,
|
|
7
|
+
layers: JSON.parse(JSON.stringify(n.layers)),
|
|
8
|
+
adj: { ...n.adj },
|
|
9
|
+
sel: n.selectedId
|
|
73
10
|
};
|
|
74
11
|
}
|
|
75
|
-
function
|
|
76
|
-
(e.
|
|
77
|
-
try {
|
|
78
|
-
r(l);
|
|
79
|
-
} catch (t) {
|
|
80
|
-
console.error(t);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
12
|
+
function p(n) {
|
|
13
|
+
n.undoStack.push(d(n)), n.undoStack.length > e && n.undoStack.shift(), n.redoStack = [], o(n);
|
|
83
14
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
15
|
+
function S(n) {
|
|
16
|
+
n.undoStack.pop(), o(n);
|
|
86
17
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
18
|
+
function c(n, r) {
|
|
19
|
+
n.sourceCanvas.width = r.raster.width, n.sourceCanvas.height = r.raster.height, n.sourceCanvas.getContext("2d").drawImage(r.raster, 0, 0), n.layers = JSON.parse(JSON.stringify(r.layers)), Object.assign(n.adj, r.adj), n.selectedId = r.sel, u(n), i(n);
|
|
89
20
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
21
|
+
function g(n) {
|
|
22
|
+
n.undoStack.length && (n.redoStack.push(d(n)), c(n, n.undoStack.pop()), n.statusText = "Undo", o(n));
|
|
92
23
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
version: i,
|
|
96
|
-
image: e.sourceCanvas.toDataURL("image/png"),
|
|
97
|
-
width: e.sourceCanvas.width,
|
|
98
|
-
height: e.sourceCanvas.height,
|
|
99
|
-
adjustments: { ...e.adj },
|
|
100
|
-
layers: JSON.parse(
|
|
101
|
-
JSON.stringify(
|
|
102
|
-
e.layers.map((n) => {
|
|
103
|
-
const l = { ...n };
|
|
104
|
-
return delete l._editing, l;
|
|
105
|
-
})
|
|
106
|
-
)
|
|
107
|
-
)
|
|
108
|
-
} : null;
|
|
24
|
+
function f(n) {
|
|
25
|
+
n.redoStack.length && (n.undoStack.push(d(n)), c(n, n.redoStack.pop()), n.statusText = "Redo", o(n));
|
|
109
26
|
}
|
|
110
27
|
export {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
u as getState,
|
|
118
|
-
f as resetAdjValues
|
|
28
|
+
c as applySnapshot,
|
|
29
|
+
S as popHistory,
|
|
30
|
+
p as pushHistory,
|
|
31
|
+
f as redo,
|
|
32
|
+
d as snapshot,
|
|
33
|
+
g as undo
|
|
119
34
|
};
|
|
120
35
|
//# sourceMappingURL=index.es146.js.map
|
package/dist/index.es146.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es146.js","sources":["../src/components/organisms/image-editor/engine/
|
|
1
|
+
{"version":3,"file":"index.es146.js","sources":["../src/components/organisms/image-editor/engine/history.js"],"sourcesContent":["import { MAX_HISTORY, emitChange } from './state.js'\nimport { render, syncCanvasSize } from './rendering.js'\n\nexport function snapshot(state) {\n const c = document.createElement('canvas')\n c.width = state.sourceCanvas.width\n c.height = state.sourceCanvas.height\n c.getContext('2d').drawImage(state.sourceCanvas, 0, 0)\n return {\n raster: c,\n layers: JSON.parse(JSON.stringify(state.layers)),\n adj: { ...state.adj },\n sel: state.selectedId,\n }\n}\n\nexport function pushHistory(state) {\n state.undoStack.push(snapshot(state))\n if (state.undoStack.length > MAX_HISTORY) state.undoStack.shift()\n state.redoStack = []\n emitChange(state)\n}\nexport function popHistory(state) {\n state.undoStack.pop()\n emitChange(state)\n}\n\nexport function applySnapshot(state, s) {\n state.sourceCanvas.width = s.raster.width\n state.sourceCanvas.height = s.raster.height\n state.sourceCanvas.getContext('2d').drawImage(s.raster, 0, 0)\n state.layers = JSON.parse(JSON.stringify(s.layers))\n Object.assign(state.adj, s.adj)\n state.selectedId = s.sel\n syncCanvasSize(state)\n render(state)\n}\n\nexport function undo(state) {\n if (!state.undoStack.length) return\n state.redoStack.push(snapshot(state))\n applySnapshot(state, state.undoStack.pop())\n state.statusText = 'Undo'\n emitChange(state)\n}\n\nexport function redo(state) {\n if (!state.redoStack.length) return\n state.undoStack.push(snapshot(state))\n applySnapshot(state, state.redoStack.pop())\n state.statusText = 'Redo'\n emitChange(state)\n}\n"],"names":["snapshot","state","c","pushHistory","MAX_HISTORY","emitChange","popHistory","applySnapshot","s","syncCanvasSize","render","undo","redo"],"mappings":";;AAGO,SAASA,EAASC,GAAO;AAC9B,QAAMC,IAAI,SAAS,cAAc,QAAQ;AACzC,SAAAA,EAAE,QAAQD,EAAM,aAAa,OAC7BC,EAAE,SAASD,EAAM,aAAa,QAC9BC,EAAE,WAAW,IAAI,EAAE,UAAUD,EAAM,cAAc,GAAG,CAAC,GAC9C;AAAA,IACL,QAAQC;AAAA,IACR,QAAQ,KAAK,MAAM,KAAK,UAAUD,EAAM,MAAM,CAAC;AAAA,IAC/C,KAAK,EAAE,GAAGA,EAAM,IAAG;AAAA,IACnB,KAAKA,EAAM;AAAA,EACf;AACA;AAEO,SAASE,EAAYF,GAAO;AACjC,EAAAA,EAAM,UAAU,KAAKD,EAASC,CAAK,CAAC,GAChCA,EAAM,UAAU,SAASG,KAAaH,EAAM,UAAU,MAAK,GAC/DA,EAAM,YAAY,CAAA,GAClBI,EAAWJ,CAAK;AAClB;AACO,SAASK,EAAWL,GAAO;AAChC,EAAAA,EAAM,UAAU,IAAG,GACnBI,EAAWJ,CAAK;AAClB;AAEO,SAASM,EAAcN,GAAOO,GAAG;AACtC,EAAAP,EAAM,aAAa,QAAQO,EAAE,OAAO,OACpCP,EAAM,aAAa,SAASO,EAAE,OAAO,QACrCP,EAAM,aAAa,WAAW,IAAI,EAAE,UAAUO,EAAE,QAAQ,GAAG,CAAC,GAC5DP,EAAM,SAAS,KAAK,MAAM,KAAK,UAAUO,EAAE,MAAM,CAAC,GAClD,OAAO,OAAOP,EAAM,KAAKO,EAAE,GAAG,GAC9BP,EAAM,aAAaO,EAAE,KACrBC,EAAeR,CAAK,GACpBS,EAAOT,CAAK;AACd;AAEO,SAASU,EAAKV,GAAO;AAC1B,EAAKA,EAAM,UAAU,WACrBA,EAAM,UAAU,KAAKD,EAASC,CAAK,CAAC,GACpCM,EAAcN,GAAOA,EAAM,UAAU,IAAG,CAAE,GAC1CA,EAAM,aAAa,QACnBI,EAAWJ,CAAK;AAClB;AAEO,SAASW,EAAKX,GAAO;AAC1B,EAAKA,EAAM,UAAU,WACrBA,EAAM,UAAU,KAAKD,EAASC,CAAK,CAAC,GACpCM,EAAcN,GAAOA,EAAM,UAAU,IAAG,CAAE,GAC1CA,EAAM,aAAa,QACnBI,EAAWJ,CAAK;AAClB;"}
|
package/dist/index.es147.js
CHANGED
|
@@ -1,325 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
t.viewScale = o;
|
|
18
|
-
const a = Math.round(t.sourceCanvas.width * o), r = Math.round(t.sourceCanvas.height * o);
|
|
19
|
-
t.canvasEl.style.width = t.overlayEl.style.width = a + "px", t.canvasEl.style.height = t.overlayEl.style.height = r + "px";
|
|
20
|
-
}
|
|
21
|
-
function u(t, e) {
|
|
22
|
-
if (t.zoom = Math.min(A, Math.max(R, e)), !t.mounted || !t.sourceCanvas.width) {
|
|
23
|
-
t.notify();
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
v(t), I(t), t.notify();
|
|
27
|
-
}
|
|
28
|
-
function J(t) {
|
|
29
|
-
u(t, t.zoom * m);
|
|
30
|
-
}
|
|
31
|
-
function V(t) {
|
|
32
|
-
u(t, t.zoom / m);
|
|
33
|
-
}
|
|
34
|
-
function j(t) {
|
|
35
|
-
u(t, 1);
|
|
36
|
-
}
|
|
37
|
-
function q(t) {
|
|
38
|
-
t.canvasEl.width = t.overlayEl.width = t.sourceCanvas.width, t.canvasEl.height = t.overlayEl.height = t.sourceCanvas.height, v(t);
|
|
39
|
-
}
|
|
40
|
-
function H(t) {
|
|
41
|
-
const { ctx: e, canvasEl: n, sourceCanvas: o } = t;
|
|
42
|
-
e.clearRect(0, 0, n.width, n.height);
|
|
43
|
-
const a = C(t);
|
|
44
|
-
if (k()) {
|
|
45
|
-
n.style.filter = "", e.filter = a, e.drawImage(o, 0, 0), e.filter = "none";
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
n.style.filter = a, e.drawImage(o, 0, 0);
|
|
49
|
-
}
|
|
50
|
-
function U(t) {
|
|
51
|
-
!t.mounted || !t.sourceCanvas.width || (H(t), I(t));
|
|
52
|
-
}
|
|
53
|
-
const g = 1.1;
|
|
54
|
-
function S(t, e) {
|
|
55
|
-
t.octx.font = `${e.size}px ${e.font}`;
|
|
56
|
-
const n = Math.max(e.boxWidth, 1), o = [];
|
|
57
|
-
return e.text.split(`
|
|
58
|
-
`).forEach((a) => {
|
|
59
|
-
const r = a.split(" ");
|
|
60
|
-
let i = "";
|
|
61
|
-
r.forEach((h) => {
|
|
62
|
-
const s = i ? i + " " + h : h;
|
|
63
|
-
i && t.octx.measureText(s).width > n ? (o.push(i), i = h) : i = s;
|
|
64
|
-
}), o.push(i);
|
|
65
|
-
}), o;
|
|
66
|
-
}
|
|
67
|
-
function c(t, e) {
|
|
68
|
-
if (e.type === "text") {
|
|
69
|
-
const n = S(t, e);
|
|
70
|
-
return {
|
|
71
|
-
x: e.x,
|
|
72
|
-
y: e.y,
|
|
73
|
-
w: e.boxWidth,
|
|
74
|
-
h: n.length * e.size * g
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (e.type === "shape" || e.type === "sticker")
|
|
1
|
+
import { pushHistory as d } from "./index.es146.js";
|
|
2
|
+
import { emitChange as u, resetAdjValues as v } from "./index.es144.js";
|
|
3
|
+
import { syncCanvasSize as C, render as x, normRect as w, layerBounds as R } from "./index.es145.js";
|
|
4
|
+
import { setMode as g } from "./index.es148.js";
|
|
5
|
+
function m(o, n, t) {
|
|
6
|
+
const r = R(o, n), a = { x: r.x + r.w / 2, y: r.y + r.h / 2 }, c = t(a);
|
|
7
|
+
return { x: c.x - a.x, y: c.y - a.y };
|
|
8
|
+
}
|
|
9
|
+
function T(o, n) {
|
|
10
|
+
d(o);
|
|
11
|
+
const t = n * Math.PI / 180, r = o.sourceCanvas.width, a = o.sourceCanvas.height, c = a, h = r, p = document.createElement("canvas");
|
|
12
|
+
p.width = c, p.height = h;
|
|
13
|
+
const e = p.getContext("2d");
|
|
14
|
+
e.translate(c / 2, h / 2), e.rotate(t), e.drawImage(o.sourceCanvas, -r / 2, -a / 2), o.sourceCanvas.width = c, o.sourceCanvas.height = h, o.sourceCanvas.getContext("2d").drawImage(p, 0, 0);
|
|
15
|
+
const s = (i, l) => {
|
|
16
|
+
const y = i - r / 2, f = l - a / 2;
|
|
78
17
|
return {
|
|
79
|
-
x: Math.
|
|
80
|
-
y: Math.
|
|
81
|
-
w: Math.abs(e.w),
|
|
82
|
-
h: Math.abs(e.h)
|
|
18
|
+
x: y * Math.cos(t) - f * Math.sin(t) + c / 2,
|
|
19
|
+
y: y * Math.sin(t) + f * Math.cos(t) + h / 2
|
|
83
20
|
};
|
|
84
|
-
if (e.type === "stroke") {
|
|
85
|
-
let n = 1 / 0, o = 1 / 0, a = -1 / 0, r = -1 / 0;
|
|
86
|
-
e.points.forEach((h) => {
|
|
87
|
-
n = Math.min(n, h.x), o = Math.min(o, h.y), a = Math.max(a, h.x), r = Math.max(r, h.y);
|
|
88
|
-
});
|
|
89
|
-
const i = e.width / 2;
|
|
90
|
-
return { x: n - i, y: o - i, w: a - n + i * 2, h: r - o + i * 2 };
|
|
91
|
-
}
|
|
92
|
-
return { x: 0, y: 0, w: 0, h: 0 };
|
|
93
|
-
}
|
|
94
|
-
function K(t, e) {
|
|
95
|
-
if (e.type !== "text") return;
|
|
96
|
-
const n = t.sourceCanvas.height - e.y;
|
|
97
|
-
for (; e.size > 10 && c(t, e).h > n && n > 0; )
|
|
98
|
-
e.size -= 1;
|
|
99
|
-
}
|
|
100
|
-
function Q(t, e) {
|
|
101
|
-
if (e.type !== "text") return;
|
|
102
|
-
const n = t.sourceCanvas.width - e.x;
|
|
103
|
-
e.boxWidth = Math.round(Math.max(20, Math.min(e.boxWidth, n)));
|
|
104
|
-
}
|
|
105
|
-
function E(t) {
|
|
106
|
-
return [
|
|
107
|
-
{ corner: "tl", x: t.x, y: t.y },
|
|
108
|
-
{ corner: "tr", x: t.x + t.w, y: t.y },
|
|
109
|
-
{ corner: "bl", x: t.x, y: t.y + t.h },
|
|
110
|
-
{ corner: "br", x: t.x + t.w, y: t.y + t.h }
|
|
111
|
-
];
|
|
112
|
-
}
|
|
113
|
-
const w = [
|
|
114
|
-
"line",
|
|
115
|
-
"dashedLine",
|
|
116
|
-
"arrow",
|
|
117
|
-
"dashedArrow",
|
|
118
|
-
"doubleArrow",
|
|
119
|
-
"dashedDoubleArrow"
|
|
120
|
-
], z = ["dashedLine", "dashedArrow", "dashedDoubleArrow"], D = {
|
|
121
|
-
arrow: ["end"],
|
|
122
|
-
dashedArrow: ["end"],
|
|
123
|
-
doubleArrow: ["end", "start"],
|
|
124
|
-
dashedDoubleArrow: ["end", "start"]
|
|
125
|
-
};
|
|
126
|
-
function W(t) {
|
|
127
|
-
const e = Math.max(1, t || 1);
|
|
128
|
-
return [Math.max(6, e * 2.5), Math.max(4, e * 1.75)];
|
|
129
|
-
}
|
|
130
|
-
function M(t, e, n, o, a) {
|
|
131
|
-
t.beginPath(), t.moveTo(e, n), t.lineTo(
|
|
132
|
-
e - a * Math.cos(o - Math.PI / 6),
|
|
133
|
-
n - a * Math.sin(o - Math.PI / 6)
|
|
134
|
-
), t.moveTo(e, n), t.lineTo(
|
|
135
|
-
e - a * Math.cos(o + Math.PI / 6),
|
|
136
|
-
n - a * Math.sin(o + Math.PI / 6)
|
|
137
|
-
), t.stroke();
|
|
138
|
-
}
|
|
139
|
-
const _ = 26, O = 6;
|
|
140
|
-
function y(t, e) {
|
|
141
|
-
const n = c(t, e);
|
|
142
|
-
return { x: n.x + n.w / 2, y: n.y + n.h / 2 };
|
|
143
|
-
}
|
|
144
|
-
function d(t, e, n) {
|
|
145
|
-
if (!n) return { x: t.x, y: t.y };
|
|
146
|
-
const o = n * Math.PI / 180, a = Math.cos(o), r = Math.sin(o), i = t.x - e.x, h = t.y - e.y;
|
|
147
|
-
return { x: e.x + i * a - h * r, y: e.y + i * r + h * a };
|
|
148
|
-
}
|
|
149
|
-
function X(t, e, n, o) {
|
|
150
|
-
const a = e.rotation || 0;
|
|
151
|
-
if (!a) {
|
|
152
|
-
o();
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const r = d(n, y(t, e), a);
|
|
156
|
-
o();
|
|
157
|
-
const i = d(n, y(t, e), a);
|
|
158
|
-
e.x += r.x - i.x, e.y += r.y - i.y;
|
|
159
|
-
}
|
|
160
|
-
function $(t, e, n) {
|
|
161
|
-
return d(n, y(t, e), -(e.rotation || 0));
|
|
162
|
-
}
|
|
163
|
-
function b(t, e) {
|
|
164
|
-
const n = c(t, e);
|
|
165
|
-
return {
|
|
166
|
-
x: n.x + n.w / 2,
|
|
167
|
-
y: n.y + n.h + _ / t.viewScale
|
|
168
21
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
function p(t, e, n) {
|
|
196
|
-
if (!n._editing) {
|
|
197
|
-
if (e.save(), n.type !== "stroke" || n.rotation) {
|
|
198
|
-
const o = c(t, n), a = o.x + o.w / 2, r = o.y + o.h / 2;
|
|
199
|
-
e.translate(a, r), n.rotation && e.rotate(n.rotation * Math.PI / 180), (n.flipH || n.flipV) && e.scale(n.flipH ? -1 : 1, n.flipV ? -1 : 1), e.translate(-a, -r);
|
|
200
|
-
}
|
|
201
|
-
if (n.type === "text") {
|
|
202
|
-
e.font = `${n.size}px ${n.font}`, e.fillStyle = n.color, e.textBaseline = "top", e.shadowColor = "rgba(0,0,0,.22)", e.shadowBlur = n.size * 0.05, e.shadowOffsetY = n.size * 0.02;
|
|
203
|
-
const o = n.size * g;
|
|
204
|
-
S(t, n).forEach((a, r) => {
|
|
205
|
-
e.fillText(a, n.x, n.y + r * o);
|
|
206
|
-
});
|
|
207
|
-
} else if (n.type === "shape") {
|
|
208
|
-
e.strokeStyle = n.color, e.fillStyle = n.color, e.lineWidth = n.width, e.lineCap = "round", e.lineJoin = "round";
|
|
209
|
-
const o = n.x, a = n.y, r = n.w, i = n.h;
|
|
210
|
-
if (n.shape === "rect")
|
|
211
|
-
n.fill === "fill" ? e.fillRect(o, a, r, i) : e.strokeRect(o, a, r, i);
|
|
212
|
-
else if (n.shape === "ellipse")
|
|
213
|
-
e.beginPath(), e.ellipse(
|
|
214
|
-
o + r / 2,
|
|
215
|
-
a + i / 2,
|
|
216
|
-
Math.abs(r / 2),
|
|
217
|
-
Math.abs(i / 2),
|
|
218
|
-
0,
|
|
219
|
-
0,
|
|
220
|
-
Math.PI * 2
|
|
221
|
-
), n.fill === "fill" ? e.fill() : e.stroke();
|
|
222
|
-
else if (n.shape === "circle") {
|
|
223
|
-
const h = Math.min(Math.abs(r), Math.abs(i)) / 2;
|
|
224
|
-
e.beginPath(), e.arc(o + r / 2, a + i / 2, h, 0, Math.PI * 2), n.fill === "fill" ? e.fill() : e.stroke();
|
|
225
|
-
} else if (w.includes(n.shape)) {
|
|
226
|
-
const h = o + r, s = a + i, l = z.includes(n.shape);
|
|
227
|
-
l && (e.lineCap = "butt", e.setLineDash(W(n.width))), e.beginPath(), e.moveTo(o, a), e.lineTo(h, s), e.stroke(), l && (e.setLineDash([]), e.lineCap = "round");
|
|
228
|
-
const x = Math.atan2(i, r), f = Math.max(14, n.width * 3);
|
|
229
|
-
(D[n.shape] || []).forEach((P) => {
|
|
230
|
-
P === "end" ? M(e, h, s, x, f) : M(e, o, a, x + Math.PI, f);
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
} else if (n.type === "stroke")
|
|
234
|
-
e.strokeStyle = n.color, e.lineWidth = n.width, e.lineCap = "round", e.lineJoin = "round", e.globalAlpha = n.style === "highlight" ? 0.35 : 1, e.beginPath(), n.points.forEach(
|
|
235
|
-
(o, a) => a === 0 ? e.moveTo(o.x, o.y) : e.lineTo(o.x, o.y)
|
|
236
|
-
), n.points.length === 1 && e.lineTo(n.points[0].x + 0.1, n.points[0].y + 0.1), e.stroke();
|
|
237
|
-
else if (n.type === "sticker") {
|
|
238
|
-
const o = t.stickerImageCache.get(n.src);
|
|
239
|
-
o && o.complete && o.naturalWidth && e.drawImage(o, n.x, n.y, n.w, n.h);
|
|
240
|
-
}
|
|
241
|
-
e.restore();
|
|
22
|
+
o.layers.forEach((i) => {
|
|
23
|
+
if (i.type === "text" || i.type === "shape" || i.type === "sticker") {
|
|
24
|
+
const l = m(o, i, (y) => s(y.x, y.y));
|
|
25
|
+
i.x += l.x, i.y += l.y, i.rotation = (((i.rotation || 0) + n) % 360 + 360) % 360;
|
|
26
|
+
} else i.type === "stroke" && (i.points = i.points.map((l) => s(l.x, l.y)));
|
|
27
|
+
}), C(o), x(o), o.statusText = n < 0 ? "Rotated left" : "Rotated right", u(o);
|
|
28
|
+
}
|
|
29
|
+
function b(o, n) {
|
|
30
|
+
d(o);
|
|
31
|
+
const t = o.sourceCanvas.width, r = o.sourceCanvas.height, a = document.createElement("canvas");
|
|
32
|
+
a.width = t, a.height = r;
|
|
33
|
+
const c = a.getContext("2d");
|
|
34
|
+
n ? (c.translate(t, 0), c.scale(-1, 1)) : (c.translate(0, r), c.scale(1, -1)), c.drawImage(o.sourceCanvas, 0, 0), o.sourceCanvas.getContext("2d").clearRect(0, 0, t, r), o.sourceCanvas.getContext("2d").drawImage(a, 0, 0);
|
|
35
|
+
const h = (e) => n ? t - e : e, p = (e) => n ? e : r - e;
|
|
36
|
+
o.layers.forEach((e) => {
|
|
37
|
+
if (e.type === "text" || e.type === "shape" || e.type === "sticker") {
|
|
38
|
+
const s = m(o, e, (i) => ({ x: h(i.x), y: p(i.y) }));
|
|
39
|
+
e.x += s.x, e.y += s.y, e.rotation = (360 - (e.rotation || 0) % 360) % 360, n ? e.flipH = !e.flipH : e.flipV = !e.flipV;
|
|
40
|
+
} else e.type === "stroke" && (e.points = e.points.map((s) => ({ x: h(s.x), y: p(s.y) })));
|
|
41
|
+
}), x(o), o.statusText = n ? "Flipped horizontally" : "Flipped vertically", u(o);
|
|
42
|
+
}
|
|
43
|
+
function H(o) {
|
|
44
|
+
if (!o.cropRect || Math.abs(o.cropRect.w) < 4 || Math.abs(o.cropRect.h) < 4) {
|
|
45
|
+
o.statusText = "Draw a crop box first", o.notify();
|
|
46
|
+
return;
|
|
242
47
|
}
|
|
48
|
+
d(o);
|
|
49
|
+
const n = w(o.cropRect), t = document.createElement("canvas");
|
|
50
|
+
t.width = Math.round(n.w), t.height = Math.round(n.h), t.getContext("2d").drawImage(o.sourceCanvas, n.x, n.y, n.w, n.h, 0, 0, n.w, n.h), o.sourceCanvas.width = t.width, o.sourceCanvas.height = t.height, o.sourceCanvas.getContext("2d").drawImage(t, 0, 0), o.layers.forEach((r) => {
|
|
51
|
+
r.type === "text" || r.type === "shape" || r.type === "sticker" ? (r.x -= n.x, r.y -= n.y) : r.type === "stroke" && (r.points = r.points.map((a) => ({ x: a.x - n.x, y: a.y - n.y })));
|
|
52
|
+
}), o.cropRect = null, g(o, "select"), C(o), x(o), o.statusText = "Cropped", u(o);
|
|
243
53
|
}
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
x: Math.min(t.x, t.x + t.w),
|
|
247
|
-
y: Math.min(t.y, t.y + t.h),
|
|
248
|
-
w: Math.abs(t.w),
|
|
249
|
-
h: Math.abs(t.h)
|
|
250
|
-
};
|
|
54
|
+
function V(o) {
|
|
55
|
+
g(o, "select");
|
|
251
56
|
}
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
if (!e) return;
|
|
255
|
-
const r = B(e), i = n.width, h = n.height;
|
|
256
|
-
o.save(), o.fillStyle = "rgba(0,0,0,.45)", o.fillRect(0, 0, i, Math.max(0, r.y)), o.fillRect(0, Math.min(h, r.y + r.h), i, Math.max(0, h - (r.y + r.h))), o.fillRect(0, r.y, Math.max(0, r.x), r.h), o.fillRect(Math.min(i, r.x + r.w), r.y, Math.max(0, i - (r.x + r.w)), r.h), o.strokeStyle = "#fff", o.lineWidth = Math.max(1, a.width / 500), o.setLineDash([8, 6]), o.strokeRect(r.x, r.y, r.w, r.h), o.restore();
|
|
57
|
+
function D(o, n) {
|
|
58
|
+
o.cropRatio = n, o.notify();
|
|
257
59
|
}
|
|
258
|
-
function
|
|
259
|
-
|
|
260
|
-
if (e.clearRect(0, 0, n.width, n.height), o.forEach((i) => {
|
|
261
|
-
try {
|
|
262
|
-
p(t, e, i);
|
|
263
|
-
} catch (h) {
|
|
264
|
-
console.error("[image-editor] failed to paint layer", i.id, i.type, h);
|
|
265
|
-
}
|
|
266
|
-
}), a === "select" && r != null) {
|
|
267
|
-
const i = o.find((h) => h.id === r);
|
|
268
|
-
if (i) {
|
|
269
|
-
const h = c(t, i);
|
|
270
|
-
if (e.save(), i.rotation) {
|
|
271
|
-
const l = y(t, i);
|
|
272
|
-
e.translate(l.x, l.y), e.rotate(i.rotation * Math.PI / 180), e.translate(-l.x, -l.y);
|
|
273
|
-
}
|
|
274
|
-
if (e.strokeStyle = "#2f5fd2", e.lineWidth = Math.max(1.2, 1.5 / t.viewScale), e.setLineDash([6 / t.viewScale, 4 / t.viewScale]), e.strokeRect(h.x - 4, h.y - 4, h.w + 8, h.h + 8), e.setLineDash([]), i.type !== "stroke") {
|
|
275
|
-
const l = 9 / t.viewScale;
|
|
276
|
-
e.fillStyle = "#fff", e.strokeStyle = "#2f5fd2", (i.type === "shape" && w.includes(i.shape) ? [
|
|
277
|
-
{ x: i.x, y: i.y },
|
|
278
|
-
{ x: i.x + i.w, y: i.y + i.h }
|
|
279
|
-
] : E(h)).forEach((f) => {
|
|
280
|
-
e.fillRect(f.x - l / 2, f.y - l / 2, l, l), e.strokeRect(f.x - l / 2, f.y - l / 2, l, l);
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
const s = b(t, i);
|
|
284
|
-
e.strokeStyle = "#2f5fd2", e.fillStyle = "#fff", e.beginPath(), e.moveTo(s.x, h.y + h.h + 4), e.lineTo(s.x, s.y), e.stroke(), e.beginPath(), e.arc(
|
|
285
|
-
s.x,
|
|
286
|
-
s.y,
|
|
287
|
-
O / t.viewScale,
|
|
288
|
-
0,
|
|
289
|
-
Math.PI * 2
|
|
290
|
-
), e.fill(), e.stroke(), e.restore();
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
t.pendingShape && p(t, e, t.pendingShape), a === "crop" && t.cropRect && F(t);
|
|
60
|
+
function F(o) {
|
|
61
|
+
o.originalCanvas && (d(o), o.sourceCanvas.width = o.originalCanvas.width, o.sourceCanvas.height = o.originalCanvas.height, o.sourceCanvas.getContext("2d").drawImage(o.originalCanvas, 0, 0), o.layers = [], o.selectedId = null, o.zoom = 1, v(o), C(o), x(o), o.statusText = "Reset to original", u(o));
|
|
294
62
|
}
|
|
295
63
|
export {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
Q as clampBoxWidth,
|
|
303
|
-
K as clampTextSize,
|
|
304
|
-
E as cornerPoints,
|
|
305
|
-
F as drawCropOverlay,
|
|
306
|
-
v as fitStage,
|
|
307
|
-
X as keepingFixed,
|
|
308
|
-
c as layerBounds,
|
|
309
|
-
y as layerCenter,
|
|
310
|
-
B as normRect,
|
|
311
|
-
L as onResizeHandle,
|
|
312
|
-
Y as onRotateHandle,
|
|
313
|
-
p as paintLayer,
|
|
314
|
-
U as render,
|
|
315
|
-
H as renderBase,
|
|
316
|
-
I as renderOverlay,
|
|
317
|
-
d as rotatePoint,
|
|
318
|
-
q as syncCanvasSize,
|
|
319
|
-
$ as toLayerSpace,
|
|
320
|
-
S as wrapTextLines,
|
|
321
|
-
J as zoomIn,
|
|
322
|
-
V as zoomOut,
|
|
323
|
-
j as zoomToFit
|
|
64
|
+
H as applyCrop,
|
|
65
|
+
V as cancelCrop,
|
|
66
|
+
b as flip,
|
|
67
|
+
F as resetToOriginal,
|
|
68
|
+
T as rotate,
|
|
69
|
+
D as setCropRatio
|
|
324
70
|
};
|
|
325
71
|
//# sourceMappingURL=index.es147.js.map
|