@8btc/whiteboard 0.0.19-beta.2 → 0.0.19-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.
- package/dist/adapter/maze.js +117 -108
- package/dist/index.d.ts +4 -2
- package/dist/index.js +25 -25
- package/dist/maze.d.ts +6 -3
- package/package.json +1 -1
package/dist/adapter/maze.js
CHANGED
|
@@ -1,164 +1,173 @@
|
|
|
1
|
-
import { v4 as
|
|
1
|
+
import { v4 as _ } from "uuid";
|
|
2
2
|
import { N as M } from "../const-CpLk0Av6.js";
|
|
3
|
-
async function
|
|
4
|
-
return new Promise((o,
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
o({ width:
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
},
|
|
3
|
+
async function S(t) {
|
|
4
|
+
return new Promise((o, n) => {
|
|
5
|
+
const e = new Image();
|
|
6
|
+
e.onload = () => {
|
|
7
|
+
o({ width: e.naturalWidth, height: e.naturalHeight });
|
|
8
|
+
}, e.onerror = () => {
|
|
9
|
+
n(new Error(`Failed to load image: ${t}`));
|
|
10
|
+
}, e.src = t;
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function A(t) {
|
|
14
14
|
if (!t) return { x: 0, y: 0 };
|
|
15
15
|
if ((t.getState().nodes || []).length > 0) {
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
if (
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
|
|
16
|
+
const e = t.getMainLayer();
|
|
17
|
+
let i = 1 / 0, r = -1 / 0;
|
|
18
|
+
if (e.children.forEach((s) => {
|
|
19
|
+
if (s.visible() && s.getClassName() !== "Transformer" && s.hasName(M.selectable)) {
|
|
20
|
+
const a = s.getAttrs(), c = a.x || 0, d = a.y || 0, f = a.height || 0;
|
|
21
|
+
i = Math.min(i, c), r = Math.max(r, d + f);
|
|
22
22
|
}
|
|
23
|
-
}),
|
|
24
|
-
return { x:
|
|
23
|
+
}), i !== 1 / 0 && r !== -1 / 0)
|
|
24
|
+
return { x: i, y: r };
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const n = t.getState().viewport;
|
|
27
27
|
return {
|
|
28
|
-
x:
|
|
29
|
-
y:
|
|
28
|
+
x: n.x,
|
|
29
|
+
y: n.y
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
async function
|
|
32
|
+
async function p(t, o, n, e) {
|
|
33
33
|
if (!t) return;
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const i = Array.isArray(o) ? o : [o];
|
|
35
|
+
if (i.length === 0) return;
|
|
36
|
+
const r = e?.spacing ?? 20, s = e?.scrollToView ?? !0, a = e?.direction ?? "horizontal", c = e?.reuseExisting ?? !0, d = /* @__PURE__ */ new Map();
|
|
37
|
+
c && (t.getState().nodes || []).forEach((y) => {
|
|
38
|
+
y.$_type === "image" && y.$_imageUrl && d.set(y.$_imageUrl, y.id);
|
|
39
|
+
});
|
|
40
|
+
const f = await Promise.all(i.map((l) => S(l))), u = [], m = [];
|
|
41
|
+
let h = n.x, g = n.y;
|
|
42
|
+
return i.forEach((l, y) => {
|
|
43
|
+
if (c && d.has(l)) {
|
|
44
|
+
const x = d.get(l);
|
|
45
|
+
m.push(x);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const { width: w, height: $ } = f[y], I = _();
|
|
49
|
+
u.push({
|
|
41
50
|
id: I,
|
|
42
51
|
$_type: "image",
|
|
43
|
-
x:
|
|
44
|
-
y:
|
|
45
|
-
width:
|
|
46
|
-
height:
|
|
47
|
-
$_imageUrl:
|
|
48
|
-
}),
|
|
49
|
-
}), t.createNodes(
|
|
52
|
+
x: h,
|
|
53
|
+
y: g,
|
|
54
|
+
width: w,
|
|
55
|
+
height: $,
|
|
56
|
+
$_imageUrl: l
|
|
57
|
+
}), m.push(I), a === "horizontal" ? h += w + r : g += $ + r;
|
|
58
|
+
}), u.length > 0 && t.createNodes(u, !0), s && t.scrollToContent({ scale: !1, nodeIds: m }), m;
|
|
50
59
|
}
|
|
51
|
-
async function
|
|
60
|
+
async function L(t, o) {
|
|
52
61
|
if (!t) return;
|
|
53
|
-
const
|
|
54
|
-
return
|
|
55
|
-
x:
|
|
56
|
-
y:
|
|
62
|
+
const n = A(t);
|
|
63
|
+
return p(t, o, {
|
|
64
|
+
x: n.x,
|
|
65
|
+
y: n.y + 20
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
|
-
function
|
|
68
|
+
function X(t, o) {
|
|
60
69
|
if (!t) return;
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
let
|
|
64
|
-
if (t.getMainLayer().children.forEach((
|
|
65
|
-
if (
|
|
66
|
-
const u =
|
|
67
|
-
|
|
70
|
+
const n = t.getState().selectedNodeIds || [];
|
|
71
|
+
if (n.length === 0) return;
|
|
72
|
+
let e = 1 / 0, i = 1 / 0, r = -1 / 0, s = -1 / 0;
|
|
73
|
+
if (t.getMainLayer().children.forEach((f) => {
|
|
74
|
+
if (f.visible() && f.getClassName() !== "Transformer" && n.includes(f.id())) {
|
|
75
|
+
const u = f.getAttrs(), m = u.x || 0, h = u.y || 0, g = u.width || 0, l = u.height || 0;
|
|
76
|
+
e = Math.min(e, m), i = Math.min(i, h), r = Math.max(r, m + g), s = Math.max(s, h + l);
|
|
68
77
|
}
|
|
69
|
-
}),
|
|
78
|
+
}), e === 1 / 0 || i === 1 / 0 || r === -1 / 0 || s === -1 / 0)
|
|
70
79
|
return;
|
|
71
|
-
const
|
|
72
|
-
x:
|
|
73
|
-
y:
|
|
74
|
-
width:
|
|
75
|
-
height:
|
|
76
|
-
},
|
|
77
|
-
id:
|
|
80
|
+
const c = {
|
|
81
|
+
x: r + 20,
|
|
82
|
+
y: i,
|
|
83
|
+
width: r - e,
|
|
84
|
+
height: s - i
|
|
85
|
+
}, d = {
|
|
86
|
+
id: _(),
|
|
78
87
|
$_type: "html",
|
|
79
|
-
x:
|
|
80
|
-
y:
|
|
81
|
-
width:
|
|
82
|
-
height:
|
|
88
|
+
x: c.x,
|
|
89
|
+
y: c.y,
|
|
90
|
+
width: c.width,
|
|
91
|
+
height: c.height,
|
|
83
92
|
$_imageUrl: o,
|
|
84
93
|
// 示例 loading 图片 URL
|
|
85
94
|
$_htmlContent: `
|
|
86
95
|
<img alt="loading" src="${o}" style="width: 100%; height: 100%; object-fit: contain;" />
|
|
87
96
|
`
|
|
88
97
|
};
|
|
89
|
-
return t.createNodes([
|
|
98
|
+
return t.createNodes([d], !0), d.id;
|
|
90
99
|
}
|
|
91
|
-
function
|
|
100
|
+
function Y(t, o, n) {
|
|
92
101
|
if (!t) return;
|
|
93
|
-
const
|
|
94
|
-
if (!
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
|
|
102
|
+
const e = t.getCanvasNodeById(o);
|
|
103
|
+
if (!e) return;
|
|
104
|
+
const i = e.getConfig();
|
|
105
|
+
if (i.$_type !== "html") return;
|
|
106
|
+
const r = Array.isArray(n) ? n : [n];
|
|
107
|
+
if (r.length === 0) return;
|
|
108
|
+
const s = i.x, a = i.y;
|
|
109
|
+
p(t, r, { x: s, y: a }), t.deleteNodes([o]);
|
|
101
110
|
}
|
|
102
|
-
async function
|
|
111
|
+
async function R(t, o) {
|
|
103
112
|
if (!t) return null;
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
113
|
+
const n = t.getCanvasNodeById(o);
|
|
114
|
+
if (!n) return null;
|
|
115
|
+
const e = n.getConfig();
|
|
116
|
+
if (e.$_type !== "image-marker" || !e.$_relativeBox)
|
|
108
117
|
return null;
|
|
109
|
-
const
|
|
110
|
-
if (!r) return null;
|
|
111
|
-
const i = t.getCanvasNodeById(r);
|
|
118
|
+
const i = e.$_parentId;
|
|
112
119
|
if (!i) return null;
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
|
|
120
|
+
const r = t.getCanvasNodeById(i);
|
|
121
|
+
if (!r) return null;
|
|
122
|
+
const s = r.getConfig();
|
|
123
|
+
if (s.$_type !== "image" || !s.$_imageUrl) return null;
|
|
124
|
+
const { start: a, end: c } = e.$_relativeBox, d = a.ratioX, f = a.ratioY, u = c.ratioX - a.ratioX, m = c.ratioY - a.ratioY;
|
|
125
|
+
return new Promise((h) => {
|
|
117
126
|
const g = new Image();
|
|
118
127
|
g.crossOrigin = "anonymous", g.onload = () => {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
const N =
|
|
128
|
+
const l = g.naturalWidth, y = g.naturalHeight, w = d * l, $ = f * y, I = u * l, x = m * y, C = document.createElement("canvas");
|
|
129
|
+
C.width = I, C.height = x;
|
|
130
|
+
const N = C.getContext("2d");
|
|
122
131
|
if (!N) {
|
|
123
|
-
|
|
132
|
+
h(null);
|
|
124
133
|
return;
|
|
125
134
|
}
|
|
126
135
|
N.drawImage(
|
|
127
136
|
g,
|
|
128
|
-
I,
|
|
129
|
-
v,
|
|
130
137
|
w,
|
|
131
|
-
|
|
138
|
+
$,
|
|
139
|
+
I,
|
|
140
|
+
x,
|
|
132
141
|
0,
|
|
133
142
|
0,
|
|
134
|
-
|
|
135
|
-
|
|
143
|
+
I,
|
|
144
|
+
x
|
|
136
145
|
);
|
|
137
|
-
const
|
|
138
|
-
|
|
146
|
+
const v = C.toDataURL("image/png");
|
|
147
|
+
h(v);
|
|
139
148
|
}, g.onerror = () => {
|
|
140
|
-
console.error("Failed to load image:",
|
|
141
|
-
}, g.src =
|
|
149
|
+
console.error("Failed to load image:", s.$_imageUrl), h(null);
|
|
150
|
+
}, g.src = s.$_imageUrl;
|
|
142
151
|
});
|
|
143
152
|
}
|
|
144
|
-
function
|
|
153
|
+
function H(t) {
|
|
145
154
|
if (!t) return null;
|
|
146
155
|
const o = t.getState().selectedNodeIds || [];
|
|
147
156
|
if (o.length === 0) return null;
|
|
148
157
|
if (o.length === 1) {
|
|
149
|
-
const
|
|
150
|
-
if (!
|
|
151
|
-
if (
|
|
152
|
-
return
|
|
158
|
+
const n = t.getCanvasNodeById(o[0]);
|
|
159
|
+
if (!n) return null;
|
|
160
|
+
if (n.getConfig().$_type === "image")
|
|
161
|
+
return n.getConfig().$_imageUrl || null;
|
|
153
162
|
}
|
|
154
163
|
return t.exportSelectionAsImage();
|
|
155
164
|
}
|
|
156
165
|
export {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
A as calculateBottomLeftOfCanvasContent,
|
|
167
|
+
R as exportMarkedRegion,
|
|
168
|
+
H as exportSelectionAsImage,
|
|
169
|
+
L as insertImageBesideContent,
|
|
170
|
+
p as insertImagesAtPosition,
|
|
171
|
+
X as insertLoadingImageBesideSelection,
|
|
172
|
+
Y as replaceLoadingImageNode
|
|
164
173
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -411,8 +411,8 @@ export declare const NODE_NAMES: {
|
|
|
411
411
|
};
|
|
412
412
|
|
|
413
413
|
declare interface NodeStyle {
|
|
414
|
-
$_strokeColor: "theme.stroke-color.
|
|
415
|
-
$_fillColor: "theme.fill-color.
|
|
414
|
+
$_strokeColor: ThemeKeysStartingWith<"theme.stroke-color."> | string;
|
|
415
|
+
$_fillColor: ThemeKeysStartingWith<"theme.fill-color."> | string;
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
export declare type NodeType = "rectangle" | "image" | "image-marker" | "html";
|
|
@@ -454,6 +454,8 @@ export declare interface Theme {
|
|
|
454
454
|
"theme.fill-color.3": string;
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
+
declare type ThemeKeysStartingWith<Prefix extends string> = Extract<keyof Theme, `${Prefix}${string}`>;
|
|
458
|
+
|
|
457
459
|
export declare type ToolType = "select" | "hand" | "rectangle" | "image-marker";
|
|
458
460
|
|
|
459
461
|
declare type TransformerConfig = {
|
package/dist/index.js
CHANGED
|
@@ -307,12 +307,12 @@ ct = new WeakMap(), S = new WeakMap(), bt = new WeakMap(), It = new WeakMap(), C
|
|
|
307
307
|
ae = function() {
|
|
308
308
|
e(this, S).on("transformstart", e(this, bt)), e(this, S).on("transform", e(this, It)), e(this, S).on("transformend", e(this, Ct)), e(this, S).on("dragstart", e(this, kt)), e(this, S).on("dragmove", e(this, $t)), e(this, S).on("dragend", e(this, Tt));
|
|
309
309
|
};
|
|
310
|
-
var
|
|
310
|
+
var $, R, X, D;
|
|
311
311
|
class ze {
|
|
312
312
|
// todo: 优化 selectedNodeIds 的存储和查询性能
|
|
313
313
|
// private _selectedNodeIds: Set<string> = new Set();
|
|
314
314
|
constructor(i) {
|
|
315
|
-
l(this,
|
|
315
|
+
l(this, $, []);
|
|
316
316
|
l(this, R);
|
|
317
317
|
l(this, X, []);
|
|
318
318
|
l(this, D);
|
|
@@ -329,7 +329,7 @@ class ze {
|
|
|
329
329
|
*/
|
|
330
330
|
getHistory() {
|
|
331
331
|
return {
|
|
332
|
-
past: [...e(this,
|
|
332
|
+
past: [...e(this, $)],
|
|
333
333
|
present: { ...e(this, R) },
|
|
334
334
|
future: [...e(this, X)]
|
|
335
335
|
};
|
|
@@ -338,7 +338,7 @@ class ze {
|
|
|
338
338
|
* 是否可以撤销
|
|
339
339
|
*/
|
|
340
340
|
canUndo() {
|
|
341
|
-
return e(this,
|
|
341
|
+
return e(this, $).length > 0;
|
|
342
342
|
}
|
|
343
343
|
/**
|
|
344
344
|
* 是否可以重做
|
|
@@ -369,9 +369,9 @@ class ze {
|
|
|
369
369
|
* 撤销操作
|
|
370
370
|
*/
|
|
371
371
|
undo() {
|
|
372
|
-
if (e(this,
|
|
373
|
-
const i = e(this,
|
|
374
|
-
d(this,
|
|
372
|
+
if (e(this, $).length === 0) return;
|
|
373
|
+
const i = e(this, $)[e(this, $).length - 1], t = e(this, $).slice(0, e(this, $).length - 1);
|
|
374
|
+
d(this, $, t), d(this, X, [e(this, R), ...e(this, X)]), d(this, R, i), this._renderCanvas(i), e(this, D).emit("state:undo", i), e(this, D).emit("state:change", i);
|
|
375
375
|
}
|
|
376
376
|
/**
|
|
377
377
|
* 重做操作
|
|
@@ -379,13 +379,13 @@ class ze {
|
|
|
379
379
|
redo() {
|
|
380
380
|
if (e(this, X).length === 0) return;
|
|
381
381
|
const i = e(this, X)[0], t = e(this, X).slice(1);
|
|
382
|
-
d(this,
|
|
382
|
+
d(this, $, [...e(this, $), e(this, R)]), d(this, X, t), d(this, R, i), this._renderCanvas(i), e(this, D).emit("state:redo", i), e(this, D).emit("state:change", i);
|
|
383
383
|
}
|
|
384
384
|
/**
|
|
385
385
|
* 重置历史记录
|
|
386
386
|
*/
|
|
387
387
|
resetHistory() {
|
|
388
|
-
d(this,
|
|
388
|
+
d(this, $, []), d(this, X, []), e(this, D).emit("state:reset", e(this, R)), e(this, D).emit("state:change", e(this, R));
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
391
391
|
* 更新状态
|
|
@@ -394,7 +394,7 @@ class ze {
|
|
|
394
394
|
*/
|
|
395
395
|
_updateState(i, t) {
|
|
396
396
|
const s = { ...e(this, R), ...i };
|
|
397
|
-
t && (d(this,
|
|
397
|
+
t && (d(this, $, [...e(this, $), e(this, R)]), d(this, X, [])), d(this, R, s), e(this, D).emit("state:change", s);
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
400
400
|
* 清理资源
|
|
@@ -403,7 +403,7 @@ class ze {
|
|
|
403
403
|
e(this, D).all.clear();
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
|
|
406
|
+
$ = new WeakMap(), R = new WeakMap(), X = new WeakMap(), D = new WeakMap();
|
|
407
407
|
class Ot {
|
|
408
408
|
}
|
|
409
409
|
const Xe = {
|
|
@@ -434,7 +434,7 @@ function Yt(r, i) {
|
|
|
434
434
|
if (n in r) {
|
|
435
435
|
const o = r[n];
|
|
436
436
|
let a = o;
|
|
437
|
-
o.startsWith("theme.") && (a = i[o]), a && (t[s] = a);
|
|
437
|
+
o.startsWith("theme.") && o in i && (a = i[o]), a && (t[s] = a);
|
|
438
438
|
}
|
|
439
439
|
}), t;
|
|
440
440
|
}
|
|
@@ -683,7 +683,7 @@ Ht = function() {
|
|
|
683
683
|
c.forEach((m) => {
|
|
684
684
|
const f = g.find((u) => u.id === m.id());
|
|
685
685
|
if (f?.$_type === "image-marker" && f.$_relativeBox) {
|
|
686
|
-
const { start: u, end: w } = f.$_relativeBox, v = n + u.ratioX * a, b = o + u.ratioY * h, M = n + w.ratioX * a,
|
|
686
|
+
const { start: u, end: w } = f.$_relativeBox, v = n + u.ratioX * a, b = o + u.ratioY * h, M = n + w.ratioX * a, T = o + w.ratioY * h, zt = Math.min(v, M), Ft = Math.min(b, T), G = Math.abs(M - v), ot = Math.abs(T - b);
|
|
687
687
|
m.setAttrs({
|
|
688
688
|
x: zt,
|
|
689
689
|
y: Ft,
|
|
@@ -1126,8 +1126,8 @@ const at = class at extends ze {
|
|
|
1126
1126
|
createImageMarkerNode(t, s, n, o) {
|
|
1127
1127
|
const a = this.getState().nodes || [];
|
|
1128
1128
|
let h = 0;
|
|
1129
|
-
a.forEach((
|
|
1130
|
-
|
|
1129
|
+
a.forEach((T) => {
|
|
1130
|
+
T.$_type === "image-marker" && typeof T.$_markerNumber == "number" && (h = Math.max(h, T.$_markerNumber));
|
|
1131
1131
|
});
|
|
1132
1132
|
const c = (s.x - o.x) / o.width, g = (s.y - o.y) / o.height, m = (n.x - o.x) / o.width, f = (n.y - o.y) / o.height, u = Math.min(s.x, n.x), w = Math.min(s.y, n.y), v = Math.abs(n.x - s.x), b = Math.abs(n.y - s.y), M = {
|
|
1133
1133
|
id: yt(),
|
|
@@ -1212,8 +1212,8 @@ const at = class at extends ze {
|
|
|
1212
1212
|
y: s.y + (s.height || 0)
|
|
1213
1213
|
}, [c, g] = Ut(a, h), m = this.getState().nodes || [];
|
|
1214
1214
|
let f = 0;
|
|
1215
|
-
m.forEach((
|
|
1216
|
-
|
|
1215
|
+
m.forEach((T) => {
|
|
1216
|
+
T.$_type === "image-marker" && typeof T.$_markerNumber == "number" && (f = Math.max(f, T.$_markerNumber));
|
|
1217
1217
|
});
|
|
1218
1218
|
const u = (c.x - o.x) / o.width, w = (c.y - o.y) / o.height, v = (g.x - o.x) / o.width, b = (g.y - o.y) / o.height, M = {
|
|
1219
1219
|
...s,
|
|
@@ -1404,14 +1404,14 @@ Vt = function(t) {
|
|
|
1404
1404
|
* 更新 state.nodes
|
|
1405
1405
|
*/
|
|
1406
1406
|
Lt = function(t, s) {
|
|
1407
|
-
t.forEach((n) => {
|
|
1407
|
+
t.length !== 0 && (t.forEach((n) => {
|
|
1408
1408
|
e(this, B).set(n.getID(), n);
|
|
1409
|
-
}),
|
|
1409
|
+
}), _(this, Y, Vt).call(this, s));
|
|
1410
1410
|
}, fe = function(t, s = !1) {
|
|
1411
|
-
t.forEach((n) => {
|
|
1411
|
+
t.length !== 0 && (t.forEach((n) => {
|
|
1412
1412
|
const o = e(this, B).get(n);
|
|
1413
1413
|
o && o.destroy(), e(this, B).delete(n);
|
|
1414
|
-
}),
|
|
1414
|
+
}), _(this, Y, Vt).call(this, s));
|
|
1415
1415
|
}, /** 全局注册的主题 */
|
|
1416
1416
|
l(at, ut, null);
|
|
1417
1417
|
let Wt = at;
|
|
@@ -1609,13 +1609,13 @@ class qe extends Wt {
|
|
|
1609
1609
|
a = Math.min(a, Kt), h = Math.min(h, qt), c = Math.max(c, Kt + pe), g = Math.max(g, qt + ye);
|
|
1610
1610
|
}
|
|
1611
1611
|
}), a === 1 / 0 || h === 1 / 0) return;
|
|
1612
|
-
const b = c - a, M = g - h,
|
|
1612
|
+
const b = c - a, M = g - h, T = a + b / 2, zt = h + M / 2;
|
|
1613
1613
|
let G = this.getState().viewport.scale;
|
|
1614
1614
|
if (n) {
|
|
1615
1615
|
const z = (this.getStage().width() - s * 2) / b, Q = (this.getStage().height() - s * 2) / M;
|
|
1616
1616
|
G = Math.min(z, Q, 1);
|
|
1617
1617
|
}
|
|
1618
|
-
const ot = this.getStage().width() / 2 -
|
|
1618
|
+
const ot = this.getStage().width() / 2 - T * G, Gt = this.getStage().height() / 2 - zt * G;
|
|
1619
1619
|
this.updateViewport({ x: ot, y: Gt, scale: G }, !0);
|
|
1620
1620
|
}
|
|
1621
1621
|
/**
|
|
@@ -1674,7 +1674,7 @@ function Je({
|
|
|
1674
1674
|
"aria-hidden": "true",
|
|
1675
1675
|
children: [
|
|
1676
1676
|
/* @__PURE__ */ E("defs", { children: oe.map(({ min: c, mid: g, step: m }, f) => {
|
|
1677
|
-
const u = m * s * h, w = 0.5 + o * h, v = 0.5 + a * h, b = w > 0 ? w % u : u + w % u, M = v > 0 ? v % u : u + v % u,
|
|
1677
|
+
const u = m * s * h, w = 0.5 + o * h, v = 0.5 + a * h, b = w > 0 ? w % u : u + w % u, M = v > 0 ? v % u : u + v % u, T = h < g ? je(h, [c, g], [0, 1]) : 1;
|
|
1678
1678
|
return /* @__PURE__ */ E(
|
|
1679
1679
|
"pattern",
|
|
1680
1680
|
{
|
|
@@ -1689,7 +1689,7 @@ function Je({
|
|
|
1689
1689
|
cx: b,
|
|
1690
1690
|
cy: M,
|
|
1691
1691
|
r: 1,
|
|
1692
|
-
opacity:
|
|
1692
|
+
opacity: T
|
|
1693
1693
|
}
|
|
1694
1694
|
)
|
|
1695
1695
|
},
|
package/dist/maze.d.ts
CHANGED
|
@@ -365,7 +365,7 @@ declare interface CommonNodeConfig<T = NodeType> extends Partial<NodeStyle> {
|
|
|
365
365
|
* @param imageMarkerNodeId 图片标注节点 ID
|
|
366
366
|
* @returns Promise<string | null> 裁剪后的图片 base64 字符串,失败返回 null
|
|
367
367
|
*/
|
|
368
|
-
export declare function
|
|
368
|
+
export declare function exportMarkedRegion(api: CanvasApi | null | undefined, imageMarkerNodeId: string): Promise<string | null>;
|
|
369
369
|
|
|
370
370
|
/**
|
|
371
371
|
* 导出当前选中节点为图片
|
|
@@ -443,6 +443,7 @@ export declare function insertImagesAtPosition(api: CanvasApi | null | undefined
|
|
|
443
443
|
spacing?: number;
|
|
444
444
|
scrollToView?: boolean;
|
|
445
445
|
direction?: "horizontal" | "vertical";
|
|
446
|
+
reuseExisting?: boolean;
|
|
446
447
|
}): Promise<string[] | undefined>;
|
|
447
448
|
|
|
448
449
|
/**
|
|
@@ -460,8 +461,8 @@ declare interface IViewport {
|
|
|
460
461
|
}
|
|
461
462
|
|
|
462
463
|
declare interface NodeStyle {
|
|
463
|
-
$_strokeColor: "theme.stroke-color.
|
|
464
|
-
$_fillColor: "theme.fill-color.
|
|
464
|
+
$_strokeColor: ThemeKeysStartingWith<"theme.stroke-color."> | string;
|
|
465
|
+
$_fillColor: ThemeKeysStartingWith<"theme.fill-color."> | string;
|
|
465
466
|
}
|
|
466
467
|
|
|
467
468
|
declare type NodeType = "rectangle" | "image" | "image-marker" | "html";
|
|
@@ -505,6 +506,8 @@ declare interface Theme {
|
|
|
505
506
|
"theme.fill-color.3": string;
|
|
506
507
|
}
|
|
507
508
|
|
|
509
|
+
declare type ThemeKeysStartingWith<Prefix extends string> = Extract<keyof Theme, `${Prefix}${string}`>;
|
|
510
|
+
|
|
508
511
|
declare type ToolType = "select" | "hand" | "rectangle" | "image-marker";
|
|
509
512
|
|
|
510
513
|
declare type TransformerConfig = {
|