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