@idraw/core 0.4.0-beta.15 → 0.4.0-beta.17
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/esm/index.d.ts +4 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/middleware/selector/config.d.ts +5 -0
- package/dist/esm/middleware/selector/config.js +5 -0
- package/dist/esm/middleware/selector/draw-auxiliary.d.ts +5 -4
- package/dist/esm/middleware/selector/draw-auxiliary.js +40 -13
- package/dist/esm/middleware/selector/draw-base.d.ts +6 -1
- package/dist/esm/middleware/selector/draw-base.js +31 -2
- package/dist/esm/middleware/selector/draw-reference.d.ts +5 -0
- package/dist/esm/middleware/selector/draw-reference.js +31 -0
- package/dist/esm/middleware/selector/draw-wrapper.d.ts +2 -2
- package/dist/esm/middleware/selector/draw-wrapper.js +2 -3
- package/dist/esm/middleware/selector/index.js +101 -15
- package/dist/esm/middleware/selector/reference.d.ts +13 -0
- package/dist/esm/middleware/selector/reference.js +273 -0
- package/dist/esm/middleware/selector/types.d.ts +5 -3
- package/dist/esm/middleware/selector/types.js +1 -1
- package/dist/esm/middleware/selector/util.js +12 -13
- package/dist/esm/middleware/text-editor/index.js +13 -0
- package/dist/index.global.js +883 -170
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -23,18 +23,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
var _eventHub, _container, _cursorType, _resizeCursorBaseImage, _cursorImageMap, _init, init_fn, _loadResizeCursorBaseImage, loadResizeCursorBaseImage_fn, _resetCursor, resetCursor_fn, _setCursorResize, setCursorResize_fn, _appendRotateResizeImage, appendRotateResizeImage_fn, _board, _canvas, _container2, _initContainer, initContainer_fn;
|
|
26
|
-
function throttle(fn, timeout) {
|
|
27
|
-
let timer = -1;
|
|
28
|
-
return function(...args) {
|
|
29
|
-
if (timer >= 0) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
timer = setTimeout(() => {
|
|
33
|
-
fn(...args);
|
|
34
|
-
timer = -1;
|
|
35
|
-
}, timeout);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
26
|
function isColorStr(color2) {
|
|
39
27
|
return typeof color2 === "string" && (/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));
|
|
40
28
|
}
|
|
@@ -851,8 +839,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
851
839
|
get(name) {
|
|
852
840
|
return __classPrivateFieldGet$7(this, _Store_temp, "f")[name];
|
|
853
841
|
}
|
|
854
|
-
getSnapshot() {
|
|
855
|
-
|
|
842
|
+
getSnapshot(opts) {
|
|
843
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.deepClone) === true) {
|
|
844
|
+
return deepClone(__classPrivateFieldGet$7(this, _Store_temp, "f"));
|
|
845
|
+
}
|
|
846
|
+
return Object.assign({}, __classPrivateFieldGet$7(this, _Store_temp, "f"));
|
|
856
847
|
}
|
|
857
848
|
clear() {
|
|
858
849
|
__classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
@@ -1200,6 +1191,24 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1200
1191
|
_scan(uuid, elements);
|
|
1201
1192
|
return groupQueue;
|
|
1202
1193
|
}
|
|
1194
|
+
function getGroupQueueByElementPosition(elements, position) {
|
|
1195
|
+
var _a;
|
|
1196
|
+
const groupQueue = [];
|
|
1197
|
+
let currentElements = elements;
|
|
1198
|
+
if (position.length > 1) {
|
|
1199
|
+
for (let i = 0; i < position.length - 1; i++) {
|
|
1200
|
+
const index = position[i];
|
|
1201
|
+
const group = currentElements[index];
|
|
1202
|
+
if ((group === null || group === void 0 ? void 0 : group.type) === "group" && Array.isArray((_a = group === null || group === void 0 ? void 0 : group.detail) === null || _a === void 0 ? void 0 : _a.children)) {
|
|
1203
|
+
groupQueue.push(group);
|
|
1204
|
+
currentElements = group.detail.children;
|
|
1205
|
+
} else {
|
|
1206
|
+
return null;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
return groupQueue;
|
|
1211
|
+
}
|
|
1203
1212
|
function findElementsFromListByPositions(positions, list) {
|
|
1204
1213
|
const elements = [];
|
|
1205
1214
|
positions.forEach((pos) => {
|
|
@@ -1253,15 +1262,86 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1253
1262
|
return result;
|
|
1254
1263
|
}
|
|
1255
1264
|
function checkRectIntersect(rect1, rect2) {
|
|
1256
|
-
const
|
|
1257
|
-
const
|
|
1258
|
-
const
|
|
1259
|
-
const
|
|
1260
|
-
const
|
|
1261
|
-
const
|
|
1262
|
-
const
|
|
1263
|
-
const
|
|
1264
|
-
return
|
|
1265
|
+
const rect1MinX = rect1.x;
|
|
1266
|
+
const rect1MinY = rect1.y;
|
|
1267
|
+
const rect1MaxX = rect1.x + rect1.w;
|
|
1268
|
+
const rect1MaxY = rect1.y + rect1.h;
|
|
1269
|
+
const rect2MinX = rect2.x;
|
|
1270
|
+
const rect2MinY = rect2.y;
|
|
1271
|
+
const rect2MaxX = rect2.x + rect2.w;
|
|
1272
|
+
const rect2MaxY = rect2.y + rect2.h;
|
|
1273
|
+
return rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY;
|
|
1274
|
+
}
|
|
1275
|
+
function getElementVertexes(elemSize) {
|
|
1276
|
+
const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
|
|
1277
|
+
return [
|
|
1278
|
+
{ x: x2, y: y2 },
|
|
1279
|
+
{ x: x2 + w2, y: y2 },
|
|
1280
|
+
{ x: x2 + w2, y: y2 + h2 },
|
|
1281
|
+
{ x: x2, y: y2 + h2 }
|
|
1282
|
+
];
|
|
1283
|
+
}
|
|
1284
|
+
function calcElementVertexes(elemSize) {
|
|
1285
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
1286
|
+
if (angle2 === 0) {
|
|
1287
|
+
return getElementVertexes(elemSize);
|
|
1288
|
+
}
|
|
1289
|
+
return getElementRotateVertexes(elemSize, calcElementCenter({ x: x2, y: y2, w: w2, h: h2, angle: angle2 }), angle2);
|
|
1290
|
+
}
|
|
1291
|
+
function calcElementQueueVertexesQueueInGroup(groupQueue) {
|
|
1292
|
+
const vesList = [];
|
|
1293
|
+
let totalX = 0;
|
|
1294
|
+
let totalY = 0;
|
|
1295
|
+
const rotateActionList = [];
|
|
1296
|
+
const elemQueue = [...groupQueue];
|
|
1297
|
+
for (let i = 0; i < elemQueue.length; i++) {
|
|
1298
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemQueue[i];
|
|
1299
|
+
totalX += x2;
|
|
1300
|
+
totalY += y2;
|
|
1301
|
+
let ves;
|
|
1302
|
+
if (i === 0) {
|
|
1303
|
+
const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
|
|
1304
|
+
ves = calcElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1305
|
+
rotateActionList.push({
|
|
1306
|
+
center: calcElementCenter(elemSize),
|
|
1307
|
+
angle: angle2,
|
|
1308
|
+
radian: parseAngleToRadian(angle2)
|
|
1309
|
+
});
|
|
1310
|
+
} else {
|
|
1311
|
+
const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
|
|
1312
|
+
ves = getElementVertexes(elemSize);
|
|
1313
|
+
for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
|
|
1314
|
+
const { center, radian } = rotateActionList[aIdx];
|
|
1315
|
+
ves = rotateVertexes(center, ves, radian);
|
|
1316
|
+
}
|
|
1317
|
+
const vesCenter = calcElementCenterFromVertexes(ves);
|
|
1318
|
+
if (angle2 > 0 || angle2 < 0) {
|
|
1319
|
+
const radian = parseAngleToRadian(angle2);
|
|
1320
|
+
ves = rotateVertexes(vesCenter, ves, radian);
|
|
1321
|
+
}
|
|
1322
|
+
rotateActionList.push({
|
|
1323
|
+
center: vesCenter,
|
|
1324
|
+
angle: angle2,
|
|
1325
|
+
radian: parseAngleToRadian(angle2)
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
vesList.push(ves);
|
|
1329
|
+
}
|
|
1330
|
+
return vesList;
|
|
1331
|
+
}
|
|
1332
|
+
function calcElementVertexesQueueInGroup(targetElem, opts) {
|
|
1333
|
+
const { groupQueue } = opts;
|
|
1334
|
+
if (!(groupQueue.length > 0)) {
|
|
1335
|
+
return [calcElementVertexes(targetElem)];
|
|
1336
|
+
}
|
|
1337
|
+
const elemQueue = [...groupQueue, ...[targetElem]];
|
|
1338
|
+
const vesList = calcElementQueueVertexesQueueInGroup(elemQueue);
|
|
1339
|
+
return vesList;
|
|
1340
|
+
}
|
|
1341
|
+
function calcElementVertexesInGroup(targetElem, opts) {
|
|
1342
|
+
const vesList = calcElementVertexesQueueInGroup(targetElem, opts);
|
|
1343
|
+
const ves = vesList.pop();
|
|
1344
|
+
return ves || null;
|
|
1265
1345
|
}
|
|
1266
1346
|
function calcViewScaleInfo(info, opts) {
|
|
1267
1347
|
const { scale, offsetX, offsetY } = info;
|
|
@@ -1446,76 +1526,152 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1446
1526
|
const elemSize = { x: elemStartX, y: elemStartY, w: elemEndX - elemStartX, h: elemEndY - elemStartY };
|
|
1447
1527
|
return checkRectIntersect(viewSize, elemSize);
|
|
1448
1528
|
}
|
|
1449
|
-
function
|
|
1450
|
-
const {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
];
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
const
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1529
|
+
function calcElementOriginRectInfo(elemSize, opts) {
|
|
1530
|
+
const { groupQueue } = opts;
|
|
1531
|
+
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
1532
|
+
const top = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
|
|
1533
|
+
const right = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
|
|
1534
|
+
const bottom = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
|
|
1535
|
+
const left = getCenterFromTwoPoints(vertexes[3], vertexes[0]);
|
|
1536
|
+
const topLeft = vertexes[0];
|
|
1537
|
+
const topRight = vertexes[1];
|
|
1538
|
+
const bottomRight = vertexes[2];
|
|
1539
|
+
const bottomLeft = vertexes[3];
|
|
1540
|
+
const maxX = Math.max(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
|
|
1541
|
+
const maxY = Math.max(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
|
|
1542
|
+
const minX = Math.min(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
|
|
1543
|
+
const minY = Math.min(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
|
|
1544
|
+
const center = {
|
|
1545
|
+
x: (maxX + minX) / 2,
|
|
1546
|
+
y: (maxY + minY) / 2
|
|
1547
|
+
};
|
|
1548
|
+
const rectInfo = {
|
|
1549
|
+
center,
|
|
1550
|
+
topLeft,
|
|
1551
|
+
topRight,
|
|
1552
|
+
bottomLeft,
|
|
1553
|
+
bottomRight,
|
|
1554
|
+
top,
|
|
1555
|
+
right,
|
|
1556
|
+
left,
|
|
1557
|
+
bottom
|
|
1558
|
+
};
|
|
1559
|
+
return rectInfo;
|
|
1560
|
+
}
|
|
1561
|
+
function originRectInfoToRangeRectInfo(originRectInfo) {
|
|
1562
|
+
const rangeMaxX = Math.max(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
|
|
1563
|
+
const rangeMaxY = Math.max(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
|
|
1564
|
+
const rangeMinX = Math.min(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
|
|
1565
|
+
const rangeMinY = Math.min(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
|
|
1566
|
+
const rangeCenter = { x: originRectInfo.center.x, y: originRectInfo.center.y };
|
|
1567
|
+
const rangeTopLeft = { x: rangeMinX, y: rangeMinY };
|
|
1568
|
+
const rangeTopRight = { x: rangeMaxX, y: rangeMinY };
|
|
1569
|
+
const rangeBottomRight = { x: rangeMaxX, y: rangeMaxY };
|
|
1570
|
+
const rangeBottomLeft = { x: rangeMinX, y: rangeMaxY };
|
|
1571
|
+
const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
|
|
1572
|
+
const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
|
|
1573
|
+
const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
|
|
1574
|
+
const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
|
|
1575
|
+
const rangeRectInfo = {
|
|
1576
|
+
center: rangeCenter,
|
|
1577
|
+
topLeft: rangeTopLeft,
|
|
1578
|
+
topRight: rangeTopRight,
|
|
1579
|
+
bottomLeft: rangeBottomLeft,
|
|
1580
|
+
bottomRight: rangeBottomRight,
|
|
1581
|
+
top: rangeTop,
|
|
1582
|
+
right: rangeRight,
|
|
1583
|
+
left: rangeLeft,
|
|
1584
|
+
bottom: rangeBottom
|
|
1585
|
+
};
|
|
1586
|
+
return rangeRectInfo;
|
|
1587
|
+
}
|
|
1588
|
+
function sortElementsViewVisiableInfoMap(elements, opts) {
|
|
1589
|
+
const visibleInfoMap = {};
|
|
1590
|
+
const currentPosition = [];
|
|
1591
|
+
const _walk = (elem) => {
|
|
1592
|
+
const baseInfo = {
|
|
1593
|
+
isVisibleInView: true,
|
|
1594
|
+
isGroup: elem.type === "group",
|
|
1595
|
+
position: [...currentPosition]
|
|
1596
|
+
};
|
|
1597
|
+
let originRectInfo = null;
|
|
1598
|
+
const groupQueue = getGroupQueueByElementPosition(elements, currentPosition);
|
|
1599
|
+
originRectInfo = calcElementOriginRectInfo(elem, {
|
|
1600
|
+
groupQueue: groupQueue || []
|
|
1601
|
+
});
|
|
1602
|
+
visibleInfoMap[elem.uuid] = Object.assign(Object.assign({}, baseInfo), {
|
|
1603
|
+
originRectInfo,
|
|
1604
|
+
rangeRectInfo: is.angle(elem.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo
|
|
1605
|
+
});
|
|
1606
|
+
if (elem.type === "group") {
|
|
1607
|
+
elem.detail.children.forEach((ele, i) => {
|
|
1608
|
+
currentPosition.push(i);
|
|
1609
|
+
_walk(ele);
|
|
1610
|
+
currentPosition.pop();
|
|
1500
1611
|
});
|
|
1501
1612
|
}
|
|
1502
|
-
|
|
1613
|
+
};
|
|
1614
|
+
elements.forEach((elem, index) => {
|
|
1615
|
+
currentPosition.push(index);
|
|
1616
|
+
_walk(elem);
|
|
1617
|
+
currentPosition.pop();
|
|
1618
|
+
});
|
|
1619
|
+
return updateViewVisibleInfoMapStatus(visibleInfoMap, opts);
|
|
1620
|
+
}
|
|
1621
|
+
function isRangeRectInfoCollide(info1, info2) {
|
|
1622
|
+
const rect1MinX = Math.min(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
|
|
1623
|
+
const rect1MaxX = Math.max(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
|
|
1624
|
+
const rect1MinY = Math.min(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
|
|
1625
|
+
const rect1MaxY = Math.max(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
|
|
1626
|
+
const rect2MinX = Math.min(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
|
|
1627
|
+
const rect2MaxX = Math.max(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
|
|
1628
|
+
const rect2MinY = Math.min(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
|
|
1629
|
+
const rect2MaxY = Math.max(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
|
|
1630
|
+
if (rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY || rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY && rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY) {
|
|
1631
|
+
return true;
|
|
1503
1632
|
}
|
|
1504
|
-
return
|
|
1633
|
+
return false;
|
|
1505
1634
|
}
|
|
1506
|
-
function
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1635
|
+
function updateViewVisibleInfoMapStatus(viewVisibleInfoMap, opts) {
|
|
1636
|
+
const canvasRectInfo = calcVisibleOriginCanvasRectInfo(opts);
|
|
1637
|
+
let visibleCount = 0;
|
|
1638
|
+
let invisibleCount = 0;
|
|
1639
|
+
Object.keys(viewVisibleInfoMap).forEach((uuid) => {
|
|
1640
|
+
const info = viewVisibleInfoMap[uuid];
|
|
1641
|
+
info.isVisibleInView = isRangeRectInfoCollide(info.rangeRectInfo, canvasRectInfo);
|
|
1642
|
+
info.isVisibleInView ? visibleCount++ : invisibleCount++;
|
|
1643
|
+
});
|
|
1644
|
+
return { viewVisibleInfoMap, visibleCount, invisibleCount };
|
|
1514
1645
|
}
|
|
1515
|
-
function
|
|
1516
|
-
const
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1646
|
+
function calcVisibleOriginCanvasRectInfo(opts) {
|
|
1647
|
+
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
1648
|
+
const { scale, offsetTop, offsetLeft } = viewScaleInfo;
|
|
1649
|
+
const { width, height } = viewSizeInfo;
|
|
1650
|
+
const x2 = 0 - offsetLeft / scale;
|
|
1651
|
+
const y2 = 0 - offsetTop / scale;
|
|
1652
|
+
const w2 = width / scale;
|
|
1653
|
+
const h2 = height / scale;
|
|
1654
|
+
const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
|
|
1655
|
+
const topLeft = { x: x2, y: y2 };
|
|
1656
|
+
const topRight = { x: x2 + w2, y: y2 };
|
|
1657
|
+
const bottomLeft = { x: x2, y: y2 + h2 };
|
|
1658
|
+
const bottomRight = { x: x2 + w2, y: y2 + h2 };
|
|
1659
|
+
const left = { x: x2, y: center.y };
|
|
1660
|
+
const top = { x: center.x, y: y2 };
|
|
1661
|
+
const right = { x: x2 + w2, y: center.y };
|
|
1662
|
+
const bottom = { x: center.x, y: y2 + h2 };
|
|
1663
|
+
const rectInfo = {
|
|
1664
|
+
center,
|
|
1665
|
+
topLeft,
|
|
1666
|
+
topRight,
|
|
1667
|
+
bottomLeft,
|
|
1668
|
+
bottomRight,
|
|
1669
|
+
left,
|
|
1670
|
+
top,
|
|
1671
|
+
right,
|
|
1672
|
+
bottom
|
|
1673
|
+
};
|
|
1674
|
+
return rectInfo;
|
|
1519
1675
|
}
|
|
1520
1676
|
function createControllerElementSizeFromCenter(center, opts) {
|
|
1521
1677
|
const { x: x2, y: y2 } = center;
|
|
@@ -2155,7 +2311,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2155
2311
|
}
|
|
2156
2312
|
function drawCircle(ctx, elem, opts) {
|
|
2157
2313
|
const { detail, angle: angle2 } = elem;
|
|
2158
|
-
const {
|
|
2314
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2159
2315
|
const { background: background2 = "#000000", borderColor: borderColor2 = "#000000", boxSizing, borderWidth: borderWidth2 = 0 } = detail;
|
|
2160
2316
|
let bw = 0;
|
|
2161
2317
|
if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
|
|
@@ -2164,7 +2320,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2164
2320
|
bw = borderWidth2[0];
|
|
2165
2321
|
}
|
|
2166
2322
|
bw = bw * viewScaleInfo.scale;
|
|
2167
|
-
const { x: x2, y: y2, w: w2, h: h2 } = (
|
|
2323
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2168
2324
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2169
2325
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2170
2326
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2217,8 +2373,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2217
2373
|
});
|
|
2218
2374
|
}
|
|
2219
2375
|
function drawRect(ctx, elem, opts) {
|
|
2220
|
-
const {
|
|
2221
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (
|
|
2376
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2377
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2222
2378
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2223
2379
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2224
2380
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2240,8 +2396,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2240
2396
|
}
|
|
2241
2397
|
function drawImage(ctx, elem, opts) {
|
|
2242
2398
|
const content = opts.loader.getContent(elem);
|
|
2243
|
-
const {
|
|
2244
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (
|
|
2399
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2400
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2245
2401
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2246
2402
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2247
2403
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2287,8 +2443,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2287
2443
|
}
|
|
2288
2444
|
function drawSVG(ctx, elem, opts) {
|
|
2289
2445
|
const content = opts.loader.getContent(elem);
|
|
2290
|
-
const {
|
|
2291
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (
|
|
2446
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2447
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2292
2448
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2293
2449
|
if (!content && !opts.loader.isDestroyed()) {
|
|
2294
2450
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
@@ -2302,8 +2458,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2302
2458
|
}
|
|
2303
2459
|
function drawHTML(ctx, elem, opts) {
|
|
2304
2460
|
const content = opts.loader.getContent(elem);
|
|
2305
|
-
const {
|
|
2306
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (
|
|
2461
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2462
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2307
2463
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2308
2464
|
if (!content && !opts.loader.isDestroyed()) {
|
|
2309
2465
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
@@ -2317,8 +2473,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2317
2473
|
}
|
|
2318
2474
|
const detailConfig = getDefaultElementDetailConfig();
|
|
2319
2475
|
function drawText(ctx, elem, opts) {
|
|
2320
|
-
const {
|
|
2321
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (
|
|
2476
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2477
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2322
2478
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2323
2479
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2324
2480
|
drawBox(ctx, viewElem, {
|
|
@@ -2421,8 +2577,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2421
2577
|
function drawPath(ctx, elem, opts) {
|
|
2422
2578
|
const { detail } = elem;
|
|
2423
2579
|
const { originX, originY, originW, originH } = detail;
|
|
2424
|
-
const {
|
|
2425
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (
|
|
2580
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2581
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2426
2582
|
const scaleW = w2 / originW;
|
|
2427
2583
|
const scaleH = h2 / originH;
|
|
2428
2584
|
const viewOriginX = originX * scaleW;
|
|
@@ -2520,8 +2676,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2520
2676
|
}
|
|
2521
2677
|
}
|
|
2522
2678
|
function drawGroup(ctx, elem, opts) {
|
|
2523
|
-
const {
|
|
2524
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (
|
|
2679
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2680
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2525
2681
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2526
2682
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2527
2683
|
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
@@ -2562,7 +2718,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2562
2718
|
h: elem.h || parentSize.h,
|
|
2563
2719
|
angle: elem.angle
|
|
2564
2720
|
};
|
|
2565
|
-
const { calculator
|
|
2721
|
+
const { calculator } = opts;
|
|
2566
2722
|
for (let i = 0; i < elem.detail.children.length; i++) {
|
|
2567
2723
|
let child = elem.detail.children[i];
|
|
2568
2724
|
child = Object.assign(Object.assign({}, child), {
|
|
@@ -2570,7 +2726,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2570
2726
|
y: newParentSize.y + child.y
|
|
2571
2727
|
});
|
|
2572
2728
|
if (opts.forceDrawAll !== true) {
|
|
2573
|
-
if (!(
|
|
2729
|
+
if (!(calculator === null || calculator === void 0 ? void 0 : calculator.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo))) {
|
|
2574
2730
|
continue;
|
|
2575
2731
|
}
|
|
2576
2732
|
}
|
|
@@ -2616,9 +2772,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2616
2772
|
}
|
|
2617
2773
|
}
|
|
2618
2774
|
function drawUnderlay(ctx, underlay, opts) {
|
|
2619
|
-
const {
|
|
2775
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2620
2776
|
const elem = Object.assign({ uuid: "underlay" }, underlay);
|
|
2621
|
-
const { x: x2, y: y2, w: w2, h: h2 } = (
|
|
2777
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2622
2778
|
const angle2 = 0;
|
|
2623
2779
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2624
2780
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2988,18 +3144,26 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2988
3144
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2989
3145
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2990
3146
|
};
|
|
2991
|
-
var _Calculator_opts;
|
|
3147
|
+
var _Calculator_opts, _Calculator_store;
|
|
2992
3148
|
class Calculator {
|
|
2993
3149
|
constructor(opts) {
|
|
2994
3150
|
_Calculator_opts.set(this, void 0);
|
|
3151
|
+
_Calculator_store.set(this, void 0);
|
|
2995
3152
|
__classPrivateFieldSet$4(this, _Calculator_opts, opts, "f");
|
|
3153
|
+
__classPrivateFieldSet$4(this, _Calculator_store, new Store({
|
|
3154
|
+
defaultStorage: {
|
|
3155
|
+
viewVisibleInfoMap: {},
|
|
3156
|
+
visibleCount: 0,
|
|
3157
|
+
invisibleCount: 0
|
|
3158
|
+
}
|
|
3159
|
+
}), "f");
|
|
3160
|
+
}
|
|
3161
|
+
toGridNum(num) {
|
|
3162
|
+
return Math.round(num);
|
|
2996
3163
|
}
|
|
2997
3164
|
destroy() {
|
|
2998
3165
|
__classPrivateFieldSet$4(this, _Calculator_opts, null, "f");
|
|
2999
3166
|
}
|
|
3000
|
-
elementSize(size, viewScaleInfo, viewSizeInfo) {
|
|
3001
|
-
return calcViewElementSize(size, { viewScaleInfo, viewSizeInfo });
|
|
3002
|
-
}
|
|
3003
3167
|
isElementInView(elem, viewScaleInfo, viewSizeInfo) {
|
|
3004
3168
|
return isElementInView(elem, { viewScaleInfo, viewSizeInfo });
|
|
3005
3169
|
}
|
|
@@ -3016,8 +3180,103 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3016
3180
|
const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
|
|
3017
3181
|
return getViewPointAtElement(p, Object.assign(Object.assign({}, opts), { context2d }));
|
|
3018
3182
|
}
|
|
3183
|
+
resetViewVisibleInfoMap(data, opts) {
|
|
3184
|
+
if (data) {
|
|
3185
|
+
const { viewVisibleInfoMap, invisibleCount, visibleCount } = sortElementsViewVisiableInfoMap(data.elements, opts);
|
|
3186
|
+
__classPrivateFieldGet$4(this, _Calculator_store, "f").set("viewVisibleInfoMap", viewVisibleInfoMap);
|
|
3187
|
+
__classPrivateFieldGet$4(this, _Calculator_store, "f").set("invisibleCount", invisibleCount);
|
|
3188
|
+
__classPrivateFieldGet$4(this, _Calculator_store, "f").set("visibleCount", visibleCount);
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
updateVisiableStatus(opts) {
|
|
3192
|
+
const { viewVisibleInfoMap, invisibleCount, visibleCount } = updateViewVisibleInfoMapStatus(__classPrivateFieldGet$4(this, _Calculator_store, "f").get("viewVisibleInfoMap"), opts);
|
|
3193
|
+
__classPrivateFieldGet$4(this, _Calculator_store, "f").set("viewVisibleInfoMap", viewVisibleInfoMap);
|
|
3194
|
+
__classPrivateFieldGet$4(this, _Calculator_store, "f").set("invisibleCount", invisibleCount);
|
|
3195
|
+
__classPrivateFieldGet$4(this, _Calculator_store, "f").set("visibleCount", visibleCount);
|
|
3196
|
+
}
|
|
3197
|
+
calcViewRectInfoFromOrigin(uuid, opts) {
|
|
3198
|
+
const infoData = __classPrivateFieldGet$4(this, _Calculator_store, "f").get("viewVisibleInfoMap")[uuid];
|
|
3199
|
+
if (!(infoData === null || infoData === void 0 ? void 0 : infoData.originRectInfo)) {
|
|
3200
|
+
return null;
|
|
3201
|
+
}
|
|
3202
|
+
const { checkVisible, viewScaleInfo, viewSizeInfo } = opts;
|
|
3203
|
+
const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.originRectInfo;
|
|
3204
|
+
if (checkVisible === true && infoData.isVisibleInView === false) {
|
|
3205
|
+
return null;
|
|
3206
|
+
}
|
|
3207
|
+
const calcOpts = { viewScaleInfo, viewSizeInfo };
|
|
3208
|
+
const viewRectInfo = {
|
|
3209
|
+
center: calcViewPointSize(center, calcOpts),
|
|
3210
|
+
left: calcViewPointSize(left, calcOpts),
|
|
3211
|
+
right: calcViewPointSize(right, calcOpts),
|
|
3212
|
+
bottom: calcViewPointSize(bottom, calcOpts),
|
|
3213
|
+
top: calcViewPointSize(top, calcOpts),
|
|
3214
|
+
topLeft: calcViewPointSize(topLeft, calcOpts),
|
|
3215
|
+
topRight: calcViewPointSize(topRight, calcOpts),
|
|
3216
|
+
bottomLeft: calcViewPointSize(bottomLeft, calcOpts),
|
|
3217
|
+
bottomRight: calcViewPointSize(bottomRight, calcOpts)
|
|
3218
|
+
};
|
|
3219
|
+
return viewRectInfo;
|
|
3220
|
+
}
|
|
3221
|
+
calcViewRectInfoFromRange(uuid, opts) {
|
|
3222
|
+
const infoData = __classPrivateFieldGet$4(this, _Calculator_store, "f").get("viewVisibleInfoMap")[uuid];
|
|
3223
|
+
if (!(infoData === null || infoData === void 0 ? void 0 : infoData.originRectInfo)) {
|
|
3224
|
+
return null;
|
|
3225
|
+
}
|
|
3226
|
+
const { checkVisible, viewScaleInfo, viewSizeInfo } = opts;
|
|
3227
|
+
const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.rangeRectInfo;
|
|
3228
|
+
if (checkVisible === true && infoData.isVisibleInView === false) {
|
|
3229
|
+
return null;
|
|
3230
|
+
}
|
|
3231
|
+
const calcOpts = { viewScaleInfo, viewSizeInfo };
|
|
3232
|
+
const viewRectInfo = {
|
|
3233
|
+
center: calcViewPointSize(center, calcOpts),
|
|
3234
|
+
left: calcViewPointSize(left, calcOpts),
|
|
3235
|
+
right: calcViewPointSize(right, calcOpts),
|
|
3236
|
+
bottom: calcViewPointSize(bottom, calcOpts),
|
|
3237
|
+
top: calcViewPointSize(top, calcOpts),
|
|
3238
|
+
topLeft: calcViewPointSize(topLeft, calcOpts),
|
|
3239
|
+
topRight: calcViewPointSize(topRight, calcOpts),
|
|
3240
|
+
bottomLeft: calcViewPointSize(bottomLeft, calcOpts),
|
|
3241
|
+
bottomRight: calcViewPointSize(bottomRight, calcOpts)
|
|
3242
|
+
};
|
|
3243
|
+
return viewRectInfo;
|
|
3244
|
+
}
|
|
3245
|
+
modifyViewVisibleInfoMap(data, opts) {
|
|
3246
|
+
const { modifyOptions, viewScaleInfo, viewSizeInfo } = opts;
|
|
3247
|
+
const { type, content } = modifyOptions;
|
|
3248
|
+
const list = data.elements;
|
|
3249
|
+
const viewVisibleInfoMap = __classPrivateFieldGet$4(this, _Calculator_store, "f").get("viewVisibleInfoMap");
|
|
3250
|
+
if (type === "deleteElement") {
|
|
3251
|
+
const { element } = content;
|
|
3252
|
+
delete viewVisibleInfoMap[element.uuid];
|
|
3253
|
+
} else if (type === "addElement" || type === "updateElement") {
|
|
3254
|
+
const { position } = content;
|
|
3255
|
+
const element = findElementFromListByPosition(position, data.elements);
|
|
3256
|
+
const groupQueue = getGroupQueueByElementPosition(list, position);
|
|
3257
|
+
if (element) {
|
|
3258
|
+
const originRectInfo = calcElementOriginRectInfo(element, {
|
|
3259
|
+
groupQueue: groupQueue || []
|
|
3260
|
+
});
|
|
3261
|
+
const newViewVisibleInfo = {
|
|
3262
|
+
originRectInfo,
|
|
3263
|
+
rangeRectInfo: is.angle(element.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo,
|
|
3264
|
+
isVisibleInView: true,
|
|
3265
|
+
isGroup: (element === null || element === void 0 ? void 0 : element.type) === "group",
|
|
3266
|
+
position: [...position]
|
|
3267
|
+
};
|
|
3268
|
+
viewVisibleInfoMap[element.uuid] = newViewVisibleInfo;
|
|
3269
|
+
if (type === "updateElement") {
|
|
3270
|
+
this.updateVisiableStatus({ viewScaleInfo, viewSizeInfo });
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
} else if (type === "moveElement") {
|
|
3274
|
+
this.resetViewVisibleInfoMap(data, { viewScaleInfo, viewSizeInfo });
|
|
3275
|
+
}
|
|
3276
|
+
__classPrivateFieldGet$4(this, _Calculator_store, "f").set("viewVisibleInfoMap", viewVisibleInfoMap);
|
|
3277
|
+
}
|
|
3019
3278
|
}
|
|
3020
|
-
_Calculator_opts = /* @__PURE__ */ new WeakMap();
|
|
3279
|
+
_Calculator_opts = /* @__PURE__ */ new WeakMap(), _Calculator_store = /* @__PURE__ */ new WeakMap();
|
|
3021
3280
|
var __classPrivateFieldSet$3 = function(receiver, state, value, kind, f) {
|
|
3022
3281
|
if (kind === "m")
|
|
3023
3282
|
throw new TypeError("Private method is not writable");
|
|
@@ -3257,8 +3516,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3257
3516
|
setActiveStorage(key2, storage) {
|
|
3258
3517
|
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set(key2, storage);
|
|
3259
3518
|
}
|
|
3260
|
-
getActiveStoreSnapshot() {
|
|
3261
|
-
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").getSnapshot();
|
|
3519
|
+
getActiveStoreSnapshot(opts) {
|
|
3520
|
+
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").getSnapshot(opts);
|
|
3262
3521
|
}
|
|
3263
3522
|
getSharedStorage(key2) {
|
|
3264
3523
|
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").get(key2);
|
|
@@ -3266,8 +3525,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3266
3525
|
setSharedStorage(key2, storage) {
|
|
3267
3526
|
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").set(key2, storage);
|
|
3268
3527
|
}
|
|
3269
|
-
getSharedStoreSnapshot() {
|
|
3270
|
-
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").getSnapshot();
|
|
3528
|
+
getSharedStoreSnapshot(opts) {
|
|
3529
|
+
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").getSnapshot(opts);
|
|
3271
3530
|
}
|
|
3272
3531
|
getActiveViewScaleInfo() {
|
|
3273
3532
|
const viewScaleInfo = {
|
|
@@ -3334,6 +3593,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3334
3593
|
__classPrivateFieldSet$1(this, _Viewer_opts, opts, "f");
|
|
3335
3594
|
__classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_init).call(this);
|
|
3336
3595
|
}
|
|
3596
|
+
resetViewVisibleInfoMap(data, opts) {
|
|
3597
|
+
if (data) {
|
|
3598
|
+
__classPrivateFieldGet$1(this, _Viewer_opts, "f").calculator.resetViewVisibleInfoMap(data, opts);
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3337
3601
|
drawFrame() {
|
|
3338
3602
|
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3339
3603
|
const activeStore = sharer.getActiveStoreSnapshot();
|
|
@@ -3345,7 +3609,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3345
3609
|
__classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_drawAnimationFrame).call(this);
|
|
3346
3610
|
}
|
|
3347
3611
|
scale(opts) {
|
|
3348
|
-
const { scale, point } = opts;
|
|
3612
|
+
const { scale, point, ignoreUpdateVisibleStatus } = opts;
|
|
3349
3613
|
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3350
3614
|
const { moveX, moveY } = viewScale({
|
|
3351
3615
|
scale,
|
|
@@ -3354,12 +3618,18 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3354
3618
|
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3355
3619
|
});
|
|
3356
3620
|
sharer.setActiveStorage("scale", scale);
|
|
3621
|
+
if (!ignoreUpdateVisibleStatus) {
|
|
3622
|
+
__classPrivateFieldGet$1(this, _Viewer_opts, "f").calculator.updateVisiableStatus({
|
|
3623
|
+
viewScaleInfo: sharer.getActiveViewScaleInfo(),
|
|
3624
|
+
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3357
3627
|
return { moveX, moveY };
|
|
3358
3628
|
}
|
|
3359
3629
|
scroll(opts) {
|
|
3360
3630
|
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3361
3631
|
const prevViewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
3362
|
-
const { moveX, moveY } = opts;
|
|
3632
|
+
const { moveX, moveY, ignoreUpdateVisibleStatus } = opts;
|
|
3363
3633
|
const viewSizeInfo = sharer.getActiveViewSizeInfo();
|
|
3364
3634
|
const viewScaleInfo = viewScroll({
|
|
3365
3635
|
moveX,
|
|
@@ -3368,6 +3638,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3368
3638
|
viewSizeInfo
|
|
3369
3639
|
});
|
|
3370
3640
|
sharer.setActiveViewScaleInfo(viewScaleInfo);
|
|
3641
|
+
if (!ignoreUpdateVisibleStatus) {
|
|
3642
|
+
__classPrivateFieldGet$1(this, _Viewer_opts, "f").calculator.updateVisiableStatus({
|
|
3643
|
+
viewScaleInfo: sharer.getActiveViewScaleInfo(),
|
|
3644
|
+
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3645
|
+
});
|
|
3646
|
+
}
|
|
3371
3647
|
return viewScaleInfo;
|
|
3372
3648
|
}
|
|
3373
3649
|
updateViewScaleInfo(opts) {
|
|
@@ -3376,9 +3652,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3376
3652
|
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3377
3653
|
});
|
|
3378
3654
|
sharer.setActiveViewScaleInfo(viewScaleInfo);
|
|
3655
|
+
__classPrivateFieldGet$1(this, _Viewer_opts, "f").calculator.updateVisiableStatus({
|
|
3656
|
+
viewScaleInfo: sharer.getActiveViewScaleInfo(),
|
|
3657
|
+
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3658
|
+
});
|
|
3379
3659
|
return viewScaleInfo;
|
|
3380
3660
|
}
|
|
3381
|
-
resize(viewSize = {}) {
|
|
3661
|
+
resize(viewSize = {}, opts) {
|
|
3382
3662
|
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3383
3663
|
const originViewSize = sharer.getActiveViewSizeInfo();
|
|
3384
3664
|
const newViewSize = Object.assign(Object.assign({}, originViewSize), viewSize);
|
|
@@ -3395,6 +3675,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3395
3675
|
viewContext.canvas.width = width * devicePixelRatio;
|
|
3396
3676
|
viewContext.canvas.height = height * devicePixelRatio;
|
|
3397
3677
|
sharer.setActiveViewSizeInfo(newViewSize);
|
|
3678
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.ignoreUpdateVisibleStatus)) {
|
|
3679
|
+
__classPrivateFieldGet$1(this, _Viewer_opts, "f").calculator.updateVisiableStatus({
|
|
3680
|
+
viewScaleInfo: sharer.getActiveViewScaleInfo(),
|
|
3681
|
+
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3682
|
+
});
|
|
3683
|
+
}
|
|
3398
3684
|
return newViewSize;
|
|
3399
3685
|
}
|
|
3400
3686
|
}
|
|
@@ -3464,7 +3750,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3464
3750
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
3465
3751
|
};
|
|
3466
3752
|
var _Board_instances, _Board_opts, _Board_middlewareMap, _Board_middlewares, _Board_activeMiddlewareObjs, _Board_watcher, _Board_renderer, _Board_sharer, _Board_viewer, _Board_calculator, _Board_eventHub, _Board_hasDestroyed, _Board_init, _Board_handlePointStart, _Board_handlePointEnd, _Board_handlePointMove, _Board_handleHover, _Board_handleDoubleClick, _Board_handleWheel, _Board_handleWheelScale, _Board_handleScrollX, _Board_handleScrollY, _Board_handleResize, _Board_handleClear, _Board_handleBeforeDrawFrame, _Board_handleAfterDrawFrame, _Board_resetActiveMiddlewareObjs;
|
|
3467
|
-
const throttleTime = 10;
|
|
3468
3753
|
class Board {
|
|
3469
3754
|
constructor(opts) {
|
|
3470
3755
|
_Board_instances.add(this);
|
|
@@ -3530,15 +3815,28 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3530
3815
|
getRenderer() {
|
|
3531
3816
|
return __classPrivateFieldGet(this, _Board_renderer, "f");
|
|
3532
3817
|
}
|
|
3533
|
-
setData(data) {
|
|
3818
|
+
setData(data, opts) {
|
|
3819
|
+
const { modifiedOptions } = opts || {};
|
|
3534
3820
|
const sharer = __classPrivateFieldGet(this, _Board_sharer, "f");
|
|
3535
3821
|
__classPrivateFieldGet(this, _Board_sharer, "f").setActiveStorage("data", data);
|
|
3536
3822
|
const viewSizeInfo = sharer.getActiveViewSizeInfo();
|
|
3823
|
+
const viewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
3537
3824
|
const newViewContextSize = calcElementsContextSize(data.elements, {
|
|
3538
3825
|
viewWidth: viewSizeInfo.width,
|
|
3539
3826
|
viewHeight: viewSizeInfo.height,
|
|
3540
3827
|
extend: true
|
|
3541
3828
|
});
|
|
3829
|
+
if (modifiedOptions) {
|
|
3830
|
+
__classPrivateFieldGet(this, _Board_viewer, "f").resetViewVisibleInfoMap(data, {
|
|
3831
|
+
viewSizeInfo,
|
|
3832
|
+
viewScaleInfo
|
|
3833
|
+
});
|
|
3834
|
+
} else {
|
|
3835
|
+
__classPrivateFieldGet(this, _Board_viewer, "f").resetViewVisibleInfoMap(data, {
|
|
3836
|
+
viewSizeInfo,
|
|
3837
|
+
viewScaleInfo
|
|
3838
|
+
});
|
|
3839
|
+
}
|
|
3542
3840
|
__classPrivateFieldGet(this, _Board_viewer, "f").drawFrame();
|
|
3543
3841
|
const newViewSizeInfo = Object.assign(Object.assign({}, viewSizeInfo), newViewContextSize);
|
|
3544
3842
|
__classPrivateFieldGet(this, _Board_sharer, "f").setActiveViewSizeInfo(newViewSizeInfo);
|
|
@@ -3587,17 +3885,22 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3587
3885
|
}
|
|
3588
3886
|
scale(opts) {
|
|
3589
3887
|
const viewer = __classPrivateFieldGet(this, _Board_viewer, "f");
|
|
3590
|
-
const {
|
|
3591
|
-
|
|
3888
|
+
const { ignoreUpdateVisibleStatus } = opts;
|
|
3889
|
+
const { moveX, moveY } = viewer.scale(Object.assign(Object.assign({}, opts), {
|
|
3890
|
+
ignoreUpdateVisibleStatus: true
|
|
3891
|
+
}));
|
|
3892
|
+
viewer.scroll({ moveX, moveY, ignoreUpdateVisibleStatus });
|
|
3592
3893
|
}
|
|
3593
3894
|
scroll(opts) {
|
|
3594
|
-
|
|
3895
|
+
const result = __classPrivateFieldGet(this, _Board_viewer, "f").scroll(opts);
|
|
3896
|
+
return result;
|
|
3595
3897
|
}
|
|
3596
3898
|
updateViewScaleInfo(opts) {
|
|
3597
|
-
|
|
3899
|
+
const result = __classPrivateFieldGet(this, _Board_viewer, "f").updateViewScaleInfo(opts);
|
|
3900
|
+
return result;
|
|
3598
3901
|
}
|
|
3599
|
-
resize(newViewSize) {
|
|
3600
|
-
const viewSize = __classPrivateFieldGet(this, _Board_viewer, "f").resize(newViewSize);
|
|
3902
|
+
resize(newViewSize, opts) {
|
|
3903
|
+
const viewSize = __classPrivateFieldGet(this, _Board_viewer, "f").resize(newViewSize, opts);
|
|
3601
3904
|
const { width, height, devicePixelRatio } = newViewSize;
|
|
3602
3905
|
const { boardContent } = __classPrivateFieldGet(this, _Board_opts, "f");
|
|
3603
3906
|
boardContent.viewContext.$resize({ width, height, devicePixelRatio });
|
|
@@ -3630,18 +3933,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3630
3933
|
_Board_opts = /* @__PURE__ */ new WeakMap(), _Board_middlewareMap = /* @__PURE__ */ new WeakMap(), _Board_middlewares = /* @__PURE__ */ new WeakMap(), _Board_activeMiddlewareObjs = /* @__PURE__ */ new WeakMap(), _Board_watcher = /* @__PURE__ */ new WeakMap(), _Board_renderer = /* @__PURE__ */ new WeakMap(), _Board_sharer = /* @__PURE__ */ new WeakMap(), _Board_viewer = /* @__PURE__ */ new WeakMap(), _Board_calculator = /* @__PURE__ */ new WeakMap(), _Board_eventHub = /* @__PURE__ */ new WeakMap(), _Board_hasDestroyed = /* @__PURE__ */ new WeakMap(), _Board_instances = /* @__PURE__ */ new WeakSet(), _Board_init = function _Board_init2() {
|
|
3631
3934
|
__classPrivateFieldGet(this, _Board_watcher, "f").on("pointStart", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointStart).bind(this));
|
|
3632
3935
|
__classPrivateFieldGet(this, _Board_watcher, "f").on("pointEnd", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointEnd).bind(this));
|
|
3633
|
-
__classPrivateFieldGet(this, _Board_watcher, "f").on("pointMove",
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
__classPrivateFieldGet(this, _Board_watcher, "f").on("
|
|
3637
|
-
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleHover).call(this, e);
|
|
3638
|
-
}, throttleTime));
|
|
3639
|
-
__classPrivateFieldGet(this, _Board_watcher, "f").on("wheel", throttle((e) => {
|
|
3640
|
-
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheel).call(this, e);
|
|
3641
|
-
}, throttleTime));
|
|
3642
|
-
__classPrivateFieldGet(this, _Board_watcher, "f").on("wheelScale", throttle((e) => {
|
|
3643
|
-
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheelScale).call(this, e);
|
|
3644
|
-
}, throttleTime));
|
|
3936
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("pointMove", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointMove).bind(this));
|
|
3937
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("hover", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleHover).bind(this));
|
|
3938
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("wheel", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheel).bind(this));
|
|
3939
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("wheelScale", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheelScale).bind(this));
|
|
3645
3940
|
__classPrivateFieldGet(this, _Board_watcher, "f").on("scrollX", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleScrollX).bind(this));
|
|
3646
3941
|
__classPrivateFieldGet(this, _Board_watcher, "f").on("scrollY", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleScrollY).bind(this));
|
|
3647
3942
|
__classPrivateFieldGet(this, _Board_watcher, "f").on("resize", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleResize).bind(this));
|
|
@@ -3933,6 +4228,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3933
4228
|
const keySelectedElementList = Symbol(`${key$2}_selectedElementList`);
|
|
3934
4229
|
const keySelectedElementListVertexes = Symbol(`${key$2}_selectedElementListVertexes`);
|
|
3935
4230
|
const keySelectedElementController = Symbol(`${key$2}_selectedElementController`);
|
|
4231
|
+
const keySelectedElementPosition = Symbol(`${key$2}_selectedElementPosition`);
|
|
4232
|
+
const keySelectedReferenceXLines = Symbol(`${key$2}_selectedReferenceXLines`);
|
|
4233
|
+
const keySelectedReferenceYLines = Symbol(`${key$2}_selectedReferenceYLines`);
|
|
3936
4234
|
const keyGroupQueue = Symbol(`${key$2}_groupQueue`);
|
|
3937
4235
|
const keyGroupQueueVertexesList = Symbol(`${key$2}_groupQueueVertexesList`);
|
|
3938
4236
|
const keyIsMoving = Symbol(`${key$2}_isMoving`);
|
|
@@ -3942,6 +4240,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3942
4240
|
const wrapperColor = "#1973ba";
|
|
3943
4241
|
const lockColor = "#5b5959b5";
|
|
3944
4242
|
const controllerSize = 10;
|
|
4243
|
+
const referenceColor = "#f7276e";
|
|
3945
4244
|
function drawVertexes(ctx, vertexes, opts) {
|
|
3946
4245
|
const { borderColor: borderColor2, borderWidth: borderWidth2, background: background2, lineDash } = opts;
|
|
3947
4246
|
ctx.setLineDash([]);
|
|
@@ -3996,11 +4295,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3996
4295
|
}
|
|
3997
4296
|
}
|
|
3998
4297
|
function drawCrossVertexes(ctx, vertexes, opts) {
|
|
3999
|
-
const { borderColor: borderColor2, borderWidth: borderWidth2,
|
|
4298
|
+
const { borderColor: borderColor2, borderWidth: borderWidth2, lineDash } = opts;
|
|
4000
4299
|
ctx.setLineDash([]);
|
|
4001
4300
|
ctx.lineWidth = borderWidth2;
|
|
4002
4301
|
ctx.strokeStyle = borderColor2;
|
|
4003
|
-
ctx.fillStyle = background2;
|
|
4004
4302
|
ctx.setLineDash(lineDash);
|
|
4005
4303
|
ctx.beginPath();
|
|
4006
4304
|
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
@@ -4013,6 +4311,36 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4013
4311
|
ctx.closePath();
|
|
4014
4312
|
ctx.stroke();
|
|
4015
4313
|
}
|
|
4314
|
+
function drawCrossByCenter(ctx, center, opts) {
|
|
4315
|
+
const { size, borderColor: borderColor2, borderWidth: borderWidth2, lineDash } = opts;
|
|
4316
|
+
const minX = center.x - size / 2;
|
|
4317
|
+
const maxX = center.x + size / 2;
|
|
4318
|
+
const minY = center.y - size / 2;
|
|
4319
|
+
const maxY = center.y + size / 2;
|
|
4320
|
+
const vertexes = [
|
|
4321
|
+
{
|
|
4322
|
+
x: minX,
|
|
4323
|
+
y: minY
|
|
4324
|
+
},
|
|
4325
|
+
{
|
|
4326
|
+
x: maxX,
|
|
4327
|
+
y: minY
|
|
4328
|
+
},
|
|
4329
|
+
{
|
|
4330
|
+
x: maxX,
|
|
4331
|
+
y: maxY
|
|
4332
|
+
},
|
|
4333
|
+
{
|
|
4334
|
+
x: minX,
|
|
4335
|
+
y: maxY
|
|
4336
|
+
}
|
|
4337
|
+
];
|
|
4338
|
+
drawCrossVertexes(ctx, vertexes, {
|
|
4339
|
+
borderColor: borderColor2,
|
|
4340
|
+
borderWidth: borderWidth2,
|
|
4341
|
+
lineDash
|
|
4342
|
+
});
|
|
4343
|
+
}
|
|
4016
4344
|
function drawHoverVertexesWrapper(ctx, vertexes, opts) {
|
|
4017
4345
|
if (!vertexes) {
|
|
4018
4346
|
return;
|
|
@@ -4044,7 +4372,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4044
4372
|
if (!controller) {
|
|
4045
4373
|
return;
|
|
4046
4374
|
}
|
|
4047
|
-
const {
|
|
4375
|
+
const {
|
|
4376
|
+
hideControllers
|
|
4377
|
+
// calculator, element, viewScaleInfo, viewSizeInfo
|
|
4378
|
+
} = opts;
|
|
4048
4379
|
const { elementWrapper, topLeft, topRight, bottomLeft, bottomRight, top, rotate } = controller;
|
|
4049
4380
|
const wrapperOpts = { borderColor: wrapperColor, borderWidth: selectWrapperBorderWidth, background: "transparent", lineDash: [] };
|
|
4050
4381
|
const ctrlOpts = { ...wrapperOpts, borderWidth: resizeControllerBorderWidth, background: "#FFFFFF" };
|
|
@@ -4096,6 +4427,35 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4096
4427
|
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
4097
4428
|
}
|
|
4098
4429
|
}
|
|
4430
|
+
function drawReferenceLines(ctx, opts) {
|
|
4431
|
+
const { xLines, yLines } = opts;
|
|
4432
|
+
const lineOpts = {
|
|
4433
|
+
borderColor: referenceColor,
|
|
4434
|
+
borderWidth: 1,
|
|
4435
|
+
lineDash: []
|
|
4436
|
+
};
|
|
4437
|
+
const crossOpts = { ...lineOpts, size: 6 };
|
|
4438
|
+
if (xLines) {
|
|
4439
|
+
xLines.forEach((line) => {
|
|
4440
|
+
line.forEach((p, pIdx) => {
|
|
4441
|
+
drawCrossByCenter(ctx, p, crossOpts);
|
|
4442
|
+
if (line[pIdx + 1]) {
|
|
4443
|
+
drawLine(ctx, line[pIdx], line[pIdx + 1], lineOpts);
|
|
4444
|
+
}
|
|
4445
|
+
});
|
|
4446
|
+
});
|
|
4447
|
+
}
|
|
4448
|
+
if (yLines) {
|
|
4449
|
+
yLines.forEach((line) => {
|
|
4450
|
+
line.forEach((p, pIdx) => {
|
|
4451
|
+
drawCrossByCenter(ctx, p, crossOpts);
|
|
4452
|
+
if (line[pIdx + 1]) {
|
|
4453
|
+
drawLine(ctx, line[pIdx], line[pIdx + 1], lineOpts);
|
|
4454
|
+
}
|
|
4455
|
+
});
|
|
4456
|
+
});
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4099
4459
|
function parseRadian(angle2) {
|
|
4100
4460
|
return angle2 * Math.PI / 180;
|
|
4101
4461
|
}
|
|
@@ -4106,11 +4466,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4106
4466
|
return moveDirect > 0 ? Math.abs(moveDist) : 0 - Math.abs(moveDist);
|
|
4107
4467
|
}
|
|
4108
4468
|
function isPointInViewActiveVertexes(p, opts) {
|
|
4109
|
-
const { ctx, viewScaleInfo,
|
|
4110
|
-
const v0 = calcViewPointSize(vertexes[0], { viewScaleInfo
|
|
4111
|
-
const v1 = calcViewPointSize(vertexes[1], { viewScaleInfo
|
|
4112
|
-
const v2 = calcViewPointSize(vertexes[2], { viewScaleInfo
|
|
4113
|
-
const v3 = calcViewPointSize(vertexes[3], { viewScaleInfo
|
|
4469
|
+
const { ctx, viewScaleInfo, vertexes } = opts;
|
|
4470
|
+
const v0 = calcViewPointSize(vertexes[0], { viewScaleInfo });
|
|
4471
|
+
const v1 = calcViewPointSize(vertexes[1], { viewScaleInfo });
|
|
4472
|
+
const v2 = calcViewPointSize(vertexes[2], { viewScaleInfo });
|
|
4473
|
+
const v3 = calcViewPointSize(vertexes[3], { viewScaleInfo });
|
|
4114
4474
|
ctx.beginPath();
|
|
4115
4475
|
ctx.moveTo(v0.x, v0.y);
|
|
4116
4476
|
ctx.lineTo(v1.x, v1.y);
|
|
@@ -4729,10 +5089,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4729
5089
|
}
|
|
4730
5090
|
function rotateElement(elem, opts) {
|
|
4731
5091
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elem;
|
|
4732
|
-
const { center, start, end, viewScaleInfo
|
|
5092
|
+
const { center, start, end, viewScaleInfo } = opts;
|
|
4733
5093
|
const elemCenter = calcViewPointSize(center, {
|
|
4734
|
-
viewScaleInfo
|
|
4735
|
-
viewSizeInfo
|
|
5094
|
+
viewScaleInfo
|
|
4736
5095
|
});
|
|
4737
5096
|
const startAngle = limitAngle(angle2);
|
|
4738
5097
|
const changedRadian = calcRadian(elemCenter, start, end);
|
|
@@ -4750,7 +5109,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4750
5109
|
const indexes = [];
|
|
4751
5110
|
const uuids = [];
|
|
4752
5111
|
const elements = [];
|
|
4753
|
-
const {
|
|
5112
|
+
const { viewScaleInfo, viewSizeInfo, start, end } = opts;
|
|
4754
5113
|
if (!(Array.isArray(data.elements) && start && end)) {
|
|
4755
5114
|
return { indexes, uuids, elements };
|
|
4756
5115
|
}
|
|
@@ -4763,7 +5122,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4763
5122
|
if (((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.lock) === true) {
|
|
4764
5123
|
continue;
|
|
4765
5124
|
}
|
|
4766
|
-
const elemSize =
|
|
5125
|
+
const elemSize = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
|
|
4767
5126
|
const center = calcElementCenter(elemSize);
|
|
4768
5127
|
if (center.x >= startX && center.x <= endX && center.y >= startY && center.y <= endY) {
|
|
4769
5128
|
indexes.push(idx);
|
|
@@ -4790,14 +5149,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4790
5149
|
return null;
|
|
4791
5150
|
}
|
|
4792
5151
|
const area = { x: 0, y: 0, w: 0, h: 0 };
|
|
4793
|
-
const {
|
|
5152
|
+
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
4794
5153
|
let prevElemSize = null;
|
|
4795
5154
|
for (let i = 0; i < elements.length; i++) {
|
|
4796
5155
|
const elem = elements[i];
|
|
4797
5156
|
if ((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.invisible) {
|
|
4798
5157
|
continue;
|
|
4799
5158
|
}
|
|
4800
|
-
const elemSize =
|
|
5159
|
+
const elemSize = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
|
|
4801
5160
|
if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
|
|
4802
5161
|
const ves = rotateElementVertexes(elemSize);
|
|
4803
5162
|
if (ves.length === 4) {
|
|
@@ -4865,6 +5224,264 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4865
5224
|
moveY
|
|
4866
5225
|
};
|
|
4867
5226
|
}
|
|
5227
|
+
const unitSize = 2;
|
|
5228
|
+
function getViewBoxInfo(rectInfo) {
|
|
5229
|
+
const boxInfo = {
|
|
5230
|
+
minX: rectInfo.topLeft.x,
|
|
5231
|
+
minY: rectInfo.topLeft.y,
|
|
5232
|
+
maxX: rectInfo.bottomRight.x,
|
|
5233
|
+
maxY: rectInfo.bottomRight.y,
|
|
5234
|
+
midX: rectInfo.center.x,
|
|
5235
|
+
midY: rectInfo.center.y
|
|
5236
|
+
};
|
|
5237
|
+
return boxInfo;
|
|
5238
|
+
}
|
|
5239
|
+
const getClosestNumInSortedKeys = (sortedKeys, target) => {
|
|
5240
|
+
if (sortedKeys.length === 0) {
|
|
5241
|
+
throw null;
|
|
5242
|
+
}
|
|
5243
|
+
if (sortedKeys.length === 1) {
|
|
5244
|
+
return sortedKeys[0];
|
|
5245
|
+
}
|
|
5246
|
+
let left = 0;
|
|
5247
|
+
let right = sortedKeys.length - 1;
|
|
5248
|
+
while (left <= right) {
|
|
5249
|
+
const mid = Math.floor((left + right) / 2);
|
|
5250
|
+
if (sortedKeys[mid] === target) {
|
|
5251
|
+
return sortedKeys[mid];
|
|
5252
|
+
} else if (sortedKeys[mid] < target) {
|
|
5253
|
+
left = mid + 1;
|
|
5254
|
+
} else {
|
|
5255
|
+
right = mid - 1;
|
|
5256
|
+
}
|
|
5257
|
+
}
|
|
5258
|
+
if (left >= sortedKeys.length) {
|
|
5259
|
+
return sortedKeys[right];
|
|
5260
|
+
}
|
|
5261
|
+
if (right < 0) {
|
|
5262
|
+
return sortedKeys[left];
|
|
5263
|
+
}
|
|
5264
|
+
return Math.abs(sortedKeys[right] - target) <= Math.abs(sortedKeys[left] - target) ? sortedKeys[right] : sortedKeys[left];
|
|
5265
|
+
};
|
|
5266
|
+
const isEqualNum = (a, b) => Math.abs(a - b) < 1e-5;
|
|
5267
|
+
function calcReferenceInfo(uuid, opts) {
|
|
5268
|
+
var _a, _b;
|
|
5269
|
+
const { data, groupQueue, calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
5270
|
+
let targetElements = data.elements || [];
|
|
5271
|
+
if ((groupQueue == null ? void 0 : groupQueue.length) > 0) {
|
|
5272
|
+
targetElements = ((_b = (_a = groupQueue[groupQueue.length - 1]) == null ? void 0 : _a.detail) == null ? void 0 : _b.children) || [];
|
|
5273
|
+
}
|
|
5274
|
+
const siblingViewRectInfoList = [];
|
|
5275
|
+
targetElements.forEach((elem) => {
|
|
5276
|
+
if (elem.uuid !== uuid) {
|
|
5277
|
+
const info = calculator.calcViewRectInfoFromRange(elem.uuid, { checkVisible: true, viewScaleInfo, viewSizeInfo });
|
|
5278
|
+
if (info) {
|
|
5279
|
+
siblingViewRectInfoList.push(info);
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
});
|
|
5283
|
+
const targetRectInfo = calculator.calcViewRectInfoFromRange(uuid, { viewScaleInfo, viewSizeInfo });
|
|
5284
|
+
if (!targetRectInfo) {
|
|
5285
|
+
return null;
|
|
5286
|
+
}
|
|
5287
|
+
const vRefLineDotMap = {};
|
|
5288
|
+
const hRefLineDotMap = {};
|
|
5289
|
+
const vHelperLineDotMapList = [];
|
|
5290
|
+
const hHelperLineDotMapList = [];
|
|
5291
|
+
let sortedRefXKeys = [];
|
|
5292
|
+
let sortedRefYKeys = [];
|
|
5293
|
+
const targetBox = getViewBoxInfo(targetRectInfo);
|
|
5294
|
+
siblingViewRectInfoList.forEach((info) => {
|
|
5295
|
+
const box = getViewBoxInfo(info);
|
|
5296
|
+
if (!vRefLineDotMap[box.minX]) {
|
|
5297
|
+
vRefLineDotMap[box.minX] = [];
|
|
5298
|
+
}
|
|
5299
|
+
if (!vRefLineDotMap[box.midX]) {
|
|
5300
|
+
vRefLineDotMap[box.midX] = [];
|
|
5301
|
+
}
|
|
5302
|
+
if (!vRefLineDotMap[box.maxX]) {
|
|
5303
|
+
vRefLineDotMap[box.maxX] = [];
|
|
5304
|
+
}
|
|
5305
|
+
if (!hRefLineDotMap[box.minY]) {
|
|
5306
|
+
hRefLineDotMap[box.minY] = [];
|
|
5307
|
+
}
|
|
5308
|
+
if (!hRefLineDotMap[box.midY]) {
|
|
5309
|
+
hRefLineDotMap[box.midY] = [];
|
|
5310
|
+
}
|
|
5311
|
+
if (!hRefLineDotMap[box.maxY]) {
|
|
5312
|
+
hRefLineDotMap[box.maxY] = [];
|
|
5313
|
+
}
|
|
5314
|
+
vRefLineDotMap[box.minX] = [box.minY, box.midY, box.maxY];
|
|
5315
|
+
vRefLineDotMap[box.midX] = [box.minY, box.midY, box.maxY];
|
|
5316
|
+
vRefLineDotMap[box.maxX] = [box.minY, box.midY, box.maxY];
|
|
5317
|
+
sortedRefXKeys.push(box.minX);
|
|
5318
|
+
sortedRefXKeys.push(box.midX);
|
|
5319
|
+
sortedRefXKeys.push(box.maxX);
|
|
5320
|
+
hRefLineDotMap[box.minY] = [box.minX, box.midX, box.maxX];
|
|
5321
|
+
hRefLineDotMap[box.midY] = [box.minX, box.midX, box.maxX];
|
|
5322
|
+
hRefLineDotMap[box.maxY] = [box.minX, box.midX, box.maxX];
|
|
5323
|
+
sortedRefYKeys.push(box.minY);
|
|
5324
|
+
sortedRefYKeys.push(box.midY);
|
|
5325
|
+
sortedRefYKeys.push(box.maxY);
|
|
5326
|
+
});
|
|
5327
|
+
sortedRefXKeys = sortedRefXKeys.sort((a, b) => a - b);
|
|
5328
|
+
sortedRefYKeys = sortedRefYKeys.sort((a, b) => a - b);
|
|
5329
|
+
let offsetX = null;
|
|
5330
|
+
let offsetY = null;
|
|
5331
|
+
let closestMinX = null;
|
|
5332
|
+
let closestMidX = null;
|
|
5333
|
+
let closestMaxX = null;
|
|
5334
|
+
let closestMinY = null;
|
|
5335
|
+
let closestMidY = null;
|
|
5336
|
+
let closestMaxY = null;
|
|
5337
|
+
if (sortedRefXKeys.length > 0) {
|
|
5338
|
+
closestMinX = getClosestNumInSortedKeys(sortedRefXKeys, targetBox.minX);
|
|
5339
|
+
closestMidX = getClosestNumInSortedKeys(sortedRefXKeys, targetBox.midX);
|
|
5340
|
+
closestMaxX = getClosestNumInSortedKeys(sortedRefXKeys, targetBox.maxX);
|
|
5341
|
+
const distMinX = Math.abs(closestMinX - targetBox.minX);
|
|
5342
|
+
const distMidX = Math.abs(closestMidX - targetBox.midX);
|
|
5343
|
+
const distMaxX = Math.abs(closestMaxX - targetBox.maxX);
|
|
5344
|
+
const closestXDist = Math.min(distMinX, distMidX, distMaxX);
|
|
5345
|
+
if (closestXDist <= unitSize / viewScaleInfo.scale) {
|
|
5346
|
+
if (isEqualNum(closestXDist, distMinX)) {
|
|
5347
|
+
offsetX = closestMinX - targetBox.minX;
|
|
5348
|
+
} else if (isEqualNum(closestXDist, distMidX)) {
|
|
5349
|
+
offsetX = closestMidX - targetBox.midX;
|
|
5350
|
+
} else if (isEqualNum(closestXDist, distMaxX)) {
|
|
5351
|
+
offsetX = closestMaxX - targetBox.maxX;
|
|
5352
|
+
}
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5355
|
+
if (sortedRefYKeys.length > 0) {
|
|
5356
|
+
closestMinY = getClosestNumInSortedKeys(sortedRefYKeys, targetBox.minY);
|
|
5357
|
+
closestMidY = getClosestNumInSortedKeys(sortedRefYKeys, targetBox.midY);
|
|
5358
|
+
closestMaxY = getClosestNumInSortedKeys(sortedRefYKeys, targetBox.maxY);
|
|
5359
|
+
const distMinY = Math.abs(closestMinY - targetBox.minY);
|
|
5360
|
+
const distMidY = Math.abs(closestMidY - targetBox.midY);
|
|
5361
|
+
const distMaxY = Math.abs(closestMaxY - targetBox.maxY);
|
|
5362
|
+
const closestYDist = Math.min(distMinY, distMidY, distMaxY);
|
|
5363
|
+
if (closestYDist <= unitSize / viewScaleInfo.scale) {
|
|
5364
|
+
if (isEqualNum(closestYDist, distMinY)) {
|
|
5365
|
+
offsetY = closestMinY - targetBox.minY;
|
|
5366
|
+
} else if (isEqualNum(closestYDist, distMidY)) {
|
|
5367
|
+
offsetY = closestMidY - targetBox.midY;
|
|
5368
|
+
} else if (isEqualNum(closestYDist, distMaxY)) {
|
|
5369
|
+
offsetY = closestMaxY - targetBox.maxY;
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5373
|
+
const newTargetBox = { ...targetBox };
|
|
5374
|
+
if (offsetX !== null) {
|
|
5375
|
+
newTargetBox.minX += offsetX;
|
|
5376
|
+
newTargetBox.midX += offsetX;
|
|
5377
|
+
newTargetBox.maxX += offsetX;
|
|
5378
|
+
}
|
|
5379
|
+
if (offsetY !== null) {
|
|
5380
|
+
newTargetBox.minY += offsetY;
|
|
5381
|
+
newTargetBox.midY += offsetY;
|
|
5382
|
+
newTargetBox.maxY += offsetY;
|
|
5383
|
+
}
|
|
5384
|
+
if (is.x(offsetX) && offsetX !== null && closestMinX !== null && closestMidX !== null && closestMaxX !== null) {
|
|
5385
|
+
if (isEqualNum(offsetX, closestMinX - targetBox.minX)) {
|
|
5386
|
+
const vLine = {
|
|
5387
|
+
x: closestMinX,
|
|
5388
|
+
yList: []
|
|
5389
|
+
};
|
|
5390
|
+
vLine.yList.push(newTargetBox.minY);
|
|
5391
|
+
vLine.yList.push(newTargetBox.midY);
|
|
5392
|
+
vLine.yList.push(newTargetBox.maxY);
|
|
5393
|
+
vLine.yList.push(...(hRefLineDotMap == null ? void 0 : hRefLineDotMap[closestMinX]) || []);
|
|
5394
|
+
vHelperLineDotMapList.push(vLine);
|
|
5395
|
+
}
|
|
5396
|
+
if (isEqualNum(offsetX, closestMidX - targetBox.minX)) {
|
|
5397
|
+
const vLine = {
|
|
5398
|
+
x: closestMidX,
|
|
5399
|
+
yList: []
|
|
5400
|
+
};
|
|
5401
|
+
vLine.yList.push(newTargetBox.minY);
|
|
5402
|
+
vLine.yList.push(newTargetBox.midY);
|
|
5403
|
+
vLine.yList.push(newTargetBox.maxY);
|
|
5404
|
+
vLine.yList.push(...(hRefLineDotMap == null ? void 0 : hRefLineDotMap[closestMidX]) || []);
|
|
5405
|
+
vHelperLineDotMapList.push(vLine);
|
|
5406
|
+
}
|
|
5407
|
+
if (isEqualNum(offsetX, closestMaxX - targetBox.minX)) {
|
|
5408
|
+
const vLine = {
|
|
5409
|
+
x: closestMaxX,
|
|
5410
|
+
yList: []
|
|
5411
|
+
};
|
|
5412
|
+
vLine.yList.push(newTargetBox.minY);
|
|
5413
|
+
vLine.yList.push(newTargetBox.midY);
|
|
5414
|
+
vLine.yList.push(newTargetBox.maxY);
|
|
5415
|
+
vLine.yList.push(...(hRefLineDotMap == null ? void 0 : hRefLineDotMap[closestMaxX]) || []);
|
|
5416
|
+
vHelperLineDotMapList.push(vLine);
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5419
|
+
if (is.y(offsetY) && offsetY !== null && closestMinY !== null && closestMidY !== null && closestMaxY !== null) {
|
|
5420
|
+
if (isEqualNum(offsetY, closestMinY - targetBox.minY)) {
|
|
5421
|
+
const hLine = {
|
|
5422
|
+
y: closestMinY,
|
|
5423
|
+
xList: []
|
|
5424
|
+
};
|
|
5425
|
+
hLine.xList.push(newTargetBox.minX);
|
|
5426
|
+
hLine.xList.push(newTargetBox.midX);
|
|
5427
|
+
hLine.xList.push(newTargetBox.maxX);
|
|
5428
|
+
hLine.xList.push(...(vRefLineDotMap == null ? void 0 : vRefLineDotMap[closestMinY]) || []);
|
|
5429
|
+
hHelperLineDotMapList.push(hLine);
|
|
5430
|
+
}
|
|
5431
|
+
if (isEqualNum(offsetY, closestMidY - targetBox.midY)) {
|
|
5432
|
+
const hLine = {
|
|
5433
|
+
y: closestMidY,
|
|
5434
|
+
xList: []
|
|
5435
|
+
};
|
|
5436
|
+
hLine.xList.push(newTargetBox.minX);
|
|
5437
|
+
hLine.xList.push(newTargetBox.midX);
|
|
5438
|
+
hLine.xList.push(newTargetBox.maxX);
|
|
5439
|
+
hLine.xList.push(...(vRefLineDotMap == null ? void 0 : vRefLineDotMap[closestMinY]) || []);
|
|
5440
|
+
hHelperLineDotMapList.push(hLine);
|
|
5441
|
+
}
|
|
5442
|
+
if (isEqualNum(offsetY, closestMaxY - targetBox.maxY)) {
|
|
5443
|
+
const hLine = {
|
|
5444
|
+
y: closestMaxY,
|
|
5445
|
+
xList: []
|
|
5446
|
+
};
|
|
5447
|
+
hLine.xList.push(newTargetBox.minX);
|
|
5448
|
+
hLine.xList.push(newTargetBox.midX);
|
|
5449
|
+
hLine.xList.push(newTargetBox.maxX);
|
|
5450
|
+
hLine.xList.push(...(vRefLineDotMap == null ? void 0 : vRefLineDotMap[closestMaxY]) || []);
|
|
5451
|
+
hHelperLineDotMapList.push(hLine);
|
|
5452
|
+
}
|
|
5453
|
+
}
|
|
5454
|
+
const yLines = [];
|
|
5455
|
+
if ((vHelperLineDotMapList == null ? void 0 : vHelperLineDotMapList.length) > 0) {
|
|
5456
|
+
vHelperLineDotMapList.forEach((item, i) => {
|
|
5457
|
+
yLines.push([]);
|
|
5458
|
+
item.yList.forEach((y2) => {
|
|
5459
|
+
yLines[i].push({
|
|
5460
|
+
x: item.x,
|
|
5461
|
+
y: y2
|
|
5462
|
+
});
|
|
5463
|
+
});
|
|
5464
|
+
});
|
|
5465
|
+
}
|
|
5466
|
+
const xLines = [];
|
|
5467
|
+
if ((hHelperLineDotMapList == null ? void 0 : hHelperLineDotMapList.length) > 0) {
|
|
5468
|
+
hHelperLineDotMapList.forEach((item, i) => {
|
|
5469
|
+
xLines.push([]);
|
|
5470
|
+
item.xList.forEach((x2) => {
|
|
5471
|
+
xLines[i].push({
|
|
5472
|
+
x: x2,
|
|
5473
|
+
y: item.y
|
|
5474
|
+
});
|
|
5475
|
+
});
|
|
5476
|
+
});
|
|
5477
|
+
}
|
|
5478
|
+
return {
|
|
5479
|
+
offsetX,
|
|
5480
|
+
offsetY,
|
|
5481
|
+
yLines,
|
|
5482
|
+
xLines
|
|
5483
|
+
};
|
|
5484
|
+
}
|
|
4868
5485
|
const middlewareEventTextEdit = "@middleware/text-edit";
|
|
4869
5486
|
const middlewareEventTextChange = "@middleware/text-change";
|
|
4870
5487
|
const defaultElementDetail = getDefaultElementDetailConfig();
|
|
@@ -5039,6 +5656,19 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5039
5656
|
}
|
|
5040
5657
|
hideTextArea();
|
|
5041
5658
|
});
|
|
5659
|
+
textarea.addEventListener("keydown", (e) => {
|
|
5660
|
+
e.stopPropagation();
|
|
5661
|
+
});
|
|
5662
|
+
textarea.addEventListener("keypress", (e) => {
|
|
5663
|
+
e.stopPropagation();
|
|
5664
|
+
});
|
|
5665
|
+
textarea.addEventListener("keyup", (e) => {
|
|
5666
|
+
e.stopPropagation();
|
|
5667
|
+
});
|
|
5668
|
+
textarea.addEventListener("wheel", (e) => {
|
|
5669
|
+
e.stopPropagation();
|
|
5670
|
+
e.preventDefault();
|
|
5671
|
+
});
|
|
5042
5672
|
const textEditCallback = (e) => {
|
|
5043
5673
|
var _a;
|
|
5044
5674
|
if ((e == null ? void 0 : e.position) && (e == null ? void 0 : e.element) && ((_a = e == null ? void 0 : e.element) == null ? void 0 : _a.type) === "text") {
|
|
@@ -5098,6 +5728,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5098
5728
|
sharer.setSharedStorage(keyHoverElementVertexes, vertexes);
|
|
5099
5729
|
};
|
|
5100
5730
|
const updateSelectedElementList = (list, opts2) => {
|
|
5731
|
+
var _a;
|
|
5101
5732
|
sharer.setSharedStorage(keySelectedElementList, list);
|
|
5102
5733
|
if (list.length === 1) {
|
|
5103
5734
|
const controller = calcElementSizeController(list[0], {
|
|
@@ -5106,8 +5737,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5106
5737
|
viewScaleInfo: sharer.getActiveViewScaleInfo()
|
|
5107
5738
|
});
|
|
5108
5739
|
sharer.setSharedStorage(keySelectedElementController, controller);
|
|
5740
|
+
sharer.setSharedStorage(keySelectedElementPosition, getElementPositionFromList(list[0].uuid, ((_a = sharer.getActiveStorage("data")) == null ? void 0 : _a.elements) || []));
|
|
5109
5741
|
} else {
|
|
5110
5742
|
sharer.setSharedStorage(keySelectedElementController, null);
|
|
5743
|
+
sharer.setSharedStorage(keySelectedElementPosition, []);
|
|
5111
5744
|
}
|
|
5112
5745
|
if ((opts2 == null ? void 0 : opts2.triggerEvent) === true) {
|
|
5113
5746
|
eventHub.trigger(middlewareEventSelect, { uuids: list.map((elem) => elem.uuid) });
|
|
@@ -5123,7 +5756,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5123
5756
|
viewSizeInfo: sharer.getActiveViewSizeInfo(),
|
|
5124
5757
|
groupQueue: sharer.getSharedStorage(keyGroupQueue),
|
|
5125
5758
|
areaSize: null,
|
|
5126
|
-
selectedElementController: sharer.getSharedStorage(keySelectedElementController)
|
|
5759
|
+
selectedElementController: sharer.getSharedStorage(keySelectedElementController),
|
|
5760
|
+
selectedElementPosition: sharer.getSharedStorage(keySelectedElementPosition)
|
|
5127
5761
|
};
|
|
5128
5762
|
};
|
|
5129
5763
|
const clear = () => {
|
|
@@ -5138,6 +5772,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5138
5772
|
sharer.setSharedStorage(keySelectedElementList, []);
|
|
5139
5773
|
sharer.setSharedStorage(keySelectedElementListVertexes, null);
|
|
5140
5774
|
sharer.setSharedStorage(keySelectedElementController, null);
|
|
5775
|
+
sharer.setSharedStorage(keySelectedElementPosition, []);
|
|
5776
|
+
sharer.setSharedStorage(keySelectedReferenceXLines, []);
|
|
5777
|
+
sharer.setSharedStorage(keySelectedReferenceYLines, []);
|
|
5141
5778
|
sharer.setSharedStorage(keyIsMoving, null);
|
|
5142
5779
|
};
|
|
5143
5780
|
clear();
|
|
@@ -5327,6 +5964,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5327
5964
|
},
|
|
5328
5965
|
pointMove: (e) => {
|
|
5329
5966
|
var _a, _b, _c;
|
|
5967
|
+
sharer.setSharedStorage(keySelectedReferenceXLines, []);
|
|
5968
|
+
sharer.setSharedStorage(keySelectedReferenceYLines, []);
|
|
5330
5969
|
sharer.setSharedStorage(keyIsMoving, true);
|
|
5331
5970
|
const data = sharer.getActiveStorage("data");
|
|
5332
5971
|
const elems = getActiveElements();
|
|
@@ -5342,9 +5981,43 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5342
5981
|
inBusyMode = "drag";
|
|
5343
5982
|
if (data && (elems == null ? void 0 : elems.length) === 1 && start && end && ((_b = (_a = elems[0]) == null ? void 0 : _a.operations) == null ? void 0 : _b.lock) !== true) {
|
|
5344
5983
|
const { moveX, moveY } = calcMoveInGroup(start, end, groupQueue);
|
|
5345
|
-
|
|
5346
|
-
|
|
5984
|
+
let totalMoveX = calculator.toGridNum(moveX / scale);
|
|
5985
|
+
let totalMoveY = calculator.toGridNum(moveY / scale);
|
|
5986
|
+
const referenceInfo = calcReferenceInfo(elems[0].uuid, {
|
|
5987
|
+
calculator,
|
|
5988
|
+
data,
|
|
5989
|
+
groupQueue,
|
|
5990
|
+
viewScaleInfo,
|
|
5991
|
+
viewSizeInfo
|
|
5992
|
+
});
|
|
5993
|
+
try {
|
|
5994
|
+
if (referenceInfo) {
|
|
5995
|
+
if (is.x(referenceInfo.offsetX) && referenceInfo.offsetX !== null) {
|
|
5996
|
+
totalMoveX = calculator.toGridNum(totalMoveX + referenceInfo.offsetX);
|
|
5997
|
+
}
|
|
5998
|
+
if (is.y(referenceInfo.offsetY) && referenceInfo.offsetY !== null) {
|
|
5999
|
+
totalMoveY = calculator.toGridNum(totalMoveY + referenceInfo.offsetY);
|
|
6000
|
+
}
|
|
6001
|
+
sharer.setSharedStorage(keySelectedReferenceXLines, referenceInfo.xLines);
|
|
6002
|
+
sharer.setSharedStorage(keySelectedReferenceYLines, referenceInfo.yLines);
|
|
6003
|
+
}
|
|
6004
|
+
} catch (err) {
|
|
6005
|
+
console.error(err);
|
|
6006
|
+
}
|
|
6007
|
+
elems[0].x = calculator.toGridNum(elems[0].x + totalMoveX);
|
|
6008
|
+
elems[0].y = calculator.toGridNum(elems[0].y + totalMoveY);
|
|
5347
6009
|
updateSelectedElementList([elems[0]]);
|
|
6010
|
+
calculator.modifyViewVisibleInfoMap(data, {
|
|
6011
|
+
modifyOptions: {
|
|
6012
|
+
type: "updateElement",
|
|
6013
|
+
content: {
|
|
6014
|
+
element: elems[0],
|
|
6015
|
+
position: sharer.getSharedStorage(keySelectedElementPosition) || []
|
|
6016
|
+
}
|
|
6017
|
+
},
|
|
6018
|
+
viewSizeInfo,
|
|
6019
|
+
viewScaleInfo
|
|
6020
|
+
});
|
|
5348
6021
|
}
|
|
5349
6022
|
viewer.drawFrame();
|
|
5350
6023
|
} else if (actionType === "drag-list") {
|
|
@@ -5355,8 +6028,19 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5355
6028
|
elems.forEach((elem) => {
|
|
5356
6029
|
var _a2;
|
|
5357
6030
|
if (elem && ((_a2 = elem == null ? void 0 : elem.operations) == null ? void 0 : _a2.lock) !== true) {
|
|
5358
|
-
elem.x
|
|
5359
|
-
elem.y
|
|
6031
|
+
elem.x = calculator.toGridNum(elem.x + moveX);
|
|
6032
|
+
elem.y = calculator.toGridNum(elem.y + moveY);
|
|
6033
|
+
calculator.modifyViewVisibleInfoMap(data, {
|
|
6034
|
+
modifyOptions: {
|
|
6035
|
+
type: "updateElement",
|
|
6036
|
+
content: {
|
|
6037
|
+
element: elem,
|
|
6038
|
+
position: sharer.getSharedStorage(keySelectedElementPosition) || []
|
|
6039
|
+
}
|
|
6040
|
+
},
|
|
6041
|
+
viewSizeInfo,
|
|
6042
|
+
viewScaleInfo
|
|
6043
|
+
});
|
|
5360
6044
|
}
|
|
5361
6045
|
});
|
|
5362
6046
|
sharer.setActiveStorage("data", data);
|
|
@@ -5403,19 +6087,30 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5403
6087
|
elems[0].angle = resizedElemSize.angle;
|
|
5404
6088
|
} else {
|
|
5405
6089
|
const resizedElemSize = resizeElement(elems[0], { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
|
|
5406
|
-
elems[0].x = resizedElemSize.x;
|
|
5407
|
-
elems[0].y = resizedElemSize.y;
|
|
6090
|
+
elems[0].x = calculator.toGridNum(resizedElemSize.x);
|
|
6091
|
+
elems[0].y = calculator.toGridNum(resizedElemSize.y);
|
|
5408
6092
|
if (elems[0].type === "group" && ((_c = elems[0].operations) == null ? void 0 : _c.deepResize) === true) {
|
|
5409
6093
|
deepResizeGroupElement(elems[0], {
|
|
5410
|
-
w: resizedElemSize.w,
|
|
5411
|
-
h: resizedElemSize.h
|
|
6094
|
+
w: calculator.toGridNum(resizedElemSize.w),
|
|
6095
|
+
h: calculator.toGridNum(resizedElemSize.h)
|
|
5412
6096
|
});
|
|
5413
6097
|
} else {
|
|
5414
|
-
elems[0].w = resizedElemSize.w;
|
|
5415
|
-
elems[0].h = resizedElemSize.h;
|
|
6098
|
+
elems[0].w = calculator.toGridNum(resizedElemSize.w);
|
|
6099
|
+
elems[0].h = calculator.toGridNum(resizedElemSize.h);
|
|
5416
6100
|
}
|
|
5417
6101
|
}
|
|
5418
6102
|
updateSelectedElementList([elems[0]]);
|
|
6103
|
+
calculator.modifyViewVisibleInfoMap(data, {
|
|
6104
|
+
modifyOptions: {
|
|
6105
|
+
type: "updateElement",
|
|
6106
|
+
content: {
|
|
6107
|
+
element: elems[0],
|
|
6108
|
+
position: sharer.getSharedStorage(keySelectedElementPosition) || []
|
|
6109
|
+
}
|
|
6110
|
+
},
|
|
6111
|
+
viewSizeInfo,
|
|
6112
|
+
viewScaleInfo
|
|
6113
|
+
});
|
|
5419
6114
|
viewer.drawFrame();
|
|
5420
6115
|
}
|
|
5421
6116
|
} else if (actionType === "area") {
|
|
@@ -5427,6 +6122,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5427
6122
|
},
|
|
5428
6123
|
pointEnd(e) {
|
|
5429
6124
|
inBusyMode = null;
|
|
6125
|
+
sharer.setSharedStorage(keySelectedReferenceXLines, []);
|
|
6126
|
+
sharer.setSharedStorage(keySelectedReferenceYLines, []);
|
|
5430
6127
|
sharer.setSharedStorage(keyIsMoving, false);
|
|
5431
6128
|
const data = sharer.getActiveStorage("data");
|
|
5432
6129
|
const resizeType = sharer.getSharedStorage(keyResizeType);
|
|
@@ -5568,9 +6265,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5568
6265
|
drawSelectedElementControllersVertexes(helperContext, selectedElementController, {
|
|
5569
6266
|
...drawBaseOpts,
|
|
5570
6267
|
element: elem,
|
|
5571
|
-
|
|
6268
|
+
calculator,
|
|
5572
6269
|
hideControllers: !!isMoving && actionType === "drag"
|
|
5573
6270
|
});
|
|
6271
|
+
if (actionType === "drag") {
|
|
6272
|
+
const xLines = sharer2.getSharedStorage(keySelectedReferenceXLines);
|
|
6273
|
+
const yLines = sharer2.getSharedStorage(keySelectedReferenceYLines);
|
|
6274
|
+
drawReferenceLines(helperContext, {
|
|
6275
|
+
xLines,
|
|
6276
|
+
yLines
|
|
6277
|
+
});
|
|
6278
|
+
}
|
|
5574
6279
|
}
|
|
5575
6280
|
} else {
|
|
5576
6281
|
if (hoverElement && actionType !== "drag") {
|
|
@@ -5591,9 +6296,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5591
6296
|
drawSelectedElementControllersVertexes(helperContext, selectedElementController, {
|
|
5592
6297
|
...drawBaseOpts,
|
|
5593
6298
|
element: elem,
|
|
5594
|
-
|
|
6299
|
+
calculator,
|
|
5595
6300
|
hideControllers: !!isMoving && actionType === "drag"
|
|
5596
6301
|
});
|
|
6302
|
+
if (actionType === "drag") {
|
|
6303
|
+
const xLines = sharer2.getSharedStorage(keySelectedReferenceXLines);
|
|
6304
|
+
const yLines = sharer2.getSharedStorage(keySelectedReferenceYLines);
|
|
6305
|
+
drawReferenceLines(helperContext, {
|
|
6306
|
+
xLines,
|
|
6307
|
+
yLines
|
|
6308
|
+
});
|
|
6309
|
+
}
|
|
5597
6310
|
} else if (actionType === "area" && areaStart && areaEnd) {
|
|
5598
6311
|
drawArea(helperContext, { start: areaStart, end: areaEnd });
|
|
5599
6312
|
} else if (["drag-list", "drag-list-end"].includes(actionType)) {
|
|
@@ -6239,9 +6952,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6239
6952
|
disuse(middleware) {
|
|
6240
6953
|
__privateGet(this, _board).disuse(middleware);
|
|
6241
6954
|
}
|
|
6242
|
-
setData(data) {
|
|
6955
|
+
setData(data, opts) {
|
|
6243
6956
|
validateElements((data == null ? void 0 : data.elements) || []);
|
|
6244
|
-
__privateGet(this, _board).setData(data);
|
|
6957
|
+
__privateGet(this, _board).setData(data, opts);
|
|
6245
6958
|
}
|
|
6246
6959
|
getData() {
|
|
6247
6960
|
return __privateGet(this, _board).getData();
|