@meta2d/core 1.0.24 → 1.0.26
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/package.json +1 -1
- package/src/canvas/canvas.d.ts +1 -0
- package/src/canvas/canvas.js +199 -99
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.js +7 -8
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/core.d.ts +5 -1
- package/src/core.js +220 -47
- package/src/core.js.map +1 -1
- package/src/diagrams/iframe.d.ts +0 -3
- package/src/diagrams/iframe.js +204 -21
- package/src/diagrams/iframe.js.map +1 -1
- package/src/event/event.d.ts +5 -2
- package/src/event/event.js +2 -0
- package/src/event/event.js.map +1 -1
- package/src/options.d.ts +6 -0
- package/src/options.js +1 -0
- package/src/options.js.map +1 -1
- package/src/pen/model.d.ts +4 -0
- package/src/pen/model.js +1 -1
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +1 -1
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.js +17 -1
- package/src/pen/text.js.map +1 -1
- package/src/rect/rect.js +15 -2
- package/src/rect/rect.js.map +1 -1
- package/src/store/store.d.ts +7 -0
- package/src/store/store.js +1 -0
- package/src/store/store.js.map +1 -1
- package/src/title/title.js +9 -9
- package/src/title/title.js.map +1 -1
- package/src/utils/clone.d.ts +1 -1
- package/src/utils/clone.js +14 -4
- package/src/utils/clone.js.map +1 -1
- package/src/utils/url.d.ts +3 -0
- package/src/utils/url.js +7 -0
- package/src/utils/url.js.map +1 -0
package/src/canvas/canvas.js
CHANGED
|
@@ -242,6 +242,12 @@ var Canvas = /** @class */ (function () {
|
|
|
242
242
|
if (_this.pencil) {
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
|
+
if (_this.store.hover) {
|
|
246
|
+
if (_this.store.hover.onWheel) {
|
|
247
|
+
_this.store.hover.onWheel(_this.store.hover, e);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
245
251
|
if (_this.store.options.disableScale) {
|
|
246
252
|
return;
|
|
247
253
|
}
|
|
@@ -381,13 +387,14 @@ var Canvas = /** @class */ (function () {
|
|
|
381
387
|
_this.translateAnchor(-1, 0);
|
|
382
388
|
break;
|
|
383
389
|
}
|
|
384
|
-
x = -
|
|
390
|
+
x = -1;
|
|
385
391
|
if (e.shiftKey) {
|
|
386
392
|
x = -5;
|
|
387
393
|
}
|
|
388
394
|
if (e.ctrlKey || e.metaKey) {
|
|
389
|
-
x = -
|
|
395
|
+
x = -10;
|
|
390
396
|
}
|
|
397
|
+
x = x * _this.store.data.scale;
|
|
391
398
|
_this.translatePens(_this.store.active, x, 0);
|
|
392
399
|
break;
|
|
393
400
|
case 'ArrowUp':
|
|
@@ -395,13 +402,14 @@ var Canvas = /** @class */ (function () {
|
|
|
395
402
|
_this.translateAnchor(0, -1);
|
|
396
403
|
break;
|
|
397
404
|
}
|
|
398
|
-
y = -
|
|
405
|
+
y = -1;
|
|
399
406
|
if (e.shiftKey) {
|
|
400
407
|
y = -5;
|
|
401
408
|
}
|
|
402
409
|
if (e.ctrlKey || e.metaKey) {
|
|
403
|
-
y = -
|
|
410
|
+
y = -10;
|
|
404
411
|
}
|
|
412
|
+
y = y * _this.store.data.scale;
|
|
405
413
|
_this.translatePens(_this.store.active, 0, y);
|
|
406
414
|
break;
|
|
407
415
|
case 'ArrowRight':
|
|
@@ -409,12 +417,14 @@ var Canvas = /** @class */ (function () {
|
|
|
409
417
|
_this.translateAnchor(1, 0);
|
|
410
418
|
break;
|
|
411
419
|
}
|
|
420
|
+
x = 1;
|
|
412
421
|
if (e.shiftKey) {
|
|
413
422
|
x = 5;
|
|
414
423
|
}
|
|
415
424
|
if (e.ctrlKey || e.metaKey) {
|
|
416
|
-
x =
|
|
425
|
+
x = 10;
|
|
417
426
|
}
|
|
427
|
+
x = x * _this.store.data.scale;
|
|
418
428
|
_this.translatePens(_this.store.active, x, 0);
|
|
419
429
|
break;
|
|
420
430
|
case 'ArrowDown':
|
|
@@ -422,12 +432,14 @@ var Canvas = /** @class */ (function () {
|
|
|
422
432
|
_this.translateAnchor(0, 1);
|
|
423
433
|
break;
|
|
424
434
|
}
|
|
435
|
+
y = 1;
|
|
425
436
|
if (e.shiftKey) {
|
|
426
437
|
y = 5;
|
|
427
438
|
}
|
|
428
439
|
if (e.ctrlKey || e.metaKey) {
|
|
429
|
-
y =
|
|
440
|
+
y = 10;
|
|
430
441
|
}
|
|
442
|
+
y = y * _this.store.data.scale;
|
|
431
443
|
_this.translatePens(_this.store.active, 0, y);
|
|
432
444
|
break;
|
|
433
445
|
case 'd':
|
|
@@ -1424,6 +1436,16 @@ var Canvas = /** @class */ (function () {
|
|
|
1424
1436
|
// Add pen
|
|
1425
1437
|
if (_this.addCaches && _this.addCaches.length) {
|
|
1426
1438
|
if (!_this.store.data.locked) {
|
|
1439
|
+
if (_this.dragRect) {
|
|
1440
|
+
// 只存在一个缓存图元
|
|
1441
|
+
if (_this.addCaches.length === 1) {
|
|
1442
|
+
var target = _this.addCaches[0];
|
|
1443
|
+
target.width = _this.dragRect.width;
|
|
1444
|
+
target.height = _this.dragRect.height;
|
|
1445
|
+
e.x = (_this.dragRect.x + _this.dragRect.ex) / 2;
|
|
1446
|
+
e.y = (_this.dragRect.y + _this.dragRect.ey) / 2;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1427
1449
|
_this.dropPens(_this.addCaches, e);
|
|
1428
1450
|
}
|
|
1429
1451
|
_this.addCaches = undefined;
|
|
@@ -1553,6 +1575,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1553
1575
|
var hoverType = HoverType.None;
|
|
1554
1576
|
_this.store.hover = undefined;
|
|
1555
1577
|
_this.store.hoverAnchor = undefined;
|
|
1578
|
+
_this.title.hide();
|
|
1556
1579
|
_this.store.pointAt = undefined;
|
|
1557
1580
|
_this.store.pointAtIndex = undefined;
|
|
1558
1581
|
var activeLine = _this.store.active.length === 1 && _this.store.active[0].type;
|
|
@@ -1644,7 +1667,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1644
1667
|
this.inPens = function (pt, pens) {
|
|
1645
1668
|
var hoverType = HoverType.None;
|
|
1646
1669
|
var _loop_2 = function (i) {
|
|
1647
|
-
var e_1, _a, e_2, _b
|
|
1670
|
+
var e_1, _a, e_2, _b;
|
|
1648
1671
|
var pen = pens[i];
|
|
1649
1672
|
if (pen.visible == false ||
|
|
1650
1673
|
pen.calculative.inView == false ||
|
|
@@ -1658,47 +1681,48 @@ var Canvas = /** @class */ (function () {
|
|
|
1658
1681
|
return "continue";
|
|
1659
1682
|
}
|
|
1660
1683
|
//anchor title
|
|
1661
|
-
if (
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
+
// if (this.store.data.locked) {
|
|
1685
|
+
// // locked>0
|
|
1686
|
+
// if (pen.calculative.worldAnchors) {
|
|
1687
|
+
// for (const anchor of pen.calculative.worldAnchors) {
|
|
1688
|
+
// if (
|
|
1689
|
+
// hitPoint(
|
|
1690
|
+
// pt,
|
|
1691
|
+
// anchor,
|
|
1692
|
+
// this.pointSize,
|
|
1693
|
+
// anchor.penId ? this.store.pens[anchor.penId] : undefined
|
|
1694
|
+
// )
|
|
1695
|
+
// ) {
|
|
1696
|
+
// this.title.show(anchor, pen);
|
|
1697
|
+
// if (anchor.title) {
|
|
1698
|
+
// break outer;
|
|
1699
|
+
// }
|
|
1700
|
+
// }
|
|
1701
|
+
// }
|
|
1702
|
+
// }
|
|
1703
|
+
// }
|
|
1684
1704
|
// 锚点
|
|
1685
1705
|
if (!_this.store.data.locked && _this.hotkeyType !== HotkeyType.Resize) {
|
|
1686
1706
|
if (pen.calculative.worldAnchors) {
|
|
1687
1707
|
try {
|
|
1688
|
-
for (var
|
|
1689
|
-
var anchor =
|
|
1708
|
+
for (var _c = (e_1 = void 0, __values(pen.calculative.worldAnchors)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1709
|
+
var anchor = _d.value;
|
|
1690
1710
|
hoverType = _this.inAnchor(pt, pen, anchor);
|
|
1691
1711
|
if (hoverType) {
|
|
1712
|
+
//title显示
|
|
1713
|
+
var _anchor = deepClone(anchor);
|
|
1714
|
+
Object.assign(_anchor, pt);
|
|
1715
|
+
_this.title.show(_anchor, pen);
|
|
1692
1716
|
return "break-outer";
|
|
1693
1717
|
}
|
|
1694
1718
|
}
|
|
1695
1719
|
}
|
|
1696
|
-
catch (
|
|
1720
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1697
1721
|
finally {
|
|
1698
1722
|
try {
|
|
1699
|
-
if (
|
|
1723
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1700
1724
|
}
|
|
1701
|
-
finally { if (
|
|
1725
|
+
finally { if (e_1) throw e_1.error; }
|
|
1702
1726
|
}
|
|
1703
1727
|
}
|
|
1704
1728
|
}
|
|
@@ -1759,7 +1783,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1759
1783
|
_this.store.pointAt = pt;
|
|
1760
1784
|
// 锚点贴边吸附
|
|
1761
1785
|
if (!pt.ctrlKey) {
|
|
1762
|
-
var
|
|
1786
|
+
var _e = _this.store.hover.calculative.worldRect, x = _e.x, y = _e.y, ex = _e.ex, ey = _e.ey, rotate_1 = _e.rotate, center_1 = _e.center;
|
|
1763
1787
|
if (rotate_1) {
|
|
1764
1788
|
var pts = [
|
|
1765
1789
|
{ x: x, y: y },
|
|
@@ -1772,7 +1796,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1772
1796
|
});
|
|
1773
1797
|
var last = pts[pts.length - 1];
|
|
1774
1798
|
try {
|
|
1775
|
-
for (var pts_1 = (
|
|
1799
|
+
for (var pts_1 = (e_2 = void 0, __values(pts)), pts_1_1 = pts_1.next(); !pts_1_1.done; pts_1_1 = pts_1.next()) {
|
|
1776
1800
|
var item = pts_1_1.value;
|
|
1777
1801
|
if (last.y > pt.y !== item.y > pt.y) {
|
|
1778
1802
|
var tempx = item.x +
|
|
@@ -1784,12 +1808,12 @@ var Canvas = /** @class */ (function () {
|
|
|
1784
1808
|
last = item;
|
|
1785
1809
|
}
|
|
1786
1810
|
}
|
|
1787
|
-
catch (
|
|
1811
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1788
1812
|
finally {
|
|
1789
1813
|
try {
|
|
1790
|
-
if (pts_1_1 && !pts_1_1.done && (
|
|
1814
|
+
if (pts_1_1 && !pts_1_1.done && (_b = pts_1.return)) _b.call(pts_1);
|
|
1791
1815
|
}
|
|
1792
|
-
finally { if (
|
|
1816
|
+
finally { if (e_2) throw e_2.error; }
|
|
1793
1817
|
}
|
|
1794
1818
|
}
|
|
1795
1819
|
else {
|
|
@@ -1822,7 +1846,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1822
1846
|
return hoverType;
|
|
1823
1847
|
};
|
|
1824
1848
|
this.dockInAnchor = function (pt) {
|
|
1825
|
-
var
|
|
1849
|
+
var e_3, _a;
|
|
1826
1850
|
var _b, _c;
|
|
1827
1851
|
_this.store.hover = undefined;
|
|
1828
1852
|
for (var i = _this.store.data.pens.length - 1; i >= 0; --i) {
|
|
@@ -1842,7 +1866,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1842
1866
|
if (_this.hotkeyType !== HotkeyType.Resize) {
|
|
1843
1867
|
if (pen.calculative.worldAnchors) {
|
|
1844
1868
|
try {
|
|
1845
|
-
for (var _d = (
|
|
1869
|
+
for (var _d = (e_3 = void 0, __values(pen.calculative.worldAnchors)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1846
1870
|
var anchor = _e.value;
|
|
1847
1871
|
if (anchor.twoWay === TwoWay.In) {
|
|
1848
1872
|
var to = getToAnchor(_this.store.active[0]);
|
|
@@ -1867,12 +1891,12 @@ var Canvas = /** @class */ (function () {
|
|
|
1867
1891
|
}
|
|
1868
1892
|
}
|
|
1869
1893
|
}
|
|
1870
|
-
catch (
|
|
1894
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1871
1895
|
finally {
|
|
1872
1896
|
try {
|
|
1873
1897
|
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1874
1898
|
}
|
|
1875
|
-
finally { if (
|
|
1899
|
+
finally { if (e_3) throw e_3.error; }
|
|
1876
1900
|
}
|
|
1877
1901
|
}
|
|
1878
1902
|
}
|
|
@@ -1927,7 +1951,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1927
1951
|
_this.patchFlags = false;
|
|
1928
1952
|
};
|
|
1929
1953
|
this.renderPens = function () {
|
|
1930
|
-
var
|
|
1954
|
+
var e_4, _a;
|
|
1931
1955
|
var ctx = _this.offscreen.getContext('2d');
|
|
1932
1956
|
ctx.strokeStyle = getGlobalColor(_this.store);
|
|
1933
1957
|
try {
|
|
@@ -1941,12 +1965,12 @@ var Canvas = /** @class */ (function () {
|
|
|
1941
1965
|
}
|
|
1942
1966
|
}
|
|
1943
1967
|
}
|
|
1944
|
-
catch (
|
|
1968
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1945
1969
|
finally {
|
|
1946
1970
|
try {
|
|
1947
1971
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1948
1972
|
}
|
|
1949
|
-
finally { if (
|
|
1973
|
+
finally { if (e_4) throw e_4.error; }
|
|
1950
1974
|
}
|
|
1951
1975
|
if (_this.drawingLine) {
|
|
1952
1976
|
renderPen(ctx, _this.drawingLine);
|
|
@@ -1983,9 +2007,13 @@ var Canvas = /** @class */ (function () {
|
|
|
1983
2007
|
ctx.translate(-_this.activeRect.center.x, -_this.activeRect.center.y);
|
|
1984
2008
|
}
|
|
1985
2009
|
ctx.strokeStyle = _this.store.options.activeColor;
|
|
1986
|
-
ctx.globalAlpha = 0.3;
|
|
2010
|
+
ctx.globalAlpha = _this.store.options.activeGlobalAlpha || 0.3;
|
|
1987
2011
|
ctx.beginPath();
|
|
2012
|
+
ctx.lineWidth = _this.store.options.activeLineWidth || 1;
|
|
2013
|
+
ctx.setLineDash(_this.store.options.activeLineDash || []);
|
|
1988
2014
|
ctx.strokeRect(_this.activeRect.x, _this.activeRect.y, _this.activeRect.width, _this.activeRect.height);
|
|
2015
|
+
ctx.setLineDash([]);
|
|
2016
|
+
ctx.lineWidth = 1;
|
|
1989
2017
|
ctx.globalAlpha = 1;
|
|
1990
2018
|
if (getPensLock(_this.store.active) ||
|
|
1991
2019
|
getPensDisableRotate(_this.store.active) ||
|
|
@@ -2186,7 +2214,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2186
2214
|
* @returns 复制后的画笔
|
|
2187
2215
|
*/
|
|
2188
2216
|
this.pastePen = function (pen, parentId) {
|
|
2189
|
-
var
|
|
2217
|
+
var e_5, _a;
|
|
2190
2218
|
var oldId = pen.id;
|
|
2191
2219
|
randomId(pen);
|
|
2192
2220
|
pen.parentId = parentId;
|
|
@@ -2227,12 +2255,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2227
2255
|
_loop_3(childId);
|
|
2228
2256
|
}
|
|
2229
2257
|
}
|
|
2230
|
-
catch (
|
|
2258
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
2231
2259
|
finally {
|
|
2232
2260
|
try {
|
|
2233
2261
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
2234
2262
|
}
|
|
2235
|
-
finally { if (
|
|
2263
|
+
finally { if (e_5) throw e_5.error; }
|
|
2236
2264
|
}
|
|
2237
2265
|
}
|
|
2238
2266
|
pen.children = newChildren;
|
|
@@ -2527,7 +2555,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2527
2555
|
_this.render();
|
|
2528
2556
|
};
|
|
2529
2557
|
this.setDropdownList = function (search) {
|
|
2530
|
-
var
|
|
2558
|
+
var e_6, _a;
|
|
2531
2559
|
_this.clearDropdownList();
|
|
2532
2560
|
if (!_this.store.data.locked) {
|
|
2533
2561
|
return;
|
|
@@ -2574,12 +2602,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2574
2602
|
++i;
|
|
2575
2603
|
}
|
|
2576
2604
|
}
|
|
2577
|
-
catch (
|
|
2605
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
2578
2606
|
finally {
|
|
2579
2607
|
try {
|
|
2580
2608
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2581
2609
|
}
|
|
2582
|
-
finally { if (
|
|
2610
|
+
finally { if (e_6) throw e_6.error; }
|
|
2583
2611
|
}
|
|
2584
2612
|
if (!_this.dropdown.hasChildNodes()) {
|
|
2585
2613
|
var none = document.createElement('div');
|
|
@@ -2723,6 +2751,17 @@ var Canvas = /** @class */ (function () {
|
|
|
2723
2751
|
});
|
|
2724
2752
|
};
|
|
2725
2753
|
this.externalElements.onmouseleave = function (e) {
|
|
2754
|
+
//离开画布取消所有选中
|
|
2755
|
+
_this.store.data.pens.forEach(function (pen) {
|
|
2756
|
+
if (pen.calculative.hover) {
|
|
2757
|
+
pen.calculative.hover = false;
|
|
2758
|
+
}
|
|
2759
|
+
});
|
|
2760
|
+
if (_this.store.hover) {
|
|
2761
|
+
_this.store.hover.calculative.hover = false;
|
|
2762
|
+
_this.store.hover = undefined;
|
|
2763
|
+
}
|
|
2764
|
+
_this.render();
|
|
2726
2765
|
if (e.toElement !== _this.tooltip.box) {
|
|
2727
2766
|
_this.tooltip.hide();
|
|
2728
2767
|
_this.store.lastHover = undefined;
|
|
@@ -2865,7 +2904,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2865
2904
|
Canvas.prototype.dropPens = function (pens, e) {
|
|
2866
2905
|
return __awaiter(this, void 0, void 0, function () {
|
|
2867
2906
|
var pens_2, pens_2_1, pen, pens_3, pens_3_1, pen, pens_4, pens_4_1, pen, width, height, rect_1, flag, pens_5, pens_5_1, pen, points;
|
|
2868
|
-
var
|
|
2907
|
+
var e_7, _a, e_8, _b, e_9, _c, e_10, _d;
|
|
2869
2908
|
return __generator(this, function (_e) {
|
|
2870
2909
|
switch (_e.label) {
|
|
2871
2910
|
case 0:
|
|
@@ -2876,12 +2915,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2876
2915
|
!pen.parentId && this.randomCombineId(pen, pens);
|
|
2877
2916
|
}
|
|
2878
2917
|
}
|
|
2879
|
-
catch (
|
|
2918
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
2880
2919
|
finally {
|
|
2881
2920
|
try {
|
|
2882
2921
|
if (pens_2_1 && !pens_2_1.done && (_a = pens_2.return)) _a.call(pens_2);
|
|
2883
2922
|
}
|
|
2884
|
-
finally { if (
|
|
2923
|
+
finally { if (e_7) throw e_7.error; }
|
|
2885
2924
|
}
|
|
2886
2925
|
try {
|
|
2887
2926
|
for (pens_3 = __values(pens), pens_3_1 = pens_3.next(); !pens_3_1.done; pens_3_1 = pens_3.next()) {
|
|
@@ -2894,12 +2933,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2894
2933
|
this.store.pens[pen.id] = pen;
|
|
2895
2934
|
}
|
|
2896
2935
|
}
|
|
2897
|
-
catch (
|
|
2936
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
2898
2937
|
finally {
|
|
2899
2938
|
try {
|
|
2900
2939
|
if (pens_3_1 && !pens_3_1.done && (_b = pens_3.return)) _b.call(pens_3);
|
|
2901
2940
|
}
|
|
2902
|
-
finally { if (
|
|
2941
|
+
finally { if (e_8) throw e_8.error; }
|
|
2903
2942
|
}
|
|
2904
2943
|
try {
|
|
2905
2944
|
// // 计算区域
|
|
@@ -2921,12 +2960,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2921
2960
|
}
|
|
2922
2961
|
}
|
|
2923
2962
|
}
|
|
2924
|
-
catch (
|
|
2963
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
2925
2964
|
finally {
|
|
2926
2965
|
try {
|
|
2927
2966
|
if (pens_4_1 && !pens_4_1.done && (_c = pens_4.return)) _c.call(pens_4);
|
|
2928
2967
|
}
|
|
2929
|
-
finally { if (
|
|
2968
|
+
finally { if (e_9) throw e_9.error; }
|
|
2930
2969
|
}
|
|
2931
2970
|
width = this.store.data.width || this.store.options.width;
|
|
2932
2971
|
height = this.store.data.height || this.store.options.height;
|
|
@@ -2959,12 +2998,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2959
2998
|
}
|
|
2960
2999
|
}
|
|
2961
3000
|
}
|
|
2962
|
-
catch (
|
|
3001
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
2963
3002
|
finally {
|
|
2964
3003
|
try {
|
|
2965
3004
|
if (pens_5_1 && !pens_5_1.done && (_d = pens_5.return)) _d.call(pens_5);
|
|
2966
3005
|
}
|
|
2967
|
-
finally { if (
|
|
3006
|
+
finally { if (e_10) throw e_10.error; }
|
|
2968
3007
|
}
|
|
2969
3008
|
if (flag) {
|
|
2970
3009
|
console.info('画笔在大屏范围外');
|
|
@@ -2983,7 +3022,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2983
3022
|
});
|
|
2984
3023
|
};
|
|
2985
3024
|
Canvas.prototype.randomCombineId = function (pen, pens, parentId) {
|
|
2986
|
-
var
|
|
3025
|
+
var e_11, _a;
|
|
2987
3026
|
randomId(pen);
|
|
2988
3027
|
pen.parentId = parentId;
|
|
2989
3028
|
var newChildren = [];
|
|
@@ -3000,12 +3039,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3000
3039
|
_loop_4(childId);
|
|
3001
3040
|
}
|
|
3002
3041
|
}
|
|
3003
|
-
catch (
|
|
3042
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
3004
3043
|
finally {
|
|
3005
3044
|
try {
|
|
3006
3045
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3007
3046
|
}
|
|
3008
|
-
finally { if (
|
|
3047
|
+
finally { if (e_11) throw e_11.error; }
|
|
3009
3048
|
}
|
|
3010
3049
|
}
|
|
3011
3050
|
pen.children = newChildren;
|
|
@@ -3014,7 +3053,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3014
3053
|
Canvas.prototype.addPens = function (pens, history) {
|
|
3015
3054
|
return __awaiter(this, void 0, void 0, function () {
|
|
3016
3055
|
var _a, list, pens_6, pens_6_1, pen;
|
|
3017
|
-
var
|
|
3056
|
+
var e_12, _b;
|
|
3018
3057
|
return __generator(this, function (_c) {
|
|
3019
3058
|
switch (_c.label) {
|
|
3020
3059
|
case 0:
|
|
@@ -3039,12 +3078,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3039
3078
|
list.push(pen);
|
|
3040
3079
|
}
|
|
3041
3080
|
}
|
|
3042
|
-
catch (
|
|
3081
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
3043
3082
|
finally {
|
|
3044
3083
|
try {
|
|
3045
3084
|
if (pens_6_1 && !pens_6_1.done && (_b = pens_6.return)) _b.call(pens_6);
|
|
3046
3085
|
}
|
|
3047
|
-
finally { if (
|
|
3086
|
+
finally { if (e_12) throw e_12.error; }
|
|
3048
3087
|
}
|
|
3049
3088
|
this.render();
|
|
3050
3089
|
this.store.emitter.emit('add', list);
|
|
@@ -3314,7 +3353,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3314
3353
|
this.patchFlags = true;
|
|
3315
3354
|
};
|
|
3316
3355
|
Canvas.prototype.active = function (pens, emit) {
|
|
3317
|
-
var
|
|
3356
|
+
var e_13, _a, _b;
|
|
3318
3357
|
if (emit === void 0) { emit = true; }
|
|
3319
3358
|
if (this.store.active) {
|
|
3320
3359
|
emit && this.store.emitter.emit('inactive', this.store.active);
|
|
@@ -3326,12 +3365,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3326
3365
|
setChildrenActive(pen, false);
|
|
3327
3366
|
}
|
|
3328
3367
|
}
|
|
3329
|
-
catch (
|
|
3368
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
3330
3369
|
finally {
|
|
3331
3370
|
try {
|
|
3332
3371
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
3333
3372
|
}
|
|
3334
|
-
finally { if (
|
|
3373
|
+
finally { if (e_13) throw e_13.error; }
|
|
3335
3374
|
}
|
|
3336
3375
|
}
|
|
3337
3376
|
this.store.active = [];
|
|
@@ -3517,7 +3556,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3517
3556
|
return HoverType.None;
|
|
3518
3557
|
};
|
|
3519
3558
|
Canvas.prototype.resize = function (w, h) {
|
|
3520
|
-
var
|
|
3559
|
+
var e_14, _a;
|
|
3521
3560
|
w = w || this.parentElement.clientWidth;
|
|
3522
3561
|
h = h || this.parentElement.clientHeight;
|
|
3523
3562
|
this.width = w;
|
|
@@ -3558,12 +3597,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3558
3597
|
calcInView(pen);
|
|
3559
3598
|
}
|
|
3560
3599
|
}
|
|
3561
|
-
catch (
|
|
3600
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
3562
3601
|
finally {
|
|
3563
3602
|
try {
|
|
3564
3603
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3565
3604
|
}
|
|
3566
|
-
finally { if (
|
|
3605
|
+
finally { if (e_14) throw e_14.error; }
|
|
3567
3606
|
}
|
|
3568
3607
|
};
|
|
3569
3608
|
Canvas.prototype.clearCanvas = function () {
|
|
@@ -3628,7 +3667,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3628
3667
|
this.store.histories.splice(this.store.historyIndex + 1, this.store.histories.length - this.store.historyIndex - 1);
|
|
3629
3668
|
}
|
|
3630
3669
|
(_a = action.pens) === null || _a === void 0 ? void 0 : _a.forEach(function (pen) {
|
|
3631
|
-
var
|
|
3670
|
+
var e_15, _a;
|
|
3632
3671
|
var found;
|
|
3633
3672
|
if (action.initPens) {
|
|
3634
3673
|
try {
|
|
@@ -3639,12 +3678,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3639
3678
|
}
|
|
3640
3679
|
}
|
|
3641
3680
|
}
|
|
3642
|
-
catch (
|
|
3681
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
3643
3682
|
finally {
|
|
3644
3683
|
try {
|
|
3645
3684
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3646
3685
|
}
|
|
3647
|
-
finally { if (
|
|
3686
|
+
finally { if (e_15) throw e_15.error; }
|
|
3648
3687
|
}
|
|
3649
3688
|
}
|
|
3650
3689
|
if (found) {
|
|
@@ -4293,7 +4332,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4293
4332
|
this.onMovePens();
|
|
4294
4333
|
};
|
|
4295
4334
|
Canvas.prototype.onMovePens = function () {
|
|
4296
|
-
var
|
|
4335
|
+
var e_16, _a;
|
|
4297
4336
|
var _b;
|
|
4298
4337
|
var map = this.parent.map;
|
|
4299
4338
|
if (map && map.isShow) {
|
|
@@ -4318,12 +4357,12 @@ var Canvas = /** @class */ (function () {
|
|
|
4318
4357
|
}
|
|
4319
4358
|
}
|
|
4320
4359
|
}
|
|
4321
|
-
catch (
|
|
4360
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
4322
4361
|
finally {
|
|
4323
4362
|
try {
|
|
4324
4363
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
4325
4364
|
}
|
|
4326
|
-
finally { if (
|
|
4365
|
+
finally { if (e_16) throw e_16.error; }
|
|
4327
4366
|
}
|
|
4328
4367
|
};
|
|
4329
4368
|
/**
|
|
@@ -4383,7 +4422,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4383
4422
|
});
|
|
4384
4423
|
};
|
|
4385
4424
|
Canvas.prototype.rotatePens = function (e) {
|
|
4386
|
-
var
|
|
4425
|
+
var e_17, _a;
|
|
4387
4426
|
var _this = this;
|
|
4388
4427
|
if (!this.initPens) {
|
|
4389
4428
|
this.initPens = deepClone(this.getAllByPens(this.store.active));
|
|
@@ -4410,12 +4449,12 @@ var Canvas = /** @class */ (function () {
|
|
|
4410
4449
|
this.updateLines(pen);
|
|
4411
4450
|
}
|
|
4412
4451
|
}
|
|
4413
|
-
catch (
|
|
4452
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
4414
4453
|
finally {
|
|
4415
4454
|
try {
|
|
4416
4455
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
4417
4456
|
}
|
|
4418
|
-
finally { if (
|
|
4457
|
+
finally { if (e_17) throw e_17.error; }
|
|
4419
4458
|
}
|
|
4420
4459
|
this.lastRotate = this.activeRect.rotate;
|
|
4421
4460
|
this.getSizeCPs();
|
|
@@ -4482,6 +4521,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4482
4521
|
var sign = [1, 3].includes(this.resizeIndex) ? -1 : 1;
|
|
4483
4522
|
offsetY = (sign * (offsetX * h)) / w;
|
|
4484
4523
|
}
|
|
4524
|
+
this.activeRect.ratio = this.initPens[0].ratio;
|
|
4485
4525
|
resizeRect(this.activeRect, offsetX, offsetY, this.resizeIndex);
|
|
4486
4526
|
calcCenter(this.activeRect);
|
|
4487
4527
|
var scaleX = this.activeRect.width / w;
|
|
@@ -5310,7 +5350,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5310
5350
|
return;
|
|
5311
5351
|
}
|
|
5312
5352
|
requestAnimationFrame(function () {
|
|
5313
|
-
var
|
|
5353
|
+
var e_18, _a;
|
|
5314
5354
|
var now = Date.now();
|
|
5315
5355
|
if (now - _this.lastAnimateRender < _this.store.options.animateInterval) {
|
|
5316
5356
|
if (_this.store.animates.size > 0) {
|
|
@@ -5395,12 +5435,12 @@ var Canvas = /** @class */ (function () {
|
|
|
5395
5435
|
_loop_5(pen);
|
|
5396
5436
|
}
|
|
5397
5437
|
}
|
|
5398
|
-
catch (
|
|
5438
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
5399
5439
|
finally {
|
|
5400
5440
|
try {
|
|
5401
5441
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
5402
5442
|
}
|
|
5403
|
-
finally { if (
|
|
5443
|
+
finally { if (e_18) throw e_18.error; }
|
|
5404
5444
|
}
|
|
5405
5445
|
if (active) {
|
|
5406
5446
|
_this.calcActiveRect();
|
|
@@ -5487,7 +5527,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5487
5527
|
var _a;
|
|
5488
5528
|
return __awaiter(this, void 0, void 0, function () {
|
|
5489
5529
|
var clipboardText, clipboard, _b, _c, offset, pos, curPage, rootPens, rootPens_1, rootPens_1_1, pen;
|
|
5490
|
-
var
|
|
5530
|
+
var e_19, _d;
|
|
5491
5531
|
return __generator(this, function (_e) {
|
|
5492
5532
|
switch (_e.label) {
|
|
5493
5533
|
case 0:
|
|
@@ -5560,12 +5600,12 @@ var Canvas = /** @class */ (function () {
|
|
|
5560
5600
|
this.pastePen(pen, undefined);
|
|
5561
5601
|
}
|
|
5562
5602
|
}
|
|
5563
|
-
catch (
|
|
5603
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
5564
5604
|
finally {
|
|
5565
5605
|
try {
|
|
5566
5606
|
if (rootPens_1_1 && !rootPens_1_1.done && (_d = rootPens_1.return)) _d.call(rootPens_1);
|
|
5567
5607
|
}
|
|
5568
|
-
finally { if (
|
|
5608
|
+
finally { if (e_19) throw e_19.error; }
|
|
5569
5609
|
}
|
|
5570
5610
|
sessionStorage.setItem('page', clipboard.page);
|
|
5571
5611
|
this.active(rootPens);
|
|
@@ -5583,7 +5623,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5583
5623
|
* @param pens 不包含子节点
|
|
5584
5624
|
*/
|
|
5585
5625
|
Canvas.prototype.getAllByPens = function (pens) {
|
|
5586
|
-
var
|
|
5626
|
+
var e_20, _a;
|
|
5587
5627
|
var retPens = [];
|
|
5588
5628
|
try {
|
|
5589
5629
|
for (var pens_8 = __values(pens), pens_8_1 = pens_8.next(); !pens_8_1.done; pens_8_1 = pens_8.next()) {
|
|
@@ -5591,12 +5631,12 @@ var Canvas = /** @class */ (function () {
|
|
|
5591
5631
|
retPens.push.apply(retPens, __spreadArray([], __read(deepClone(getAllChildren(pen, this.store), true)), false));
|
|
5592
5632
|
}
|
|
5593
5633
|
}
|
|
5594
|
-
catch (
|
|
5634
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
5595
5635
|
finally {
|
|
5596
5636
|
try {
|
|
5597
5637
|
if (pens_8_1 && !pens_8_1.done && (_a = pens_8.return)) _a.call(pens_8);
|
|
5598
5638
|
}
|
|
5599
|
-
finally { if (
|
|
5639
|
+
finally { if (e_20) throw e_20.error; }
|
|
5600
5640
|
}
|
|
5601
5641
|
return retPens.concat(pens);
|
|
5602
5642
|
};
|
|
@@ -5639,7 +5679,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5639
5679
|
* @param pastePens 此处复制的全部 pens (包含子节点)
|
|
5640
5680
|
*/
|
|
5641
5681
|
Canvas.prototype.changeNodeConnectedLine = function (oldId, line, pastePens) {
|
|
5642
|
-
var
|
|
5682
|
+
var e_21, _a;
|
|
5643
5683
|
var _b;
|
|
5644
5684
|
var from = line.anchors[0];
|
|
5645
5685
|
var to = line.anchors[line.anchors.length - 1];
|
|
@@ -5675,12 +5715,12 @@ var Canvas = /** @class */ (function () {
|
|
|
5675
5715
|
_loop_7(anchor);
|
|
5676
5716
|
}
|
|
5677
5717
|
}
|
|
5678
|
-
catch (
|
|
5718
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
5679
5719
|
finally {
|
|
5680
5720
|
try {
|
|
5681
5721
|
if (anchors_1_1 && !anchors_1_1.done && (_a = anchors_1.return)) _a.call(anchors_1);
|
|
5682
5722
|
}
|
|
5683
|
-
finally { if (
|
|
5723
|
+
finally { if (e_21) throw e_21.error; }
|
|
5684
5724
|
}
|
|
5685
5725
|
};
|
|
5686
5726
|
Canvas.prototype.delete = function (pens, canDelLocked, history) {
|
|
@@ -6194,7 +6234,7 @@ var Canvas = /** @class */ (function () {
|
|
|
6194
6234
|
};
|
|
6195
6235
|
};
|
|
6196
6236
|
Canvas.prototype.toPng = function (padding, callback, containBkImg) {
|
|
6197
|
-
var
|
|
6237
|
+
var e_22, _a;
|
|
6198
6238
|
if (padding === void 0) { padding = 2; }
|
|
6199
6239
|
if (containBkImg === void 0) { containBkImg = false; }
|
|
6200
6240
|
var rect = getRect(this.store.data.pens);
|
|
@@ -6282,12 +6322,12 @@ var Canvas = /** @class */ (function () {
|
|
|
6282
6322
|
pen.calculative.active = active;
|
|
6283
6323
|
}
|
|
6284
6324
|
}
|
|
6285
|
-
catch (
|
|
6325
|
+
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
6286
6326
|
finally {
|
|
6287
6327
|
try {
|
|
6288
6328
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6289
6329
|
}
|
|
6290
|
-
finally { if (
|
|
6330
|
+
finally { if (e_22) throw e_22.error; }
|
|
6291
6331
|
}
|
|
6292
6332
|
if (callback) {
|
|
6293
6333
|
canvas.toBlob(callback);
|
|
@@ -6295,6 +6335,66 @@ var Canvas = /** @class */ (function () {
|
|
|
6295
6335
|
}
|
|
6296
6336
|
return canvas.toDataURL();
|
|
6297
6337
|
};
|
|
6338
|
+
Canvas.prototype.activeToPng = function (padding) {
|
|
6339
|
+
var e_23, _a;
|
|
6340
|
+
if (padding === void 0) { padding = 2; }
|
|
6341
|
+
var allPens = this.getAllByPens(this.store.active);
|
|
6342
|
+
var ids = allPens.map(function (pen) { return pen.id; });
|
|
6343
|
+
var rect = getRect(allPens);
|
|
6344
|
+
if (!isFinite(rect.width)) {
|
|
6345
|
+
throw new Error('can not to png, because width is not finite');
|
|
6346
|
+
}
|
|
6347
|
+
var oldRect = deepClone(rect);
|
|
6348
|
+
var p = formatPadding(padding);
|
|
6349
|
+
rect.x -= p[3];
|
|
6350
|
+
rect.y -= p[0];
|
|
6351
|
+
rect.width += p[3] + p[1];
|
|
6352
|
+
rect.height += p[0] + p[2];
|
|
6353
|
+
calcRightBottom(rect);
|
|
6354
|
+
var canvas = document.createElement('canvas');
|
|
6355
|
+
canvas.width = rect.width;
|
|
6356
|
+
canvas.height = rect.height;
|
|
6357
|
+
if (canvas.width > 32767 ||
|
|
6358
|
+
canvas.height > 32767 ||
|
|
6359
|
+
(!navigator.userAgent.includes('Firefox') &&
|
|
6360
|
+
canvas.height * canvas.width > 268435456) ||
|
|
6361
|
+
(navigator.userAgent.includes('Firefox') &&
|
|
6362
|
+
canvas.height * canvas.width > 472907776)) {
|
|
6363
|
+
throw new Error('can not to png, because the size exceeds the browser limit');
|
|
6364
|
+
}
|
|
6365
|
+
var ctx = canvas.getContext('2d');
|
|
6366
|
+
ctx.textBaseline = 'middle'; // 默认垂直居中
|
|
6367
|
+
// // 平移画布,画笔的 worldRect 不变化
|
|
6368
|
+
ctx.translate(-oldRect.x, -oldRect.y);
|
|
6369
|
+
try {
|
|
6370
|
+
for (var _b = __values(this.store.data.pens), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6371
|
+
var pen = _c.value;
|
|
6372
|
+
if (ids.includes(pen.id)) {
|
|
6373
|
+
// 不使用 calculative.inView 的原因是,如果 pen 在 view 之外,那么它的 calculative.inView 为 false,但是它的绘制还是需要的
|
|
6374
|
+
if (!isShowChild(pen, this.store) || pen.visible == false) {
|
|
6375
|
+
continue;
|
|
6376
|
+
}
|
|
6377
|
+
var active = pen.calculative.active;
|
|
6378
|
+
pen.calculative.active = false;
|
|
6379
|
+
if (pen.calculative.img) {
|
|
6380
|
+
renderPenRaw(ctx, pen);
|
|
6381
|
+
}
|
|
6382
|
+
else {
|
|
6383
|
+
renderPen(ctx, pen);
|
|
6384
|
+
}
|
|
6385
|
+
pen.calculative.active = active;
|
|
6386
|
+
}
|
|
6387
|
+
}
|
|
6388
|
+
}
|
|
6389
|
+
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
6390
|
+
finally {
|
|
6391
|
+
try {
|
|
6392
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6393
|
+
}
|
|
6394
|
+
finally { if (e_23) throw e_23.error; }
|
|
6395
|
+
}
|
|
6396
|
+
return canvas.toDataURL();
|
|
6397
|
+
};
|
|
6298
6398
|
Canvas.prototype.toggleAnchorMode = function () {
|
|
6299
6399
|
var _a;
|
|
6300
6400
|
if (!this.hotkeyType) {
|