@idraw/core 0.1.13 → 0.2.0-alpha.3
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.cjs.js +1293 -1172
- package/dist/index.d.ts +13 -59
- package/dist/index.es.js +1293 -1172
- package/dist/index.global.js +1293 -1172
- package/package.json +5 -5
package/dist/index.cjs.js
CHANGED
|
@@ -124,7 +124,7 @@ function createUUID$3() {
|
|
|
124
124
|
}
|
|
125
125
|
return "" + str4() + str4() + "-" + str4() + "-" + str4() + "-" + str4() + "-" + str4() + str4() + str4();
|
|
126
126
|
}
|
|
127
|
-
function deepClone$
|
|
127
|
+
function deepClone$6(target) {
|
|
128
128
|
function _clone(t) {
|
|
129
129
|
var type = is$2(t);
|
|
130
130
|
if (['Null', 'Number', 'String', 'Boolean', 'Undefined'].indexOf(type) >= 0) {
|
|
@@ -272,7 +272,7 @@ var index$1 = {
|
|
|
272
272
|
},
|
|
273
273
|
istype: istype$2,
|
|
274
274
|
data: {
|
|
275
|
-
deepClone: deepClone$
|
|
275
|
+
deepClone: deepClone$6,
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
278
|
var BoardEvent = (function () {
|
|
@@ -916,7 +916,7 @@ var _watcher = Symbol('_watcher');
|
|
|
916
916
|
var _render = Symbol('_render');
|
|
917
917
|
var _parsePrivateOptions = Symbol('_parsePrivateOptions');
|
|
918
918
|
var _scroller = Symbol('_scroller');
|
|
919
|
-
var _initEvent
|
|
919
|
+
var _initEvent = Symbol('_initEvent');
|
|
920
920
|
var _doScrollX = Symbol('_doScrollX');
|
|
921
921
|
var _doScrollY = Symbol('_doScrollY');
|
|
922
922
|
var _doMoveScroll = Symbol('_doMoveScroll');
|
|
@@ -1045,7 +1045,7 @@ var Board = (function () {
|
|
|
1045
1045
|
return;
|
|
1046
1046
|
}
|
|
1047
1047
|
this[_resetContext]();
|
|
1048
|
-
this[_initEvent
|
|
1048
|
+
this[_initEvent]();
|
|
1049
1049
|
this[_hasRendered] = true;
|
|
1050
1050
|
};
|
|
1051
1051
|
Board.prototype[_resetContext] = function () {
|
|
@@ -1065,7 +1065,7 @@ var Board = (function () {
|
|
|
1065
1065
|
};
|
|
1066
1066
|
return __assign(__assign({}, defaultOpts), opts);
|
|
1067
1067
|
};
|
|
1068
|
-
Board.prototype[_initEvent
|
|
1068
|
+
Board.prototype[_initEvent] = function () {
|
|
1069
1069
|
var _this = this;
|
|
1070
1070
|
if (this[_hasRendered] === true) {
|
|
1071
1071
|
return;
|
|
@@ -1206,7 +1206,7 @@ function createUUID$2() {
|
|
|
1206
1206
|
}
|
|
1207
1207
|
return "" + str4() + str4() + "-" + str4() + "-" + str4() + "-" + str4() + "-" + str4() + str4() + str4();
|
|
1208
1208
|
}
|
|
1209
|
-
function deepClone$
|
|
1209
|
+
function deepClone$5(target) {
|
|
1210
1210
|
function _clone(t) {
|
|
1211
1211
|
var type = is$1(t);
|
|
1212
1212
|
if (['Null', 'Number', 'String', 'Boolean', 'Undefined'].indexOf(type) >= 0) {
|
|
@@ -1354,10 +1354,212 @@ var index = {
|
|
|
1354
1354
|
},
|
|
1355
1355
|
istype: istype$1,
|
|
1356
1356
|
data: {
|
|
1357
|
-
deepClone: deepClone$
|
|
1357
|
+
deepClone: deepClone$5,
|
|
1358
1358
|
}
|
|
1359
1359
|
};
|
|
1360
1360
|
|
|
1361
|
+
var isColorStr$1 = index.color.isColorStr;
|
|
1362
|
+
function number(value) {
|
|
1363
|
+
return (typeof value === 'number' && (value > 0 || value <= 0));
|
|
1364
|
+
}
|
|
1365
|
+
function x(value) {
|
|
1366
|
+
return number(value);
|
|
1367
|
+
}
|
|
1368
|
+
function y(value) {
|
|
1369
|
+
return number(value);
|
|
1370
|
+
}
|
|
1371
|
+
function w(value) {
|
|
1372
|
+
return (typeof value === 'number' && value >= 0);
|
|
1373
|
+
}
|
|
1374
|
+
function h(value) {
|
|
1375
|
+
return (typeof value === 'number' && value >= 0);
|
|
1376
|
+
}
|
|
1377
|
+
function angle(value) {
|
|
1378
|
+
return (typeof value === 'number' && value >= -360 && value <= 360);
|
|
1379
|
+
}
|
|
1380
|
+
function borderWidth(value) {
|
|
1381
|
+
return w(value);
|
|
1382
|
+
}
|
|
1383
|
+
function borderRadius(value) {
|
|
1384
|
+
return number(value) && value >= 0;
|
|
1385
|
+
}
|
|
1386
|
+
function color$1(value) {
|
|
1387
|
+
return isColorStr$1(value);
|
|
1388
|
+
}
|
|
1389
|
+
function imageURL(value) {
|
|
1390
|
+
return (typeof value === 'string' && /^(http:\/\/|https:\/\/|\.\/|\/)/.test("" + value));
|
|
1391
|
+
}
|
|
1392
|
+
function imageBase64(value) {
|
|
1393
|
+
return (typeof value === 'string' && /^(data:image\/)/.test("" + value));
|
|
1394
|
+
}
|
|
1395
|
+
function imageSrc(value) {
|
|
1396
|
+
return (imageBase64(value) || imageURL(value));
|
|
1397
|
+
}
|
|
1398
|
+
function svg(value) {
|
|
1399
|
+
return (typeof value === 'string' && /^(<svg[\s]{1,}|<svg>)/i.test(("" + value).trim()) && /<\/[\s]{0,}svg>$/i.test(("" + value).trim()));
|
|
1400
|
+
}
|
|
1401
|
+
function html(value) {
|
|
1402
|
+
var result = false;
|
|
1403
|
+
if (typeof value === 'string') {
|
|
1404
|
+
var div = document.createElement('div');
|
|
1405
|
+
div.innerHTML = value;
|
|
1406
|
+
if (div.children.length > 0) {
|
|
1407
|
+
result = true;
|
|
1408
|
+
}
|
|
1409
|
+
div = null;
|
|
1410
|
+
}
|
|
1411
|
+
return result;
|
|
1412
|
+
}
|
|
1413
|
+
function text(value) {
|
|
1414
|
+
return typeof value === 'string';
|
|
1415
|
+
}
|
|
1416
|
+
function fontSize(value) {
|
|
1417
|
+
return number(value) && value > 0;
|
|
1418
|
+
}
|
|
1419
|
+
function lineHeight(value) {
|
|
1420
|
+
return number(value) && value > 0;
|
|
1421
|
+
}
|
|
1422
|
+
function textAlign(value) {
|
|
1423
|
+
return ['center', 'left', 'right'].includes(value);
|
|
1424
|
+
}
|
|
1425
|
+
function fontFamily(value) {
|
|
1426
|
+
return typeof value === 'string' && value.length > 0;
|
|
1427
|
+
}
|
|
1428
|
+
function fontWeight(value) {
|
|
1429
|
+
return ['bold'].includes(value);
|
|
1430
|
+
}
|
|
1431
|
+
var is = {
|
|
1432
|
+
x: x,
|
|
1433
|
+
y: y,
|
|
1434
|
+
w: w,
|
|
1435
|
+
h: h,
|
|
1436
|
+
angle: angle,
|
|
1437
|
+
number: number,
|
|
1438
|
+
borderWidth: borderWidth,
|
|
1439
|
+
borderRadius: borderRadius,
|
|
1440
|
+
color: color$1,
|
|
1441
|
+
imageSrc: imageSrc,
|
|
1442
|
+
imageURL: imageURL,
|
|
1443
|
+
imageBase64: imageBase64,
|
|
1444
|
+
svg: svg,
|
|
1445
|
+
html: html,
|
|
1446
|
+
text: text,
|
|
1447
|
+
fontSize: fontSize,
|
|
1448
|
+
lineHeight: lineHeight,
|
|
1449
|
+
textAlign: textAlign,
|
|
1450
|
+
fontFamily: fontFamily,
|
|
1451
|
+
fontWeight: fontWeight,
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
function attrs(attrs) {
|
|
1455
|
+
var x = attrs.x, y = attrs.y, w = attrs.w, h = attrs.h, angle = attrs.angle;
|
|
1456
|
+
if (!(is.x(x) && is.y(y) && is.w(w) && is.h(h) && is.angle(angle))) {
|
|
1457
|
+
return false;
|
|
1458
|
+
}
|
|
1459
|
+
if (!(angle >= -360 && angle <= 360)) {
|
|
1460
|
+
return false;
|
|
1461
|
+
}
|
|
1462
|
+
return true;
|
|
1463
|
+
}
|
|
1464
|
+
function box(desc) {
|
|
1465
|
+
if (desc === void 0) { desc = {}; }
|
|
1466
|
+
var borderColor = desc.borderColor, borderRadius = desc.borderRadius, borderWidth = desc.borderWidth;
|
|
1467
|
+
if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
|
|
1468
|
+
return false;
|
|
1469
|
+
}
|
|
1470
|
+
if (desc.hasOwnProperty('borderRadius') && !is.number(borderRadius)) {
|
|
1471
|
+
return false;
|
|
1472
|
+
}
|
|
1473
|
+
if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
|
|
1474
|
+
return false;
|
|
1475
|
+
}
|
|
1476
|
+
return true;
|
|
1477
|
+
}
|
|
1478
|
+
function rectDesc(desc) {
|
|
1479
|
+
var bgColor = desc.bgColor;
|
|
1480
|
+
if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
|
|
1481
|
+
return false;
|
|
1482
|
+
}
|
|
1483
|
+
if (!box(desc)) {
|
|
1484
|
+
return false;
|
|
1485
|
+
}
|
|
1486
|
+
return true;
|
|
1487
|
+
}
|
|
1488
|
+
function circleDesc(desc) {
|
|
1489
|
+
var bgColor = desc.bgColor, borderColor = desc.borderColor, borderWidth = desc.borderWidth;
|
|
1490
|
+
if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
|
|
1491
|
+
return false;
|
|
1492
|
+
}
|
|
1493
|
+
if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
|
|
1497
|
+
return false;
|
|
1498
|
+
}
|
|
1499
|
+
return true;
|
|
1500
|
+
}
|
|
1501
|
+
function imageDesc(desc) {
|
|
1502
|
+
var src = desc.src;
|
|
1503
|
+
if (!is.imageSrc(src)) {
|
|
1504
|
+
return false;
|
|
1505
|
+
}
|
|
1506
|
+
return true;
|
|
1507
|
+
}
|
|
1508
|
+
function svgDesc(desc) {
|
|
1509
|
+
var svg = desc.svg;
|
|
1510
|
+
if (!is.svg(svg)) {
|
|
1511
|
+
return false;
|
|
1512
|
+
}
|
|
1513
|
+
return true;
|
|
1514
|
+
}
|
|
1515
|
+
function htmlDesc(desc) {
|
|
1516
|
+
var html = desc.html;
|
|
1517
|
+
if (!is.html(html)) {
|
|
1518
|
+
return false;
|
|
1519
|
+
}
|
|
1520
|
+
return true;
|
|
1521
|
+
}
|
|
1522
|
+
function textDesc(desc) {
|
|
1523
|
+
var text = desc.text, color = desc.color, fontSize = desc.fontSize, lineHeight = desc.lineHeight, fontFamily = desc.fontFamily, textAlign = desc.textAlign, fontWeight = desc.fontWeight, bgColor = desc.bgColor;
|
|
1524
|
+
if (!is.text(text)) {
|
|
1525
|
+
return false;
|
|
1526
|
+
}
|
|
1527
|
+
if (!is.color(color)) {
|
|
1528
|
+
return false;
|
|
1529
|
+
}
|
|
1530
|
+
if (!is.fontSize(fontSize)) {
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1533
|
+
if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
|
|
1534
|
+
return false;
|
|
1535
|
+
}
|
|
1536
|
+
if (desc.hasOwnProperty('fontWeight') && !is.fontWeight(fontWeight)) {
|
|
1537
|
+
return false;
|
|
1538
|
+
}
|
|
1539
|
+
if (desc.hasOwnProperty('lineHeight') && !is.lineHeight(lineHeight)) {
|
|
1540
|
+
return false;
|
|
1541
|
+
}
|
|
1542
|
+
if (desc.hasOwnProperty('fontFamily') && !is.fontFamily(fontFamily)) {
|
|
1543
|
+
return false;
|
|
1544
|
+
}
|
|
1545
|
+
if (desc.hasOwnProperty('textAlign') && !is.textAlign(textAlign)) {
|
|
1546
|
+
return false;
|
|
1547
|
+
}
|
|
1548
|
+
if (!box(desc)) {
|
|
1549
|
+
return false;
|
|
1550
|
+
}
|
|
1551
|
+
return true;
|
|
1552
|
+
}
|
|
1553
|
+
var check = {
|
|
1554
|
+
attrs: attrs,
|
|
1555
|
+
textDesc: textDesc,
|
|
1556
|
+
rectDesc: rectDesc,
|
|
1557
|
+
circleDesc: circleDesc,
|
|
1558
|
+
imageDesc: imageDesc,
|
|
1559
|
+
svgDesc: svgDesc,
|
|
1560
|
+
htmlDesc: htmlDesc,
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1361
1563
|
function parseRadianToAngle(radian) {
|
|
1362
1564
|
return radian / Math.PI * 180;
|
|
1363
1565
|
}
|
|
@@ -1442,7 +1644,7 @@ function rotateContext(ctx, center, radian, callback) {
|
|
|
1442
1644
|
}
|
|
1443
1645
|
}
|
|
1444
1646
|
|
|
1445
|
-
var istype = index.istype, color
|
|
1647
|
+
var istype = index.istype, color = index.color;
|
|
1446
1648
|
function clearContext(ctx) {
|
|
1447
1649
|
ctx.setFillStyle('#000000');
|
|
1448
1650
|
ctx.setStrokeStyle('#000000');
|
|
@@ -1488,7 +1690,7 @@ function drawBoxBorder(ctx, elem) {
|
|
|
1488
1690
|
}
|
|
1489
1691
|
var bw = elem.desc.borderWidth;
|
|
1490
1692
|
var borderColor = '#000000';
|
|
1491
|
-
if (color
|
|
1693
|
+
if (color.isColorStr(elem.desc.borderColor) === true) {
|
|
1492
1694
|
borderColor = elem.desc.borderColor;
|
|
1493
1695
|
}
|
|
1494
1696
|
var x = elem.x - bw / 2;
|
|
@@ -1514,7 +1716,7 @@ function drawBoxBorder(ctx, elem) {
|
|
|
1514
1716
|
}
|
|
1515
1717
|
|
|
1516
1718
|
function drawRect(ctx, elem) {
|
|
1517
|
-
drawBox(ctx, elem, elem.desc.
|
|
1719
|
+
drawBox(ctx, elem, elem.desc.bgColor);
|
|
1518
1720
|
}
|
|
1519
1721
|
|
|
1520
1722
|
function drawImage(ctx, elem, loader) {
|
|
@@ -1613,7 +1815,7 @@ function drawText(ctx, elem, loader, helperConfig) {
|
|
|
1613
1815
|
function drawCircle(ctx, elem) {
|
|
1614
1816
|
rotateElement(ctx, elem, function (ctx) {
|
|
1615
1817
|
var x = elem.x, y = elem.y, w = elem.w, h = elem.h, desc = elem.desc;
|
|
1616
|
-
var _a = desc.
|
|
1818
|
+
var _a = desc.bgColor, bgColor = _a === void 0 ? '#000000' : _a, _b = desc.borderColor, borderColor = _b === void 0 ? '#000000' : _b, borderWidth = desc.borderWidth;
|
|
1617
1819
|
var a = w / 2;
|
|
1618
1820
|
var b = h / 2;
|
|
1619
1821
|
var centerX = x + a;
|
|
@@ -1633,7 +1835,7 @@ function drawCircle(ctx, elem) {
|
|
|
1633
1835
|
ctx.stroke();
|
|
1634
1836
|
}
|
|
1635
1837
|
ctx.beginPath();
|
|
1636
|
-
ctx.setFillStyle(
|
|
1838
|
+
ctx.setFillStyle(bgColor);
|
|
1637
1839
|
ctx.moveTo(centerX + a, centerY);
|
|
1638
1840
|
for (var i = 0; i < 2 * Math.PI; i += unit) {
|
|
1639
1841
|
ctx.lineTo(centerX + a * Math.cos(i), centerY + b * Math.sin(i));
|
|
@@ -1776,13 +1978,13 @@ function drawElementListWrappers(ctx, config) {
|
|
|
1776
1978
|
});
|
|
1777
1979
|
}
|
|
1778
1980
|
|
|
1779
|
-
var isColorStr
|
|
1981
|
+
var isColorStr = index.color.isColorStr;
|
|
1780
1982
|
function drawContext(ctx, data, helperConfig, loader) {
|
|
1781
1983
|
var _a;
|
|
1782
1984
|
clearContext(ctx);
|
|
1783
1985
|
var size = ctx.getSize();
|
|
1784
1986
|
ctx.clearRect(0, 0, size.contextWidth, size.contextHeight);
|
|
1785
|
-
if (typeof data.bgColor === 'string' && isColorStr
|
|
1987
|
+
if (typeof data.bgColor === 'string' && isColorStr(data.bgColor)) {
|
|
1786
1988
|
drawBgColor(ctx, data.bgColor);
|
|
1787
1989
|
}
|
|
1788
1990
|
if (!(data.elements.length > 0)) {
|
|
@@ -1825,11 +2027,30 @@ function drawContext(ctx, data, helperConfig, loader) {
|
|
|
1825
2027
|
drawElementListWrappers(ctx, helperConfig);
|
|
1826
2028
|
}
|
|
1827
2029
|
|
|
1828
|
-
var
|
|
1829
|
-
|
|
2030
|
+
var defaultConfig = {
|
|
2031
|
+
elementWrapper: {
|
|
2032
|
+
color: '#2ab6f1',
|
|
2033
|
+
lockColor: '#aaaaaa',
|
|
2034
|
+
dotSize: 6,
|
|
2035
|
+
lineWidth: 1,
|
|
2036
|
+
lineDash: [4, 3],
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2039
|
+
function mergeConfig(config) {
|
|
2040
|
+
var result = index.data.deepClone(defaultConfig);
|
|
2041
|
+
if (config) {
|
|
2042
|
+
if (config.elementWrapper) {
|
|
2043
|
+
result.elementWrapper = __assign$1(__assign$1({}, result.elementWrapper), config.elementWrapper);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
return result;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
var CoreEvent = (function () {
|
|
2050
|
+
function CoreEvent() {
|
|
1830
2051
|
this._listeners = new Map();
|
|
1831
2052
|
}
|
|
1832
|
-
|
|
2053
|
+
CoreEvent.prototype.on = function (eventKey, callback) {
|
|
1833
2054
|
if (this._listeners.has(eventKey)) {
|
|
1834
2055
|
var callbacks = this._listeners.get(eventKey);
|
|
1835
2056
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
@@ -1839,7 +2060,7 @@ var LoaderEvent = (function () {
|
|
|
1839
2060
|
this._listeners.set(eventKey, [callback]);
|
|
1840
2061
|
}
|
|
1841
2062
|
};
|
|
1842
|
-
|
|
2063
|
+
CoreEvent.prototype.off = function (eventKey, callback) {
|
|
1843
2064
|
if (this._listeners.has(eventKey)) {
|
|
1844
2065
|
var callbacks = this._listeners.get(eventKey);
|
|
1845
2066
|
if (Array.isArray(callbacks)) {
|
|
@@ -1853,7 +2074,7 @@ var LoaderEvent = (function () {
|
|
|
1853
2074
|
this._listeners.set(eventKey, callbacks || []);
|
|
1854
2075
|
}
|
|
1855
2076
|
};
|
|
1856
|
-
|
|
2077
|
+
CoreEvent.prototype.trigger = function (eventKey, arg) {
|
|
1857
2078
|
var callbacks = this._listeners.get(eventKey);
|
|
1858
2079
|
if (Array.isArray(callbacks)) {
|
|
1859
2080
|
callbacks.forEach(function (cb) {
|
|
@@ -1865,7 +2086,7 @@ var LoaderEvent = (function () {
|
|
|
1865
2086
|
return false;
|
|
1866
2087
|
}
|
|
1867
2088
|
};
|
|
1868
|
-
|
|
2089
|
+
CoreEvent.prototype.has = function (name) {
|
|
1869
2090
|
if (this._listeners.has(name)) {
|
|
1870
2091
|
var list = this._listeners.get(name);
|
|
1871
2092
|
if (Array.isArray(list) && list.length > 0) {
|
|
@@ -1874,327 +2095,87 @@ var LoaderEvent = (function () {
|
|
|
1874
2095
|
}
|
|
1875
2096
|
return false;
|
|
1876
2097
|
};
|
|
1877
|
-
return
|
|
2098
|
+
return CoreEvent;
|
|
1878
2099
|
}());
|
|
1879
2100
|
|
|
1880
|
-
function
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
var
|
|
1886
|
-
(
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
}
|
|
1902
|
-
Loader.prototype.load = function (data, changeResourceUUIDs) {
|
|
1903
|
-
var _a = this._resetLoadData(data, changeResourceUUIDs), uuidQueue = _a[0], loadData = _a[1];
|
|
1904
|
-
if (this._status === LoaderStatus.FREE || this._status === LoaderStatus.COMPLETE) {
|
|
1905
|
-
this._currentUUIDQueue = uuidQueue;
|
|
1906
|
-
this._currentLoadData = loadData;
|
|
1907
|
-
this._loadTask();
|
|
1908
|
-
}
|
|
1909
|
-
else if (this._status === LoaderStatus.LOADING && uuidQueue.length > 0) {
|
|
1910
|
-
this._waitingLoadQueue.push({
|
|
1911
|
-
uuidQueue: uuidQueue,
|
|
1912
|
-
loadData: loadData,
|
|
1913
|
-
});
|
|
1914
|
-
}
|
|
1915
|
-
};
|
|
1916
|
-
Loader.prototype.on = function (name, callback) {
|
|
1917
|
-
this._event.on(name, callback);
|
|
1918
|
-
};
|
|
1919
|
-
Loader.prototype.off = function (name, callback) {
|
|
1920
|
-
this._event.off(name, callback);
|
|
1921
|
-
};
|
|
1922
|
-
Loader.prototype.isComplete = function () {
|
|
1923
|
-
return this._status === LoaderStatus.COMPLETE;
|
|
1924
|
-
};
|
|
1925
|
-
Loader.prototype.getContent = function (uuid) {
|
|
1926
|
-
var _a;
|
|
1927
|
-
if (((_a = this._storageLoadData[uuid]) === null || _a === void 0 ? void 0 : _a.status) === 'loaded') {
|
|
1928
|
-
return this._storageLoadData[uuid].content;
|
|
1929
|
-
}
|
|
1930
|
-
return null;
|
|
1931
|
-
};
|
|
1932
|
-
Loader.prototype._resetLoadData = function (data, changeResourceUUIDs) {
|
|
1933
|
-
var loadData = {};
|
|
1934
|
-
var uuidQueue = [];
|
|
1935
|
-
var storageLoadData = this._storageLoadData;
|
|
1936
|
-
for (var i = data.elements.length - 1; i >= 0; i--) {
|
|
1937
|
-
var elem = data.elements[i];
|
|
1938
|
-
if (['image', 'svg', 'html',].includes(elem.type)) {
|
|
1939
|
-
if (!storageLoadData[elem.uuid]) {
|
|
1940
|
-
loadData[elem.uuid] = this._createEmptyLoadItem(elem);
|
|
1941
|
-
uuidQueue.push(elem.uuid);
|
|
1942
|
-
}
|
|
1943
|
-
else {
|
|
1944
|
-
if (changeResourceUUIDs.includes(elem.uuid)) {
|
|
1945
|
-
loadData[elem.uuid] = this._createEmptyLoadItem(elem);
|
|
1946
|
-
uuidQueue.push(elem.uuid);
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
return [uuidQueue, loadData];
|
|
1952
|
-
};
|
|
1953
|
-
Loader.prototype._createEmptyLoadItem = function (elem) {
|
|
1954
|
-
var source = '';
|
|
1955
|
-
var type = elem.type;
|
|
1956
|
-
var elemW = elem.w;
|
|
1957
|
-
var elemH = elem.h;
|
|
1958
|
-
if (elem.type === 'image') {
|
|
1959
|
-
var _elem = elem;
|
|
1960
|
-
source = _elem.desc.src || '';
|
|
1961
|
-
}
|
|
1962
|
-
else if (elem.type === 'svg') {
|
|
1963
|
-
var _elem = elem;
|
|
1964
|
-
source = _elem.desc.svg || '';
|
|
1965
|
-
}
|
|
1966
|
-
else if (elem.type === 'html') {
|
|
1967
|
-
var _elem = elem;
|
|
1968
|
-
source = filterScript(_elem.desc.html || '');
|
|
1969
|
-
elemW = _elem.desc.width || elem.w;
|
|
1970
|
-
elemH = _elem.desc.height || elem.h;
|
|
2101
|
+
function isChangeImageElementResource(before, after) {
|
|
2102
|
+
var _a, _b;
|
|
2103
|
+
return (((_a = before === null || before === void 0 ? void 0 : before.desc) === null || _a === void 0 ? void 0 : _a.src) !== ((_b = after === null || after === void 0 ? void 0 : after.desc) === null || _b === void 0 ? void 0 : _b.src));
|
|
2104
|
+
}
|
|
2105
|
+
function isChangeSVGElementResource(before, after) {
|
|
2106
|
+
var _a, _b;
|
|
2107
|
+
return (((_a = before === null || before === void 0 ? void 0 : before.desc) === null || _a === void 0 ? void 0 : _a.svg) !== ((_b = after === null || after === void 0 ? void 0 : after.desc) === null || _b === void 0 ? void 0 : _b.svg));
|
|
2108
|
+
}
|
|
2109
|
+
function isChangeHTMLElementResource(before, after) {
|
|
2110
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2111
|
+
return (((_a = before === null || before === void 0 ? void 0 : before.desc) === null || _a === void 0 ? void 0 : _a.html) !== ((_b = after === null || after === void 0 ? void 0 : after.desc) === null || _b === void 0 ? void 0 : _b.html)
|
|
2112
|
+
|| ((_c = before === null || before === void 0 ? void 0 : before.desc) === null || _c === void 0 ? void 0 : _c.width) !== ((_d = after === null || after === void 0 ? void 0 : after.desc) === null || _d === void 0 ? void 0 : _d.width)
|
|
2113
|
+
|| ((_e = before === null || before === void 0 ? void 0 : before.desc) === null || _e === void 0 ? void 0 : _e.height) !== ((_f = after === null || after === void 0 ? void 0 : after.desc) === null || _f === void 0 ? void 0 : _f.height));
|
|
2114
|
+
}
|
|
2115
|
+
function diffElementResourceChange(before, after) {
|
|
2116
|
+
var result = null;
|
|
2117
|
+
var isChange = false;
|
|
2118
|
+
switch (after.type) {
|
|
2119
|
+
case 'image': {
|
|
2120
|
+
isChange = isChangeImageElementResource(before, after);
|
|
2121
|
+
break;
|
|
1971
2122
|
}
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
content: null,
|
|
1976
|
-
source: source,
|
|
1977
|
-
elemW: elemW,
|
|
1978
|
-
elemH: elemH,
|
|
1979
|
-
};
|
|
1980
|
-
};
|
|
1981
|
-
Loader.prototype._loadTask = function () {
|
|
1982
|
-
var _this = this;
|
|
1983
|
-
if (this._status === LoaderStatus.LOADING) {
|
|
1984
|
-
return;
|
|
2123
|
+
case 'svg': {
|
|
2124
|
+
isChange = isChangeSVGElementResource(before, after);
|
|
2125
|
+
break;
|
|
1985
2126
|
}
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
this._status = LoaderStatus.COMPLETE;
|
|
1990
|
-
this._event.trigger('complete', undefined);
|
|
1991
|
-
return;
|
|
1992
|
-
}
|
|
1993
|
-
else {
|
|
1994
|
-
var waitingItem = this._waitingLoadQueue.shift();
|
|
1995
|
-
if (waitingItem) {
|
|
1996
|
-
var uuidQueue = waitingItem.uuidQueue, loadData = waitingItem.loadData;
|
|
1997
|
-
this._currentLoadData = loadData;
|
|
1998
|
-
this._currentUUIDQueue = uuidQueue;
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2127
|
+
case 'html': {
|
|
2128
|
+
isChange = isChangeHTMLElementResource(before, after);
|
|
2129
|
+
break;
|
|
2001
2130
|
}
|
|
2002
|
-
var maxParallelNum = this._opts.maxParallelNum;
|
|
2003
|
-
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
2004
|
-
var uuidMap = {};
|
|
2005
|
-
uuids.forEach(function (url, i) {
|
|
2006
|
-
uuidMap[url] = i;
|
|
2007
|
-
});
|
|
2008
|
-
var loadUUIDList = [];
|
|
2009
|
-
var _loadAction = function () {
|
|
2010
|
-
if (loadUUIDList.length >= maxParallelNum) {
|
|
2011
|
-
return false;
|
|
2012
|
-
}
|
|
2013
|
-
if (uuids.length === 0) {
|
|
2014
|
-
return true;
|
|
2015
|
-
}
|
|
2016
|
-
var _loop_1 = function (i) {
|
|
2017
|
-
var uuid = uuids.shift();
|
|
2018
|
-
if (uuid === undefined) {
|
|
2019
|
-
return "break";
|
|
2020
|
-
}
|
|
2021
|
-
loadUUIDList.push(uuid);
|
|
2022
|
-
_this._loadElementSource(_this._currentLoadData[uuid]).then(function (image) {
|
|
2023
|
-
loadUUIDList.splice(loadUUIDList.indexOf(uuid), 1);
|
|
2024
|
-
var status = _loadAction();
|
|
2025
|
-
_this._storageLoadData[uuid] = {
|
|
2026
|
-
type: _this._currentLoadData[uuid].type,
|
|
2027
|
-
status: 'loaded',
|
|
2028
|
-
content: image,
|
|
2029
|
-
source: _this._currentLoadData[uuid].source,
|
|
2030
|
-
elemW: _this._currentLoadData[uuid].elemW,
|
|
2031
|
-
elemH: _this._currentLoadData[uuid].elemH,
|
|
2032
|
-
};
|
|
2033
|
-
if (loadUUIDList.length === 0 && uuids.length === 0 && status === true) {
|
|
2034
|
-
_this._status = LoaderStatus.FREE;
|
|
2035
|
-
_this._loadTask();
|
|
2036
|
-
}
|
|
2037
|
-
_this._event.trigger('load', {
|
|
2038
|
-
type: _this._storageLoadData[uuid].type,
|
|
2039
|
-
status: _this._storageLoadData[uuid].status,
|
|
2040
|
-
content: _this._storageLoadData[uuid].content,
|
|
2041
|
-
source: _this._storageLoadData[uuid].source,
|
|
2042
|
-
elemW: _this._storageLoadData[uuid].elemW,
|
|
2043
|
-
elemH: _this._storageLoadData[uuid].elemH,
|
|
2044
|
-
});
|
|
2045
|
-
}).catch(function (err) {
|
|
2046
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2047
|
-
console.warn(err);
|
|
2048
|
-
loadUUIDList.splice(loadUUIDList.indexOf(uuid), 1);
|
|
2049
|
-
var status = _loadAction();
|
|
2050
|
-
if (_this._currentLoadData[uuid]) {
|
|
2051
|
-
_this._storageLoadData[uuid] = {
|
|
2052
|
-
type: (_a = _this._currentLoadData[uuid]) === null || _a === void 0 ? void 0 : _a.type,
|
|
2053
|
-
status: 'fail',
|
|
2054
|
-
content: null,
|
|
2055
|
-
error: err,
|
|
2056
|
-
source: (_b = _this._currentLoadData[uuid]) === null || _b === void 0 ? void 0 : _b.source,
|
|
2057
|
-
elemW: (_c = _this._currentLoadData[uuid]) === null || _c === void 0 ? void 0 : _c.elemW,
|
|
2058
|
-
elemH: (_d = _this._currentLoadData[uuid]) === null || _d === void 0 ? void 0 : _d.elemH,
|
|
2059
|
-
};
|
|
2060
|
-
}
|
|
2061
|
-
if (loadUUIDList.length === 0 && uuids.length === 0 && status === true) {
|
|
2062
|
-
_this._status = LoaderStatus.FREE;
|
|
2063
|
-
_this._loadTask();
|
|
2064
|
-
}
|
|
2065
|
-
if (_this._currentLoadData[uuid]) {
|
|
2066
|
-
_this._event.trigger('error', {
|
|
2067
|
-
type: (_e = _this._storageLoadData[uuid]) === null || _e === void 0 ? void 0 : _e.type,
|
|
2068
|
-
status: (_f = _this._storageLoadData[uuid]) === null || _f === void 0 ? void 0 : _f.status,
|
|
2069
|
-
content: (_g = _this._storageLoadData[uuid]) === null || _g === void 0 ? void 0 : _g.content,
|
|
2070
|
-
source: (_h = _this._storageLoadData[uuid]) === null || _h === void 0 ? void 0 : _h.source,
|
|
2071
|
-
elemW: (_j = _this._storageLoadData[uuid]) === null || _j === void 0 ? void 0 : _j.elemW,
|
|
2072
|
-
elemH: (_k = _this._storageLoadData[uuid]) === null || _k === void 0 ? void 0 : _k.elemH,
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
});
|
|
2076
|
-
};
|
|
2077
|
-
for (var i = loadUUIDList.length; i < maxParallelNum; i++) {
|
|
2078
|
-
var state_1 = _loop_1();
|
|
2079
|
-
if (state_1 === "break")
|
|
2080
|
-
break;
|
|
2081
|
-
}
|
|
2082
|
-
return false;
|
|
2083
|
-
};
|
|
2084
|
-
_loadAction();
|
|
2085
|
-
};
|
|
2086
|
-
Loader.prototype._loadElementSource = function (params) {
|
|
2087
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2088
|
-
var image, image, image;
|
|
2089
|
-
return __generator(this, function (_a) {
|
|
2090
|
-
switch (_a.label) {
|
|
2091
|
-
case 0:
|
|
2092
|
-
if (!(params && params.type === 'image')) return [3, 2];
|
|
2093
|
-
return [4, loadImage(params.source)];
|
|
2094
|
-
case 1:
|
|
2095
|
-
image = _a.sent();
|
|
2096
|
-
return [2, image];
|
|
2097
|
-
case 2:
|
|
2098
|
-
if (!(params && params.type === 'svg')) return [3, 4];
|
|
2099
|
-
return [4, loadSVG(params.source)];
|
|
2100
|
-
case 3:
|
|
2101
|
-
image = _a.sent();
|
|
2102
|
-
return [2, image];
|
|
2103
|
-
case 4:
|
|
2104
|
-
if (!(params && params.type === 'html')) return [3, 6];
|
|
2105
|
-
return [4, loadHTML(params.source, {
|
|
2106
|
-
width: params.elemW, height: params.elemH
|
|
2107
|
-
})];
|
|
2108
|
-
case 5:
|
|
2109
|
-
image = _a.sent();
|
|
2110
|
-
return [2, image];
|
|
2111
|
-
case 6: throw Error('Element\'s source is not support!');
|
|
2112
|
-
}
|
|
2113
|
-
});
|
|
2114
|
-
});
|
|
2115
|
-
};
|
|
2116
|
-
return Loader;
|
|
2117
|
-
}());
|
|
2118
|
-
|
|
2119
|
-
var requestAnimationFrame = window.requestAnimationFrame;
|
|
2120
|
-
var deepClone$3 = index.data.deepClone;
|
|
2121
|
-
var DrawStatus;
|
|
2122
|
-
(function (DrawStatus) {
|
|
2123
|
-
DrawStatus["FREE"] = "free";
|
|
2124
|
-
DrawStatus["DRAWING"] = "drawing";
|
|
2125
|
-
})(DrawStatus || (DrawStatus = {}));
|
|
2126
|
-
var Renderer = (function () {
|
|
2127
|
-
function Renderer(board) {
|
|
2128
|
-
var _this = this;
|
|
2129
|
-
this._queue = [];
|
|
2130
|
-
this._status = DrawStatus.FREE;
|
|
2131
|
-
this._board = board;
|
|
2132
|
-
this._loader = new Loader({
|
|
2133
|
-
board: board,
|
|
2134
|
-
maxParallelNum: 6
|
|
2135
|
-
});
|
|
2136
|
-
this._loader.on('load', function (res) {
|
|
2137
|
-
_this._drawFrame();
|
|
2138
|
-
});
|
|
2139
|
-
this._loader.on('error', function (res) {
|
|
2140
|
-
console.log('Loader Error: ', res);
|
|
2141
|
-
});
|
|
2142
|
-
this._loader.on('complete', function (res) {
|
|
2143
|
-
});
|
|
2144
2131
|
}
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2132
|
+
if (isChange === true) {
|
|
2133
|
+
result = after.uuid;
|
|
2134
|
+
}
|
|
2135
|
+
return result;
|
|
2136
|
+
}
|
|
2137
|
+
function diffElementResourceChangeList(before, after) {
|
|
2138
|
+
var _a;
|
|
2139
|
+
var uuids = [];
|
|
2140
|
+
var beforeMap = parseDataElementMap(before);
|
|
2141
|
+
var afterMap = parseDataElementMap(after);
|
|
2142
|
+
for (var uuid in afterMap) {
|
|
2143
|
+
if (['image', 'svg', 'html'].includes((_a = afterMap[uuid]) === null || _a === void 0 ? void 0 : _a.type) !== true) {
|
|
2144
|
+
continue;
|
|
2151
2145
|
}
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
var item = _this._queue[0];
|
|
2159
|
-
var isLastFrame = false;
|
|
2160
|
-
if (_this._queue.length > 1) {
|
|
2161
|
-
item = _this._queue.shift();
|
|
2162
|
-
}
|
|
2163
|
-
else {
|
|
2164
|
-
isLastFrame = true;
|
|
2165
|
-
}
|
|
2166
|
-
if (_this._loader.isComplete() !== true) {
|
|
2167
|
-
_this._drawFrame();
|
|
2168
|
-
if (item) {
|
|
2169
|
-
drawContext(ctx, item.data, item.helper, _this._loader);
|
|
2170
|
-
_this._board.draw();
|
|
2146
|
+
if (beforeMap[uuid]) {
|
|
2147
|
+
var isChange = false;
|
|
2148
|
+
switch (beforeMap[uuid].type) {
|
|
2149
|
+
case 'image': {
|
|
2150
|
+
isChange = isChangeImageElementResource(beforeMap[uuid], afterMap[uuid]);
|
|
2151
|
+
break;
|
|
2171
2152
|
}
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
_this._board.draw();
|
|
2176
|
-
_this._retainQueueOneItem();
|
|
2177
|
-
if (!isLastFrame) {
|
|
2178
|
-
_this._drawFrame();
|
|
2153
|
+
case 'svg': {
|
|
2154
|
+
isChange = isChangeSVGElementResource(beforeMap[uuid], afterMap[uuid]);
|
|
2155
|
+
break;
|
|
2179
2156
|
}
|
|
2180
|
-
|
|
2181
|
-
|
|
2157
|
+
case 'html': {
|
|
2158
|
+
isChange = isChangeHTMLElementResource(beforeMap[uuid], afterMap[uuid]);
|
|
2159
|
+
break;
|
|
2182
2160
|
}
|
|
2183
2161
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2162
|
+
if (isChange === true) {
|
|
2163
|
+
uuids.push(uuid);
|
|
2186
2164
|
}
|
|
2187
|
-
});
|
|
2188
|
-
};
|
|
2189
|
-
Renderer.prototype._retainQueueOneItem = function () {
|
|
2190
|
-
if (this._queue.length <= 1) {
|
|
2191
|
-
return;
|
|
2192
2165
|
}
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2166
|
+
else {
|
|
2167
|
+
uuids.push(uuid);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
return uuids;
|
|
2171
|
+
}
|
|
2172
|
+
function parseDataElementMap(data) {
|
|
2173
|
+
var elemMap = {};
|
|
2174
|
+
data.elements.forEach(function (elem) {
|
|
2175
|
+
elemMap[elem.uuid] = elem;
|
|
2176
|
+
});
|
|
2177
|
+
return elemMap;
|
|
2178
|
+
}
|
|
2198
2179
|
|
|
2199
2180
|
function limitNum(num) {
|
|
2200
2181
|
var numStr = num.toFixed(2);
|
|
@@ -2369,7 +2350,7 @@ var Element = (function () {
|
|
|
2369
2350
|
return Element;
|
|
2370
2351
|
}());
|
|
2371
2352
|
|
|
2372
|
-
var deepClone$
|
|
2353
|
+
var deepClone$4 = index.data.deepClone;
|
|
2373
2354
|
var Helper = (function () {
|
|
2374
2355
|
function Helper(board, config) {
|
|
2375
2356
|
this._areaStart = { x: 0, y: 0 };
|
|
@@ -2387,7 +2368,7 @@ var Helper = (function () {
|
|
|
2387
2368
|
this._updateSelectedElementListWrapper(data, opts);
|
|
2388
2369
|
};
|
|
2389
2370
|
Helper.prototype.getConfig = function () {
|
|
2390
|
-
return deepClone$
|
|
2371
|
+
return deepClone$4(this._helperConfig);
|
|
2391
2372
|
};
|
|
2392
2373
|
Helper.prototype.getElementIndexByUUID = function (uuid) {
|
|
2393
2374
|
var index = this._helperConfig.elementIndexMap[uuid];
|
|
@@ -2396,25 +2377,71 @@ var Helper = (function () {
|
|
|
2396
2377
|
}
|
|
2397
2378
|
return null;
|
|
2398
2379
|
};
|
|
2399
|
-
Helper.prototype.isPointInElementWrapperDot = function (p) {
|
|
2380
|
+
Helper.prototype.isPointInElementWrapperDot = function (p, data) {
|
|
2400
2381
|
var _a, _b;
|
|
2401
2382
|
var ctx = this._ctx;
|
|
2402
|
-
var uuid = (_b = (_a = this._helperConfig) === null || _a === void 0 ? void 0 : _a.selectedElementWrapper) === null || _b === void 0 ? void 0 : _b.uuid;
|
|
2383
|
+
var uuid = ((_b = (_a = this._helperConfig) === null || _a === void 0 ? void 0 : _a.selectedElementWrapper) === null || _b === void 0 ? void 0 : _b.uuid) || null;
|
|
2384
|
+
var directIdx = null;
|
|
2403
2385
|
var direction = null;
|
|
2404
2386
|
if (!this._helperConfig.selectedElementWrapper) {
|
|
2405
|
-
return [
|
|
2387
|
+
return [uuid, direction, directIdx];
|
|
2406
2388
|
}
|
|
2407
2389
|
var wrapper = this._helperConfig.selectedElementWrapper;
|
|
2408
2390
|
var dots = [
|
|
2409
|
-
wrapper.dots.
|
|
2410
|
-
wrapper.dots.
|
|
2411
|
-
wrapper.dots.
|
|
2391
|
+
wrapper.dots.right,
|
|
2392
|
+
wrapper.dots.topRight,
|
|
2393
|
+
wrapper.dots.top,
|
|
2394
|
+
wrapper.dots.topLeft,
|
|
2395
|
+
wrapper.dots.left,
|
|
2396
|
+
wrapper.dots.bottomLeft,
|
|
2397
|
+
wrapper.dots.bottom,
|
|
2398
|
+
wrapper.dots.bottomRight,
|
|
2412
2399
|
];
|
|
2413
2400
|
var directionNames = [
|
|
2414
|
-
'
|
|
2415
|
-
'
|
|
2416
|
-
'
|
|
2401
|
+
'right',
|
|
2402
|
+
'top-right',
|
|
2403
|
+
'top',
|
|
2404
|
+
'top-left',
|
|
2405
|
+
'left',
|
|
2406
|
+
'bottom-left',
|
|
2407
|
+
'bottom',
|
|
2408
|
+
'bottom-right',
|
|
2417
2409
|
];
|
|
2410
|
+
var angleMoveNum = 0;
|
|
2411
|
+
if (data && uuid) {
|
|
2412
|
+
var elemIdx = this.getElementIndexByUUID(uuid);
|
|
2413
|
+
if (elemIdx !== null && elemIdx >= 0) {
|
|
2414
|
+
var elem = data.elements[elemIdx];
|
|
2415
|
+
var angle = elem.angle;
|
|
2416
|
+
if (angle < 0) {
|
|
2417
|
+
angle += 360;
|
|
2418
|
+
}
|
|
2419
|
+
if (angle < 45) {
|
|
2420
|
+
angleMoveNum = 0;
|
|
2421
|
+
}
|
|
2422
|
+
else if (angle < 90) {
|
|
2423
|
+
angleMoveNum = 1;
|
|
2424
|
+
}
|
|
2425
|
+
else if (angle < 135) {
|
|
2426
|
+
angleMoveNum = 2;
|
|
2427
|
+
}
|
|
2428
|
+
else if (angle < 180) {
|
|
2429
|
+
angleMoveNum = 3;
|
|
2430
|
+
}
|
|
2431
|
+
else if (angle < 225) {
|
|
2432
|
+
angleMoveNum = 4;
|
|
2433
|
+
}
|
|
2434
|
+
else if (angle < 270) {
|
|
2435
|
+
angleMoveNum = 5;
|
|
2436
|
+
}
|
|
2437
|
+
else if (angle < 315) {
|
|
2438
|
+
angleMoveNum = 6;
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
if (angleMoveNum > 0) {
|
|
2443
|
+
directionNames = directionNames.slice(-angleMoveNum).concat(directionNames.slice(0, -angleMoveNum));
|
|
2444
|
+
}
|
|
2418
2445
|
rotateContext(ctx, wrapper.translate, wrapper.radian || 0, function () {
|
|
2419
2446
|
for (var i = 0; i < dots.length; i++) {
|
|
2420
2447
|
var dot = dots[i];
|
|
@@ -2425,11 +2452,23 @@ var Helper = (function () {
|
|
|
2425
2452
|
direction = directionNames[i];
|
|
2426
2453
|
}
|
|
2427
2454
|
if (direction) {
|
|
2455
|
+
directIdx = i;
|
|
2428
2456
|
break;
|
|
2429
2457
|
}
|
|
2430
2458
|
}
|
|
2431
2459
|
});
|
|
2432
|
-
|
|
2460
|
+
if (direction === null) {
|
|
2461
|
+
rotateContext(ctx, wrapper.translate, wrapper.radian || 0, function () {
|
|
2462
|
+
var dot = wrapper.dots.rotate;
|
|
2463
|
+
ctx.beginPath();
|
|
2464
|
+
ctx.arc(dot.x, dot.y, wrapper.dotSize, 0, Math.PI * 2);
|
|
2465
|
+
ctx.closePath();
|
|
2466
|
+
if (ctx.isPointInPath(p.x, p.y)) {
|
|
2467
|
+
direction = 'rotate';
|
|
2468
|
+
}
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
return [uuid, direction, directIdx];
|
|
2433
2472
|
};
|
|
2434
2473
|
Helper.prototype.isPointInElementList = function (p, data) {
|
|
2435
2474
|
var _a, _b;
|
|
@@ -2573,70 +2612,361 @@ var Helper = (function () {
|
|
|
2573
2612
|
wrapperList.push(wrapper);
|
|
2574
2613
|
}
|
|
2575
2614
|
});
|
|
2576
|
-
this._helperConfig.selectedElementListWrappers = wrapperList;
|
|
2577
|
-
};
|
|
2578
|
-
Helper.prototype._createSelectedElementWrapper = function (elem, opts) {
|
|
2579
|
-
var _a, _b, _c;
|
|
2580
|
-
var scale = opts.scale;
|
|
2581
|
-
var elemWrapper = this._coreConfig.elementWrapper;
|
|
2582
|
-
var dotSize = elemWrapper.dotSize / scale;
|
|
2583
|
-
var lineWidth = elemWrapper.lineWidth / scale;
|
|
2584
|
-
var lineDash = elemWrapper.lineDash.map(function (n) { return (n / scale); });
|
|
2585
|
-
var rotateLimit = 12;
|
|
2586
|
-
var bw = ((_a = elem.desc) === null || _a === void 0 ? void 0 : _a.borderWidth) || 0;
|
|
2587
|
-
var wrapper = {
|
|
2588
|
-
uuid: elem.uuid,
|
|
2589
|
-
dotSize: dotSize,
|
|
2590
|
-
lock: ((_b = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _b === void 0 ? void 0 : _b.lock) === true,
|
|
2591
|
-
dots: {
|
|
2592
|
-
topLeft: {
|
|
2593
|
-
x: elem.x - dotSize - bw,
|
|
2594
|
-
y: elem.y - dotSize - bw,
|
|
2595
|
-
},
|
|
2596
|
-
top: {
|
|
2597
|
-
x: elem.x + elem.w / 2,
|
|
2598
|
-
y: elem.y - dotSize - bw,
|
|
2599
|
-
},
|
|
2600
|
-
topRight: {
|
|
2601
|
-
x: elem.x + elem.w + dotSize + bw,
|
|
2602
|
-
y: elem.y - dotSize - bw,
|
|
2603
|
-
},
|
|
2604
|
-
right: {
|
|
2605
|
-
x: elem.x + elem.w + dotSize + bw,
|
|
2606
|
-
y: elem.y + elem.h / 2,
|
|
2607
|
-
},
|
|
2608
|
-
bottomRight: {
|
|
2609
|
-
x: elem.x + elem.w + dotSize + bw,
|
|
2610
|
-
y: elem.y + elem.h + dotSize + bw,
|
|
2611
|
-
},
|
|
2612
|
-
bottom: {
|
|
2613
|
-
x: elem.x + elem.w / 2,
|
|
2614
|
-
y: elem.y + elem.h + dotSize + bw,
|
|
2615
|
-
},
|
|
2616
|
-
bottomLeft: {
|
|
2617
|
-
x: elem.x - dotSize - bw,
|
|
2618
|
-
y: elem.y + elem.h + dotSize + bw,
|
|
2619
|
-
},
|
|
2620
|
-
left: {
|
|
2621
|
-
x: elem.x - dotSize - bw,
|
|
2622
|
-
y: elem.y + elem.h / 2,
|
|
2623
|
-
},
|
|
2624
|
-
rotate: {
|
|
2625
|
-
x: elem.x + elem.w / 2,
|
|
2626
|
-
y: elem.y - dotSize - (dotSize * 2 + rotateLimit) - bw,
|
|
2615
|
+
this._helperConfig.selectedElementListWrappers = wrapperList;
|
|
2616
|
+
};
|
|
2617
|
+
Helper.prototype._createSelectedElementWrapper = function (elem, opts) {
|
|
2618
|
+
var _a, _b, _c;
|
|
2619
|
+
var scale = opts.scale;
|
|
2620
|
+
var elemWrapper = this._coreConfig.elementWrapper;
|
|
2621
|
+
var dotSize = elemWrapper.dotSize / scale;
|
|
2622
|
+
var lineWidth = elemWrapper.lineWidth / scale;
|
|
2623
|
+
var lineDash = elemWrapper.lineDash.map(function (n) { return (n / scale); });
|
|
2624
|
+
var rotateLimit = 12;
|
|
2625
|
+
var bw = ((_a = elem.desc) === null || _a === void 0 ? void 0 : _a.borderWidth) || 0;
|
|
2626
|
+
var wrapper = {
|
|
2627
|
+
uuid: elem.uuid,
|
|
2628
|
+
dotSize: dotSize,
|
|
2629
|
+
lock: ((_b = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _b === void 0 ? void 0 : _b.lock) === true,
|
|
2630
|
+
dots: {
|
|
2631
|
+
topLeft: {
|
|
2632
|
+
x: elem.x - dotSize - bw,
|
|
2633
|
+
y: elem.y - dotSize - bw,
|
|
2634
|
+
},
|
|
2635
|
+
top: {
|
|
2636
|
+
x: elem.x + elem.w / 2,
|
|
2637
|
+
y: elem.y - dotSize - bw,
|
|
2638
|
+
},
|
|
2639
|
+
topRight: {
|
|
2640
|
+
x: elem.x + elem.w + dotSize + bw,
|
|
2641
|
+
y: elem.y - dotSize - bw,
|
|
2642
|
+
},
|
|
2643
|
+
right: {
|
|
2644
|
+
x: elem.x + elem.w + dotSize + bw,
|
|
2645
|
+
y: elem.y + elem.h / 2,
|
|
2646
|
+
},
|
|
2647
|
+
bottomRight: {
|
|
2648
|
+
x: elem.x + elem.w + dotSize + bw,
|
|
2649
|
+
y: elem.y + elem.h + dotSize + bw,
|
|
2650
|
+
},
|
|
2651
|
+
bottom: {
|
|
2652
|
+
x: elem.x + elem.w / 2,
|
|
2653
|
+
y: elem.y + elem.h + dotSize + bw,
|
|
2654
|
+
},
|
|
2655
|
+
bottomLeft: {
|
|
2656
|
+
x: elem.x - dotSize - bw,
|
|
2657
|
+
y: elem.y + elem.h + dotSize + bw,
|
|
2658
|
+
},
|
|
2659
|
+
left: {
|
|
2660
|
+
x: elem.x - dotSize - bw,
|
|
2661
|
+
y: elem.y + elem.h / 2,
|
|
2662
|
+
},
|
|
2663
|
+
rotate: {
|
|
2664
|
+
x: elem.x + elem.w / 2,
|
|
2665
|
+
y: elem.y - dotSize - (dotSize * 2 + rotateLimit) - bw,
|
|
2666
|
+
}
|
|
2667
|
+
},
|
|
2668
|
+
lineWidth: lineWidth,
|
|
2669
|
+
lineDash: lineDash,
|
|
2670
|
+
color: ((_c = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _c === void 0 ? void 0 : _c.lock) === true ? elemWrapper.lockColor : elemWrapper.color,
|
|
2671
|
+
};
|
|
2672
|
+
if (typeof elem.angle === 'number' && (elem.angle > 0 || elem.angle < 0)) {
|
|
2673
|
+
wrapper.radian = parseAngleToRadian(elem.angle);
|
|
2674
|
+
wrapper.translate = calcElementCenter(elem);
|
|
2675
|
+
}
|
|
2676
|
+
return wrapper;
|
|
2677
|
+
};
|
|
2678
|
+
return Helper;
|
|
2679
|
+
}());
|
|
2680
|
+
|
|
2681
|
+
var LoaderEvent = (function () {
|
|
2682
|
+
function LoaderEvent() {
|
|
2683
|
+
this._listeners = new Map();
|
|
2684
|
+
}
|
|
2685
|
+
LoaderEvent.prototype.on = function (eventKey, callback) {
|
|
2686
|
+
if (this._listeners.has(eventKey)) {
|
|
2687
|
+
var callbacks = this._listeners.get(eventKey);
|
|
2688
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
2689
|
+
this._listeners.set(eventKey, callbacks || []);
|
|
2690
|
+
}
|
|
2691
|
+
else {
|
|
2692
|
+
this._listeners.set(eventKey, [callback]);
|
|
2693
|
+
}
|
|
2694
|
+
};
|
|
2695
|
+
LoaderEvent.prototype.off = function (eventKey, callback) {
|
|
2696
|
+
if (this._listeners.has(eventKey)) {
|
|
2697
|
+
var callbacks = this._listeners.get(eventKey);
|
|
2698
|
+
if (Array.isArray(callbacks)) {
|
|
2699
|
+
for (var i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
2700
|
+
if (callbacks[i] === callback) {
|
|
2701
|
+
callbacks.splice(i, 1);
|
|
2702
|
+
break;
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
this._listeners.set(eventKey, callbacks || []);
|
|
2707
|
+
}
|
|
2708
|
+
};
|
|
2709
|
+
LoaderEvent.prototype.trigger = function (eventKey, arg) {
|
|
2710
|
+
var callbacks = this._listeners.get(eventKey);
|
|
2711
|
+
if (Array.isArray(callbacks)) {
|
|
2712
|
+
callbacks.forEach(function (cb) {
|
|
2713
|
+
cb(arg);
|
|
2714
|
+
});
|
|
2715
|
+
return true;
|
|
2716
|
+
}
|
|
2717
|
+
else {
|
|
2718
|
+
return false;
|
|
2719
|
+
}
|
|
2720
|
+
};
|
|
2721
|
+
LoaderEvent.prototype.has = function (name) {
|
|
2722
|
+
if (this._listeners.has(name)) {
|
|
2723
|
+
var list = this._listeners.get(name);
|
|
2724
|
+
if (Array.isArray(list) && list.length > 0) {
|
|
2725
|
+
return true;
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
return false;
|
|
2729
|
+
};
|
|
2730
|
+
return LoaderEvent;
|
|
2731
|
+
}());
|
|
2732
|
+
|
|
2733
|
+
function filterScript(html) {
|
|
2734
|
+
return html.replace(/<script[\s\S]*?<\/script>/ig, '');
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
var _a = index.loader, loadImage = _a.loadImage, loadSVG = _a.loadSVG, loadHTML = _a.loadHTML;
|
|
2738
|
+
var LoaderStatus;
|
|
2739
|
+
(function (LoaderStatus) {
|
|
2740
|
+
LoaderStatus["FREE"] = "free";
|
|
2741
|
+
LoaderStatus["LOADING"] = "loading";
|
|
2742
|
+
LoaderStatus["COMPLETE"] = "complete";
|
|
2743
|
+
})(LoaderStatus || (LoaderStatus = {}));
|
|
2744
|
+
var Loader = (function () {
|
|
2745
|
+
function Loader(opts) {
|
|
2746
|
+
this._currentLoadData = {};
|
|
2747
|
+
this._currentUUIDQueue = [];
|
|
2748
|
+
this._storageLoadData = {};
|
|
2749
|
+
this._status = LoaderStatus.FREE;
|
|
2750
|
+
this._waitingLoadQueue = [];
|
|
2751
|
+
this._opts = opts;
|
|
2752
|
+
this._event = new LoaderEvent();
|
|
2753
|
+
this._waitingLoadQueue = [];
|
|
2754
|
+
}
|
|
2755
|
+
Loader.prototype.load = function (data, changeResourceUUIDs) {
|
|
2756
|
+
var _a = this._resetLoadData(data, changeResourceUUIDs), uuidQueue = _a[0], loadData = _a[1];
|
|
2757
|
+
if (this._status === LoaderStatus.FREE || this._status === LoaderStatus.COMPLETE) {
|
|
2758
|
+
this._currentUUIDQueue = uuidQueue;
|
|
2759
|
+
this._currentLoadData = loadData;
|
|
2760
|
+
this._loadTask();
|
|
2761
|
+
}
|
|
2762
|
+
else if (this._status === LoaderStatus.LOADING && uuidQueue.length > 0) {
|
|
2763
|
+
this._waitingLoadQueue.push({
|
|
2764
|
+
uuidQueue: uuidQueue,
|
|
2765
|
+
loadData: loadData,
|
|
2766
|
+
});
|
|
2767
|
+
}
|
|
2768
|
+
};
|
|
2769
|
+
Loader.prototype.on = function (name, callback) {
|
|
2770
|
+
this._event.on(name, callback);
|
|
2771
|
+
};
|
|
2772
|
+
Loader.prototype.off = function (name, callback) {
|
|
2773
|
+
this._event.off(name, callback);
|
|
2774
|
+
};
|
|
2775
|
+
Loader.prototype.isComplete = function () {
|
|
2776
|
+
return this._status === LoaderStatus.COMPLETE;
|
|
2777
|
+
};
|
|
2778
|
+
Loader.prototype.getContent = function (uuid) {
|
|
2779
|
+
var _a;
|
|
2780
|
+
if (((_a = this._storageLoadData[uuid]) === null || _a === void 0 ? void 0 : _a.status) === 'loaded') {
|
|
2781
|
+
return this._storageLoadData[uuid].content;
|
|
2782
|
+
}
|
|
2783
|
+
return null;
|
|
2784
|
+
};
|
|
2785
|
+
Loader.prototype._resetLoadData = function (data, changeResourceUUIDs) {
|
|
2786
|
+
var loadData = {};
|
|
2787
|
+
var uuidQueue = [];
|
|
2788
|
+
var storageLoadData = this._storageLoadData;
|
|
2789
|
+
for (var i = data.elements.length - 1; i >= 0; i--) {
|
|
2790
|
+
var elem = data.elements[i];
|
|
2791
|
+
if (['image', 'svg', 'html',].includes(elem.type)) {
|
|
2792
|
+
if (!storageLoadData[elem.uuid]) {
|
|
2793
|
+
loadData[elem.uuid] = this._createEmptyLoadItem(elem);
|
|
2794
|
+
uuidQueue.push(elem.uuid);
|
|
2795
|
+
}
|
|
2796
|
+
else {
|
|
2797
|
+
if (changeResourceUUIDs.includes(elem.uuid)) {
|
|
2798
|
+
loadData[elem.uuid] = this._createEmptyLoadItem(elem);
|
|
2799
|
+
uuidQueue.push(elem.uuid);
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
return [uuidQueue, loadData];
|
|
2805
|
+
};
|
|
2806
|
+
Loader.prototype._createEmptyLoadItem = function (elem) {
|
|
2807
|
+
var source = '';
|
|
2808
|
+
var type = elem.type;
|
|
2809
|
+
var elemW = elem.w;
|
|
2810
|
+
var elemH = elem.h;
|
|
2811
|
+
if (elem.type === 'image') {
|
|
2812
|
+
var _elem = elem;
|
|
2813
|
+
source = _elem.desc.src || '';
|
|
2814
|
+
}
|
|
2815
|
+
else if (elem.type === 'svg') {
|
|
2816
|
+
var _elem = elem;
|
|
2817
|
+
source = _elem.desc.svg || '';
|
|
2818
|
+
}
|
|
2819
|
+
else if (elem.type === 'html') {
|
|
2820
|
+
var _elem = elem;
|
|
2821
|
+
source = filterScript(_elem.desc.html || '');
|
|
2822
|
+
elemW = _elem.desc.width || elem.w;
|
|
2823
|
+
elemH = _elem.desc.height || elem.h;
|
|
2824
|
+
}
|
|
2825
|
+
return {
|
|
2826
|
+
type: type,
|
|
2827
|
+
status: 'null',
|
|
2828
|
+
content: null,
|
|
2829
|
+
source: source,
|
|
2830
|
+
elemW: elemW,
|
|
2831
|
+
elemH: elemH,
|
|
2832
|
+
};
|
|
2833
|
+
};
|
|
2834
|
+
Loader.prototype._loadTask = function () {
|
|
2835
|
+
var _this = this;
|
|
2836
|
+
if (this._status === LoaderStatus.LOADING) {
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
this._status = LoaderStatus.LOADING;
|
|
2840
|
+
if (this._currentUUIDQueue.length === 0) {
|
|
2841
|
+
if (this._waitingLoadQueue.length === 0) {
|
|
2842
|
+
this._status = LoaderStatus.COMPLETE;
|
|
2843
|
+
this._event.trigger('complete', undefined);
|
|
2844
|
+
return;
|
|
2845
|
+
}
|
|
2846
|
+
else {
|
|
2847
|
+
var waitingItem = this._waitingLoadQueue.shift();
|
|
2848
|
+
if (waitingItem) {
|
|
2849
|
+
var uuidQueue = waitingItem.uuidQueue, loadData = waitingItem.loadData;
|
|
2850
|
+
this._currentLoadData = loadData;
|
|
2851
|
+
this._currentUUIDQueue = uuidQueue;
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
var maxParallelNum = this._opts.maxParallelNum;
|
|
2856
|
+
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
2857
|
+
var uuidMap = {};
|
|
2858
|
+
uuids.forEach(function (url, i) {
|
|
2859
|
+
uuidMap[url] = i;
|
|
2860
|
+
});
|
|
2861
|
+
var loadUUIDList = [];
|
|
2862
|
+
var _loadAction = function () {
|
|
2863
|
+
if (loadUUIDList.length >= maxParallelNum) {
|
|
2864
|
+
return false;
|
|
2865
|
+
}
|
|
2866
|
+
if (uuids.length === 0) {
|
|
2867
|
+
return true;
|
|
2868
|
+
}
|
|
2869
|
+
var _loop_1 = function (i) {
|
|
2870
|
+
var uuid = uuids.shift();
|
|
2871
|
+
if (uuid === undefined) {
|
|
2872
|
+
return "break";
|
|
2627
2873
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2874
|
+
loadUUIDList.push(uuid);
|
|
2875
|
+
_this._loadElementSource(_this._currentLoadData[uuid]).then(function (image) {
|
|
2876
|
+
loadUUIDList.splice(loadUUIDList.indexOf(uuid), 1);
|
|
2877
|
+
var status = _loadAction();
|
|
2878
|
+
_this._storageLoadData[uuid] = {
|
|
2879
|
+
type: _this._currentLoadData[uuid].type,
|
|
2880
|
+
status: 'loaded',
|
|
2881
|
+
content: image,
|
|
2882
|
+
source: _this._currentLoadData[uuid].source,
|
|
2883
|
+
elemW: _this._currentLoadData[uuid].elemW,
|
|
2884
|
+
elemH: _this._currentLoadData[uuid].elemH,
|
|
2885
|
+
};
|
|
2886
|
+
if (loadUUIDList.length === 0 && uuids.length === 0 && status === true) {
|
|
2887
|
+
_this._status = LoaderStatus.FREE;
|
|
2888
|
+
_this._loadTask();
|
|
2889
|
+
}
|
|
2890
|
+
_this._event.trigger('load', {
|
|
2891
|
+
type: _this._storageLoadData[uuid].type,
|
|
2892
|
+
status: _this._storageLoadData[uuid].status,
|
|
2893
|
+
content: _this._storageLoadData[uuid].content,
|
|
2894
|
+
source: _this._storageLoadData[uuid].source,
|
|
2895
|
+
elemW: _this._storageLoadData[uuid].elemW,
|
|
2896
|
+
elemH: _this._storageLoadData[uuid].elemH,
|
|
2897
|
+
});
|
|
2898
|
+
}).catch(function (err) {
|
|
2899
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2900
|
+
console.warn(err);
|
|
2901
|
+
loadUUIDList.splice(loadUUIDList.indexOf(uuid), 1);
|
|
2902
|
+
var status = _loadAction();
|
|
2903
|
+
if (_this._currentLoadData[uuid]) {
|
|
2904
|
+
_this._storageLoadData[uuid] = {
|
|
2905
|
+
type: (_a = _this._currentLoadData[uuid]) === null || _a === void 0 ? void 0 : _a.type,
|
|
2906
|
+
status: 'fail',
|
|
2907
|
+
content: null,
|
|
2908
|
+
error: err,
|
|
2909
|
+
source: (_b = _this._currentLoadData[uuid]) === null || _b === void 0 ? void 0 : _b.source,
|
|
2910
|
+
elemW: (_c = _this._currentLoadData[uuid]) === null || _c === void 0 ? void 0 : _c.elemW,
|
|
2911
|
+
elemH: (_d = _this._currentLoadData[uuid]) === null || _d === void 0 ? void 0 : _d.elemH,
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
if (loadUUIDList.length === 0 && uuids.length === 0 && status === true) {
|
|
2915
|
+
_this._status = LoaderStatus.FREE;
|
|
2916
|
+
_this._loadTask();
|
|
2917
|
+
}
|
|
2918
|
+
if (_this._currentLoadData[uuid]) {
|
|
2919
|
+
_this._event.trigger('error', {
|
|
2920
|
+
type: (_e = _this._storageLoadData[uuid]) === null || _e === void 0 ? void 0 : _e.type,
|
|
2921
|
+
status: (_f = _this._storageLoadData[uuid]) === null || _f === void 0 ? void 0 : _f.status,
|
|
2922
|
+
content: (_g = _this._storageLoadData[uuid]) === null || _g === void 0 ? void 0 : _g.content,
|
|
2923
|
+
source: (_h = _this._storageLoadData[uuid]) === null || _h === void 0 ? void 0 : _h.source,
|
|
2924
|
+
elemW: (_j = _this._storageLoadData[uuid]) === null || _j === void 0 ? void 0 : _j.elemW,
|
|
2925
|
+
elemH: (_k = _this._storageLoadData[uuid]) === null || _k === void 0 ? void 0 : _k.elemH,
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
});
|
|
2929
|
+
};
|
|
2930
|
+
for (var i = loadUUIDList.length; i < maxParallelNum; i++) {
|
|
2931
|
+
var state_1 = _loop_1();
|
|
2932
|
+
if (state_1 === "break")
|
|
2933
|
+
break;
|
|
2934
|
+
}
|
|
2935
|
+
return false;
|
|
2632
2936
|
};
|
|
2633
|
-
|
|
2634
|
-
wrapper.radian = parseAngleToRadian(elem.angle);
|
|
2635
|
-
wrapper.translate = calcElementCenter(elem);
|
|
2636
|
-
}
|
|
2637
|
-
return wrapper;
|
|
2937
|
+
_loadAction();
|
|
2638
2938
|
};
|
|
2639
|
-
|
|
2939
|
+
Loader.prototype._loadElementSource = function (params) {
|
|
2940
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2941
|
+
var image, image, image;
|
|
2942
|
+
return __generator(this, function (_a) {
|
|
2943
|
+
switch (_a.label) {
|
|
2944
|
+
case 0:
|
|
2945
|
+
if (!(params && params.type === 'image')) return [3, 2];
|
|
2946
|
+
return [4, loadImage(params.source)];
|
|
2947
|
+
case 1:
|
|
2948
|
+
image = _a.sent();
|
|
2949
|
+
return [2, image];
|
|
2950
|
+
case 2:
|
|
2951
|
+
if (!(params && params.type === 'svg')) return [3, 4];
|
|
2952
|
+
return [4, loadSVG(params.source)];
|
|
2953
|
+
case 3:
|
|
2954
|
+
image = _a.sent();
|
|
2955
|
+
return [2, image];
|
|
2956
|
+
case 4:
|
|
2957
|
+
if (!(params && params.type === 'html')) return [3, 6];
|
|
2958
|
+
return [4, loadHTML(params.source, {
|
|
2959
|
+
width: params.elemW, height: params.elemH
|
|
2960
|
+
})];
|
|
2961
|
+
case 5:
|
|
2962
|
+
image = _a.sent();
|
|
2963
|
+
return [2, image];
|
|
2964
|
+
case 6: throw Error('Element\'s source is not support!');
|
|
2965
|
+
}
|
|
2966
|
+
});
|
|
2967
|
+
});
|
|
2968
|
+
};
|
|
2969
|
+
return Loader;
|
|
2640
2970
|
}());
|
|
2641
2971
|
|
|
2642
2972
|
var _board$1 = Symbol('_displayCtx');
|
|
@@ -2664,9 +2994,13 @@ var Mapper = (function () {
|
|
|
2664
2994
|
if (!this.isEffectivePoint(p)) {
|
|
2665
2995
|
return { cursor: cursor, elementUUID: elementUUID };
|
|
2666
2996
|
}
|
|
2667
|
-
var _a = this[_helper$1].isPointInElementWrapperDot(p), uuid = _a[0], direction = _a[1];
|
|
2997
|
+
var _a = this[_helper$1].isPointInElementWrapperDot(p, data), uuid = _a[0], direction = _a[1];
|
|
2668
2998
|
if (uuid && direction) {
|
|
2669
2999
|
switch (direction) {
|
|
3000
|
+
case 'top-right': {
|
|
3001
|
+
cursor = 'ne-resize';
|
|
3002
|
+
break;
|
|
3003
|
+
}
|
|
2670
3004
|
case 'top-left': {
|
|
2671
3005
|
cursor = 'nw-resize';
|
|
2672
3006
|
break;
|
|
@@ -2675,10 +3009,6 @@ var Mapper = (function () {
|
|
|
2675
3009
|
cursor = 'n-resize';
|
|
2676
3010
|
break;
|
|
2677
3011
|
}
|
|
2678
|
-
case 'top-right': {
|
|
2679
|
-
cursor = 'ne-resize';
|
|
2680
|
-
break;
|
|
2681
|
-
}
|
|
2682
3012
|
case 'right': {
|
|
2683
3013
|
cursor = 'e-resize';
|
|
2684
3014
|
break;
|
|
@@ -2699,101 +3029,30 @@ var Mapper = (function () {
|
|
|
2699
3029
|
cursor = 'w-resize';
|
|
2700
3030
|
break;
|
|
2701
3031
|
}
|
|
2702
|
-
case 'rotate': {
|
|
2703
|
-
cursor = 'grab';
|
|
2704
|
-
break;
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
if (uuid) {
|
|
2708
|
-
elementUUID = uuid;
|
|
2709
|
-
}
|
|
2710
|
-
}
|
|
2711
|
-
else {
|
|
2712
|
-
var _b = this[_element$1].isPointInElement(p, data), index = _b[0], uuid_1 = _b[1];
|
|
2713
|
-
if (index >= 0) {
|
|
2714
|
-
cursor = 'move';
|
|
2715
|
-
}
|
|
2716
|
-
if (uuid_1) {
|
|
2717
|
-
elementUUID = uuid_1;
|
|
2718
|
-
}
|
|
2719
|
-
}
|
|
2720
|
-
return {
|
|
2721
|
-
cursor: cursor,
|
|
2722
|
-
elementUUID: elementUUID,
|
|
2723
|
-
};
|
|
2724
|
-
};
|
|
2725
|
-
return Mapper;
|
|
2726
|
-
}());
|
|
2727
|
-
|
|
2728
|
-
var defaultConfig = {
|
|
2729
|
-
elementWrapper: {
|
|
2730
|
-
color: '#2ab6f1',
|
|
2731
|
-
lockColor: '#aaaaaa',
|
|
2732
|
-
dotSize: 6,
|
|
2733
|
-
lineWidth: 1,
|
|
2734
|
-
lineDash: [4, 3],
|
|
2735
|
-
}
|
|
2736
|
-
};
|
|
2737
|
-
function mergeConfig(config) {
|
|
2738
|
-
var result = index.data.deepClone(defaultConfig);
|
|
2739
|
-
if (config) {
|
|
2740
|
-
if (config.elementWrapper) {
|
|
2741
|
-
result.elementWrapper = __assign$1(__assign$1({}, result.elementWrapper), config.elementWrapper);
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
return result;
|
|
2745
|
-
}
|
|
2746
|
-
|
|
2747
|
-
var CoreEvent = (function () {
|
|
2748
|
-
function CoreEvent() {
|
|
2749
|
-
this._listeners = new Map();
|
|
2750
|
-
}
|
|
2751
|
-
CoreEvent.prototype.on = function (eventKey, callback) {
|
|
2752
|
-
if (this._listeners.has(eventKey)) {
|
|
2753
|
-
var callbacks = this._listeners.get(eventKey);
|
|
2754
|
-
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
2755
|
-
this._listeners.set(eventKey, callbacks || []);
|
|
2756
|
-
}
|
|
2757
|
-
else {
|
|
2758
|
-
this._listeners.set(eventKey, [callback]);
|
|
2759
|
-
}
|
|
2760
|
-
};
|
|
2761
|
-
CoreEvent.prototype.off = function (eventKey, callback) {
|
|
2762
|
-
if (this._listeners.has(eventKey)) {
|
|
2763
|
-
var callbacks = this._listeners.get(eventKey);
|
|
2764
|
-
if (Array.isArray(callbacks)) {
|
|
2765
|
-
for (var i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
2766
|
-
if (callbacks[i] === callback) {
|
|
2767
|
-
callbacks.splice(i, 1);
|
|
2768
|
-
break;
|
|
2769
|
-
}
|
|
2770
|
-
}
|
|
3032
|
+
case 'rotate': {
|
|
3033
|
+
cursor = 'grab';
|
|
3034
|
+
break;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
if (uuid) {
|
|
3038
|
+
elementUUID = uuid;
|
|
2771
3039
|
}
|
|
2772
|
-
this._listeners.set(eventKey, callbacks || []);
|
|
2773
|
-
}
|
|
2774
|
-
};
|
|
2775
|
-
CoreEvent.prototype.trigger = function (eventKey, arg) {
|
|
2776
|
-
var callbacks = this._listeners.get(eventKey);
|
|
2777
|
-
if (Array.isArray(callbacks)) {
|
|
2778
|
-
callbacks.forEach(function (cb) {
|
|
2779
|
-
cb(arg);
|
|
2780
|
-
});
|
|
2781
|
-
return true;
|
|
2782
3040
|
}
|
|
2783
3041
|
else {
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
if (Array.isArray(list) && list.length > 0) {
|
|
2791
|
-
return true;
|
|
3042
|
+
var _b = this[_element$1].isPointInElement(p, data), index = _b[0], uuid_1 = _b[1];
|
|
3043
|
+
if (index >= 0) {
|
|
3044
|
+
cursor = 'move';
|
|
3045
|
+
}
|
|
3046
|
+
if (uuid_1) {
|
|
3047
|
+
elementUUID = uuid_1;
|
|
2792
3048
|
}
|
|
2793
3049
|
}
|
|
2794
|
-
return
|
|
3050
|
+
return {
|
|
3051
|
+
cursor: cursor,
|
|
3052
|
+
elementUUID: elementUUID,
|
|
3053
|
+
};
|
|
2795
3054
|
};
|
|
2796
|
-
return
|
|
3055
|
+
return Mapper;
|
|
2797
3056
|
}());
|
|
2798
3057
|
|
|
2799
3058
|
var elementTypes = {
|
|
@@ -2836,215 +3095,116 @@ function isNumber(num) {
|
|
|
2836
3095
|
return (num >= 0 || num < 0);
|
|
2837
3096
|
}
|
|
2838
3097
|
|
|
2839
|
-
var
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
}
|
|
2846
|
-
function
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
}
|
|
2864
|
-
function color(value) {
|
|
2865
|
-
return isColorStr(value);
|
|
2866
|
-
}
|
|
2867
|
-
function imageURL(value) {
|
|
2868
|
-
return (typeof value === 'string' && /^(http:\/\/|https:\/\/|\.\/|\/)/.test("" + value));
|
|
2869
|
-
}
|
|
2870
|
-
function imageBase64(value) {
|
|
2871
|
-
return (typeof value === 'string' && /^(data:image\/)/.test("" + value));
|
|
2872
|
-
}
|
|
2873
|
-
function imageSrc(value) {
|
|
2874
|
-
return (imageBase64(value) || imageURL(value));
|
|
2875
|
-
}
|
|
2876
|
-
function svg(value) {
|
|
2877
|
-
return (typeof value === 'string' && /^(<svg[\s]{1,}|<svg>)/i.test(("" + value).trim()) && /<\/[\s]{0,}svg>$/i.test(("" + value).trim()));
|
|
2878
|
-
}
|
|
2879
|
-
function html(value) {
|
|
2880
|
-
var result = false;
|
|
2881
|
-
if (typeof value === 'string') {
|
|
2882
|
-
var div = document.createElement('div');
|
|
2883
|
-
div.innerHTML = value;
|
|
2884
|
-
if (div.children.length > 0) {
|
|
2885
|
-
result = true;
|
|
2886
|
-
}
|
|
2887
|
-
div = null;
|
|
2888
|
-
}
|
|
2889
|
-
return result;
|
|
2890
|
-
}
|
|
2891
|
-
function text(value) {
|
|
2892
|
-
return typeof value === 'string';
|
|
2893
|
-
}
|
|
2894
|
-
function fontSize(value) {
|
|
2895
|
-
return number(value) && value > 0;
|
|
2896
|
-
}
|
|
2897
|
-
function lineHeight(value) {
|
|
2898
|
-
return number(value) && value > 0;
|
|
2899
|
-
}
|
|
2900
|
-
function textAlign(value) {
|
|
2901
|
-
return ['center', 'left', 'right'].includes(value);
|
|
2902
|
-
}
|
|
2903
|
-
function fontFamily(value) {
|
|
2904
|
-
return typeof value === 'string' && value.length > 0;
|
|
2905
|
-
}
|
|
2906
|
-
function fontWeight(value) {
|
|
2907
|
-
return ['bold'].includes(value);
|
|
2908
|
-
}
|
|
2909
|
-
var is = {
|
|
2910
|
-
x: x,
|
|
2911
|
-
y: y,
|
|
2912
|
-
w: w,
|
|
2913
|
-
h: h,
|
|
2914
|
-
angle: angle,
|
|
2915
|
-
number: number,
|
|
2916
|
-
borderWidth: borderWidth,
|
|
2917
|
-
borderRadius: borderRadius,
|
|
2918
|
-
color: color,
|
|
2919
|
-
imageSrc: imageSrc,
|
|
2920
|
-
imageURL: imageURL,
|
|
2921
|
-
imageBase64: imageBase64,
|
|
2922
|
-
svg: svg,
|
|
2923
|
-
html: html,
|
|
2924
|
-
text: text,
|
|
2925
|
-
fontSize: fontSize,
|
|
2926
|
-
lineHeight: lineHeight,
|
|
2927
|
-
textAlign: textAlign,
|
|
2928
|
-
fontFamily: fontFamily,
|
|
2929
|
-
fontWeight: fontWeight,
|
|
2930
|
-
};
|
|
2931
|
-
|
|
2932
|
-
function attrs(attrs) {
|
|
2933
|
-
var x = attrs.x, y = attrs.y, w = attrs.w, h = attrs.h, angle = attrs.angle;
|
|
2934
|
-
if (!(is.x(x) && is.y(y) && is.w(w) && is.h(h) && is.angle(angle))) {
|
|
2935
|
-
return false;
|
|
2936
|
-
}
|
|
2937
|
-
if (!(angle >= -360 && angle <= 360)) {
|
|
2938
|
-
return false;
|
|
2939
|
-
}
|
|
2940
|
-
return true;
|
|
2941
|
-
}
|
|
2942
|
-
function box(desc) {
|
|
2943
|
-
if (desc === void 0) { desc = {}; }
|
|
2944
|
-
var borderColor = desc.borderColor, borderRadius = desc.borderRadius, borderWidth = desc.borderWidth;
|
|
2945
|
-
if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
|
|
2946
|
-
return false;
|
|
2947
|
-
}
|
|
2948
|
-
if (desc.hasOwnProperty('borderRadius') && !is.number(borderRadius)) {
|
|
2949
|
-
return false;
|
|
2950
|
-
}
|
|
2951
|
-
if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
|
|
2952
|
-
return false;
|
|
2953
|
-
}
|
|
2954
|
-
return true;
|
|
2955
|
-
}
|
|
2956
|
-
function rectDesc(desc) {
|
|
2957
|
-
var color = desc.color;
|
|
2958
|
-
if (desc.hasOwnProperty('color') && !is.color(color)) {
|
|
2959
|
-
return false;
|
|
2960
|
-
}
|
|
2961
|
-
if (!box(desc)) {
|
|
2962
|
-
return false;
|
|
2963
|
-
}
|
|
2964
|
-
return true;
|
|
2965
|
-
}
|
|
2966
|
-
function circleDesc(desc) {
|
|
2967
|
-
var color = desc.color, borderColor = desc.borderColor, borderWidth = desc.borderWidth;
|
|
2968
|
-
if (desc.hasOwnProperty('color') && !is.color(color)) {
|
|
2969
|
-
return false;
|
|
2970
|
-
}
|
|
2971
|
-
if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
|
|
2972
|
-
return false;
|
|
2973
|
-
}
|
|
2974
|
-
if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
|
|
2975
|
-
return false;
|
|
2976
|
-
}
|
|
2977
|
-
return true;
|
|
2978
|
-
}
|
|
2979
|
-
function imageDesc(desc) {
|
|
2980
|
-
var src = desc.src;
|
|
2981
|
-
if (!is.imageSrc(src)) {
|
|
2982
|
-
return false;
|
|
2983
|
-
}
|
|
2984
|
-
return true;
|
|
2985
|
-
}
|
|
2986
|
-
function svgDesc(desc) {
|
|
2987
|
-
var svg = desc.svg;
|
|
2988
|
-
if (!is.svg(svg)) {
|
|
2989
|
-
return false;
|
|
2990
|
-
}
|
|
2991
|
-
return true;
|
|
2992
|
-
}
|
|
2993
|
-
function htmlDesc(desc) {
|
|
2994
|
-
var html = desc.html;
|
|
2995
|
-
if (!is.html(html)) {
|
|
2996
|
-
return false;
|
|
2997
|
-
}
|
|
2998
|
-
return true;
|
|
2999
|
-
}
|
|
3000
|
-
function textDesc(desc) {
|
|
3001
|
-
var text = desc.text, color = desc.color, fontSize = desc.fontSize, lineHeight = desc.lineHeight, fontFamily = desc.fontFamily, textAlign = desc.textAlign, fontWeight = desc.fontWeight, bgColor = desc.bgColor;
|
|
3002
|
-
if (!is.text(text)) {
|
|
3003
|
-
return false;
|
|
3004
|
-
}
|
|
3005
|
-
if (!is.color(color)) {
|
|
3006
|
-
return false;
|
|
3007
|
-
}
|
|
3008
|
-
if (!is.fontSize(fontSize)) {
|
|
3009
|
-
return false;
|
|
3010
|
-
}
|
|
3011
|
-
if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
|
|
3012
|
-
return false;
|
|
3013
|
-
}
|
|
3014
|
-
if (desc.hasOwnProperty('fontWeight') && !is.fontWeight(fontWeight)) {
|
|
3015
|
-
return false;
|
|
3016
|
-
}
|
|
3017
|
-
if (desc.hasOwnProperty('lineHeight') && !is.lineHeight(lineHeight)) {
|
|
3018
|
-
return false;
|
|
3019
|
-
}
|
|
3020
|
-
if (desc.hasOwnProperty('fontFamily') && !is.fontFamily(fontFamily)) {
|
|
3021
|
-
return false;
|
|
3022
|
-
}
|
|
3023
|
-
if (desc.hasOwnProperty('textAlign') && !is.textAlign(textAlign)) {
|
|
3024
|
-
return false;
|
|
3025
|
-
}
|
|
3026
|
-
if (!box(desc)) {
|
|
3027
|
-
return false;
|
|
3098
|
+
var requestAnimationFrame = window.requestAnimationFrame;
|
|
3099
|
+
var deepClone$3 = index.data.deepClone;
|
|
3100
|
+
var DrawStatus;
|
|
3101
|
+
(function (DrawStatus) {
|
|
3102
|
+
DrawStatus["FREE"] = "free";
|
|
3103
|
+
DrawStatus["DRAWING"] = "drawing";
|
|
3104
|
+
})(DrawStatus || (DrawStatus = {}));
|
|
3105
|
+
var Renderer = (function () {
|
|
3106
|
+
function Renderer(board) {
|
|
3107
|
+
var _this = this;
|
|
3108
|
+
this._queue = [];
|
|
3109
|
+
this._status = DrawStatus.FREE;
|
|
3110
|
+
this._board = board;
|
|
3111
|
+
this._loader = new Loader({
|
|
3112
|
+
board: board,
|
|
3113
|
+
maxParallelNum: 6
|
|
3114
|
+
});
|
|
3115
|
+
this._loader.on('load', function (res) {
|
|
3116
|
+
_this._drawFrame();
|
|
3117
|
+
});
|
|
3118
|
+
this._loader.on('error', function (res) {
|
|
3119
|
+
console.log('Loader Error: ', res);
|
|
3120
|
+
});
|
|
3121
|
+
this._loader.on('complete', function (res) {
|
|
3122
|
+
});
|
|
3028
3123
|
}
|
|
3029
|
-
|
|
3030
|
-
}
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3124
|
+
Renderer.prototype.render = function (data, helper, changeResourceUUIDs) {
|
|
3125
|
+
var _data = deepClone$3({ data: data, helper: helper });
|
|
3126
|
+
this._queue.push(_data);
|
|
3127
|
+
if (this._status !== DrawStatus.DRAWING) {
|
|
3128
|
+
this._status = DrawStatus.DRAWING;
|
|
3129
|
+
this._drawFrame();
|
|
3130
|
+
}
|
|
3131
|
+
this._loader.load(data, changeResourceUUIDs);
|
|
3132
|
+
};
|
|
3133
|
+
Renderer.prototype._drawFrame = function () {
|
|
3134
|
+
var _this = this;
|
|
3135
|
+
requestAnimationFrame(function () {
|
|
3136
|
+
var ctx = _this._board.getContext();
|
|
3137
|
+
var item = _this._queue[0];
|
|
3138
|
+
var isLastFrame = false;
|
|
3139
|
+
if (_this._queue.length > 1) {
|
|
3140
|
+
item = _this._queue.shift();
|
|
3141
|
+
}
|
|
3142
|
+
else {
|
|
3143
|
+
isLastFrame = true;
|
|
3144
|
+
}
|
|
3145
|
+
if (_this._loader.isComplete() !== true) {
|
|
3146
|
+
_this._drawFrame();
|
|
3147
|
+
if (item) {
|
|
3148
|
+
drawContext(ctx, item.data, item.helper, _this._loader);
|
|
3149
|
+
_this._board.draw();
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
else if (item) {
|
|
3153
|
+
drawContext(ctx, item.data, item.helper, _this._loader);
|
|
3154
|
+
_this._board.draw();
|
|
3155
|
+
_this._retainQueueOneItem();
|
|
3156
|
+
if (!isLastFrame) {
|
|
3157
|
+
_this._drawFrame();
|
|
3158
|
+
}
|
|
3159
|
+
else {
|
|
3160
|
+
_this._status = DrawStatus.FREE;
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
else {
|
|
3164
|
+
_this._status = DrawStatus.FREE;
|
|
3165
|
+
}
|
|
3166
|
+
});
|
|
3167
|
+
};
|
|
3168
|
+
Renderer.prototype._retainQueueOneItem = function () {
|
|
3169
|
+
if (this._queue.length <= 1) {
|
|
3170
|
+
return;
|
|
3171
|
+
}
|
|
3172
|
+
var lastOne = deepClone$3(this._queue[this._queue.length - 1]);
|
|
3173
|
+
this._queue = [lastOne];
|
|
3174
|
+
};
|
|
3175
|
+
return Renderer;
|
|
3176
|
+
}());
|
|
3177
|
+
|
|
3178
|
+
var Mode;
|
|
3179
|
+
(function (Mode) {
|
|
3180
|
+
Mode["NULL"] = "null";
|
|
3181
|
+
Mode["SELECT_ELEMENT"] = "select-element";
|
|
3182
|
+
Mode["SELECT_ELEMENT_LIST"] = "select-element-list";
|
|
3183
|
+
Mode["SELECT_ELEMENT_WRAPPER_DOT"] = "select-element-wrapper-dot";
|
|
3184
|
+
Mode["SELECT_AREA"] = "select-area";
|
|
3185
|
+
})(Mode || (Mode = {}));
|
|
3186
|
+
var CursorStatus;
|
|
3187
|
+
(function (CursorStatus) {
|
|
3188
|
+
CursorStatus["DRAGGING"] = "dragging";
|
|
3189
|
+
CursorStatus["NULL"] = "null";
|
|
3190
|
+
})(CursorStatus || (CursorStatus = {}));
|
|
3040
3191
|
|
|
3192
|
+
function createData() {
|
|
3193
|
+
return {
|
|
3194
|
+
onlyRender: false,
|
|
3195
|
+
hasInited: false,
|
|
3196
|
+
mode: Mode.NULL,
|
|
3197
|
+
cursorStatus: CursorStatus.NULL,
|
|
3198
|
+
selectedUUID: null,
|
|
3199
|
+
selectedUUIDList: [],
|
|
3200
|
+
hoverUUID: null,
|
|
3201
|
+
selectedDotDirection: null,
|
|
3202
|
+
prevPoint: null,
|
|
3203
|
+
};
|
|
3204
|
+
}
|
|
3041
3205
|
var TempData = (function () {
|
|
3042
3206
|
function TempData() {
|
|
3043
|
-
this._temp =
|
|
3044
|
-
selectedUUID: null,
|
|
3045
|
-
selectedUUIDList: [],
|
|
3046
|
-
hoverUUID: null,
|
|
3047
|
-
};
|
|
3207
|
+
this._temp = createData();
|
|
3048
3208
|
}
|
|
3049
3209
|
TempData.prototype.set = function (name, value) {
|
|
3050
3210
|
this._temp[name] = value;
|
|
@@ -3053,11 +3213,7 @@ var TempData = (function () {
|
|
|
3053
3213
|
return this._temp[name];
|
|
3054
3214
|
};
|
|
3055
3215
|
TempData.prototype.clear = function () {
|
|
3056
|
-
this._temp =
|
|
3057
|
-
selectedUUID: null,
|
|
3058
|
-
hoverUUID: null,
|
|
3059
|
-
selectedUUIDList: [],
|
|
3060
|
-
};
|
|
3216
|
+
this._temp = createData();
|
|
3061
3217
|
};
|
|
3062
3218
|
return TempData;
|
|
3063
3219
|
}());
|
|
@@ -3069,185 +3225,431 @@ var _config = Symbol('_config');
|
|
|
3069
3225
|
var _renderer = Symbol('_renderer');
|
|
3070
3226
|
var _element = Symbol('_element');
|
|
3071
3227
|
var _helper = Symbol('_helper');
|
|
3072
|
-
var _hasInited = Symbol('_hasInited');
|
|
3073
|
-
var _mode = Symbol('_mode');
|
|
3074
3228
|
var _tempData = Symbol('_tempData');
|
|
3075
|
-
var _prevPoint = Symbol('_prevPoint');
|
|
3076
3229
|
var _draw = Symbol('_draw');
|
|
3077
|
-
var _selectedDotDirection = Symbol('_selectedDotDirection');
|
|
3078
3230
|
var _coreEvent = Symbol('_coreEvent');
|
|
3079
3231
|
var _mapper = Symbol('_mapper');
|
|
3080
|
-
var _initEvent = Symbol('_initEvent');
|
|
3081
|
-
var _handleClick = Symbol('_handleClick');
|
|
3082
|
-
var _handleDoubleClick = Symbol('_handleDoubleClick');
|
|
3083
|
-
var _handlePoint = Symbol('_handlePoint');
|
|
3084
|
-
var _handleMoveStart = Symbol('_handleMoveStart');
|
|
3085
|
-
var _handleMove = Symbol('_handleMove');
|
|
3086
|
-
var _handleMoveEnd = Symbol('_handleMoveEnd');
|
|
3087
|
-
var _handleHover = Symbol('_handleHover');
|
|
3088
|
-
var _handleLeave = Symbol('_handleLeave');
|
|
3089
|
-
var _dragElements = Symbol('_dragElements');
|
|
3090
|
-
var _transfromElement = Symbol('_transfromElement');
|
|
3091
3232
|
var _emitChangeScreen = Symbol('_emitChangeScreen');
|
|
3092
3233
|
var _emitChangeData = Symbol('_emitChangeData');
|
|
3093
|
-
var
|
|
3094
|
-
var _cursorStatus = Symbol('_cursorStatus');
|
|
3095
|
-
|
|
3096
|
-
var Mode;
|
|
3097
|
-
(function (Mode) {
|
|
3098
|
-
Mode["NULL"] = "null";
|
|
3099
|
-
Mode["SELECT_ELEMENT"] = "select-element";
|
|
3100
|
-
Mode["SELECT_ELEMENT_LIST"] = "select-element-list";
|
|
3101
|
-
Mode["SELECT_ELEMENT_WRAPPER_DOT"] = "select-element-wrapper-dot";
|
|
3102
|
-
Mode["SELECT_AREA"] = "select-area";
|
|
3103
|
-
})(Mode || (Mode = {}));
|
|
3104
|
-
var CursorStatus;
|
|
3105
|
-
(function (CursorStatus) {
|
|
3106
|
-
CursorStatus["DRAGGING"] = "dragging";
|
|
3107
|
-
CursorStatus["NULL"] = "null";
|
|
3108
|
-
})(CursorStatus || (CursorStatus = {}));
|
|
3234
|
+
var _todo = Symbol('_todo');
|
|
3109
3235
|
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3236
|
+
var deepClone$2 = index.data.deepClone;
|
|
3237
|
+
var createUUID = index.uuid.createUUID;
|
|
3238
|
+
function getSelectedElements(core) {
|
|
3239
|
+
var elems = [];
|
|
3240
|
+
var list = [];
|
|
3241
|
+
var uuid = core[_tempData].get('selectedUUID');
|
|
3242
|
+
if (typeof uuid === 'string' && uuid) {
|
|
3243
|
+
list.push(uuid);
|
|
3244
|
+
}
|
|
3245
|
+
else {
|
|
3246
|
+
list = core[_tempData].get('selectedUUIDList');
|
|
3247
|
+
}
|
|
3248
|
+
list.forEach(function (uuid) {
|
|
3249
|
+
var _a;
|
|
3250
|
+
var index = core[_helper].getElementIndexByUUID(uuid);
|
|
3251
|
+
if (index !== null && index >= 0) {
|
|
3252
|
+
var elem = (_a = core[_data]) === null || _a === void 0 ? void 0 : _a.elements[index];
|
|
3253
|
+
if (elem)
|
|
3254
|
+
elems.push(elem);
|
|
3255
|
+
}
|
|
3256
|
+
});
|
|
3257
|
+
return deepClone$2(elems);
|
|
3113
3258
|
}
|
|
3114
|
-
function
|
|
3115
|
-
var
|
|
3116
|
-
|
|
3259
|
+
function getElement(core, uuid) {
|
|
3260
|
+
var elem = null;
|
|
3261
|
+
var index = core[_helper].getElementIndexByUUID(uuid);
|
|
3262
|
+
if (index !== null && core[_data].elements[index]) {
|
|
3263
|
+
elem = deepClone$2(core[_data].elements[index]);
|
|
3264
|
+
}
|
|
3265
|
+
return elem;
|
|
3117
3266
|
}
|
|
3118
|
-
function
|
|
3119
|
-
var
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3267
|
+
function getElementByIndex(core, index) {
|
|
3268
|
+
var elem = null;
|
|
3269
|
+
if (index >= 0 && core[_data].elements[index]) {
|
|
3270
|
+
elem = deepClone$2(core[_data].elements[index]);
|
|
3271
|
+
}
|
|
3272
|
+
return elem;
|
|
3123
3273
|
}
|
|
3124
|
-
function
|
|
3125
|
-
var
|
|
3126
|
-
var
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3274
|
+
function updateElement(core, elem) {
|
|
3275
|
+
var _a;
|
|
3276
|
+
var _elem = deepClone$2(elem);
|
|
3277
|
+
var data = core[_data];
|
|
3278
|
+
var resourceChangeUUIDs = [];
|
|
3279
|
+
for (var i = 0; i < data.elements.length; i++) {
|
|
3280
|
+
if (_elem.uuid === ((_a = data.elements[i]) === null || _a === void 0 ? void 0 : _a.uuid)) {
|
|
3281
|
+
var result = diffElementResourceChange(data.elements[i], _elem);
|
|
3282
|
+
if (typeof result === 'string') {
|
|
3283
|
+
resourceChangeUUIDs.push(result);
|
|
3284
|
+
}
|
|
3285
|
+
data.elements[i] = _elem;
|
|
3130
3286
|
break;
|
|
3131
3287
|
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3288
|
+
}
|
|
3289
|
+
core[_emitChangeData]();
|
|
3290
|
+
core[_draw]({ resourceChangeUUIDs: resourceChangeUUIDs });
|
|
3291
|
+
}
|
|
3292
|
+
function selectElementByIndex(core, index, opts) {
|
|
3293
|
+
if (core[_tempData].get('onlyRender') === true)
|
|
3294
|
+
return;
|
|
3295
|
+
if (core[_data].elements[index]) {
|
|
3296
|
+
var uuid = core[_data].elements[index].uuid;
|
|
3297
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.useMode) === true) {
|
|
3298
|
+
core[_tempData].set('mode', Mode.SELECT_ELEMENT);
|
|
3135
3299
|
}
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
break;
|
|
3300
|
+
else {
|
|
3301
|
+
core[_tempData].set('mode', Mode.NULL);
|
|
3139
3302
|
}
|
|
3303
|
+
if (typeof uuid === 'string') {
|
|
3304
|
+
core[_tempData].set('selectedUUID', uuid);
|
|
3305
|
+
core[_tempData].set('selectedUUIDList', []);
|
|
3306
|
+
}
|
|
3307
|
+
core[_draw]();
|
|
3140
3308
|
}
|
|
3141
|
-
|
|
3142
|
-
|
|
3309
|
+
}
|
|
3310
|
+
function selectElement(core, uuid, opts) {
|
|
3311
|
+
if (core[_tempData].get('onlyRender') === true)
|
|
3312
|
+
return;
|
|
3313
|
+
var index = core[_helper].getElementIndexByUUID(uuid);
|
|
3314
|
+
if (typeof index === 'number' && index >= 0) {
|
|
3315
|
+
core.selectElementByIndex(index, opts);
|
|
3143
3316
|
}
|
|
3144
|
-
return result;
|
|
3145
3317
|
}
|
|
3146
|
-
function
|
|
3147
|
-
var
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3318
|
+
function moveUpElement(core, uuid) {
|
|
3319
|
+
var index = core[_helper].getElementIndexByUUID(uuid);
|
|
3320
|
+
if (typeof index === 'number' && index >= 0 && index < core[_data].elements.length - 1) {
|
|
3321
|
+
var temp = core[_data].elements[index];
|
|
3322
|
+
core[_data].elements[index] = core[_data].elements[index + 1];
|
|
3323
|
+
core[_data].elements[index + 1] = temp;
|
|
3324
|
+
}
|
|
3325
|
+
core[_emitChangeData]();
|
|
3326
|
+
core[_draw]();
|
|
3327
|
+
}
|
|
3328
|
+
function moveDownElement(core, uuid) {
|
|
3329
|
+
var index = core[_helper].getElementIndexByUUID(uuid);
|
|
3330
|
+
if (typeof index === 'number' && index > 0 && index < core[_data].elements.length) {
|
|
3331
|
+
var temp = core[_data].elements[index];
|
|
3332
|
+
core[_data].elements[index] = core[_data].elements[index - 1];
|
|
3333
|
+
core[_data].elements[index - 1] = temp;
|
|
3334
|
+
}
|
|
3335
|
+
core[_emitChangeData]();
|
|
3336
|
+
core[_draw]();
|
|
3337
|
+
}
|
|
3338
|
+
function addElement(core, elem) {
|
|
3339
|
+
var _elem = deepClone$2(elem);
|
|
3340
|
+
_elem.uuid = createUUID();
|
|
3341
|
+
core[_data].elements.push(_elem);
|
|
3342
|
+
core[_emitChangeData]();
|
|
3343
|
+
core[_draw]();
|
|
3344
|
+
return _elem.uuid;
|
|
3345
|
+
}
|
|
3346
|
+
function deleteElement(core, uuid) {
|
|
3347
|
+
var index = core[_element].getElementIndex(core[_data], uuid);
|
|
3348
|
+
if (index >= 0) {
|
|
3349
|
+
core[_data].elements.splice(index, 1);
|
|
3350
|
+
core[_emitChangeData]();
|
|
3351
|
+
core[_draw]();
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
function insertElementBefore(core, elem, beforeUUID) {
|
|
3355
|
+
var index = core[_helper].getElementIndexByUUID(beforeUUID);
|
|
3356
|
+
if (index !== null) {
|
|
3357
|
+
return core.insertElementBeforeIndex(elem, index);
|
|
3358
|
+
}
|
|
3359
|
+
return null;
|
|
3360
|
+
}
|
|
3361
|
+
function insertElementBeforeIndex(core, elem, index) {
|
|
3362
|
+
var _elem = deepClone$2(elem);
|
|
3363
|
+
_elem.uuid = createUUID();
|
|
3364
|
+
if (index >= 0) {
|
|
3365
|
+
core[_data].elements.splice(index, 0, _elem);
|
|
3366
|
+
core[_emitChangeData]();
|
|
3367
|
+
core[_draw]();
|
|
3368
|
+
return _elem.uuid;
|
|
3369
|
+
}
|
|
3370
|
+
return null;
|
|
3371
|
+
}
|
|
3372
|
+
function insertElementAfter(core, elem, beforeUUID) {
|
|
3373
|
+
var index = core[_helper].getElementIndexByUUID(beforeUUID);
|
|
3374
|
+
if (index !== null) {
|
|
3375
|
+
return core.insertElementAfterIndex(elem, index);
|
|
3376
|
+
}
|
|
3377
|
+
return null;
|
|
3378
|
+
}
|
|
3379
|
+
function insertElementAfterIndex(core, elem, index) {
|
|
3380
|
+
var _elem = deepClone$2(elem);
|
|
3381
|
+
_elem.uuid = createUUID();
|
|
3382
|
+
if (index >= 0) {
|
|
3383
|
+
core[_data].elements.splice(index + 1, 0, _elem);
|
|
3384
|
+
core[_emitChangeData]();
|
|
3385
|
+
core[_draw]();
|
|
3386
|
+
return _elem.uuid;
|
|
3387
|
+
}
|
|
3388
|
+
return null;
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3391
|
+
var time = index.time;
|
|
3392
|
+
var deepClone$1 = index.data.deepClone;
|
|
3393
|
+
function initEvent(core) {
|
|
3394
|
+
if (core[_tempData].get('hasInited') === true) {
|
|
3395
|
+
return;
|
|
3396
|
+
}
|
|
3397
|
+
core[_board].on('hover', time.throttle(handleHover(core), 32));
|
|
3398
|
+
core[_board].on('leave', time.throttle(handleLeave(core), 32));
|
|
3399
|
+
core[_board].on('point', time.throttle(handleClick(core), 16));
|
|
3400
|
+
core[_board].on('doubleClick', handleDoubleClick(core));
|
|
3401
|
+
if (core[_tempData].get('onlyRender') === true) {
|
|
3402
|
+
return;
|
|
3403
|
+
}
|
|
3404
|
+
core[_board].on('point', handlePoint(core));
|
|
3405
|
+
core[_board].on('moveStart', handleMoveStart(core));
|
|
3406
|
+
core[_board].on('move', time.throttle(handleMove(core), 16));
|
|
3407
|
+
core[_board].on('moveEnd', handleMoveEnd(core));
|
|
3408
|
+
core[_tempData].set('hasInited', true);
|
|
3409
|
+
}
|
|
3410
|
+
function handleDoubleClick(core) {
|
|
3411
|
+
return function (point) {
|
|
3412
|
+
var _a, _b, _c;
|
|
3413
|
+
var _d = core[_element].isPointInElement(point, core[_data]), index = _d[0], uuid = _d[1];
|
|
3414
|
+
if (index >= 0 && uuid) {
|
|
3415
|
+
var elem = deepClone$1((_a = core[_data].elements) === null || _a === void 0 ? void 0 : _a[index]);
|
|
3416
|
+
if (((_b = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _b === void 0 ? void 0 : _b.invisible) !== true) {
|
|
3417
|
+
core[_coreEvent].trigger('screenDoubleClickElement', { index: index, uuid: uuid, element: deepClone$1((_c = core[_data].elements) === null || _c === void 0 ? void 0 : _c[index]) });
|
|
3418
|
+
}
|
|
3154
3419
|
}
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3420
|
+
core[_draw]();
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
function handlePoint(core) {
|
|
3424
|
+
return function (point) {
|
|
3425
|
+
var _a, _b, _c;
|
|
3426
|
+
if (!core[_mapper].isEffectivePoint(point)) {
|
|
3427
|
+
return;
|
|
3428
|
+
}
|
|
3429
|
+
if (core[_helper].isPointInElementList(point, core[_data])) {
|
|
3430
|
+
core[_tempData].set('mode', Mode.SELECT_ELEMENT_LIST);
|
|
3431
|
+
}
|
|
3432
|
+
else {
|
|
3433
|
+
var _d = core[_helper].isPointInElementWrapperDot(point, core[_data]), uuid = _d[0], direction = _d[1];
|
|
3434
|
+
if (uuid && direction) {
|
|
3435
|
+
core[_tempData].set('mode', Mode.SELECT_ELEMENT_WRAPPER_DOT);
|
|
3436
|
+
core[_tempData].set('selectedDotDirection', direction);
|
|
3437
|
+
core[_tempData].set('selectedUUID', uuid);
|
|
3438
|
+
}
|
|
3439
|
+
else {
|
|
3440
|
+
var _e = core[_element].isPointInElement(point, core[_data]), index = _e[0], uuid_1 = _e[1];
|
|
3441
|
+
if (index >= 0 && ((_b = (_a = core[_data].elements[index]) === null || _a === void 0 ? void 0 : _a.operation) === null || _b === void 0 ? void 0 : _b.invisible) !== true) {
|
|
3442
|
+
core.selectElementByIndex(index, { useMode: true });
|
|
3443
|
+
if (typeof uuid_1 === 'string' && core[_coreEvent].has('screenSelectElement')) {
|
|
3444
|
+
core[_coreEvent].trigger('screenSelectElement', { index: index, uuid: uuid_1, element: deepClone$1((_c = core[_data].elements) === null || _c === void 0 ? void 0 : _c[index]) });
|
|
3445
|
+
core[_emitChangeScreen]();
|
|
3446
|
+
}
|
|
3447
|
+
core[_tempData].set('mode', Mode.SELECT_ELEMENT);
|
|
3161
3448
|
}
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3449
|
+
else {
|
|
3450
|
+
core[_tempData].set('selectedUUIDList', []);
|
|
3451
|
+
core[_tempData].set('mode', Mode.SELECT_AREA);
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
core[_draw]();
|
|
3456
|
+
};
|
|
3457
|
+
}
|
|
3458
|
+
function handleClick(core) {
|
|
3459
|
+
return function (point) {
|
|
3460
|
+
var _a;
|
|
3461
|
+
var _b = core[_element].isPointInElement(point, core[_data]), index = _b[0], uuid = _b[1];
|
|
3462
|
+
if (index >= 0 && uuid) {
|
|
3463
|
+
core[_coreEvent].trigger('screenClickElement', { index: index, uuid: uuid, element: deepClone$1((_a = core[_data].elements) === null || _a === void 0 ? void 0 : _a[index]) });
|
|
3464
|
+
}
|
|
3465
|
+
core[_draw]();
|
|
3466
|
+
};
|
|
3467
|
+
}
|
|
3468
|
+
function handleMoveStart(core) {
|
|
3469
|
+
return function (point) {
|
|
3470
|
+
core[_tempData].set('prevPoint', point);
|
|
3471
|
+
var uuid = core[_tempData].get('selectedUUID');
|
|
3472
|
+
if (core[_tempData].get('mode') === Mode.SELECT_ELEMENT_LIST) ;
|
|
3473
|
+
else if (core[_tempData].get('mode') === Mode.SELECT_ELEMENT) {
|
|
3474
|
+
if (typeof uuid === 'string' && core[_coreEvent].has('screenMoveElementStart')) {
|
|
3475
|
+
core[_coreEvent].trigger('screenMoveElementStart', {
|
|
3476
|
+
index: core[_element].getElementIndex(core[_data], uuid),
|
|
3477
|
+
uuid: uuid,
|
|
3478
|
+
x: point.x,
|
|
3479
|
+
y: point.y
|
|
3480
|
+
});
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
else if (core[_tempData].get('mode') === Mode.SELECT_AREA) {
|
|
3484
|
+
core[_helper].startSelectArea(point);
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
}
|
|
3488
|
+
function handleMove(core) {
|
|
3489
|
+
return function (point) {
|
|
3490
|
+
if (core[_tempData].get('mode') === Mode.SELECT_ELEMENT_LIST) {
|
|
3491
|
+
dragElements(core, core[_tempData].get('selectedUUIDList'), point, core[_tempData].get('prevPoint'));
|
|
3492
|
+
core[_draw]();
|
|
3493
|
+
core[_tempData].set('cursorStatus', CursorStatus.DRAGGING);
|
|
3494
|
+
}
|
|
3495
|
+
else if (typeof core[_tempData].get('selectedUUID') === 'string') {
|
|
3496
|
+
if (core[_tempData].get('mode') === Mode.SELECT_ELEMENT) {
|
|
3497
|
+
dragElements(core, [core[_tempData].get('selectedUUID')], point, core[_tempData].get('prevPoint'));
|
|
3498
|
+
core[_draw]();
|
|
3499
|
+
core[_tempData].set('cursorStatus', CursorStatus.DRAGGING);
|
|
3500
|
+
}
|
|
3501
|
+
else if (core[_tempData].get('mode') === Mode.SELECT_ELEMENT_WRAPPER_DOT && core[_tempData].get('selectedDotDirection')) {
|
|
3502
|
+
transfromElement(core, core[_tempData].get('selectedUUID'), point, core[_tempData].get('prevPoint'), core[_tempData].get('selectedDotDirection'));
|
|
3503
|
+
core[_tempData].set('cursorStatus', CursorStatus.DRAGGING);
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
else if (core[_tempData].get('mode') === Mode.SELECT_AREA) {
|
|
3507
|
+
core[_helper].changeSelectArea(point);
|
|
3508
|
+
core[_draw]();
|
|
3509
|
+
}
|
|
3510
|
+
core[_tempData].set('prevPoint', point);
|
|
3511
|
+
};
|
|
3512
|
+
}
|
|
3513
|
+
function dragElements(core, uuids, point, prevPoint) {
|
|
3514
|
+
if (!prevPoint) {
|
|
3515
|
+
return;
|
|
3516
|
+
}
|
|
3517
|
+
uuids.forEach(function (uuid) {
|
|
3518
|
+
var _a, _b;
|
|
3519
|
+
var idx = core[_helper].getElementIndexByUUID(uuid);
|
|
3520
|
+
if (idx === null)
|
|
3521
|
+
return;
|
|
3522
|
+
var elem = core[_data].elements[idx];
|
|
3523
|
+
if (((_a = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _a === void 0 ? void 0 : _a.lock) !== true && ((_b = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _b === void 0 ? void 0 : _b.invisible) !== true) {
|
|
3524
|
+
core[_element].dragElement(core[_data], uuid, point, prevPoint, core[_board].getContext().getTransform().scale);
|
|
3525
|
+
}
|
|
3526
|
+
});
|
|
3527
|
+
core[_draw]();
|
|
3528
|
+
}
|
|
3529
|
+
function handleMoveEnd(core) {
|
|
3530
|
+
return function (point) {
|
|
3531
|
+
var uuid = core[_tempData].get('selectedUUID');
|
|
3532
|
+
if (typeof uuid === 'string') {
|
|
3533
|
+
var index = core[_element].getElementIndex(core[_data], uuid);
|
|
3534
|
+
var elem = core[_data].elements[index];
|
|
3535
|
+
if (elem) {
|
|
3536
|
+
if (core[_coreEvent].has('screenMoveElementEnd')) {
|
|
3537
|
+
core[_coreEvent].trigger('screenMoveElementEnd', {
|
|
3538
|
+
index: index,
|
|
3539
|
+
uuid: uuid,
|
|
3540
|
+
x: point.x,
|
|
3541
|
+
y: point.y
|
|
3542
|
+
});
|
|
3165
3543
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3544
|
+
if (core[_coreEvent].has('screenChangeElement')) {
|
|
3545
|
+
core[_coreEvent].trigger('screenChangeElement', {
|
|
3546
|
+
index: index,
|
|
3547
|
+
uuid: uuid,
|
|
3548
|
+
width: elem.w,
|
|
3549
|
+
height: elem.h,
|
|
3550
|
+
angle: elem.angle || 0
|
|
3551
|
+
});
|
|
3169
3552
|
}
|
|
3553
|
+
core[_emitChangeData]();
|
|
3170
3554
|
}
|
|
3171
|
-
|
|
3172
|
-
|
|
3555
|
+
}
|
|
3556
|
+
else if (core[_tempData].get('mode') === Mode.SELECT_AREA) {
|
|
3557
|
+
var uuids = core[_helper].calcSelectedElements(core[_data]);
|
|
3558
|
+
if (uuids.length > 0) {
|
|
3559
|
+
core[_tempData].set('selectedUUIDList', uuids);
|
|
3560
|
+
core[_tempData].set('selectedUUID', null);
|
|
3173
3561
|
}
|
|
3562
|
+
else {
|
|
3563
|
+
core[_tempData].set('mode', Mode.NULL);
|
|
3564
|
+
}
|
|
3565
|
+
core[_helper].clearSelectedArea();
|
|
3566
|
+
core[_draw]();
|
|
3174
3567
|
}
|
|
3175
|
-
|
|
3176
|
-
|
|
3568
|
+
if (core[_tempData].get('mode') !== Mode.SELECT_ELEMENT) {
|
|
3569
|
+
core[_tempData].set('selectedUUID', null);
|
|
3177
3570
|
}
|
|
3178
|
-
|
|
3179
|
-
|
|
3571
|
+
core[_tempData].set('cursorStatus', CursorStatus.NULL);
|
|
3572
|
+
core[_tempData].set('mode', Mode.NULL);
|
|
3573
|
+
};
|
|
3180
3574
|
}
|
|
3181
|
-
function
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3575
|
+
function handleHover(core) {
|
|
3576
|
+
return function (point) {
|
|
3577
|
+
var _a, _b;
|
|
3578
|
+
var isMouseOverElement = false;
|
|
3579
|
+
if (core[_tempData].get('mode') === Mode.SELECT_AREA) {
|
|
3580
|
+
if (core[_tempData].get('onlyRender') !== true)
|
|
3581
|
+
core[_board].resetCursor();
|
|
3582
|
+
}
|
|
3583
|
+
else if (core[_tempData].get('cursorStatus') === CursorStatus.NULL) {
|
|
3584
|
+
var _c = core[_mapper].judgePointCursor(point, core[_data]), cursor = _c.cursor, elementUUID = _c.elementUUID;
|
|
3585
|
+
if (core[_tempData].get('onlyRender') !== true)
|
|
3586
|
+
core[_board].setCursor(cursor);
|
|
3587
|
+
if (elementUUID) {
|
|
3588
|
+
var index = core[_helper].getElementIndexByUUID(elementUUID);
|
|
3589
|
+
if (index !== null && index >= 0) {
|
|
3590
|
+
var elem = core[_data].elements[index];
|
|
3591
|
+
if (((_a = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _a === void 0 ? void 0 : _a.lock) === true || ((_b = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _b === void 0 ? void 0 : _b.invisible) === true) {
|
|
3592
|
+
core[_board].resetCursor();
|
|
3593
|
+
return;
|
|
3594
|
+
}
|
|
3595
|
+
if (core[_tempData].get('hoverUUID') !== elem.uuid) {
|
|
3596
|
+
var preIndex = core[_helper].getElementIndexByUUID(core[_tempData].get('hoverUUID') || '');
|
|
3597
|
+
if (preIndex !== null && core[_data].elements[preIndex]) {
|
|
3598
|
+
core[_coreEvent].trigger('mouseLeaveElement', {
|
|
3599
|
+
uuid: core[_tempData].get('hoverUUID'),
|
|
3600
|
+
index: preIndex,
|
|
3601
|
+
element: core[_data].elements[preIndex]
|
|
3602
|
+
});
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
if (elem) {
|
|
3606
|
+
core[_coreEvent].trigger('mouseOverElement', { uuid: elem.uuid, index: index, element: elem, });
|
|
3607
|
+
core[_tempData].set('hoverUUID', elem.uuid);
|
|
3608
|
+
isMouseOverElement = true;
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3207
3612
|
}
|
|
3208
|
-
|
|
3209
|
-
|
|
3613
|
+
if (isMouseOverElement !== true && core[_tempData].get('hoverUUID') !== null) {
|
|
3614
|
+
var uuid = core[_tempData].get('hoverUUID');
|
|
3615
|
+
var index = core[_helper].getElementIndexByUUID(uuid || '');
|
|
3616
|
+
if (index !== null)
|
|
3617
|
+
core[_coreEvent].trigger('mouseLeaveElement', { uuid: uuid, index: index, element: core[_data].elements[index] });
|
|
3618
|
+
core[_tempData].set('hoverUUID', null);
|
|
3619
|
+
}
|
|
3620
|
+
if (core[_coreEvent].has('mouseOverScreen'))
|
|
3621
|
+
core[_coreEvent].trigger('mouseOverScreen', point);
|
|
3622
|
+
};
|
|
3210
3623
|
}
|
|
3211
|
-
function
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
var resourceChangeUUIDs = [];
|
|
3216
|
-
for (var i = 0; i < data.elements.length; i++) {
|
|
3217
|
-
if (_elem.uuid === ((_a = data.elements[i]) === null || _a === void 0 ? void 0 : _a.uuid)) {
|
|
3218
|
-
var result = diffElementResourceChange(data.elements[i], _elem);
|
|
3219
|
-
if (typeof result === 'string') {
|
|
3220
|
-
resourceChangeUUIDs.push(result);
|
|
3221
|
-
}
|
|
3222
|
-
data.elements[i] = _elem;
|
|
3223
|
-
break;
|
|
3624
|
+
function handleLeave(core) {
|
|
3625
|
+
return function () {
|
|
3626
|
+
if (core[_coreEvent].has('mouseLeaveScreen')) {
|
|
3627
|
+
core[_coreEvent].trigger('mouseLeaveScreen', undefined);
|
|
3224
3628
|
}
|
|
3629
|
+
};
|
|
3630
|
+
}
|
|
3631
|
+
function transfromElement(core, uuid, point, prevPoint, direction) {
|
|
3632
|
+
if (!prevPoint) {
|
|
3633
|
+
return null;
|
|
3225
3634
|
}
|
|
3226
|
-
core[
|
|
3227
|
-
core[_draw](
|
|
3635
|
+
var result = core[_element].transformElement(core[_data], uuid, point, prevPoint, core[_board].getContext().getTransform().scale, direction);
|
|
3636
|
+
core[_draw]();
|
|
3637
|
+
return result;
|
|
3228
3638
|
}
|
|
3229
3639
|
|
|
3230
|
-
var time = index.time;
|
|
3231
3640
|
var deepClone = index.data.deepClone;
|
|
3232
|
-
var createUUID = index.uuid.createUUID;
|
|
3233
3641
|
var Core = (function () {
|
|
3234
3642
|
function Core(mount, opts, config) {
|
|
3235
|
-
var
|
|
3236
|
-
this[_a] =
|
|
3237
|
-
this[_b] =
|
|
3238
|
-
this[_c] = new CoreEvent();
|
|
3239
|
-
this[_d] = null;
|
|
3240
|
-
this[_e] = null;
|
|
3241
|
-
this[_f] = false;
|
|
3242
|
-
this[_g] = CursorStatus.NULL;
|
|
3643
|
+
var _c, _d, _e;
|
|
3644
|
+
this[_a] = new CoreEvent();
|
|
3645
|
+
this[_b] = new TempData();
|
|
3243
3646
|
this[_data] = { elements: [] };
|
|
3244
3647
|
this[_opts] = opts;
|
|
3245
|
-
this[
|
|
3648
|
+
this[_tempData].set('onlyRender', opts.onlyRender === true);
|
|
3246
3649
|
this[_config] = mergeConfig(config || {});
|
|
3247
|
-
this[
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
lineWidth: ((_k = config === null || config === void 0 ? void 0 : config.scrollWrapper) === null || _k === void 0 ? void 0 : _k.lineWidth) || 12,
|
|
3650
|
+
this[_board] = new Board(mount, __assign$1(__assign$1({}, this[_opts]), { canScroll: (_c = config === null || config === void 0 ? void 0 : config.scrollWrapper) === null || _c === void 0 ? void 0 : _c.use, scrollConfig: {
|
|
3651
|
+
color: ((_d = config === null || config === void 0 ? void 0 : config.scrollWrapper) === null || _d === void 0 ? void 0 : _d.color) || '#a0a0a0',
|
|
3652
|
+
lineWidth: ((_e = config === null || config === void 0 ? void 0 : config.scrollWrapper) === null || _e === void 0 ? void 0 : _e.lineWidth) || 12,
|
|
3251
3653
|
} }));
|
|
3252
3654
|
this[_renderer] = new Renderer(this[_board]);
|
|
3253
3655
|
this[_element] = new Element(this[_board].getContext());
|
|
@@ -3257,16 +3659,15 @@ var Core = (function () {
|
|
|
3257
3659
|
helper: this[_helper],
|
|
3258
3660
|
element: this[_element]
|
|
3259
3661
|
});
|
|
3260
|
-
this
|
|
3261
|
-
this[_hasInited] = true;
|
|
3662
|
+
initEvent(this);
|
|
3262
3663
|
}
|
|
3263
|
-
Core.prototype[(_a =
|
|
3264
|
-
var
|
|
3664
|
+
Core.prototype[(_a = _coreEvent, _b = _tempData, _draw)] = function (opts) {
|
|
3665
|
+
var _c, _d;
|
|
3265
3666
|
var transfrom = this[_board].getTransform();
|
|
3266
3667
|
this[_helper].updateConfig(this[_data], {
|
|
3267
3668
|
width: this[_opts].width,
|
|
3268
3669
|
height: this[_opts].height,
|
|
3269
|
-
canScroll: ((
|
|
3670
|
+
canScroll: ((_d = (_c = this[_config]) === null || _c === void 0 ? void 0 : _c.scrollWrapper) === null || _d === void 0 ? void 0 : _d.use) === true,
|
|
3270
3671
|
selectedUUID: this[_tempData].get('selectedUUID'),
|
|
3271
3672
|
selectedUUIDList: this[_tempData].get('selectedUUIDList'),
|
|
3272
3673
|
devicePixelRatio: this[_opts].devicePixelRatio,
|
|
@@ -3276,55 +3677,51 @@ var Core = (function () {
|
|
|
3276
3677
|
});
|
|
3277
3678
|
this[_renderer].render(this[_data], this[_helper].getConfig(), (opts === null || opts === void 0 ? void 0 : opts.resourceChangeUUIDs) || []);
|
|
3278
3679
|
};
|
|
3279
|
-
Core.prototype.
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3680
|
+
Core.prototype.getElement = function (uuid) {
|
|
3681
|
+
return getElement(this, uuid);
|
|
3682
|
+
};
|
|
3683
|
+
Core.prototype.getElementByIndex = function (index) {
|
|
3684
|
+
return getElementByIndex(this, index);
|
|
3283
3685
|
};
|
|
3284
3686
|
Core.prototype.selectElementByIndex = function (index, opts) {
|
|
3285
|
-
|
|
3286
|
-
return;
|
|
3287
|
-
if (this[_data].elements[index]) {
|
|
3288
|
-
var uuid = this[_data].elements[index].uuid;
|
|
3289
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.useMode) === true) {
|
|
3290
|
-
this[_mode] = Mode.SELECT_ELEMENT;
|
|
3291
|
-
}
|
|
3292
|
-
else {
|
|
3293
|
-
this[_mode] = Mode.NULL;
|
|
3294
|
-
}
|
|
3295
|
-
if (typeof uuid === 'string') {
|
|
3296
|
-
this[_tempData].set('selectedUUID', uuid);
|
|
3297
|
-
this[_tempData].set('selectedUUIDList', []);
|
|
3298
|
-
}
|
|
3299
|
-
this[_draw]();
|
|
3300
|
-
}
|
|
3687
|
+
return selectElementByIndex(this, index, opts);
|
|
3301
3688
|
};
|
|
3302
3689
|
Core.prototype.selectElement = function (uuid, opts) {
|
|
3303
|
-
|
|
3304
|
-
return;
|
|
3305
|
-
var index = this[_helper].getElementIndexByUUID(uuid);
|
|
3306
|
-
if (typeof index === 'number' && index >= 0) {
|
|
3307
|
-
this.selectElementByIndex(index, opts);
|
|
3308
|
-
}
|
|
3690
|
+
return selectElement(this, uuid, opts);
|
|
3309
3691
|
};
|
|
3310
3692
|
Core.prototype.moveUpElement = function (uuid) {
|
|
3311
|
-
|
|
3312
|
-
if (typeof index === 'number' && index >= 0 && index < this[_data].elements.length - 1) {
|
|
3313
|
-
var temp = this[_data].elements[index];
|
|
3314
|
-
this[_data].elements[index] = this[_data].elements[index + 1];
|
|
3315
|
-
this[_data].elements[index + 1] = temp;
|
|
3316
|
-
}
|
|
3317
|
-
this[_emitChangeData]();
|
|
3318
|
-
this[_draw]();
|
|
3693
|
+
return moveUpElement(this, uuid);
|
|
3319
3694
|
};
|
|
3320
3695
|
Core.prototype.moveDownElement = function (uuid) {
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
this
|
|
3696
|
+
return moveDownElement(this, uuid);
|
|
3697
|
+
};
|
|
3698
|
+
Core.prototype.updateElement = function (elem) {
|
|
3699
|
+
return updateElement(this, elem);
|
|
3700
|
+
};
|
|
3701
|
+
Core.prototype.addElement = function (elem) {
|
|
3702
|
+
return addElement(this, elem);
|
|
3703
|
+
};
|
|
3704
|
+
Core.prototype.deleteElement = function (uuid) {
|
|
3705
|
+
return deleteElement(this, uuid);
|
|
3706
|
+
};
|
|
3707
|
+
Core.prototype.insertElementBefore = function (elem, beforeUUID) {
|
|
3708
|
+
return insertElementBefore(this, elem, beforeUUID);
|
|
3709
|
+
};
|
|
3710
|
+
Core.prototype.insertElementBeforeIndex = function (elem, index) {
|
|
3711
|
+
return insertElementBeforeIndex(this, elem, index);
|
|
3712
|
+
};
|
|
3713
|
+
Core.prototype.getSelectedElements = function () {
|
|
3714
|
+
return getSelectedElements(this);
|
|
3715
|
+
};
|
|
3716
|
+
Core.prototype.insertElementAfter = function (elem, beforeUUID) {
|
|
3717
|
+
return insertElementAfter(this, elem, beforeUUID);
|
|
3718
|
+
};
|
|
3719
|
+
Core.prototype.insertElementAfterIndex = function (elem, index) {
|
|
3720
|
+
return insertElementAfterIndex(this, elem, index);
|
|
3721
|
+
};
|
|
3722
|
+
Core.prototype.resetSize = function (opts) {
|
|
3723
|
+
this[_opts] = __assign$1(__assign$1({}, this[_opts]), opts);
|
|
3724
|
+
this[_board].resetSize(opts);
|
|
3328
3725
|
this[_draw]();
|
|
3329
3726
|
};
|
|
3330
3727
|
Core.prototype.scale = function (ratio) {
|
|
@@ -3364,58 +3761,6 @@ var Core = (function () {
|
|
|
3364
3761
|
}
|
|
3365
3762
|
this[_draw]({ resourceChangeUUIDs: resourceChangeUUIDs });
|
|
3366
3763
|
};
|
|
3367
|
-
Core.prototype.updateElement = function (elem) {
|
|
3368
|
-
return updateElement(this, elem);
|
|
3369
|
-
};
|
|
3370
|
-
Core.prototype.addElement = function (elem) {
|
|
3371
|
-
var _elem = deepClone(elem);
|
|
3372
|
-
_elem.uuid = createUUID();
|
|
3373
|
-
this[_data].elements.push(_elem);
|
|
3374
|
-
this[_emitChangeData]();
|
|
3375
|
-
this[_draw]();
|
|
3376
|
-
return _elem.uuid;
|
|
3377
|
-
};
|
|
3378
|
-
Core.prototype.deleteElement = function (uuid) {
|
|
3379
|
-
var index = this[_element].getElementIndex(this[_data], uuid);
|
|
3380
|
-
if (index >= 0) {
|
|
3381
|
-
this[_data].elements.splice(index, 1);
|
|
3382
|
-
this[_emitChangeData]();
|
|
3383
|
-
this[_draw]();
|
|
3384
|
-
}
|
|
3385
|
-
};
|
|
3386
|
-
Core.prototype.insertElementBefore = function (elem, beforeUUID) {
|
|
3387
|
-
var index = this[_helper].getElementIndexByUUID(beforeUUID);
|
|
3388
|
-
if (index !== null) {
|
|
3389
|
-
this.insertElementBeforeIndex(elem, index);
|
|
3390
|
-
}
|
|
3391
|
-
};
|
|
3392
|
-
Core.prototype.insertElementBeforeIndex = function (elem, index) {
|
|
3393
|
-
var _elem = deepClone(elem);
|
|
3394
|
-
_elem.uuid = createUUID();
|
|
3395
|
-
if (index >= 0) {
|
|
3396
|
-
this[_data].elements.splice(index, 0, _elem);
|
|
3397
|
-
this[_emitChangeData]();
|
|
3398
|
-
this[_draw]();
|
|
3399
|
-
}
|
|
3400
|
-
};
|
|
3401
|
-
Core.prototype.getSelectedElements = function () {
|
|
3402
|
-
return getSelectedElements(this);
|
|
3403
|
-
};
|
|
3404
|
-
Core.prototype.insertElementAfter = function (elem, beforeUUID) {
|
|
3405
|
-
var index = this[_helper].getElementIndexByUUID(beforeUUID);
|
|
3406
|
-
if (index !== null) {
|
|
3407
|
-
this.insertElementAfterIndex(elem, index);
|
|
3408
|
-
}
|
|
3409
|
-
};
|
|
3410
|
-
Core.prototype.insertElementAfterIndex = function (elem, index) {
|
|
3411
|
-
var _elem = deepClone(elem);
|
|
3412
|
-
_elem.uuid = createUUID();
|
|
3413
|
-
if (index >= 0) {
|
|
3414
|
-
this[_data].elements.splice(index + 1, 0, _elem);
|
|
3415
|
-
this[_emitChangeData]();
|
|
3416
|
-
this[_draw]();
|
|
3417
|
-
}
|
|
3418
|
-
};
|
|
3419
3764
|
Core.prototype.clearOperation = function () {
|
|
3420
3765
|
this[_tempData].clear();
|
|
3421
3766
|
this[_draw]();
|
|
@@ -3441,233 +3786,6 @@ var Core = (function () {
|
|
|
3441
3786
|
Core.prototype.__getOriginContext = function () {
|
|
3442
3787
|
return this[_board].getOriginContext();
|
|
3443
3788
|
};
|
|
3444
|
-
Core.prototype[_initEvent] = function () {
|
|
3445
|
-
if (this[_hasInited] === true) {
|
|
3446
|
-
return;
|
|
3447
|
-
}
|
|
3448
|
-
this[_board].on('hover', time.throttle(this[_handleHover].bind(this), 32));
|
|
3449
|
-
this[_board].on('leave', time.throttle(this[_handleLeave].bind(this), 32));
|
|
3450
|
-
this[_board].on('point', time.throttle(this[_handleClick].bind(this), 16));
|
|
3451
|
-
this[_board].on('doubleClick', this[_handleDoubleClick].bind(this));
|
|
3452
|
-
if (this[_onlyRender] === true) {
|
|
3453
|
-
return;
|
|
3454
|
-
}
|
|
3455
|
-
this[_board].on('point', this[_handlePoint].bind(this));
|
|
3456
|
-
this[_board].on('moveStart', this[_handleMoveStart].bind(this));
|
|
3457
|
-
this[_board].on('move', time.throttle(this[_handleMove].bind(this), 16));
|
|
3458
|
-
this[_board].on('moveEnd', this[_handleMoveEnd].bind(this));
|
|
3459
|
-
};
|
|
3460
|
-
Core.prototype[_handleDoubleClick] = function (point) {
|
|
3461
|
-
var _h;
|
|
3462
|
-
var _j = this[_element].isPointInElement(point, this[_data]), index = _j[0], uuid = _j[1];
|
|
3463
|
-
if (index >= 0 && uuid) {
|
|
3464
|
-
this[_coreEvent].trigger('screenDoubleClickElement', { index: index, uuid: uuid, element: deepClone((_h = this[_data].elements) === null || _h === void 0 ? void 0 : _h[index]) });
|
|
3465
|
-
}
|
|
3466
|
-
this[_draw]();
|
|
3467
|
-
};
|
|
3468
|
-
Core.prototype[_handleClick] = function (point) {
|
|
3469
|
-
var _h;
|
|
3470
|
-
var _j = this[_element].isPointInElement(point, this[_data]), index = _j[0], uuid = _j[1];
|
|
3471
|
-
if (index >= 0 && uuid) {
|
|
3472
|
-
this[_coreEvent].trigger('screenClickElement', { index: index, uuid: uuid, element: deepClone((_h = this[_data].elements) === null || _h === void 0 ? void 0 : _h[index]) });
|
|
3473
|
-
}
|
|
3474
|
-
this[_draw]();
|
|
3475
|
-
};
|
|
3476
|
-
Core.prototype[_handlePoint] = function (point) {
|
|
3477
|
-
var _h, _j, _k;
|
|
3478
|
-
if (!this[_mapper].isEffectivePoint(point)) {
|
|
3479
|
-
return;
|
|
3480
|
-
}
|
|
3481
|
-
if (this[_helper].isPointInElementList(point, this[_data])) {
|
|
3482
|
-
this[_mode] = Mode.SELECT_ELEMENT_LIST;
|
|
3483
|
-
}
|
|
3484
|
-
else {
|
|
3485
|
-
var _l = this[_helper].isPointInElementWrapperDot(point), uuid = _l[0], direction = _l[1];
|
|
3486
|
-
if (uuid && direction) {
|
|
3487
|
-
this[_mode] = Mode.SELECT_ELEMENT_WRAPPER_DOT;
|
|
3488
|
-
this[_selectedDotDirection] = direction;
|
|
3489
|
-
this[_tempData].set('selectedUUID', uuid);
|
|
3490
|
-
}
|
|
3491
|
-
else {
|
|
3492
|
-
var _m = this[_element].isPointInElement(point, this[_data]), index = _m[0], uuid_1 = _m[1];
|
|
3493
|
-
if (index >= 0 && ((_j = (_h = this[_data].elements[index]) === null || _h === void 0 ? void 0 : _h.operation) === null || _j === void 0 ? void 0 : _j.invisible) !== true) {
|
|
3494
|
-
this.selectElementByIndex(index, { useMode: true });
|
|
3495
|
-
if (typeof uuid_1 === 'string' && this[_coreEvent].has('screenSelectElement')) {
|
|
3496
|
-
this[_coreEvent].trigger('screenSelectElement', { index: index, uuid: uuid_1, element: deepClone((_k = this[_data].elements) === null || _k === void 0 ? void 0 : _k[index]) });
|
|
3497
|
-
this[_emitChangeScreen]();
|
|
3498
|
-
}
|
|
3499
|
-
this[_mode] = Mode.SELECT_ELEMENT;
|
|
3500
|
-
}
|
|
3501
|
-
else {
|
|
3502
|
-
this[_tempData].set('selectedUUIDList', []);
|
|
3503
|
-
this[_mode] = Mode.SELECT_AREA;
|
|
3504
|
-
}
|
|
3505
|
-
}
|
|
3506
|
-
}
|
|
3507
|
-
this[_draw]();
|
|
3508
|
-
};
|
|
3509
|
-
Core.prototype[_handleMoveStart] = function (point) {
|
|
3510
|
-
this[_prevPoint] = point;
|
|
3511
|
-
var uuid = this[_tempData].get('selectedUUID');
|
|
3512
|
-
if (this[_mode] === Mode.SELECT_ELEMENT_LIST) ;
|
|
3513
|
-
else if (this[_mode] === Mode.SELECT_ELEMENT) {
|
|
3514
|
-
if (typeof uuid === 'string' && this[_coreEvent].has('screenMoveElementStart')) {
|
|
3515
|
-
this[_coreEvent].trigger('screenMoveElementStart', {
|
|
3516
|
-
index: this[_element].getElementIndex(this[_data], uuid),
|
|
3517
|
-
uuid: uuid,
|
|
3518
|
-
x: point.x,
|
|
3519
|
-
y: point.y
|
|
3520
|
-
});
|
|
3521
|
-
}
|
|
3522
|
-
}
|
|
3523
|
-
else if (this[_mode] === Mode.SELECT_AREA) {
|
|
3524
|
-
this[_helper].startSelectArea(point);
|
|
3525
|
-
}
|
|
3526
|
-
};
|
|
3527
|
-
Core.prototype[_handleMove] = function (point) {
|
|
3528
|
-
if (this[_mode] === Mode.SELECT_ELEMENT_LIST) {
|
|
3529
|
-
this[_dragElements](this[_tempData].get('selectedUUIDList'), point, this[_prevPoint]);
|
|
3530
|
-
this[_draw]();
|
|
3531
|
-
this[_cursorStatus] = CursorStatus.DRAGGING;
|
|
3532
|
-
}
|
|
3533
|
-
else if (typeof this[_tempData].get('selectedUUID') === 'string') {
|
|
3534
|
-
if (this[_mode] === Mode.SELECT_ELEMENT) {
|
|
3535
|
-
this[_dragElements]([this[_tempData].get('selectedUUID')], point, this[_prevPoint]);
|
|
3536
|
-
this[_draw]();
|
|
3537
|
-
this[_cursorStatus] = CursorStatus.DRAGGING;
|
|
3538
|
-
}
|
|
3539
|
-
else if (this[_mode] === Mode.SELECT_ELEMENT_WRAPPER_DOT && this[_selectedDotDirection]) {
|
|
3540
|
-
this[_transfromElement](this[_tempData].get('selectedUUID'), point, this[_prevPoint], this[_selectedDotDirection]);
|
|
3541
|
-
this[_cursorStatus] = CursorStatus.DRAGGING;
|
|
3542
|
-
}
|
|
3543
|
-
}
|
|
3544
|
-
else if (this[_mode] === Mode.SELECT_AREA) {
|
|
3545
|
-
this[_helper].changeSelectArea(point);
|
|
3546
|
-
this[_draw]();
|
|
3547
|
-
}
|
|
3548
|
-
this[_prevPoint] = point;
|
|
3549
|
-
};
|
|
3550
|
-
Core.prototype[_handleMoveEnd] = function (point) {
|
|
3551
|
-
var uuid = this[_tempData].get('selectedUUID');
|
|
3552
|
-
if (typeof uuid === 'string') {
|
|
3553
|
-
var index = this[_element].getElementIndex(this[_data], uuid);
|
|
3554
|
-
var elem = this[_data].elements[index];
|
|
3555
|
-
if (elem) {
|
|
3556
|
-
if (this[_coreEvent].has('screenMoveElementEnd')) {
|
|
3557
|
-
this[_coreEvent].trigger('screenMoveElementEnd', {
|
|
3558
|
-
index: index,
|
|
3559
|
-
uuid: uuid,
|
|
3560
|
-
x: point.x,
|
|
3561
|
-
y: point.y
|
|
3562
|
-
});
|
|
3563
|
-
}
|
|
3564
|
-
if (this[_coreEvent].has('screenChangeElement')) {
|
|
3565
|
-
this[_coreEvent].trigger('screenChangeElement', {
|
|
3566
|
-
index: index,
|
|
3567
|
-
uuid: uuid,
|
|
3568
|
-
width: elem.w,
|
|
3569
|
-
height: elem.h,
|
|
3570
|
-
angle: elem.angle || 0
|
|
3571
|
-
});
|
|
3572
|
-
}
|
|
3573
|
-
this[_emitChangeData]();
|
|
3574
|
-
}
|
|
3575
|
-
}
|
|
3576
|
-
else if (this[_mode] === Mode.SELECT_AREA) {
|
|
3577
|
-
var uuids = this[_helper].calcSelectedElements(this[_data]);
|
|
3578
|
-
if (uuids.length > 0) {
|
|
3579
|
-
this[_tempData].set('selectedUUIDList', uuids);
|
|
3580
|
-
this[_tempData].set('selectedUUID', null);
|
|
3581
|
-
}
|
|
3582
|
-
else {
|
|
3583
|
-
this[_mode] = Mode.NULL;
|
|
3584
|
-
}
|
|
3585
|
-
this[_helper].clearSelectedArea();
|
|
3586
|
-
this[_draw]();
|
|
3587
|
-
}
|
|
3588
|
-
if (this[_mode] !== Mode.SELECT_ELEMENT) {
|
|
3589
|
-
this[_tempData].set('selectedUUID', null);
|
|
3590
|
-
}
|
|
3591
|
-
this[_prevPoint] = null;
|
|
3592
|
-
this[_cursorStatus] = CursorStatus.NULL;
|
|
3593
|
-
this[_mode] = Mode.NULL;
|
|
3594
|
-
};
|
|
3595
|
-
Core.prototype[_handleHover] = function (point) {
|
|
3596
|
-
var _h, _j;
|
|
3597
|
-
var isMouseOverElement = false;
|
|
3598
|
-
if (this[_mode] === Mode.SELECT_AREA) {
|
|
3599
|
-
if (this[_onlyRender] !== true)
|
|
3600
|
-
this[_board].resetCursor();
|
|
3601
|
-
}
|
|
3602
|
-
else if (this[_cursorStatus] === CursorStatus.NULL) {
|
|
3603
|
-
var _k = this[_mapper].judgePointCursor(point, this[_data]), cursor = _k.cursor, elementUUID = _k.elementUUID;
|
|
3604
|
-
if (this[_onlyRender] !== true)
|
|
3605
|
-
this[_board].setCursor(cursor);
|
|
3606
|
-
if (elementUUID) {
|
|
3607
|
-
var index = this[_helper].getElementIndexByUUID(elementUUID);
|
|
3608
|
-
if (index !== null && index >= 0) {
|
|
3609
|
-
var elem = this[_data].elements[index];
|
|
3610
|
-
if (((_h = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _h === void 0 ? void 0 : _h.lock) === true || ((_j = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _j === void 0 ? void 0 : _j.invisible) === true) {
|
|
3611
|
-
this[_board].resetCursor();
|
|
3612
|
-
return;
|
|
3613
|
-
}
|
|
3614
|
-
if (this[_tempData].get('hoverUUID') !== elem.uuid) {
|
|
3615
|
-
var preIndex = this[_helper].getElementIndexByUUID(this[_tempData].get('hoverUUID') || '');
|
|
3616
|
-
if (preIndex !== null && this[_data].elements[preIndex]) {
|
|
3617
|
-
this[_coreEvent].trigger('mouseLeaveElement', {
|
|
3618
|
-
uuid: this[_tempData].get('hoverUUID'),
|
|
3619
|
-
index: preIndex,
|
|
3620
|
-
element: this[_data].elements[preIndex]
|
|
3621
|
-
});
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
if (elem) {
|
|
3625
|
-
this[_coreEvent].trigger('mouseOverElement', { uuid: elem.uuid, index: index, element: elem, });
|
|
3626
|
-
this[_tempData].set('hoverUUID', elem.uuid);
|
|
3627
|
-
isMouseOverElement = true;
|
|
3628
|
-
}
|
|
3629
|
-
}
|
|
3630
|
-
}
|
|
3631
|
-
}
|
|
3632
|
-
if (isMouseOverElement !== true && this[_tempData].get('hoverUUID') !== null) {
|
|
3633
|
-
var uuid = this[_tempData].get('hoverUUID');
|
|
3634
|
-
var index = this[_helper].getElementIndexByUUID(uuid || '');
|
|
3635
|
-
if (index !== null)
|
|
3636
|
-
this[_coreEvent].trigger('mouseLeaveElement', { uuid: uuid, index: index, element: this[_data].elements[index] });
|
|
3637
|
-
this[_tempData].set('hoverUUID', null);
|
|
3638
|
-
}
|
|
3639
|
-
if (this[_coreEvent].has('mouseOverScreen'))
|
|
3640
|
-
this[_coreEvent].trigger('mouseOverScreen', point);
|
|
3641
|
-
};
|
|
3642
|
-
Core.prototype[_handleLeave] = function () {
|
|
3643
|
-
if (this[_coreEvent].has('mouseLeaveScreen'))
|
|
3644
|
-
this[_coreEvent].trigger('mouseLeaveScreen', undefined);
|
|
3645
|
-
};
|
|
3646
|
-
Core.prototype[_dragElements] = function (uuids, point, prevPoint) {
|
|
3647
|
-
var _this = this;
|
|
3648
|
-
if (!prevPoint) {
|
|
3649
|
-
return;
|
|
3650
|
-
}
|
|
3651
|
-
uuids.forEach(function (uuid) {
|
|
3652
|
-
var _h, _j;
|
|
3653
|
-
var idx = _this[_helper].getElementIndexByUUID(uuid);
|
|
3654
|
-
if (idx === null)
|
|
3655
|
-
return;
|
|
3656
|
-
var elem = _this[_data].elements[idx];
|
|
3657
|
-
if (((_h = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _h === void 0 ? void 0 : _h.lock) !== true && ((_j = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _j === void 0 ? void 0 : _j.invisible) !== true) {
|
|
3658
|
-
_this[_element].dragElement(_this[_data], uuid, point, prevPoint, _this[_board].getContext().getTransform().scale);
|
|
3659
|
-
}
|
|
3660
|
-
});
|
|
3661
|
-
this[_draw]();
|
|
3662
|
-
};
|
|
3663
|
-
Core.prototype[_transfromElement] = function (uuid, point, prevPoint, direction) {
|
|
3664
|
-
if (!prevPoint) {
|
|
3665
|
-
return null;
|
|
3666
|
-
}
|
|
3667
|
-
var result = this[_element].transformElement(this[_data], uuid, point, prevPoint, this[_board].getContext().getTransform().scale, direction);
|
|
3668
|
-
this[_draw]();
|
|
3669
|
-
return result;
|
|
3670
|
-
};
|
|
3671
3789
|
Core.prototype[_emitChangeScreen] = function () {
|
|
3672
3790
|
if (this[_coreEvent].has('changeScreen')) {
|
|
3673
3791
|
this[_coreEvent].trigger('changeScreen', __assign$1({}, this.getScreenTransform()));
|
|
@@ -3678,7 +3796,10 @@ var Core = (function () {
|
|
|
3678
3796
|
this[_coreEvent].trigger('changeData', deepClone(this[_data]));
|
|
3679
3797
|
}
|
|
3680
3798
|
};
|
|
3681
|
-
|
|
3799
|
+
Core.prototype[_todo] = function () {
|
|
3800
|
+
console.log(this[_mapper]);
|
|
3801
|
+
};
|
|
3802
|
+
var _a, _b;
|
|
3682
3803
|
Core.is = is;
|
|
3683
3804
|
Core.check = check;
|
|
3684
3805
|
return Core;
|