@idraw/core 0.4.0-beta.17 → 0.4.0-beta.18
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 +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/middleware/info/draw-info.d.ts +31 -0
- package/dist/esm/middleware/info/draw-info.js +110 -0
- package/dist/esm/middleware/info/index.d.ts +3 -0
- package/dist/esm/middleware/info/index.js +110 -0
- package/dist/esm/middleware/info/types.d.ts +3 -0
- package/dist/esm/middleware/info/types.js +1 -0
- package/dist/esm/middleware/ruler/index.d.ts +2 -1
- package/dist/esm/middleware/ruler/index.js +3 -2
- package/dist/esm/middleware/ruler/types.d.ts +3 -0
- package/dist/esm/middleware/ruler/types.js +1 -0
- package/dist/esm/middleware/ruler/util.d.ts +6 -1
- package/dist/esm/middleware/ruler/util.js +55 -1
- package/dist/esm/middleware/scroller/index.d.ts +2 -1
- package/dist/esm/middleware/scroller/types.d.ts +9 -0
- package/dist/esm/middleware/scroller/types.js +1 -0
- package/dist/esm/middleware/scroller/util.js +1 -1
- package/dist/esm/middleware/selector/index.d.ts +3 -0
- package/dist/esm/middleware/selector/index.js +10 -8
- package/dist/index.global.js +340 -66
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -316,7 +316,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
316
316
|
function textAlign(value) {
|
|
317
317
|
return ["center", "left", "right"].includes(value);
|
|
318
318
|
}
|
|
319
|
-
function fontFamily$
|
|
319
|
+
function fontFamily$2(value) {
|
|
320
320
|
return typeof value === "string" && value.length > 0;
|
|
321
321
|
}
|
|
322
322
|
function fontWeight$1(value) {
|
|
@@ -345,7 +345,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
345
345
|
fontSize: fontSize$1,
|
|
346
346
|
lineHeight,
|
|
347
347
|
textAlign,
|
|
348
|
-
fontFamily: fontFamily$
|
|
348
|
+
fontFamily: fontFamily$2,
|
|
349
349
|
fontWeight: fontWeight$1,
|
|
350
350
|
strokeWidth
|
|
351
351
|
};
|
|
@@ -1261,17 +1261,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1261
1261
|
_loop(elements);
|
|
1262
1262
|
return result;
|
|
1263
1263
|
}
|
|
1264
|
-
function checkRectIntersect(rect1, rect2) {
|
|
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
1264
|
function getElementVertexes(elemSize) {
|
|
1276
1265
|
const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
|
|
1277
1266
|
return [
|
|
@@ -1512,20 +1501,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1512
1501
|
}
|
|
1513
1502
|
return result;
|
|
1514
1503
|
}
|
|
1515
|
-
function isElementInView(elem, opts) {
|
|
1516
|
-
const { viewSizeInfo, viewScaleInfo } = opts;
|
|
1517
|
-
const { width, height } = viewSizeInfo;
|
|
1518
|
-
const { angle: angle2 } = elem;
|
|
1519
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
|
|
1520
|
-
const ves = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1521
|
-
const viewSize = { x: 0, y: 0, w: width, h: height };
|
|
1522
|
-
const elemStartX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
1523
|
-
const elemStartY = Math.min(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
|
|
1524
|
-
const elemEndX = Math.max(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
1525
|
-
const elemEndY = Math.max(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
|
|
1526
|
-
const elemSize = { x: elemStartX, y: elemStartY, w: elemEndX - elemStartX, h: elemEndY - elemStartY };
|
|
1527
|
-
return checkRectIntersect(viewSize, elemSize);
|
|
1528
|
-
}
|
|
1529
1504
|
function calcElementOriginRectInfo(elemSize, opts) {
|
|
1530
1505
|
const { groupQueue } = opts;
|
|
1531
1506
|
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
@@ -2726,7 +2701,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2726
2701
|
y: newParentSize.y + child.y
|
|
2727
2702
|
});
|
|
2728
2703
|
if (opts.forceDrawAll !== true) {
|
|
2729
|
-
if (!(calculator === null || calculator === void 0 ? void 0 : calculator.
|
|
2704
|
+
if (!(calculator === null || calculator === void 0 ? void 0 : calculator.needRender(child))) {
|
|
2730
2705
|
continue;
|
|
2731
2706
|
}
|
|
2732
2707
|
}
|
|
@@ -2758,7 +2733,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2758
2733
|
detail: Object.assign(Object.assign({}, defaultDetail), element === null || element === void 0 ? void 0 : element.detail)
|
|
2759
2734
|
});
|
|
2760
2735
|
if (opts.forceDrawAll !== true) {
|
|
2761
|
-
if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.
|
|
2736
|
+
if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.needRender(elem))) {
|
|
2762
2737
|
continue;
|
|
2763
2738
|
}
|
|
2764
2739
|
}
|
|
@@ -2771,27 +2746,47 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2771
2746
|
}
|
|
2772
2747
|
}
|
|
2773
2748
|
}
|
|
2774
|
-
function
|
|
2749
|
+
function drawLayout(ctx, layout, opts, renderContent) {
|
|
2775
2750
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2776
|
-
const elem = Object.assign({ uuid: "
|
|
2751
|
+
const elem = Object.assign({ uuid: "layout", type: "group", x: 0, y: 0 }, layout);
|
|
2777
2752
|
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2778
2753
|
const angle2 = 0;
|
|
2779
2754
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2755
|
+
ctx.globalAlpha = 1;
|
|
2780
2756
|
drawBoxShadow(ctx, viewElem, {
|
|
2781
2757
|
viewScaleInfo,
|
|
2782
2758
|
viewSizeInfo,
|
|
2783
2759
|
renderContent: () => {
|
|
2784
|
-
|
|
2785
|
-
originElem: elem,
|
|
2786
|
-
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2787
|
-
viewScaleInfo,
|
|
2788
|
-
viewSizeInfo,
|
|
2789
|
-
parentOpacity,
|
|
2790
|
-
renderContent: () => {
|
|
2791
|
-
}
|
|
2792
|
-
});
|
|
2760
|
+
drawBoxBackground(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
2793
2761
|
}
|
|
2794
2762
|
});
|
|
2763
|
+
if (layout.detail.overflow === "hidden") {
|
|
2764
|
+
const { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 } = opts;
|
|
2765
|
+
const elem2 = Object.assign({ uuid: "layout", type: "group", x: 0, y: 0 }, layout);
|
|
2766
|
+
const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 }) || elem2;
|
|
2767
|
+
const viewElem2 = Object.assign(Object.assign({}, elem2), viewElemSize);
|
|
2768
|
+
const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem2, {
|
|
2769
|
+
viewScaleInfo: viewScaleInfo2,
|
|
2770
|
+
viewSizeInfo: viewSizeInfo2
|
|
2771
|
+
});
|
|
2772
|
+
ctx.save();
|
|
2773
|
+
ctx.fillStyle = "transparent";
|
|
2774
|
+
ctx.beginPath();
|
|
2775
|
+
ctx.moveTo(x3 + radiusList[0], y3);
|
|
2776
|
+
ctx.arcTo(x3 + w3, y3, x3 + w3, y3 + h3, radiusList[1]);
|
|
2777
|
+
ctx.arcTo(x3 + w3, y3 + h3, x3, y3 + h3, radiusList[2]);
|
|
2778
|
+
ctx.arcTo(x3, y3 + h3, x3, y3, radiusList[3]);
|
|
2779
|
+
ctx.arcTo(x3, y3, x3 + w3, y3, radiusList[0]);
|
|
2780
|
+
ctx.closePath();
|
|
2781
|
+
ctx.fill();
|
|
2782
|
+
ctx.clip();
|
|
2783
|
+
}
|
|
2784
|
+
renderContent(ctx);
|
|
2785
|
+
if (layout.detail.overflow === "hidden") {
|
|
2786
|
+
ctx.restore();
|
|
2787
|
+
}
|
|
2788
|
+
drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
2789
|
+
ctx.globalAlpha = parentOpacity;
|
|
2795
2790
|
}
|
|
2796
2791
|
var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
2797
2792
|
function adopt(value) {
|
|
@@ -3068,21 +3063,20 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3068
3063
|
w: opts.viewSizeInfo.width,
|
|
3069
3064
|
h: opts.viewSizeInfo.height
|
|
3070
3065
|
};
|
|
3071
|
-
|
|
3072
|
-
drawUnderlay(viewContext, data.underlay, Object.assign({
|
|
3073
|
-
loader,
|
|
3074
|
-
calculator,
|
|
3075
|
-
parentElementSize,
|
|
3076
|
-
parentOpacity: 1
|
|
3077
|
-
}, opts));
|
|
3078
|
-
}
|
|
3079
|
-
drawElementList(viewContext, data, Object.assign({
|
|
3066
|
+
const drawOpts = Object.assign({
|
|
3080
3067
|
loader,
|
|
3081
3068
|
calculator,
|
|
3082
3069
|
parentElementSize,
|
|
3083
3070
|
elementAssets: data.assets,
|
|
3084
3071
|
parentOpacity: 1
|
|
3085
|
-
}, opts)
|
|
3072
|
+
}, opts);
|
|
3073
|
+
if (data.layout) {
|
|
3074
|
+
drawLayout(viewContext, data.layout, drawOpts, () => {
|
|
3075
|
+
drawElementList(viewContext, data, drawOpts);
|
|
3076
|
+
});
|
|
3077
|
+
} else {
|
|
3078
|
+
drawElementList(viewContext, data, drawOpts);
|
|
3079
|
+
}
|
|
3086
3080
|
}
|
|
3087
3081
|
scale(num) {
|
|
3088
3082
|
const { sharer } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
|
|
@@ -3158,14 +3152,22 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3158
3152
|
}
|
|
3159
3153
|
}), "f");
|
|
3160
3154
|
}
|
|
3161
|
-
toGridNum(num) {
|
|
3155
|
+
toGridNum(num, opts) {
|
|
3156
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.ignore) === true) {
|
|
3157
|
+
return num;
|
|
3158
|
+
}
|
|
3162
3159
|
return Math.round(num);
|
|
3163
3160
|
}
|
|
3164
3161
|
destroy() {
|
|
3165
3162
|
__classPrivateFieldSet$4(this, _Calculator_opts, null, "f");
|
|
3166
3163
|
}
|
|
3167
|
-
|
|
3168
|
-
|
|
3164
|
+
needRender(elem) {
|
|
3165
|
+
const viewVisibleInfoMap = __classPrivateFieldGet$4(this, _Calculator_store, "f").get("viewVisibleInfoMap");
|
|
3166
|
+
const info = viewVisibleInfoMap[elem.uuid];
|
|
3167
|
+
if (!info) {
|
|
3168
|
+
return true;
|
|
3169
|
+
}
|
|
3170
|
+
return info.isVisibleInView;
|
|
3169
3171
|
}
|
|
3170
3172
|
isPointInElement(p, elem, viewScaleInfo, viewSizeInfo) {
|
|
3171
3173
|
const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
|
|
@@ -6035,7 +6037,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6035
6037
|
type: "updateElement",
|
|
6036
6038
|
content: {
|
|
6037
6039
|
element: elem,
|
|
6038
|
-
position:
|
|
6040
|
+
position: getElementPositionFromList(elem.uuid, data.elements) || []
|
|
6039
6041
|
}
|
|
6040
6042
|
},
|
|
6041
6043
|
viewSizeInfo,
|
|
@@ -6084,19 +6086,20 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6084
6086
|
resizeType,
|
|
6085
6087
|
sharer
|
|
6086
6088
|
});
|
|
6087
|
-
elems[0].angle = resizedElemSize.angle;
|
|
6089
|
+
elems[0].angle = calculator.toGridNum(resizedElemSize.angle || 0);
|
|
6088
6090
|
} else {
|
|
6089
6091
|
const resizedElemSize = resizeElement(elems[0], { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
|
|
6090
|
-
elems[0].
|
|
6091
|
-
elems[0].
|
|
6092
|
+
const calcOpts = { ignore: !!elems[0].angle };
|
|
6093
|
+
elems[0].x = calculator.toGridNum(resizedElemSize.x, calcOpts);
|
|
6094
|
+
elems[0].y = calculator.toGridNum(resizedElemSize.y, calcOpts);
|
|
6092
6095
|
if (elems[0].type === "group" && ((_c = elems[0].operations) == null ? void 0 : _c.deepResize) === true) {
|
|
6093
6096
|
deepResizeGroupElement(elems[0], {
|
|
6094
|
-
w: calculator.toGridNum(resizedElemSize.w),
|
|
6095
|
-
h: calculator.toGridNum(resizedElemSize.h)
|
|
6097
|
+
w: calculator.toGridNum(resizedElemSize.w, calcOpts),
|
|
6098
|
+
h: calculator.toGridNum(resizedElemSize.h, calcOpts)
|
|
6096
6099
|
});
|
|
6097
6100
|
} else {
|
|
6098
|
-
elems[0].w = calculator.toGridNum(resizedElemSize.w);
|
|
6099
|
-
elems[0].h = calculator.toGridNum(resizedElemSize.h);
|
|
6101
|
+
elems[0].w = calculator.toGridNum(resizedElemSize.w, calcOpts);
|
|
6102
|
+
elems[0].h = calculator.toGridNum(resizedElemSize.h, calcOpts);
|
|
6100
6103
|
}
|
|
6101
6104
|
}
|
|
6102
6105
|
updateSelectedElementList([elems[0]]);
|
|
@@ -6331,7 +6334,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6331
6334
|
const keyActiveThumbType = Symbol(`${key$1}_activeThumbType`);
|
|
6332
6335
|
const minScrollerWidth = 12;
|
|
6333
6336
|
const scrollerLineWidth = 16;
|
|
6334
|
-
const scrollerThumbAlpha = 0.
|
|
6337
|
+
const scrollerThumbAlpha = 0.3;
|
|
6335
6338
|
const scrollConfig = {
|
|
6336
6339
|
width: minScrollerWidth,
|
|
6337
6340
|
thumbColor: "#000000AA",
|
|
@@ -6641,12 +6644,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6641
6644
|
const borderColor = "#00000080";
|
|
6642
6645
|
const scaleColor = "#000000";
|
|
6643
6646
|
const textColor = "#00000080";
|
|
6644
|
-
const fontFamily = "monospace";
|
|
6647
|
+
const fontFamily$1 = "monospace";
|
|
6645
6648
|
const fontSize = 10;
|
|
6646
6649
|
const fontWeight = 100;
|
|
6647
6650
|
const gridColor = "#AAAAAA20";
|
|
6648
6651
|
const gridKeyColor = "#AAAAAA40";
|
|
6649
6652
|
const lineSize = 1;
|
|
6653
|
+
const selectedAreaColor = "#196097";
|
|
6650
6654
|
function calcRulerScaleList(opts) {
|
|
6651
6655
|
const { scale, viewLength, viewOffset } = opts;
|
|
6652
6656
|
const list = [];
|
|
@@ -6725,7 +6729,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6725
6729
|
ctx.$setFont({
|
|
6726
6730
|
fontWeight,
|
|
6727
6731
|
fontSize,
|
|
6728
|
-
fontFamily
|
|
6732
|
+
fontFamily: fontFamily$1
|
|
6729
6733
|
});
|
|
6730
6734
|
ctx.fillText(`${item.num}`, item.position + fontStart, fontStart);
|
|
6731
6735
|
}
|
|
@@ -6761,7 +6765,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6761
6765
|
ctx.$setFont({
|
|
6762
6766
|
fontWeight,
|
|
6763
6767
|
fontSize,
|
|
6764
|
-
fontFamily
|
|
6768
|
+
fontFamily: fontFamily$1
|
|
6765
6769
|
});
|
|
6766
6770
|
ctx.fillText(numText, fontStart + fontSize, item.position + fontStart);
|
|
6767
6771
|
});
|
|
@@ -6820,9 +6824,61 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6820
6824
|
ctx.stroke();
|
|
6821
6825
|
}
|
|
6822
6826
|
}
|
|
6827
|
+
function drawScrollerSelectedArea(ctx, opts) {
|
|
6828
|
+
const { snapshot, calculator } = opts;
|
|
6829
|
+
const { sharedStore } = snapshot;
|
|
6830
|
+
const selectedElementList = sharedStore[keySelectedElementList];
|
|
6831
|
+
const actionType = sharedStore[keyActionType];
|
|
6832
|
+
if (["select", "drag", "drag-list", "drag-list-end"].includes(actionType) && selectedElementList.length > 0) {
|
|
6833
|
+
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
6834
|
+
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
6835
|
+
const rangeRectInfoList = [];
|
|
6836
|
+
const xAreaStartList = [];
|
|
6837
|
+
const xAreaEndList = [];
|
|
6838
|
+
const yAreaStartList = [];
|
|
6839
|
+
const yAreaEndList = [];
|
|
6840
|
+
selectedElementList.forEach((elem) => {
|
|
6841
|
+
const rectInfo = calculator.calcViewRectInfoFromRange(elem.uuid, {
|
|
6842
|
+
viewScaleInfo,
|
|
6843
|
+
viewSizeInfo
|
|
6844
|
+
});
|
|
6845
|
+
if (rectInfo) {
|
|
6846
|
+
rangeRectInfoList.push(rectInfo);
|
|
6847
|
+
xAreaStartList.push(rectInfo.left.x);
|
|
6848
|
+
xAreaEndList.push(rectInfo.right.x);
|
|
6849
|
+
yAreaStartList.push(rectInfo.top.y);
|
|
6850
|
+
yAreaEndList.push(rectInfo.bottom.y);
|
|
6851
|
+
}
|
|
6852
|
+
});
|
|
6853
|
+
if (!(rangeRectInfoList.length > 0)) {
|
|
6854
|
+
return;
|
|
6855
|
+
}
|
|
6856
|
+
const xAreaStart = Math.min(...xAreaStartList);
|
|
6857
|
+
const xAreaEnd = Math.max(...xAreaEndList);
|
|
6858
|
+
const yAreaStart = Math.min(...yAreaStartList);
|
|
6859
|
+
const yAreaEnd = Math.max(...yAreaEndList);
|
|
6860
|
+
ctx.globalAlpha = 1;
|
|
6861
|
+
ctx.beginPath();
|
|
6862
|
+
ctx.moveTo(xAreaStart, 0);
|
|
6863
|
+
ctx.lineTo(xAreaEnd, 0);
|
|
6864
|
+
ctx.lineTo(xAreaEnd, rulerSize);
|
|
6865
|
+
ctx.lineTo(xAreaStart, rulerSize);
|
|
6866
|
+
ctx.fillStyle = selectedAreaColor;
|
|
6867
|
+
ctx.closePath();
|
|
6868
|
+
ctx.fill();
|
|
6869
|
+
ctx.beginPath();
|
|
6870
|
+
ctx.moveTo(0, yAreaStart);
|
|
6871
|
+
ctx.lineTo(rulerSize, yAreaStart);
|
|
6872
|
+
ctx.lineTo(rulerSize, yAreaEnd);
|
|
6873
|
+
ctx.lineTo(0, yAreaEnd);
|
|
6874
|
+
ctx.fillStyle = selectedAreaColor;
|
|
6875
|
+
ctx.closePath();
|
|
6876
|
+
ctx.fill();
|
|
6877
|
+
}
|
|
6878
|
+
}
|
|
6823
6879
|
const middlewareEventRuler = "@middleware/show-ruler";
|
|
6824
6880
|
const MiddlewareRuler = (opts) => {
|
|
6825
|
-
const { boardContent, viewer, eventHub } = opts;
|
|
6881
|
+
const { boardContent, viewer, eventHub, calculator } = opts;
|
|
6826
6882
|
const { helperContext, underContext } = boardContent;
|
|
6827
6883
|
let show = true;
|
|
6828
6884
|
let showGrid = true;
|
|
@@ -6849,6 +6905,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6849
6905
|
if (show === true) {
|
|
6850
6906
|
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
6851
6907
|
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
6908
|
+
drawScrollerSelectedArea(helperContext, { snapshot, calculator });
|
|
6852
6909
|
drawRulerBackground(helperContext, { viewScaleInfo, viewSizeInfo });
|
|
6853
6910
|
const xList = calcXRulerScaleList({ viewScaleInfo, viewSizeInfo });
|
|
6854
6911
|
drawXRuler(helperContext, { scaleList: xList });
|
|
@@ -6909,6 +6966,222 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6909
6966
|
}
|
|
6910
6967
|
};
|
|
6911
6968
|
};
|
|
6969
|
+
const fontFamily = "monospace";
|
|
6970
|
+
function drawSizeInfoText(ctx, opts) {
|
|
6971
|
+
const { point, rotateCenter, angle: angle2, text: text2, color: color2, background: background2, fontSize: fontSize2, lineHeight: lineHeight2 } = opts;
|
|
6972
|
+
rotateByCenter(ctx, angle2, rotateCenter, () => {
|
|
6973
|
+
ctx.$setFont({
|
|
6974
|
+
fontWeight: "300",
|
|
6975
|
+
fontSize: fontSize2,
|
|
6976
|
+
fontFamily
|
|
6977
|
+
});
|
|
6978
|
+
const padding = (lineHeight2 - fontSize2) / 2;
|
|
6979
|
+
const textWidth = ctx.$undoPixelRatio(ctx.measureText(text2).width);
|
|
6980
|
+
const bgStart = {
|
|
6981
|
+
x: point.x - textWidth / 2 - padding,
|
|
6982
|
+
y: point.y
|
|
6983
|
+
};
|
|
6984
|
+
const bgEnd = {
|
|
6985
|
+
x: bgStart.x + textWidth + padding * 2,
|
|
6986
|
+
y: bgStart.y + fontSize2 + padding
|
|
6987
|
+
};
|
|
6988
|
+
const textStart = {
|
|
6989
|
+
x: point.x - textWidth / 2,
|
|
6990
|
+
y: point.y
|
|
6991
|
+
};
|
|
6992
|
+
ctx.setLineDash([]);
|
|
6993
|
+
ctx.fillStyle = background2;
|
|
6994
|
+
ctx.beginPath();
|
|
6995
|
+
ctx.moveTo(bgStart.x, bgStart.y);
|
|
6996
|
+
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
6997
|
+
ctx.lineTo(bgEnd.x, bgEnd.y);
|
|
6998
|
+
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
6999
|
+
ctx.closePath();
|
|
7000
|
+
ctx.fill();
|
|
7001
|
+
ctx.fillStyle = color2;
|
|
7002
|
+
ctx.textBaseline = "top";
|
|
7003
|
+
ctx.fillText(text2, textStart.x, textStart.y + padding);
|
|
7004
|
+
});
|
|
7005
|
+
}
|
|
7006
|
+
function drawPositionInfoText(ctx, opts) {
|
|
7007
|
+
const { point, rotateCenter, angle: angle2, text: text2, color: color2, background: background2, fontSize: fontSize2, lineHeight: lineHeight2 } = opts;
|
|
7008
|
+
rotateByCenter(ctx, angle2, rotateCenter, () => {
|
|
7009
|
+
ctx.$setFont({
|
|
7010
|
+
fontWeight: "300",
|
|
7011
|
+
fontSize: fontSize2,
|
|
7012
|
+
fontFamily
|
|
7013
|
+
});
|
|
7014
|
+
const padding = (lineHeight2 - fontSize2) / 2;
|
|
7015
|
+
const textWidth = ctx.$undoPixelRatio(ctx.measureText(text2).width);
|
|
7016
|
+
const bgStart = {
|
|
7017
|
+
x: point.x,
|
|
7018
|
+
y: point.y
|
|
7019
|
+
};
|
|
7020
|
+
const bgEnd = {
|
|
7021
|
+
x: bgStart.x + textWidth + padding * 2,
|
|
7022
|
+
y: bgStart.y + fontSize2 + padding
|
|
7023
|
+
};
|
|
7024
|
+
const textStart = {
|
|
7025
|
+
x: point.x + padding,
|
|
7026
|
+
y: point.y
|
|
7027
|
+
};
|
|
7028
|
+
ctx.setLineDash([]);
|
|
7029
|
+
ctx.fillStyle = background2;
|
|
7030
|
+
ctx.beginPath();
|
|
7031
|
+
ctx.moveTo(bgStart.x, bgStart.y);
|
|
7032
|
+
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
7033
|
+
ctx.lineTo(bgEnd.x, bgEnd.y);
|
|
7034
|
+
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
7035
|
+
ctx.closePath();
|
|
7036
|
+
ctx.fill();
|
|
7037
|
+
ctx.fillStyle = color2;
|
|
7038
|
+
ctx.textBaseline = "top";
|
|
7039
|
+
ctx.fillText(text2, textStart.x, textStart.y + padding);
|
|
7040
|
+
});
|
|
7041
|
+
}
|
|
7042
|
+
function drawAngleInfoText(ctx, opts) {
|
|
7043
|
+
const { point, rotateCenter, angle: angle2, text: text2, color: color2, background: background2, fontSize: fontSize2, lineHeight: lineHeight2 } = opts;
|
|
7044
|
+
rotateByCenter(ctx, angle2, rotateCenter, () => {
|
|
7045
|
+
ctx.$setFont({
|
|
7046
|
+
fontWeight: "300",
|
|
7047
|
+
fontSize: fontSize2,
|
|
7048
|
+
fontFamily
|
|
7049
|
+
});
|
|
7050
|
+
const padding = (lineHeight2 - fontSize2) / 2;
|
|
7051
|
+
const textWidth = ctx.$undoPixelRatio(ctx.measureText(text2).width);
|
|
7052
|
+
const bgStart = {
|
|
7053
|
+
x: point.x,
|
|
7054
|
+
y: point.y
|
|
7055
|
+
};
|
|
7056
|
+
const bgEnd = {
|
|
7057
|
+
x: bgStart.x + textWidth + padding * 2,
|
|
7058
|
+
y: bgStart.y + fontSize2 + padding
|
|
7059
|
+
};
|
|
7060
|
+
const textStart = {
|
|
7061
|
+
x: point.x + padding,
|
|
7062
|
+
y: point.y
|
|
7063
|
+
};
|
|
7064
|
+
ctx.setLineDash([]);
|
|
7065
|
+
ctx.fillStyle = background2;
|
|
7066
|
+
ctx.beginPath();
|
|
7067
|
+
ctx.moveTo(bgStart.x, bgStart.y);
|
|
7068
|
+
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
7069
|
+
ctx.lineTo(bgEnd.x, bgEnd.y);
|
|
7070
|
+
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
7071
|
+
ctx.closePath();
|
|
7072
|
+
ctx.fill();
|
|
7073
|
+
ctx.fillStyle = color2;
|
|
7074
|
+
ctx.textBaseline = "top";
|
|
7075
|
+
ctx.fillText(text2, textStart.x, textStart.y + padding);
|
|
7076
|
+
});
|
|
7077
|
+
}
|
|
7078
|
+
const infoBackground = "#1973bac6";
|
|
7079
|
+
const infoTextColor = "#ffffff";
|
|
7080
|
+
const infoFontSize = 10;
|
|
7081
|
+
const infoLineHeight = 16;
|
|
7082
|
+
const MiddlewareInfo = (opts) => {
|
|
7083
|
+
const { boardContent, calculator } = opts;
|
|
7084
|
+
const { helperContext } = boardContent;
|
|
7085
|
+
return {
|
|
7086
|
+
name: "@middleware/info",
|
|
7087
|
+
beforeDrawFrame({ snapshot }) {
|
|
7088
|
+
const { sharedStore } = snapshot;
|
|
7089
|
+
const selectedElementList = sharedStore[keySelectedElementList];
|
|
7090
|
+
const actionType = sharedStore[keyActionType];
|
|
7091
|
+
const groupQueue = sharedStore[keyGroupQueue] || [];
|
|
7092
|
+
if (selectedElementList.length === 1) {
|
|
7093
|
+
const elem = selectedElementList[0];
|
|
7094
|
+
if (elem && ["select", "drag", "resize"].includes(actionType)) {
|
|
7095
|
+
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
7096
|
+
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
7097
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = elem;
|
|
7098
|
+
const totalGroupQueue = [
|
|
7099
|
+
...groupQueue,
|
|
7100
|
+
...[
|
|
7101
|
+
{
|
|
7102
|
+
uuid: createUUID(),
|
|
7103
|
+
x: x2,
|
|
7104
|
+
y: y2,
|
|
7105
|
+
w: w2,
|
|
7106
|
+
h: h2,
|
|
7107
|
+
angle: angle2,
|
|
7108
|
+
type: "group",
|
|
7109
|
+
detail: { children: [] }
|
|
7110
|
+
}
|
|
7111
|
+
]
|
|
7112
|
+
];
|
|
7113
|
+
const calcOpts = { viewScaleInfo, viewSizeInfo };
|
|
7114
|
+
const rangeRectInfo = calculator.calcViewRectInfoFromOrigin(elem.uuid, calcOpts);
|
|
7115
|
+
let totalAngle = 0;
|
|
7116
|
+
totalGroupQueue.forEach((group) => {
|
|
7117
|
+
totalAngle += group.angle || 0;
|
|
7118
|
+
});
|
|
7119
|
+
const totalRadian = parseAngleToRadian(limitAngle(0 - totalAngle));
|
|
7120
|
+
if (rangeRectInfo) {
|
|
7121
|
+
const elemCenter = rangeRectInfo == null ? void 0 : rangeRectInfo.center;
|
|
7122
|
+
const rectInfo = {
|
|
7123
|
+
topLeft: rotatePoint(elemCenter, rangeRectInfo.topLeft, totalRadian),
|
|
7124
|
+
topRight: rotatePoint(elemCenter, rangeRectInfo.topRight, totalRadian),
|
|
7125
|
+
bottomRight: rotatePoint(elemCenter, rangeRectInfo.bottomRight, totalRadian),
|
|
7126
|
+
bottomLeft: rotatePoint(elemCenter, rangeRectInfo.bottomLeft, totalRadian),
|
|
7127
|
+
center: rotatePoint(elemCenter, rangeRectInfo.center, totalRadian),
|
|
7128
|
+
top: rotatePoint(elemCenter, rangeRectInfo.top, totalRadian),
|
|
7129
|
+
right: rotatePoint(elemCenter, rangeRectInfo.right, totalRadian),
|
|
7130
|
+
bottom: rotatePoint(elemCenter, rangeRectInfo.bottom, totalRadian),
|
|
7131
|
+
left: rotatePoint(elemCenter, rangeRectInfo.left, totalRadian)
|
|
7132
|
+
};
|
|
7133
|
+
const x22 = formatNumber(elem.x, { decimalPlaces: 2 });
|
|
7134
|
+
const y22 = formatNumber(elem.y, { decimalPlaces: 2 });
|
|
7135
|
+
const w22 = formatNumber(elem.w, { decimalPlaces: 2 });
|
|
7136
|
+
const h22 = formatNumber(elem.h, { decimalPlaces: 2 });
|
|
7137
|
+
const xyText = `${formatNumber(x22, { decimalPlaces: 0 })},${formatNumber(y22, { decimalPlaces: 0 })}`;
|
|
7138
|
+
const whText = `${formatNumber(w22, { decimalPlaces: 0 })}x${formatNumber(h22, { decimalPlaces: 0 })}`;
|
|
7139
|
+
const angleText = `${formatNumber(elem.angle || 0, { decimalPlaces: 0 })}°`;
|
|
7140
|
+
drawSizeInfoText(helperContext, {
|
|
7141
|
+
point: {
|
|
7142
|
+
x: rectInfo.bottom.x,
|
|
7143
|
+
y: rectInfo.bottom.y + infoFontSize
|
|
7144
|
+
},
|
|
7145
|
+
rotateCenter: rectInfo.center,
|
|
7146
|
+
angle: totalAngle,
|
|
7147
|
+
text: whText,
|
|
7148
|
+
fontSize: infoFontSize,
|
|
7149
|
+
lineHeight: infoLineHeight,
|
|
7150
|
+
color: infoTextColor,
|
|
7151
|
+
background: infoBackground
|
|
7152
|
+
});
|
|
7153
|
+
drawPositionInfoText(helperContext, {
|
|
7154
|
+
point: {
|
|
7155
|
+
x: rectInfo.topLeft.x,
|
|
7156
|
+
y: rectInfo.topLeft.y - infoFontSize * 2
|
|
7157
|
+
},
|
|
7158
|
+
rotateCenter: rectInfo.center,
|
|
7159
|
+
angle: totalAngle,
|
|
7160
|
+
text: xyText,
|
|
7161
|
+
fontSize: infoFontSize,
|
|
7162
|
+
lineHeight: infoLineHeight,
|
|
7163
|
+
color: infoTextColor,
|
|
7164
|
+
background: infoBackground
|
|
7165
|
+
});
|
|
7166
|
+
drawAngleInfoText(helperContext, {
|
|
7167
|
+
point: {
|
|
7168
|
+
x: rectInfo.top.x + infoFontSize,
|
|
7169
|
+
y: rectInfo.top.y - infoFontSize * 2
|
|
7170
|
+
},
|
|
7171
|
+
rotateCenter: rectInfo.center,
|
|
7172
|
+
angle: totalAngle,
|
|
7173
|
+
text: angleText,
|
|
7174
|
+
fontSize: infoFontSize,
|
|
7175
|
+
lineHeight: infoLineHeight,
|
|
7176
|
+
color: infoTextColor,
|
|
7177
|
+
background: infoBackground
|
|
7178
|
+
});
|
|
7179
|
+
}
|
|
7180
|
+
}
|
|
7181
|
+
}
|
|
7182
|
+
}
|
|
7183
|
+
};
|
|
7184
|
+
};
|
|
6912
7185
|
class Core {
|
|
6913
7186
|
constructor(container, opts) {
|
|
6914
7187
|
__privateAdd(this, _initContainer);
|
|
@@ -7024,6 +7297,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
7024
7297
|
};
|
|
7025
7298
|
exports.Core = Core;
|
|
7026
7299
|
exports.MiddlewareDragger = MiddlewareDragger;
|
|
7300
|
+
exports.MiddlewareInfo = MiddlewareInfo;
|
|
7027
7301
|
exports.MiddlewareRuler = MiddlewareRuler;
|
|
7028
7302
|
exports.MiddlewareScaler = MiddlewareScaler;
|
|
7029
7303
|
exports.MiddlewareScroller = MiddlewareScroller;
|