@idraw/core 0.4.0-beta.16 → 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 +4 -0
- package/dist/esm/middleware/selector/config.js +4 -0
- package/dist/esm/middleware/selector/draw-auxiliary.d.ts +4 -4
- package/dist/esm/middleware/selector/draw-auxiliary.js +26 -11
- 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/index.global.js +800 -78
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
- package/dist/esm/middleware/selector/auxiliary.d.ts +0 -5
- package/dist/esm/middleware/selector/auxiliary.js +0 -10
package/dist/index.global.js
CHANGED
|
@@ -839,8 +839,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
839
839
|
get(name) {
|
|
840
840
|
return __classPrivateFieldGet$7(this, _Store_temp, "f")[name];
|
|
841
841
|
}
|
|
842
|
-
getSnapshot() {
|
|
843
|
-
|
|
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"));
|
|
844
847
|
}
|
|
845
848
|
clear() {
|
|
846
849
|
__classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
@@ -1188,6 +1191,24 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1188
1191
|
_scan(uuid, elements);
|
|
1189
1192
|
return groupQueue;
|
|
1190
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
|
+
}
|
|
1191
1212
|
function findElementsFromListByPositions(positions, list) {
|
|
1192
1213
|
const elements = [];
|
|
1193
1214
|
positions.forEach((pos) => {
|
|
@@ -1241,15 +1262,15 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1241
1262
|
return result;
|
|
1242
1263
|
}
|
|
1243
1264
|
function checkRectIntersect(rect1, rect2) {
|
|
1244
|
-
const
|
|
1245
|
-
const
|
|
1246
|
-
const
|
|
1247
|
-
const
|
|
1248
|
-
const
|
|
1249
|
-
const
|
|
1250
|
-
const
|
|
1251
|
-
const
|
|
1252
|
-
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;
|
|
1253
1274
|
}
|
|
1254
1275
|
function getElementVertexes(elemSize) {
|
|
1255
1276
|
const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
|
|
@@ -1505,6 +1526,153 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1505
1526
|
const elemSize = { x: elemStartX, y: elemStartY, w: elemEndX - elemStartX, h: elemEndY - elemStartY };
|
|
1506
1527
|
return checkRectIntersect(viewSize, elemSize);
|
|
1507
1528
|
}
|
|
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();
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
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;
|
|
1632
|
+
}
|
|
1633
|
+
return false;
|
|
1634
|
+
}
|
|
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 };
|
|
1645
|
+
}
|
|
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;
|
|
1675
|
+
}
|
|
1508
1676
|
function createControllerElementSizeFromCenter(center, opts) {
|
|
1509
1677
|
const { x: x2, y: y2 } = center;
|
|
1510
1678
|
const { size, angle: angle2 } = opts;
|
|
@@ -2143,7 +2311,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2143
2311
|
}
|
|
2144
2312
|
function drawCircle(ctx, elem, opts) {
|
|
2145
2313
|
const { detail, angle: angle2 } = elem;
|
|
2146
|
-
const {
|
|
2314
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2147
2315
|
const { background: background2 = "#000000", borderColor: borderColor2 = "#000000", boxSizing, borderWidth: borderWidth2 = 0 } = detail;
|
|
2148
2316
|
let bw = 0;
|
|
2149
2317
|
if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
|
|
@@ -2152,7 +2320,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2152
2320
|
bw = borderWidth2[0];
|
|
2153
2321
|
}
|
|
2154
2322
|
bw = bw * viewScaleInfo.scale;
|
|
2155
|
-
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;
|
|
2156
2324
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2157
2325
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2158
2326
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2205,8 +2373,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2205
2373
|
});
|
|
2206
2374
|
}
|
|
2207
2375
|
function drawRect(ctx, elem, opts) {
|
|
2208
|
-
const {
|
|
2209
|
-
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;
|
|
2210
2378
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2211
2379
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2212
2380
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2228,8 +2396,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2228
2396
|
}
|
|
2229
2397
|
function drawImage(ctx, elem, opts) {
|
|
2230
2398
|
const content = opts.loader.getContent(elem);
|
|
2231
|
-
const {
|
|
2232
|
-
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;
|
|
2233
2401
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2234
2402
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2235
2403
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2275,8 +2443,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2275
2443
|
}
|
|
2276
2444
|
function drawSVG(ctx, elem, opts) {
|
|
2277
2445
|
const content = opts.loader.getContent(elem);
|
|
2278
|
-
const {
|
|
2279
|
-
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;
|
|
2280
2448
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2281
2449
|
if (!content && !opts.loader.isDestroyed()) {
|
|
2282
2450
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
@@ -2290,8 +2458,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2290
2458
|
}
|
|
2291
2459
|
function drawHTML(ctx, elem, opts) {
|
|
2292
2460
|
const content = opts.loader.getContent(elem);
|
|
2293
|
-
const {
|
|
2294
|
-
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;
|
|
2295
2463
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2296
2464
|
if (!content && !opts.loader.isDestroyed()) {
|
|
2297
2465
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
@@ -2305,8 +2473,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2305
2473
|
}
|
|
2306
2474
|
const detailConfig = getDefaultElementDetailConfig();
|
|
2307
2475
|
function drawText(ctx, elem, opts) {
|
|
2308
|
-
const {
|
|
2309
|
-
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;
|
|
2310
2478
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2311
2479
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2312
2480
|
drawBox(ctx, viewElem, {
|
|
@@ -2409,8 +2577,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2409
2577
|
function drawPath(ctx, elem, opts) {
|
|
2410
2578
|
const { detail } = elem;
|
|
2411
2579
|
const { originX, originY, originW, originH } = detail;
|
|
2412
|
-
const {
|
|
2413
|
-
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;
|
|
2414
2582
|
const scaleW = w2 / originW;
|
|
2415
2583
|
const scaleH = h2 / originH;
|
|
2416
2584
|
const viewOriginX = originX * scaleW;
|
|
@@ -2508,8 +2676,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2508
2676
|
}
|
|
2509
2677
|
}
|
|
2510
2678
|
function drawGroup(ctx, elem, opts) {
|
|
2511
|
-
const {
|
|
2512
|
-
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;
|
|
2513
2681
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2514
2682
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2515
2683
|
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
@@ -2550,7 +2718,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2550
2718
|
h: elem.h || parentSize.h,
|
|
2551
2719
|
angle: elem.angle
|
|
2552
2720
|
};
|
|
2553
|
-
const { calculator
|
|
2721
|
+
const { calculator } = opts;
|
|
2554
2722
|
for (let i = 0; i < elem.detail.children.length; i++) {
|
|
2555
2723
|
let child = elem.detail.children[i];
|
|
2556
2724
|
child = Object.assign(Object.assign({}, child), {
|
|
@@ -2558,7 +2726,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2558
2726
|
y: newParentSize.y + child.y
|
|
2559
2727
|
});
|
|
2560
2728
|
if (opts.forceDrawAll !== true) {
|
|
2561
|
-
if (!(
|
|
2729
|
+
if (!(calculator === null || calculator === void 0 ? void 0 : calculator.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo))) {
|
|
2562
2730
|
continue;
|
|
2563
2731
|
}
|
|
2564
2732
|
}
|
|
@@ -2604,9 +2772,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2604
2772
|
}
|
|
2605
2773
|
}
|
|
2606
2774
|
function drawUnderlay(ctx, underlay, opts) {
|
|
2607
|
-
const {
|
|
2775
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2608
2776
|
const elem = Object.assign({ uuid: "underlay" }, underlay);
|
|
2609
|
-
const { x: x2, y: y2, w: w2, h: h2 } = (
|
|
2777
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2610
2778
|
const angle2 = 0;
|
|
2611
2779
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2612
2780
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2976,18 +3144,26 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2976
3144
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2977
3145
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2978
3146
|
};
|
|
2979
|
-
var _Calculator_opts;
|
|
3147
|
+
var _Calculator_opts, _Calculator_store;
|
|
2980
3148
|
class Calculator {
|
|
2981
3149
|
constructor(opts) {
|
|
2982
3150
|
_Calculator_opts.set(this, void 0);
|
|
3151
|
+
_Calculator_store.set(this, void 0);
|
|
2983
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);
|
|
2984
3163
|
}
|
|
2985
3164
|
destroy() {
|
|
2986
3165
|
__classPrivateFieldSet$4(this, _Calculator_opts, null, "f");
|
|
2987
3166
|
}
|
|
2988
|
-
elementSize(size, viewScaleInfo, viewSizeInfo) {
|
|
2989
|
-
return calcViewElementSize(size, { viewScaleInfo, viewSizeInfo });
|
|
2990
|
-
}
|
|
2991
3167
|
isElementInView(elem, viewScaleInfo, viewSizeInfo) {
|
|
2992
3168
|
return isElementInView(elem, { viewScaleInfo, viewSizeInfo });
|
|
2993
3169
|
}
|
|
@@ -3004,8 +3180,103 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3004
3180
|
const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
|
|
3005
3181
|
return getViewPointAtElement(p, Object.assign(Object.assign({}, opts), { context2d }));
|
|
3006
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
|
+
}
|
|
3007
3278
|
}
|
|
3008
|
-
_Calculator_opts = /* @__PURE__ */ new WeakMap();
|
|
3279
|
+
_Calculator_opts = /* @__PURE__ */ new WeakMap(), _Calculator_store = /* @__PURE__ */ new WeakMap();
|
|
3009
3280
|
var __classPrivateFieldSet$3 = function(receiver, state, value, kind, f) {
|
|
3010
3281
|
if (kind === "m")
|
|
3011
3282
|
throw new TypeError("Private method is not writable");
|
|
@@ -3245,8 +3516,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3245
3516
|
setActiveStorage(key2, storage) {
|
|
3246
3517
|
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set(key2, storage);
|
|
3247
3518
|
}
|
|
3248
|
-
getActiveStoreSnapshot() {
|
|
3249
|
-
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").getSnapshot();
|
|
3519
|
+
getActiveStoreSnapshot(opts) {
|
|
3520
|
+
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").getSnapshot(opts);
|
|
3250
3521
|
}
|
|
3251
3522
|
getSharedStorage(key2) {
|
|
3252
3523
|
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").get(key2);
|
|
@@ -3254,8 +3525,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3254
3525
|
setSharedStorage(key2, storage) {
|
|
3255
3526
|
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").set(key2, storage);
|
|
3256
3527
|
}
|
|
3257
|
-
getSharedStoreSnapshot() {
|
|
3258
|
-
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").getSnapshot();
|
|
3528
|
+
getSharedStoreSnapshot(opts) {
|
|
3529
|
+
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").getSnapshot(opts);
|
|
3259
3530
|
}
|
|
3260
3531
|
getActiveViewScaleInfo() {
|
|
3261
3532
|
const viewScaleInfo = {
|
|
@@ -3322,6 +3593,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3322
3593
|
__classPrivateFieldSet$1(this, _Viewer_opts, opts, "f");
|
|
3323
3594
|
__classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_init).call(this);
|
|
3324
3595
|
}
|
|
3596
|
+
resetViewVisibleInfoMap(data, opts) {
|
|
3597
|
+
if (data) {
|
|
3598
|
+
__classPrivateFieldGet$1(this, _Viewer_opts, "f").calculator.resetViewVisibleInfoMap(data, opts);
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3325
3601
|
drawFrame() {
|
|
3326
3602
|
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3327
3603
|
const activeStore = sharer.getActiveStoreSnapshot();
|
|
@@ -3333,7 +3609,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3333
3609
|
__classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_drawAnimationFrame).call(this);
|
|
3334
3610
|
}
|
|
3335
3611
|
scale(opts) {
|
|
3336
|
-
const { scale, point } = opts;
|
|
3612
|
+
const { scale, point, ignoreUpdateVisibleStatus } = opts;
|
|
3337
3613
|
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3338
3614
|
const { moveX, moveY } = viewScale({
|
|
3339
3615
|
scale,
|
|
@@ -3342,12 +3618,18 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3342
3618
|
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3343
3619
|
});
|
|
3344
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
|
+
}
|
|
3345
3627
|
return { moveX, moveY };
|
|
3346
3628
|
}
|
|
3347
3629
|
scroll(opts) {
|
|
3348
3630
|
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3349
3631
|
const prevViewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
3350
|
-
const { moveX, moveY } = opts;
|
|
3632
|
+
const { moveX, moveY, ignoreUpdateVisibleStatus } = opts;
|
|
3351
3633
|
const viewSizeInfo = sharer.getActiveViewSizeInfo();
|
|
3352
3634
|
const viewScaleInfo = viewScroll({
|
|
3353
3635
|
moveX,
|
|
@@ -3356,6 +3638,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3356
3638
|
viewSizeInfo
|
|
3357
3639
|
});
|
|
3358
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
|
+
}
|
|
3359
3647
|
return viewScaleInfo;
|
|
3360
3648
|
}
|
|
3361
3649
|
updateViewScaleInfo(opts) {
|
|
@@ -3364,9 +3652,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3364
3652
|
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3365
3653
|
});
|
|
3366
3654
|
sharer.setActiveViewScaleInfo(viewScaleInfo);
|
|
3655
|
+
__classPrivateFieldGet$1(this, _Viewer_opts, "f").calculator.updateVisiableStatus({
|
|
3656
|
+
viewScaleInfo: sharer.getActiveViewScaleInfo(),
|
|
3657
|
+
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
3658
|
+
});
|
|
3367
3659
|
return viewScaleInfo;
|
|
3368
3660
|
}
|
|
3369
|
-
resize(viewSize = {}) {
|
|
3661
|
+
resize(viewSize = {}, opts) {
|
|
3370
3662
|
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3371
3663
|
const originViewSize = sharer.getActiveViewSizeInfo();
|
|
3372
3664
|
const newViewSize = Object.assign(Object.assign({}, originViewSize), viewSize);
|
|
@@ -3383,6 +3675,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3383
3675
|
viewContext.canvas.width = width * devicePixelRatio;
|
|
3384
3676
|
viewContext.canvas.height = height * devicePixelRatio;
|
|
3385
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
|
+
}
|
|
3386
3684
|
return newViewSize;
|
|
3387
3685
|
}
|
|
3388
3686
|
}
|
|
@@ -3517,15 +3815,28 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3517
3815
|
getRenderer() {
|
|
3518
3816
|
return __classPrivateFieldGet(this, _Board_renderer, "f");
|
|
3519
3817
|
}
|
|
3520
|
-
setData(data) {
|
|
3818
|
+
setData(data, opts) {
|
|
3819
|
+
const { modifiedOptions } = opts || {};
|
|
3521
3820
|
const sharer = __classPrivateFieldGet(this, _Board_sharer, "f");
|
|
3522
3821
|
__classPrivateFieldGet(this, _Board_sharer, "f").setActiveStorage("data", data);
|
|
3523
3822
|
const viewSizeInfo = sharer.getActiveViewSizeInfo();
|
|
3823
|
+
const viewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
3524
3824
|
const newViewContextSize = calcElementsContextSize(data.elements, {
|
|
3525
3825
|
viewWidth: viewSizeInfo.width,
|
|
3526
3826
|
viewHeight: viewSizeInfo.height,
|
|
3527
3827
|
extend: true
|
|
3528
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
|
+
}
|
|
3529
3840
|
__classPrivateFieldGet(this, _Board_viewer, "f").drawFrame();
|
|
3530
3841
|
const newViewSizeInfo = Object.assign(Object.assign({}, viewSizeInfo), newViewContextSize);
|
|
3531
3842
|
__classPrivateFieldGet(this, _Board_sharer, "f").setActiveViewSizeInfo(newViewSizeInfo);
|
|
@@ -3574,17 +3885,22 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3574
3885
|
}
|
|
3575
3886
|
scale(opts) {
|
|
3576
3887
|
const viewer = __classPrivateFieldGet(this, _Board_viewer, "f");
|
|
3577
|
-
const {
|
|
3578
|
-
|
|
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 });
|
|
3579
3893
|
}
|
|
3580
3894
|
scroll(opts) {
|
|
3581
|
-
|
|
3895
|
+
const result = __classPrivateFieldGet(this, _Board_viewer, "f").scroll(opts);
|
|
3896
|
+
return result;
|
|
3582
3897
|
}
|
|
3583
3898
|
updateViewScaleInfo(opts) {
|
|
3584
|
-
|
|
3899
|
+
const result = __classPrivateFieldGet(this, _Board_viewer, "f").updateViewScaleInfo(opts);
|
|
3900
|
+
return result;
|
|
3585
3901
|
}
|
|
3586
|
-
resize(newViewSize) {
|
|
3587
|
-
const viewSize = __classPrivateFieldGet(this, _Board_viewer, "f").resize(newViewSize);
|
|
3902
|
+
resize(newViewSize, opts) {
|
|
3903
|
+
const viewSize = __classPrivateFieldGet(this, _Board_viewer, "f").resize(newViewSize, opts);
|
|
3588
3904
|
const { width, height, devicePixelRatio } = newViewSize;
|
|
3589
3905
|
const { boardContent } = __classPrivateFieldGet(this, _Board_opts, "f");
|
|
3590
3906
|
boardContent.viewContext.$resize({ width, height, devicePixelRatio });
|
|
@@ -3912,6 +4228,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3912
4228
|
const keySelectedElementList = Symbol(`${key$2}_selectedElementList`);
|
|
3913
4229
|
const keySelectedElementListVertexes = Symbol(`${key$2}_selectedElementListVertexes`);
|
|
3914
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`);
|
|
3915
4234
|
const keyGroupQueue = Symbol(`${key$2}_groupQueue`);
|
|
3916
4235
|
const keyGroupQueueVertexesList = Symbol(`${key$2}_groupQueueVertexesList`);
|
|
3917
4236
|
const keyIsMoving = Symbol(`${key$2}_isMoving`);
|
|
@@ -3921,6 +4240,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3921
4240
|
const wrapperColor = "#1973ba";
|
|
3922
4241
|
const lockColor = "#5b5959b5";
|
|
3923
4242
|
const controllerSize = 10;
|
|
4243
|
+
const referenceColor = "#f7276e";
|
|
3924
4244
|
function drawVertexes(ctx, vertexes, opts) {
|
|
3925
4245
|
const { borderColor: borderColor2, borderWidth: borderWidth2, background: background2, lineDash } = opts;
|
|
3926
4246
|
ctx.setLineDash([]);
|
|
@@ -3991,6 +4311,36 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3991
4311
|
ctx.closePath();
|
|
3992
4312
|
ctx.stroke();
|
|
3993
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
|
+
}
|
|
3994
4344
|
function drawHoverVertexesWrapper(ctx, vertexes, opts) {
|
|
3995
4345
|
if (!vertexes) {
|
|
3996
4346
|
return;
|
|
@@ -4022,7 +4372,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4022
4372
|
if (!controller) {
|
|
4023
4373
|
return;
|
|
4024
4374
|
}
|
|
4025
|
-
const {
|
|
4375
|
+
const {
|
|
4376
|
+
hideControllers
|
|
4377
|
+
// calculator, element, viewScaleInfo, viewSizeInfo
|
|
4378
|
+
} = opts;
|
|
4026
4379
|
const { elementWrapper, topLeft, topRight, bottomLeft, bottomRight, top, rotate } = controller;
|
|
4027
4380
|
const wrapperOpts = { borderColor: wrapperColor, borderWidth: selectWrapperBorderWidth, background: "transparent", lineDash: [] };
|
|
4028
4381
|
const ctrlOpts = { ...wrapperOpts, borderWidth: resizeControllerBorderWidth, background: "#FFFFFF" };
|
|
@@ -4074,6 +4427,35 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4074
4427
|
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
4075
4428
|
}
|
|
4076
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
|
+
}
|
|
4077
4459
|
function parseRadian(angle2) {
|
|
4078
4460
|
return angle2 * Math.PI / 180;
|
|
4079
4461
|
}
|
|
@@ -4084,11 +4466,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4084
4466
|
return moveDirect > 0 ? Math.abs(moveDist) : 0 - Math.abs(moveDist);
|
|
4085
4467
|
}
|
|
4086
4468
|
function isPointInViewActiveVertexes(p, opts) {
|
|
4087
|
-
const { ctx, viewScaleInfo,
|
|
4088
|
-
const v0 = calcViewPointSize(vertexes[0], { viewScaleInfo
|
|
4089
|
-
const v1 = calcViewPointSize(vertexes[1], { viewScaleInfo
|
|
4090
|
-
const v2 = calcViewPointSize(vertexes[2], { viewScaleInfo
|
|
4091
|
-
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 });
|
|
4092
4474
|
ctx.beginPath();
|
|
4093
4475
|
ctx.moveTo(v0.x, v0.y);
|
|
4094
4476
|
ctx.lineTo(v1.x, v1.y);
|
|
@@ -4707,10 +5089,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4707
5089
|
}
|
|
4708
5090
|
function rotateElement(elem, opts) {
|
|
4709
5091
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elem;
|
|
4710
|
-
const { center, start, end, viewScaleInfo
|
|
5092
|
+
const { center, start, end, viewScaleInfo } = opts;
|
|
4711
5093
|
const elemCenter = calcViewPointSize(center, {
|
|
4712
|
-
viewScaleInfo
|
|
4713
|
-
viewSizeInfo
|
|
5094
|
+
viewScaleInfo
|
|
4714
5095
|
});
|
|
4715
5096
|
const startAngle = limitAngle(angle2);
|
|
4716
5097
|
const changedRadian = calcRadian(elemCenter, start, end);
|
|
@@ -4728,7 +5109,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4728
5109
|
const indexes = [];
|
|
4729
5110
|
const uuids = [];
|
|
4730
5111
|
const elements = [];
|
|
4731
|
-
const {
|
|
5112
|
+
const { viewScaleInfo, viewSizeInfo, start, end } = opts;
|
|
4732
5113
|
if (!(Array.isArray(data.elements) && start && end)) {
|
|
4733
5114
|
return { indexes, uuids, elements };
|
|
4734
5115
|
}
|
|
@@ -4741,7 +5122,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4741
5122
|
if (((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.lock) === true) {
|
|
4742
5123
|
continue;
|
|
4743
5124
|
}
|
|
4744
|
-
const elemSize =
|
|
5125
|
+
const elemSize = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
|
|
4745
5126
|
const center = calcElementCenter(elemSize);
|
|
4746
5127
|
if (center.x >= startX && center.x <= endX && center.y >= startY && center.y <= endY) {
|
|
4747
5128
|
indexes.push(idx);
|
|
@@ -4768,14 +5149,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4768
5149
|
return null;
|
|
4769
5150
|
}
|
|
4770
5151
|
const area = { x: 0, y: 0, w: 0, h: 0 };
|
|
4771
|
-
const {
|
|
5152
|
+
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
4772
5153
|
let prevElemSize = null;
|
|
4773
5154
|
for (let i = 0; i < elements.length; i++) {
|
|
4774
5155
|
const elem = elements[i];
|
|
4775
5156
|
if ((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.invisible) {
|
|
4776
5157
|
continue;
|
|
4777
5158
|
}
|
|
4778
|
-
const elemSize =
|
|
5159
|
+
const elemSize = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
|
|
4779
5160
|
if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
|
|
4780
5161
|
const ves = rotateElementVertexes(elemSize);
|
|
4781
5162
|
if (ves.length === 4) {
|
|
@@ -4843,6 +5224,264 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4843
5224
|
moveY
|
|
4844
5225
|
};
|
|
4845
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
|
+
}
|
|
4846
5485
|
const middlewareEventTextEdit = "@middleware/text-edit";
|
|
4847
5486
|
const middlewareEventTextChange = "@middleware/text-change";
|
|
4848
5487
|
const defaultElementDetail = getDefaultElementDetailConfig();
|
|
@@ -5089,6 +5728,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5089
5728
|
sharer.setSharedStorage(keyHoverElementVertexes, vertexes);
|
|
5090
5729
|
};
|
|
5091
5730
|
const updateSelectedElementList = (list, opts2) => {
|
|
5731
|
+
var _a;
|
|
5092
5732
|
sharer.setSharedStorage(keySelectedElementList, list);
|
|
5093
5733
|
if (list.length === 1) {
|
|
5094
5734
|
const controller = calcElementSizeController(list[0], {
|
|
@@ -5097,8 +5737,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5097
5737
|
viewScaleInfo: sharer.getActiveViewScaleInfo()
|
|
5098
5738
|
});
|
|
5099
5739
|
sharer.setSharedStorage(keySelectedElementController, controller);
|
|
5740
|
+
sharer.setSharedStorage(keySelectedElementPosition, getElementPositionFromList(list[0].uuid, ((_a = sharer.getActiveStorage("data")) == null ? void 0 : _a.elements) || []));
|
|
5100
5741
|
} else {
|
|
5101
5742
|
sharer.setSharedStorage(keySelectedElementController, null);
|
|
5743
|
+
sharer.setSharedStorage(keySelectedElementPosition, []);
|
|
5102
5744
|
}
|
|
5103
5745
|
if ((opts2 == null ? void 0 : opts2.triggerEvent) === true) {
|
|
5104
5746
|
eventHub.trigger(middlewareEventSelect, { uuids: list.map((elem) => elem.uuid) });
|
|
@@ -5114,7 +5756,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5114
5756
|
viewSizeInfo: sharer.getActiveViewSizeInfo(),
|
|
5115
5757
|
groupQueue: sharer.getSharedStorage(keyGroupQueue),
|
|
5116
5758
|
areaSize: null,
|
|
5117
|
-
selectedElementController: sharer.getSharedStorage(keySelectedElementController)
|
|
5759
|
+
selectedElementController: sharer.getSharedStorage(keySelectedElementController),
|
|
5760
|
+
selectedElementPosition: sharer.getSharedStorage(keySelectedElementPosition)
|
|
5118
5761
|
};
|
|
5119
5762
|
};
|
|
5120
5763
|
const clear = () => {
|
|
@@ -5129,6 +5772,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5129
5772
|
sharer.setSharedStorage(keySelectedElementList, []);
|
|
5130
5773
|
sharer.setSharedStorage(keySelectedElementListVertexes, null);
|
|
5131
5774
|
sharer.setSharedStorage(keySelectedElementController, null);
|
|
5775
|
+
sharer.setSharedStorage(keySelectedElementPosition, []);
|
|
5776
|
+
sharer.setSharedStorage(keySelectedReferenceXLines, []);
|
|
5777
|
+
sharer.setSharedStorage(keySelectedReferenceYLines, []);
|
|
5132
5778
|
sharer.setSharedStorage(keyIsMoving, null);
|
|
5133
5779
|
};
|
|
5134
5780
|
clear();
|
|
@@ -5318,6 +5964,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5318
5964
|
},
|
|
5319
5965
|
pointMove: (e) => {
|
|
5320
5966
|
var _a, _b, _c;
|
|
5967
|
+
sharer.setSharedStorage(keySelectedReferenceXLines, []);
|
|
5968
|
+
sharer.setSharedStorage(keySelectedReferenceYLines, []);
|
|
5321
5969
|
sharer.setSharedStorage(keyIsMoving, true);
|
|
5322
5970
|
const data = sharer.getActiveStorage("data");
|
|
5323
5971
|
const elems = getActiveElements();
|
|
@@ -5333,9 +5981,43 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5333
5981
|
inBusyMode = "drag";
|
|
5334
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) {
|
|
5335
5983
|
const { moveX, moveY } = calcMoveInGroup(start, end, groupQueue);
|
|
5336
|
-
|
|
5337
|
-
|
|
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);
|
|
5338
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
|
+
});
|
|
5339
6021
|
}
|
|
5340
6022
|
viewer.drawFrame();
|
|
5341
6023
|
} else if (actionType === "drag-list") {
|
|
@@ -5346,8 +6028,19 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5346
6028
|
elems.forEach((elem) => {
|
|
5347
6029
|
var _a2;
|
|
5348
6030
|
if (elem && ((_a2 = elem == null ? void 0 : elem.operations) == null ? void 0 : _a2.lock) !== true) {
|
|
5349
|
-
elem.x
|
|
5350
|
-
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
|
+
});
|
|
5351
6044
|
}
|
|
5352
6045
|
});
|
|
5353
6046
|
sharer.setActiveStorage("data", data);
|
|
@@ -5394,19 +6087,30 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5394
6087
|
elems[0].angle = resizedElemSize.angle;
|
|
5395
6088
|
} else {
|
|
5396
6089
|
const resizedElemSize = resizeElement(elems[0], { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
|
|
5397
|
-
elems[0].x = resizedElemSize.x;
|
|
5398
|
-
elems[0].y = resizedElemSize.y;
|
|
6090
|
+
elems[0].x = calculator.toGridNum(resizedElemSize.x);
|
|
6091
|
+
elems[0].y = calculator.toGridNum(resizedElemSize.y);
|
|
5399
6092
|
if (elems[0].type === "group" && ((_c = elems[0].operations) == null ? void 0 : _c.deepResize) === true) {
|
|
5400
6093
|
deepResizeGroupElement(elems[0], {
|
|
5401
|
-
w: resizedElemSize.w,
|
|
5402
|
-
h: resizedElemSize.h
|
|
6094
|
+
w: calculator.toGridNum(resizedElemSize.w),
|
|
6095
|
+
h: calculator.toGridNum(resizedElemSize.h)
|
|
5403
6096
|
});
|
|
5404
6097
|
} else {
|
|
5405
|
-
elems[0].w = resizedElemSize.w;
|
|
5406
|
-
elems[0].h = resizedElemSize.h;
|
|
6098
|
+
elems[0].w = calculator.toGridNum(resizedElemSize.w);
|
|
6099
|
+
elems[0].h = calculator.toGridNum(resizedElemSize.h);
|
|
5407
6100
|
}
|
|
5408
6101
|
}
|
|
5409
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
|
+
});
|
|
5410
6114
|
viewer.drawFrame();
|
|
5411
6115
|
}
|
|
5412
6116
|
} else if (actionType === "area") {
|
|
@@ -5418,6 +6122,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5418
6122
|
},
|
|
5419
6123
|
pointEnd(e) {
|
|
5420
6124
|
inBusyMode = null;
|
|
6125
|
+
sharer.setSharedStorage(keySelectedReferenceXLines, []);
|
|
6126
|
+
sharer.setSharedStorage(keySelectedReferenceYLines, []);
|
|
5421
6127
|
sharer.setSharedStorage(keyIsMoving, false);
|
|
5422
6128
|
const data = sharer.getActiveStorage("data");
|
|
5423
6129
|
const resizeType = sharer.getSharedStorage(keyResizeType);
|
|
@@ -5559,9 +6265,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5559
6265
|
drawSelectedElementControllersVertexes(helperContext, selectedElementController, {
|
|
5560
6266
|
...drawBaseOpts,
|
|
5561
6267
|
element: elem,
|
|
5562
|
-
|
|
6268
|
+
calculator,
|
|
5563
6269
|
hideControllers: !!isMoving && actionType === "drag"
|
|
5564
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
|
+
}
|
|
5565
6279
|
}
|
|
5566
6280
|
} else {
|
|
5567
6281
|
if (hoverElement && actionType !== "drag") {
|
|
@@ -5582,9 +6296,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5582
6296
|
drawSelectedElementControllersVertexes(helperContext, selectedElementController, {
|
|
5583
6297
|
...drawBaseOpts,
|
|
5584
6298
|
element: elem,
|
|
5585
|
-
|
|
6299
|
+
calculator,
|
|
5586
6300
|
hideControllers: !!isMoving && actionType === "drag"
|
|
5587
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
|
+
}
|
|
5588
6310
|
} else if (actionType === "area" && areaStart && areaEnd) {
|
|
5589
6311
|
drawArea(helperContext, { start: areaStart, end: areaEnd });
|
|
5590
6312
|
} else if (["drag-list", "drag-list-end"].includes(actionType)) {
|
|
@@ -6230,9 +6952,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6230
6952
|
disuse(middleware) {
|
|
6231
6953
|
__privateGet(this, _board).disuse(middleware);
|
|
6232
6954
|
}
|
|
6233
|
-
setData(data) {
|
|
6955
|
+
setData(data, opts) {
|
|
6234
6956
|
validateElements((data == null ? void 0 : data.elements) || []);
|
|
6235
|
-
__privateGet(this, _board).setData(data);
|
|
6957
|
+
__privateGet(this, _board).setData(data, opts);
|
|
6236
6958
|
}
|
|
6237
6959
|
getData() {
|
|
6238
6960
|
return __privateGet(this, _board).getData();
|