@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.
@@ -1,164 +1,173 @@
1
- import { v4 as $ } from "uuid";
1
+ import { v4 as _ } from "uuid";
2
2
  import { N as M } from "../const-CpLk0Av6.js";
3
- async function A(t) {
4
- return new Promise((o, e) => {
5
- const n = new Image();
6
- n.onload = () => {
7
- o({ width: n.naturalWidth, height: n.naturalHeight });
8
- }, n.onerror = () => {
9
- e(new Error(`Failed to load image: ${t}`));
10
- }, n.src = t;
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 B(t) {
13
+ function A(t) {
14
14
  if (!t) return { x: 0, y: 0 };
15
15
  if ((t.getState().nodes || []).length > 0) {
16
- const n = t.getMainLayer();
17
- let r = 1 / 0, i = -1 / 0;
18
- if (n.children.forEach((a) => {
19
- if (a.visible() && a.getClassName() !== "Transformer" && a.hasName(M.selectable)) {
20
- const s = a.getAttrs(), l = s.x || 0, f = s.y || 0, c = s.height || 0;
21
- r = Math.min(r, l), i = Math.max(i, f + c);
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
- }), r !== 1 / 0 && i !== -1 / 0)
24
- return { x: r, y: i };
23
+ }), i !== 1 / 0 && r !== -1 / 0)
24
+ return { x: i, y: r };
25
25
  }
26
- const e = t.getState().viewport;
26
+ const n = t.getState().viewport;
27
27
  return {
28
- x: e.x,
29
- y: e.y
28
+ x: n.x,
29
+ y: n.y
30
30
  };
31
31
  }
32
- async function _(t, o, e, n) {
32
+ async function p(t, o, n, e) {
33
33
  if (!t) return;
34
- const r = Array.isArray(o) ? o : [o];
35
- if (r.length === 0) return;
36
- const i = n?.spacing ?? 20, a = n?.scrollToView ?? !0, s = n?.direction ?? "vertical", l = await Promise.all(r.map((d) => A(d))), f = [], c = [];
37
- let u = e.x, m = e.y;
38
- return r.forEach((d, g) => {
39
- const { width: h, height: y } = l[g], I = $();
40
- f.push({
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: u,
44
- y: m,
45
- width: h,
46
- height: y,
47
- $_imageUrl: d
48
- }), c.push(I), s === "horizontal" ? u += h + i : m += y + i;
49
- }), t.createNodes(f, !0), t.getMainLayer().draw(), a && t.scrollToContent({ scale: !1, nodeIds: c }), c;
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 X(t, o) {
60
+ async function L(t, o) {
52
61
  if (!t) return;
53
- const e = B(t);
54
- return _(t, o, {
55
- x: e.x,
56
- y: e.y + 20
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 Y(t, o) {
68
+ function X(t, o) {
60
69
  if (!t) return;
61
- const e = t.getState().selectedNodeIds || [];
62
- if (e.length === 0) return;
63
- let n = 1 / 0, r = 1 / 0, i = -1 / 0, a = -1 / 0;
64
- if (t.getMainLayer().children.forEach((c) => {
65
- if (c.visible() && c.getClassName() !== "Transformer" && e.includes(c.id())) {
66
- const u = c.getAttrs(), m = u.x || 0, d = u.y || 0, g = u.width || 0, h = u.height || 0;
67
- n = Math.min(n, m), r = Math.min(r, d), i = Math.max(i, m + g), a = Math.max(a, d + h);
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
- }), n === 1 / 0 || r === 1 / 0 || i === -1 / 0 || a === -1 / 0)
78
+ }), e === 1 / 0 || i === 1 / 0 || r === -1 / 0 || s === -1 / 0)
70
79
  return;
71
- const l = {
72
- x: i + 20,
73
- y: r,
74
- width: i - n,
75
- height: a - r
76
- }, f = {
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: l.x,
80
- y: l.y,
81
- width: l.width,
82
- height: l.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([f], !0), f.id;
98
+ return t.createNodes([d], !0), d.id;
90
99
  }
91
- function E(t, o, e) {
100
+ function Y(t, o, n) {
92
101
  if (!t) return;
93
- const n = t.getCanvasNodeById(o);
94
- if (!n) return;
95
- const r = n.getConfig();
96
- if (r.$_type !== "html") return;
97
- const i = Array.isArray(e) ? e : [e];
98
- if (i.length === 0) return;
99
- const a = r.x, s = r.y;
100
- _(t, i, { x: a, y: s }), t.deleteNodes([o]);
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 H(t, o) {
111
+ async function R(t, o) {
103
112
  if (!t) return null;
104
- const e = t.getCanvasNodeById(o);
105
- if (!e) return null;
106
- const n = e.getConfig();
107
- if (n.$_type !== "image-marker" || !n.$_relativeBox)
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 r = n.$_parentId;
110
- if (!r) return null;
111
- const i = t.getCanvasNodeById(r);
118
+ const i = e.$_parentId;
112
119
  if (!i) return null;
113
- const a = i.getConfig();
114
- if (a.$_type !== "image" || !a.$_imageUrl) return null;
115
- const { start: s, end: l } = n.$_relativeBox, f = s.ratioX, c = s.ratioY, u = l.ratioX - s.ratioX, m = l.ratioY - s.ratioY;
116
- return new Promise((d) => {
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 h = g.naturalWidth, y = g.naturalHeight, I = f * h, v = c * y, w = u * h, C = m * y, x = document.createElement("canvas");
120
- x.width = w, x.height = C;
121
- const N = x.getContext("2d");
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
- d(null);
132
+ h(null);
124
133
  return;
125
134
  }
126
135
  N.drawImage(
127
136
  g,
128
- I,
129
- v,
130
137
  w,
131
- C,
138
+ $,
139
+ I,
140
+ x,
132
141
  0,
133
142
  0,
134
- w,
135
- C
143
+ I,
144
+ x
136
145
  );
137
- const p = x.toDataURL("image/png");
138
- d(p);
146
+ const v = C.toDataURL("image/png");
147
+ h(v);
139
148
  }, g.onerror = () => {
140
- console.error("Failed to load image:", a.$_imageUrl), d(null);
141
- }, g.src = a.$_imageUrl;
149
+ console.error("Failed to load image:", s.$_imageUrl), h(null);
150
+ }, g.src = s.$_imageUrl;
142
151
  });
143
152
  }
144
- function R(t) {
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 e = t.getCanvasNodeById(o[0]);
150
- if (!e) return null;
151
- if (e.getConfig().$_type === "image")
152
- return e.getConfig().$_imageUrl || null;
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
- B as calculateBottomLeftOfCanvasContent,
158
- H as cropImageBaseOnImageMarker,
159
- R as exportSelectionAsImage,
160
- X as insertImageBesideContent,
161
- _ as insertImagesAtPosition,
162
- Y as insertLoadingImageBesideSelection,
163
- E as replaceLoadingImageNode
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.1" | "theme.stroke-color.2" | "theme.stroke-color.3";
415
- $_fillColor: "theme.fill-color.1" | "theme.fill-color.2" | "theme.fill-color.3";
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 T, R, X, D;
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, T, []);
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, T)],
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, T).length > 0;
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, T).length === 0) return;
373
- const i = e(this, T)[e(this, T).length - 1], t = e(this, T).slice(0, e(this, T).length - 1);
374
- d(this, T, 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);
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, T, [...e(this, T), 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);
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, T, []), d(this, X, []), e(this, D).emit("state:reset", e(this, R)), e(this, D).emit("state:change", e(this, R));
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, T, [...e(this, T), e(this, R)]), d(this, X, [])), d(this, R, s), e(this, D).emit("state:change", s);
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
- T = new WeakMap(), R = new WeakMap(), X = new WeakMap(), D = new WeakMap();
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, $ = o + w.ratioY * h, zt = Math.min(v, M), Ft = Math.min(b, $), G = Math.abs(M - v), ot = Math.abs($ - b);
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
- $.$_type === "image-marker" && typeof $.$_markerNumber == "number" && (h = Math.max(h, $.$_markerNumber));
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
- $.$_type === "image-marker" && $.$_parentId === s.$_parentId && typeof $.$_markerNumber == "number" && (f = Math.max(f, $.$_markerNumber));
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
- }), t.length !== 0 && _(this, Y, Vt).call(this, s);
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
- }), t.length !== 0 && _(this, Y, Vt).call(this, s);
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, $ = a + b / 2, zt = h + M / 2;
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 - $ * G, Gt = this.getStage().height() / 2 - zt * G;
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, $ = h < g ? je(h, [c, g], [0, 1]) : 1;
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 cropImageBaseOnImageMarker(api: CanvasApi | null | undefined, imageMarkerNodeId: string): Promise<string | null>;
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.1" | "theme.stroke-color.2" | "theme.stroke-color.3";
464
- $_fillColor: "theme.fill-color.1" | "theme.fill-color.2" | "theme.fill-color.3";
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 = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8btc/whiteboard",
3
3
  "private": false,
4
- "version": "0.0.19-beta.2",
4
+ "version": "0.0.19-beta.4",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
7
7
  "module": "./dist/index.js",