@8btc/whiteboard 0.0.19-beta.3 → 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/index.d.ts +4 -2
- package/dist/index.js +21 -21
- package/dist/maze.d.ts +4 -2
- package/package.json +1 -1
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,
|
|
@@ -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
|
@@ -461,8 +461,8 @@ declare interface IViewport {
|
|
|
461
461
|
}
|
|
462
462
|
|
|
463
463
|
declare interface NodeStyle {
|
|
464
|
-
$_strokeColor: "theme.stroke-color.
|
|
465
|
-
$_fillColor: "theme.fill-color.
|
|
464
|
+
$_strokeColor: ThemeKeysStartingWith<"theme.stroke-color."> | string;
|
|
465
|
+
$_fillColor: ThemeKeysStartingWith<"theme.fill-color."> | string;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
declare type NodeType = "rectangle" | "image" | "image-marker" | "html";
|
|
@@ -506,6 +506,8 @@ declare interface Theme {
|
|
|
506
506
|
"theme.fill-color.3": string;
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
+
declare type ThemeKeysStartingWith<Prefix extends string> = Extract<keyof Theme, `${Prefix}${string}`>;
|
|
510
|
+
|
|
509
511
|
declare type ToolType = "select" | "hand" | "rectangle" | "image-marker";
|
|
510
512
|
|
|
511
513
|
declare type TransformerConfig = {
|