@meta2d/core 1.0.25 → 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 +2 -2
- package/src/canvas/canvas.js +106 -98
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.js +35 -8
- package/src/core.js.map +1 -1
- package/src/diagrams/iframe.js +27 -4
- package/src/diagrams/iframe.js.map +1 -1
- package/src/event/event.d.ts +3 -1
- 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 +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/text.js +17 -1
- package/src/pen/text.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meta2d/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"gitHead": "78f2a53ca1839c89b56e2e498d17ba4eb987ad14"
|
|
39
|
-
}
|
|
39
|
+
}
|
package/src/canvas/canvas.js
CHANGED
|
@@ -394,6 +394,7 @@ var Canvas = /** @class */ (function () {
|
|
|
394
394
|
if (e.ctrlKey || e.metaKey) {
|
|
395
395
|
x = -10;
|
|
396
396
|
}
|
|
397
|
+
x = x * _this.store.data.scale;
|
|
397
398
|
_this.translatePens(_this.store.active, x, 0);
|
|
398
399
|
break;
|
|
399
400
|
case 'ArrowUp':
|
|
@@ -408,6 +409,7 @@ var Canvas = /** @class */ (function () {
|
|
|
408
409
|
if (e.ctrlKey || e.metaKey) {
|
|
409
410
|
y = -10;
|
|
410
411
|
}
|
|
412
|
+
y = y * _this.store.data.scale;
|
|
411
413
|
_this.translatePens(_this.store.active, 0, y);
|
|
412
414
|
break;
|
|
413
415
|
case 'ArrowRight':
|
|
@@ -422,6 +424,7 @@ var Canvas = /** @class */ (function () {
|
|
|
422
424
|
if (e.ctrlKey || e.metaKey) {
|
|
423
425
|
x = 10;
|
|
424
426
|
}
|
|
427
|
+
x = x * _this.store.data.scale;
|
|
425
428
|
_this.translatePens(_this.store.active, x, 0);
|
|
426
429
|
break;
|
|
427
430
|
case 'ArrowDown':
|
|
@@ -436,6 +439,7 @@ var Canvas = /** @class */ (function () {
|
|
|
436
439
|
if (e.ctrlKey || e.metaKey) {
|
|
437
440
|
y = 10;
|
|
438
441
|
}
|
|
442
|
+
y = y * _this.store.data.scale;
|
|
439
443
|
_this.translatePens(_this.store.active, 0, y);
|
|
440
444
|
break;
|
|
441
445
|
case 'd':
|
|
@@ -1571,6 +1575,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1571
1575
|
var hoverType = HoverType.None;
|
|
1572
1576
|
_this.store.hover = undefined;
|
|
1573
1577
|
_this.store.hoverAnchor = undefined;
|
|
1578
|
+
_this.title.hide();
|
|
1574
1579
|
_this.store.pointAt = undefined;
|
|
1575
1580
|
_this.store.pointAtIndex = undefined;
|
|
1576
1581
|
var activeLine = _this.store.active.length === 1 && _this.store.active[0].type;
|
|
@@ -1662,7 +1667,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1662
1667
|
this.inPens = function (pt, pens) {
|
|
1663
1668
|
var hoverType = HoverType.None;
|
|
1664
1669
|
var _loop_2 = function (i) {
|
|
1665
|
-
var e_1, _a, e_2, _b
|
|
1670
|
+
var e_1, _a, e_2, _b;
|
|
1666
1671
|
var pen = pens[i];
|
|
1667
1672
|
if (pen.visible == false ||
|
|
1668
1673
|
pen.calculative.inView == false ||
|
|
@@ -1676,47 +1681,48 @@ var Canvas = /** @class */ (function () {
|
|
|
1676
1681
|
return "continue";
|
|
1677
1682
|
}
|
|
1678
1683
|
//anchor title
|
|
1679
|
-
if (
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
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
|
+
// }
|
|
1702
1704
|
// 锚点
|
|
1703
1705
|
if (!_this.store.data.locked && _this.hotkeyType !== HotkeyType.Resize) {
|
|
1704
1706
|
if (pen.calculative.worldAnchors) {
|
|
1705
1707
|
try {
|
|
1706
|
-
for (var
|
|
1707
|
-
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;
|
|
1708
1710
|
hoverType = _this.inAnchor(pt, pen, anchor);
|
|
1709
1711
|
if (hoverType) {
|
|
1712
|
+
//title显示
|
|
1713
|
+
var _anchor = deepClone(anchor);
|
|
1714
|
+
Object.assign(_anchor, pt);
|
|
1715
|
+
_this.title.show(_anchor, pen);
|
|
1710
1716
|
return "break-outer";
|
|
1711
1717
|
}
|
|
1712
1718
|
}
|
|
1713
1719
|
}
|
|
1714
|
-
catch (
|
|
1720
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1715
1721
|
finally {
|
|
1716
1722
|
try {
|
|
1717
|
-
if (
|
|
1723
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1718
1724
|
}
|
|
1719
|
-
finally { if (
|
|
1725
|
+
finally { if (e_1) throw e_1.error; }
|
|
1720
1726
|
}
|
|
1721
1727
|
}
|
|
1722
1728
|
}
|
|
@@ -1777,7 +1783,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1777
1783
|
_this.store.pointAt = pt;
|
|
1778
1784
|
// 锚点贴边吸附
|
|
1779
1785
|
if (!pt.ctrlKey) {
|
|
1780
|
-
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;
|
|
1781
1787
|
if (rotate_1) {
|
|
1782
1788
|
var pts = [
|
|
1783
1789
|
{ x: x, y: y },
|
|
@@ -1790,7 +1796,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1790
1796
|
});
|
|
1791
1797
|
var last = pts[pts.length - 1];
|
|
1792
1798
|
try {
|
|
1793
|
-
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()) {
|
|
1794
1800
|
var item = pts_1_1.value;
|
|
1795
1801
|
if (last.y > pt.y !== item.y > pt.y) {
|
|
1796
1802
|
var tempx = item.x +
|
|
@@ -1802,12 +1808,12 @@ var Canvas = /** @class */ (function () {
|
|
|
1802
1808
|
last = item;
|
|
1803
1809
|
}
|
|
1804
1810
|
}
|
|
1805
|
-
catch (
|
|
1811
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1806
1812
|
finally {
|
|
1807
1813
|
try {
|
|
1808
|
-
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);
|
|
1809
1815
|
}
|
|
1810
|
-
finally { if (
|
|
1816
|
+
finally { if (e_2) throw e_2.error; }
|
|
1811
1817
|
}
|
|
1812
1818
|
}
|
|
1813
1819
|
else {
|
|
@@ -1840,7 +1846,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1840
1846
|
return hoverType;
|
|
1841
1847
|
};
|
|
1842
1848
|
this.dockInAnchor = function (pt) {
|
|
1843
|
-
var
|
|
1849
|
+
var e_3, _a;
|
|
1844
1850
|
var _b, _c;
|
|
1845
1851
|
_this.store.hover = undefined;
|
|
1846
1852
|
for (var i = _this.store.data.pens.length - 1; i >= 0; --i) {
|
|
@@ -1860,7 +1866,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1860
1866
|
if (_this.hotkeyType !== HotkeyType.Resize) {
|
|
1861
1867
|
if (pen.calculative.worldAnchors) {
|
|
1862
1868
|
try {
|
|
1863
|
-
for (var _d = (
|
|
1869
|
+
for (var _d = (e_3 = void 0, __values(pen.calculative.worldAnchors)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1864
1870
|
var anchor = _e.value;
|
|
1865
1871
|
if (anchor.twoWay === TwoWay.In) {
|
|
1866
1872
|
var to = getToAnchor(_this.store.active[0]);
|
|
@@ -1885,12 +1891,12 @@ var Canvas = /** @class */ (function () {
|
|
|
1885
1891
|
}
|
|
1886
1892
|
}
|
|
1887
1893
|
}
|
|
1888
|
-
catch (
|
|
1894
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1889
1895
|
finally {
|
|
1890
1896
|
try {
|
|
1891
1897
|
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1892
1898
|
}
|
|
1893
|
-
finally { if (
|
|
1899
|
+
finally { if (e_3) throw e_3.error; }
|
|
1894
1900
|
}
|
|
1895
1901
|
}
|
|
1896
1902
|
}
|
|
@@ -1945,7 +1951,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1945
1951
|
_this.patchFlags = false;
|
|
1946
1952
|
};
|
|
1947
1953
|
this.renderPens = function () {
|
|
1948
|
-
var
|
|
1954
|
+
var e_4, _a;
|
|
1949
1955
|
var ctx = _this.offscreen.getContext('2d');
|
|
1950
1956
|
ctx.strokeStyle = getGlobalColor(_this.store);
|
|
1951
1957
|
try {
|
|
@@ -1959,12 +1965,12 @@ var Canvas = /** @class */ (function () {
|
|
|
1959
1965
|
}
|
|
1960
1966
|
}
|
|
1961
1967
|
}
|
|
1962
|
-
catch (
|
|
1968
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1963
1969
|
finally {
|
|
1964
1970
|
try {
|
|
1965
1971
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1966
1972
|
}
|
|
1967
|
-
finally { if (
|
|
1973
|
+
finally { if (e_4) throw e_4.error; }
|
|
1968
1974
|
}
|
|
1969
1975
|
if (_this.drawingLine) {
|
|
1970
1976
|
renderPen(ctx, _this.drawingLine);
|
|
@@ -2001,9 +2007,13 @@ var Canvas = /** @class */ (function () {
|
|
|
2001
2007
|
ctx.translate(-_this.activeRect.center.x, -_this.activeRect.center.y);
|
|
2002
2008
|
}
|
|
2003
2009
|
ctx.strokeStyle = _this.store.options.activeColor;
|
|
2004
|
-
ctx.globalAlpha = 0.3;
|
|
2010
|
+
ctx.globalAlpha = _this.store.options.activeGlobalAlpha || 0.3;
|
|
2005
2011
|
ctx.beginPath();
|
|
2012
|
+
ctx.lineWidth = _this.store.options.activeLineWidth || 1;
|
|
2013
|
+
ctx.setLineDash(_this.store.options.activeLineDash || []);
|
|
2006
2014
|
ctx.strokeRect(_this.activeRect.x, _this.activeRect.y, _this.activeRect.width, _this.activeRect.height);
|
|
2015
|
+
ctx.setLineDash([]);
|
|
2016
|
+
ctx.lineWidth = 1;
|
|
2007
2017
|
ctx.globalAlpha = 1;
|
|
2008
2018
|
if (getPensLock(_this.store.active) ||
|
|
2009
2019
|
getPensDisableRotate(_this.store.active) ||
|
|
@@ -2204,7 +2214,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2204
2214
|
* @returns 复制后的画笔
|
|
2205
2215
|
*/
|
|
2206
2216
|
this.pastePen = function (pen, parentId) {
|
|
2207
|
-
var
|
|
2217
|
+
var e_5, _a;
|
|
2208
2218
|
var oldId = pen.id;
|
|
2209
2219
|
randomId(pen);
|
|
2210
2220
|
pen.parentId = parentId;
|
|
@@ -2245,12 +2255,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2245
2255
|
_loop_3(childId);
|
|
2246
2256
|
}
|
|
2247
2257
|
}
|
|
2248
|
-
catch (
|
|
2258
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
2249
2259
|
finally {
|
|
2250
2260
|
try {
|
|
2251
2261
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
2252
2262
|
}
|
|
2253
|
-
finally { if (
|
|
2263
|
+
finally { if (e_5) throw e_5.error; }
|
|
2254
2264
|
}
|
|
2255
2265
|
}
|
|
2256
2266
|
pen.children = newChildren;
|
|
@@ -2545,7 +2555,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2545
2555
|
_this.render();
|
|
2546
2556
|
};
|
|
2547
2557
|
this.setDropdownList = function (search) {
|
|
2548
|
-
var
|
|
2558
|
+
var e_6, _a;
|
|
2549
2559
|
_this.clearDropdownList();
|
|
2550
2560
|
if (!_this.store.data.locked) {
|
|
2551
2561
|
return;
|
|
@@ -2592,12 +2602,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2592
2602
|
++i;
|
|
2593
2603
|
}
|
|
2594
2604
|
}
|
|
2595
|
-
catch (
|
|
2605
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
2596
2606
|
finally {
|
|
2597
2607
|
try {
|
|
2598
2608
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2599
2609
|
}
|
|
2600
|
-
finally { if (
|
|
2610
|
+
finally { if (e_6) throw e_6.error; }
|
|
2601
2611
|
}
|
|
2602
2612
|
if (!_this.dropdown.hasChildNodes()) {
|
|
2603
2613
|
var none = document.createElement('div');
|
|
@@ -2894,7 +2904,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2894
2904
|
Canvas.prototype.dropPens = function (pens, e) {
|
|
2895
2905
|
return __awaiter(this, void 0, void 0, function () {
|
|
2896
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;
|
|
2897
|
-
var
|
|
2907
|
+
var e_7, _a, e_8, _b, e_9, _c, e_10, _d;
|
|
2898
2908
|
return __generator(this, function (_e) {
|
|
2899
2909
|
switch (_e.label) {
|
|
2900
2910
|
case 0:
|
|
@@ -2905,12 +2915,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2905
2915
|
!pen.parentId && this.randomCombineId(pen, pens);
|
|
2906
2916
|
}
|
|
2907
2917
|
}
|
|
2908
|
-
catch (
|
|
2918
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
2909
2919
|
finally {
|
|
2910
2920
|
try {
|
|
2911
2921
|
if (pens_2_1 && !pens_2_1.done && (_a = pens_2.return)) _a.call(pens_2);
|
|
2912
2922
|
}
|
|
2913
|
-
finally { if (
|
|
2923
|
+
finally { if (e_7) throw e_7.error; }
|
|
2914
2924
|
}
|
|
2915
2925
|
try {
|
|
2916
2926
|
for (pens_3 = __values(pens), pens_3_1 = pens_3.next(); !pens_3_1.done; pens_3_1 = pens_3.next()) {
|
|
@@ -2923,12 +2933,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2923
2933
|
this.store.pens[pen.id] = pen;
|
|
2924
2934
|
}
|
|
2925
2935
|
}
|
|
2926
|
-
catch (
|
|
2936
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
2927
2937
|
finally {
|
|
2928
2938
|
try {
|
|
2929
2939
|
if (pens_3_1 && !pens_3_1.done && (_b = pens_3.return)) _b.call(pens_3);
|
|
2930
2940
|
}
|
|
2931
|
-
finally { if (
|
|
2941
|
+
finally { if (e_8) throw e_8.error; }
|
|
2932
2942
|
}
|
|
2933
2943
|
try {
|
|
2934
2944
|
// // 计算区域
|
|
@@ -2950,12 +2960,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2950
2960
|
}
|
|
2951
2961
|
}
|
|
2952
2962
|
}
|
|
2953
|
-
catch (
|
|
2963
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
2954
2964
|
finally {
|
|
2955
2965
|
try {
|
|
2956
2966
|
if (pens_4_1 && !pens_4_1.done && (_c = pens_4.return)) _c.call(pens_4);
|
|
2957
2967
|
}
|
|
2958
|
-
finally { if (
|
|
2968
|
+
finally { if (e_9) throw e_9.error; }
|
|
2959
2969
|
}
|
|
2960
2970
|
width = this.store.data.width || this.store.options.width;
|
|
2961
2971
|
height = this.store.data.height || this.store.options.height;
|
|
@@ -2988,12 +2998,12 @@ var Canvas = /** @class */ (function () {
|
|
|
2988
2998
|
}
|
|
2989
2999
|
}
|
|
2990
3000
|
}
|
|
2991
|
-
catch (
|
|
3001
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
2992
3002
|
finally {
|
|
2993
3003
|
try {
|
|
2994
3004
|
if (pens_5_1 && !pens_5_1.done && (_d = pens_5.return)) _d.call(pens_5);
|
|
2995
3005
|
}
|
|
2996
|
-
finally { if (
|
|
3006
|
+
finally { if (e_10) throw e_10.error; }
|
|
2997
3007
|
}
|
|
2998
3008
|
if (flag) {
|
|
2999
3009
|
console.info('画笔在大屏范围外');
|
|
@@ -3012,7 +3022,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3012
3022
|
});
|
|
3013
3023
|
};
|
|
3014
3024
|
Canvas.prototype.randomCombineId = function (pen, pens, parentId) {
|
|
3015
|
-
var
|
|
3025
|
+
var e_11, _a;
|
|
3016
3026
|
randomId(pen);
|
|
3017
3027
|
pen.parentId = parentId;
|
|
3018
3028
|
var newChildren = [];
|
|
@@ -3029,12 +3039,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3029
3039
|
_loop_4(childId);
|
|
3030
3040
|
}
|
|
3031
3041
|
}
|
|
3032
|
-
catch (
|
|
3042
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
3033
3043
|
finally {
|
|
3034
3044
|
try {
|
|
3035
3045
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3036
3046
|
}
|
|
3037
|
-
finally { if (
|
|
3047
|
+
finally { if (e_11) throw e_11.error; }
|
|
3038
3048
|
}
|
|
3039
3049
|
}
|
|
3040
3050
|
pen.children = newChildren;
|
|
@@ -3043,7 +3053,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3043
3053
|
Canvas.prototype.addPens = function (pens, history) {
|
|
3044
3054
|
return __awaiter(this, void 0, void 0, function () {
|
|
3045
3055
|
var _a, list, pens_6, pens_6_1, pen;
|
|
3046
|
-
var
|
|
3056
|
+
var e_12, _b;
|
|
3047
3057
|
return __generator(this, function (_c) {
|
|
3048
3058
|
switch (_c.label) {
|
|
3049
3059
|
case 0:
|
|
@@ -3068,12 +3078,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3068
3078
|
list.push(pen);
|
|
3069
3079
|
}
|
|
3070
3080
|
}
|
|
3071
|
-
catch (
|
|
3081
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
3072
3082
|
finally {
|
|
3073
3083
|
try {
|
|
3074
3084
|
if (pens_6_1 && !pens_6_1.done && (_b = pens_6.return)) _b.call(pens_6);
|
|
3075
3085
|
}
|
|
3076
|
-
finally { if (
|
|
3086
|
+
finally { if (e_12) throw e_12.error; }
|
|
3077
3087
|
}
|
|
3078
3088
|
this.render();
|
|
3079
3089
|
this.store.emitter.emit('add', list);
|
|
@@ -3343,7 +3353,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3343
3353
|
this.patchFlags = true;
|
|
3344
3354
|
};
|
|
3345
3355
|
Canvas.prototype.active = function (pens, emit) {
|
|
3346
|
-
var
|
|
3356
|
+
var e_13, _a, _b;
|
|
3347
3357
|
if (emit === void 0) { emit = true; }
|
|
3348
3358
|
if (this.store.active) {
|
|
3349
3359
|
emit && this.store.emitter.emit('inactive', this.store.active);
|
|
@@ -3355,12 +3365,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3355
3365
|
setChildrenActive(pen, false);
|
|
3356
3366
|
}
|
|
3357
3367
|
}
|
|
3358
|
-
catch (
|
|
3368
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
3359
3369
|
finally {
|
|
3360
3370
|
try {
|
|
3361
3371
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
3362
3372
|
}
|
|
3363
|
-
finally { if (
|
|
3373
|
+
finally { if (e_13) throw e_13.error; }
|
|
3364
3374
|
}
|
|
3365
3375
|
}
|
|
3366
3376
|
this.store.active = [];
|
|
@@ -3546,7 +3556,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3546
3556
|
return HoverType.None;
|
|
3547
3557
|
};
|
|
3548
3558
|
Canvas.prototype.resize = function (w, h) {
|
|
3549
|
-
var
|
|
3559
|
+
var e_14, _a;
|
|
3550
3560
|
w = w || this.parentElement.clientWidth;
|
|
3551
3561
|
h = h || this.parentElement.clientHeight;
|
|
3552
3562
|
this.width = w;
|
|
@@ -3587,12 +3597,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3587
3597
|
calcInView(pen);
|
|
3588
3598
|
}
|
|
3589
3599
|
}
|
|
3590
|
-
catch (
|
|
3600
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
3591
3601
|
finally {
|
|
3592
3602
|
try {
|
|
3593
3603
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3594
3604
|
}
|
|
3595
|
-
finally { if (
|
|
3605
|
+
finally { if (e_14) throw e_14.error; }
|
|
3596
3606
|
}
|
|
3597
3607
|
};
|
|
3598
3608
|
Canvas.prototype.clearCanvas = function () {
|
|
@@ -3657,7 +3667,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3657
3667
|
this.store.histories.splice(this.store.historyIndex + 1, this.store.histories.length - this.store.historyIndex - 1);
|
|
3658
3668
|
}
|
|
3659
3669
|
(_a = action.pens) === null || _a === void 0 ? void 0 : _a.forEach(function (pen) {
|
|
3660
|
-
var
|
|
3670
|
+
var e_15, _a;
|
|
3661
3671
|
var found;
|
|
3662
3672
|
if (action.initPens) {
|
|
3663
3673
|
try {
|
|
@@ -3668,12 +3678,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3668
3678
|
}
|
|
3669
3679
|
}
|
|
3670
3680
|
}
|
|
3671
|
-
catch (
|
|
3681
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
3672
3682
|
finally {
|
|
3673
3683
|
try {
|
|
3674
3684
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3675
3685
|
}
|
|
3676
|
-
finally { if (
|
|
3686
|
+
finally { if (e_15) throw e_15.error; }
|
|
3677
3687
|
}
|
|
3678
3688
|
}
|
|
3679
3689
|
if (found) {
|
|
@@ -4322,7 +4332,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4322
4332
|
this.onMovePens();
|
|
4323
4333
|
};
|
|
4324
4334
|
Canvas.prototype.onMovePens = function () {
|
|
4325
|
-
var
|
|
4335
|
+
var e_16, _a;
|
|
4326
4336
|
var _b;
|
|
4327
4337
|
var map = this.parent.map;
|
|
4328
4338
|
if (map && map.isShow) {
|
|
@@ -4347,12 +4357,12 @@ var Canvas = /** @class */ (function () {
|
|
|
4347
4357
|
}
|
|
4348
4358
|
}
|
|
4349
4359
|
}
|
|
4350
|
-
catch (
|
|
4360
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
4351
4361
|
finally {
|
|
4352
4362
|
try {
|
|
4353
4363
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
4354
4364
|
}
|
|
4355
|
-
finally { if (
|
|
4365
|
+
finally { if (e_16) throw e_16.error; }
|
|
4356
4366
|
}
|
|
4357
4367
|
};
|
|
4358
4368
|
/**
|
|
@@ -4412,7 +4422,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4412
4422
|
});
|
|
4413
4423
|
};
|
|
4414
4424
|
Canvas.prototype.rotatePens = function (e) {
|
|
4415
|
-
var
|
|
4425
|
+
var e_17, _a;
|
|
4416
4426
|
var _this = this;
|
|
4417
4427
|
if (!this.initPens) {
|
|
4418
4428
|
this.initPens = deepClone(this.getAllByPens(this.store.active));
|
|
@@ -4439,12 +4449,12 @@ var Canvas = /** @class */ (function () {
|
|
|
4439
4449
|
this.updateLines(pen);
|
|
4440
4450
|
}
|
|
4441
4451
|
}
|
|
4442
|
-
catch (
|
|
4452
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
4443
4453
|
finally {
|
|
4444
4454
|
try {
|
|
4445
4455
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
4446
4456
|
}
|
|
4447
|
-
finally { if (
|
|
4457
|
+
finally { if (e_17) throw e_17.error; }
|
|
4448
4458
|
}
|
|
4449
4459
|
this.lastRotate = this.activeRect.rotate;
|
|
4450
4460
|
this.getSizeCPs();
|
|
@@ -4977,8 +4987,6 @@ var Canvas = /** @class */ (function () {
|
|
|
4977
4987
|
Canvas.prototype.translatePens = function (pens, x, y, doing) {
|
|
4978
4988
|
var _this = this;
|
|
4979
4989
|
if (pens === void 0) { pens = this.store.active; }
|
|
4980
|
-
x = x * this.store.data.scale;
|
|
4981
|
-
y = y * this.store.data.scale;
|
|
4982
4990
|
if (!pens || !pens.length) {
|
|
4983
4991
|
return;
|
|
4984
4992
|
}
|
|
@@ -5342,7 +5350,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5342
5350
|
return;
|
|
5343
5351
|
}
|
|
5344
5352
|
requestAnimationFrame(function () {
|
|
5345
|
-
var
|
|
5353
|
+
var e_18, _a;
|
|
5346
5354
|
var now = Date.now();
|
|
5347
5355
|
if (now - _this.lastAnimateRender < _this.store.options.animateInterval) {
|
|
5348
5356
|
if (_this.store.animates.size > 0) {
|
|
@@ -5427,12 +5435,12 @@ var Canvas = /** @class */ (function () {
|
|
|
5427
5435
|
_loop_5(pen);
|
|
5428
5436
|
}
|
|
5429
5437
|
}
|
|
5430
|
-
catch (
|
|
5438
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
5431
5439
|
finally {
|
|
5432
5440
|
try {
|
|
5433
5441
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
5434
5442
|
}
|
|
5435
|
-
finally { if (
|
|
5443
|
+
finally { if (e_18) throw e_18.error; }
|
|
5436
5444
|
}
|
|
5437
5445
|
if (active) {
|
|
5438
5446
|
_this.calcActiveRect();
|
|
@@ -5519,7 +5527,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5519
5527
|
var _a;
|
|
5520
5528
|
return __awaiter(this, void 0, void 0, function () {
|
|
5521
5529
|
var clipboardText, clipboard, _b, _c, offset, pos, curPage, rootPens, rootPens_1, rootPens_1_1, pen;
|
|
5522
|
-
var
|
|
5530
|
+
var e_19, _d;
|
|
5523
5531
|
return __generator(this, function (_e) {
|
|
5524
5532
|
switch (_e.label) {
|
|
5525
5533
|
case 0:
|
|
@@ -5592,12 +5600,12 @@ var Canvas = /** @class */ (function () {
|
|
|
5592
5600
|
this.pastePen(pen, undefined);
|
|
5593
5601
|
}
|
|
5594
5602
|
}
|
|
5595
|
-
catch (
|
|
5603
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
5596
5604
|
finally {
|
|
5597
5605
|
try {
|
|
5598
5606
|
if (rootPens_1_1 && !rootPens_1_1.done && (_d = rootPens_1.return)) _d.call(rootPens_1);
|
|
5599
5607
|
}
|
|
5600
|
-
finally { if (
|
|
5608
|
+
finally { if (e_19) throw e_19.error; }
|
|
5601
5609
|
}
|
|
5602
5610
|
sessionStorage.setItem('page', clipboard.page);
|
|
5603
5611
|
this.active(rootPens);
|
|
@@ -5615,7 +5623,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5615
5623
|
* @param pens 不包含子节点
|
|
5616
5624
|
*/
|
|
5617
5625
|
Canvas.prototype.getAllByPens = function (pens) {
|
|
5618
|
-
var
|
|
5626
|
+
var e_20, _a;
|
|
5619
5627
|
var retPens = [];
|
|
5620
5628
|
try {
|
|
5621
5629
|
for (var pens_8 = __values(pens), pens_8_1 = pens_8.next(); !pens_8_1.done; pens_8_1 = pens_8.next()) {
|
|
@@ -5623,12 +5631,12 @@ var Canvas = /** @class */ (function () {
|
|
|
5623
5631
|
retPens.push.apply(retPens, __spreadArray([], __read(deepClone(getAllChildren(pen, this.store), true)), false));
|
|
5624
5632
|
}
|
|
5625
5633
|
}
|
|
5626
|
-
catch (
|
|
5634
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
5627
5635
|
finally {
|
|
5628
5636
|
try {
|
|
5629
5637
|
if (pens_8_1 && !pens_8_1.done && (_a = pens_8.return)) _a.call(pens_8);
|
|
5630
5638
|
}
|
|
5631
|
-
finally { if (
|
|
5639
|
+
finally { if (e_20) throw e_20.error; }
|
|
5632
5640
|
}
|
|
5633
5641
|
return retPens.concat(pens);
|
|
5634
5642
|
};
|
|
@@ -5671,7 +5679,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5671
5679
|
* @param pastePens 此处复制的全部 pens (包含子节点)
|
|
5672
5680
|
*/
|
|
5673
5681
|
Canvas.prototype.changeNodeConnectedLine = function (oldId, line, pastePens) {
|
|
5674
|
-
var
|
|
5682
|
+
var e_21, _a;
|
|
5675
5683
|
var _b;
|
|
5676
5684
|
var from = line.anchors[0];
|
|
5677
5685
|
var to = line.anchors[line.anchors.length - 1];
|
|
@@ -5707,12 +5715,12 @@ var Canvas = /** @class */ (function () {
|
|
|
5707
5715
|
_loop_7(anchor);
|
|
5708
5716
|
}
|
|
5709
5717
|
}
|
|
5710
|
-
catch (
|
|
5718
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
5711
5719
|
finally {
|
|
5712
5720
|
try {
|
|
5713
5721
|
if (anchors_1_1 && !anchors_1_1.done && (_a = anchors_1.return)) _a.call(anchors_1);
|
|
5714
5722
|
}
|
|
5715
|
-
finally { if (
|
|
5723
|
+
finally { if (e_21) throw e_21.error; }
|
|
5716
5724
|
}
|
|
5717
5725
|
};
|
|
5718
5726
|
Canvas.prototype.delete = function (pens, canDelLocked, history) {
|
|
@@ -6226,7 +6234,7 @@ var Canvas = /** @class */ (function () {
|
|
|
6226
6234
|
};
|
|
6227
6235
|
};
|
|
6228
6236
|
Canvas.prototype.toPng = function (padding, callback, containBkImg) {
|
|
6229
|
-
var
|
|
6237
|
+
var e_22, _a;
|
|
6230
6238
|
if (padding === void 0) { padding = 2; }
|
|
6231
6239
|
if (containBkImg === void 0) { containBkImg = false; }
|
|
6232
6240
|
var rect = getRect(this.store.data.pens);
|
|
@@ -6314,12 +6322,12 @@ var Canvas = /** @class */ (function () {
|
|
|
6314
6322
|
pen.calculative.active = active;
|
|
6315
6323
|
}
|
|
6316
6324
|
}
|
|
6317
|
-
catch (
|
|
6325
|
+
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
6318
6326
|
finally {
|
|
6319
6327
|
try {
|
|
6320
6328
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6321
6329
|
}
|
|
6322
|
-
finally { if (
|
|
6330
|
+
finally { if (e_22) throw e_22.error; }
|
|
6323
6331
|
}
|
|
6324
6332
|
if (callback) {
|
|
6325
6333
|
canvas.toBlob(callback);
|
|
@@ -6328,7 +6336,7 @@ var Canvas = /** @class */ (function () {
|
|
|
6328
6336
|
return canvas.toDataURL();
|
|
6329
6337
|
};
|
|
6330
6338
|
Canvas.prototype.activeToPng = function (padding) {
|
|
6331
|
-
var
|
|
6339
|
+
var e_23, _a;
|
|
6332
6340
|
if (padding === void 0) { padding = 2; }
|
|
6333
6341
|
var allPens = this.getAllByPens(this.store.active);
|
|
6334
6342
|
var ids = allPens.map(function (pen) { return pen.id; });
|
|
@@ -6378,12 +6386,12 @@ var Canvas = /** @class */ (function () {
|
|
|
6378
6386
|
}
|
|
6379
6387
|
}
|
|
6380
6388
|
}
|
|
6381
|
-
catch (
|
|
6389
|
+
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
6382
6390
|
finally {
|
|
6383
6391
|
try {
|
|
6384
6392
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6385
6393
|
}
|
|
6386
|
-
finally { if (
|
|
6394
|
+
finally { if (e_23) throw e_23.error; }
|
|
6387
6395
|
}
|
|
6388
6396
|
return canvas.toDataURL();
|
|
6389
6397
|
};
|