@idraw/core 0.4.0-beta.29 → 0.4.0-beta.30
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/middleware/layout-selector/config.d.ts +4 -1
- package/dist/esm/middleware/layout-selector/config.js +4 -1
- package/dist/esm/middleware/layout-selector/index.d.ts +2 -0
- package/dist/esm/middleware/layout-selector/index.js +176 -95
- package/dist/esm/middleware/layout-selector/types.d.ts +7 -4
- package/dist/esm/middleware/layout-selector/types.js +2 -2
- package/dist/esm/middleware/layout-selector/util.d.ts +4 -1
- package/dist/esm/middleware/layout-selector/util.js +15 -0
- package/dist/esm/middleware/scroller/config.d.ts +2 -0
- package/dist/esm/middleware/scroller/config.js +2 -0
- package/dist/esm/middleware/scroller/index.js +29 -2
- package/dist/esm/middleware/scroller/types.d.ts +3 -1
- package/dist/esm/middleware/scroller/types.js +1 -1
- package/dist/esm/middleware/scroller/util.js +14 -9
- package/dist/esm/middleware/selector/index.d.ts +2 -2
- package/dist/esm/middleware/selector/index.js +6 -1
- package/dist/esm/middleware/selector/types.d.ts +2 -0
- package/dist/esm/middleware/selector/types.js +1 -0
- package/dist/esm/middleware/text-editor/index.js +2 -1
- package/dist/index.global.js +661 -520
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -1435,6 +1435,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1435
1435
|
}
|
|
1436
1436
|
return false;
|
|
1437
1437
|
}
|
|
1438
|
+
function isViewPointInElementSize(p, elemSize, opts) {
|
|
1439
|
+
const vertexes = calcElementVertexes(elemSize);
|
|
1440
|
+
return isViewPointInVertexes(p, vertexes);
|
|
1441
|
+
}
|
|
1438
1442
|
function isViewPointInVertexes(p, vertexes, opts) {
|
|
1439
1443
|
const xList = [vertexes[0].x, vertexes[1].x, vertexes[2].x, vertexes[3].x];
|
|
1440
1444
|
const yList = [vertexes[0].y, vertexes[1].y, vertexes[2].y, vertexes[3].y];
|
|
@@ -2681,140 +2685,146 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2681
2685
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
2682
2686
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2683
2687
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2684
|
-
|
|
2685
|
-
originElem: elem,
|
|
2686
|
-
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2688
|
+
drawBoxShadow(ctx, viewElem, {
|
|
2687
2689
|
viewScaleInfo,
|
|
2688
2690
|
viewSizeInfo,
|
|
2689
|
-
parentOpacity,
|
|
2690
2691
|
renderContent: () => {
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
const originLineHeight = detail.lineHeight || originFontSize;
|
|
2698
|
-
const lineHeight2 = originLineHeight * viewScaleInfo.scale;
|
|
2699
|
-
ctx.fillStyle = elem.detail.color || detailConfig.color;
|
|
2700
|
-
ctx.textBaseline = "top";
|
|
2701
|
-
ctx.$setFont({
|
|
2702
|
-
fontWeight: detail.fontWeight,
|
|
2703
|
-
fontSize: fontSize2,
|
|
2704
|
-
fontFamily: enhanceFontFamliy(detail.fontFamily)
|
|
2692
|
+
drawBox(ctx, viewElem, {
|
|
2693
|
+
originElem: elem,
|
|
2694
|
+
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2695
|
+
viewScaleInfo,
|
|
2696
|
+
viewSizeInfo,
|
|
2697
|
+
parentOpacity
|
|
2705
2698
|
});
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2699
|
+
}
|
|
2700
|
+
});
|
|
2701
|
+
{
|
|
2702
|
+
const detail = Object.assign(Object.assign({}, detailConfig), elem.detail);
|
|
2703
|
+
const originFontSize = detail.fontSize || detailConfig.fontSize;
|
|
2704
|
+
const fontSize2 = originFontSize * viewScaleInfo.scale;
|
|
2705
|
+
if (fontSize2 < 2) {
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2708
|
+
const originLineHeight = detail.lineHeight || originFontSize;
|
|
2709
|
+
const lineHeight2 = originLineHeight * viewScaleInfo.scale;
|
|
2710
|
+
ctx.fillStyle = elem.detail.color || detailConfig.color;
|
|
2711
|
+
ctx.textBaseline = "top";
|
|
2712
|
+
ctx.$setFont({
|
|
2713
|
+
fontWeight: detail.fontWeight,
|
|
2714
|
+
fontSize: fontSize2,
|
|
2715
|
+
fontFamily: enhanceFontFamliy(detail.fontFamily)
|
|
2716
|
+
});
|
|
2717
|
+
let detailText = detail.text.replace(/\r\n/gi, "\n");
|
|
2718
|
+
if (detail.textTransform === "lowercase") {
|
|
2719
|
+
detailText = detailText.toLowerCase();
|
|
2720
|
+
} else if (detail.textTransform === "uppercase") {
|
|
2721
|
+
detailText = detailText.toUpperCase();
|
|
2722
|
+
}
|
|
2723
|
+
const fontHeight = lineHeight2;
|
|
2724
|
+
const detailTextList = detailText.split("\n");
|
|
2725
|
+
const lines = [];
|
|
2726
|
+
let lineNum = 0;
|
|
2727
|
+
detailTextList.forEach((itemText, idx) => {
|
|
2728
|
+
if (detail.minInlineSize === "maxContent") {
|
|
2729
|
+
lines.push({
|
|
2730
|
+
text: itemText,
|
|
2731
|
+
width: ctx.$undoPixelRatio(ctx.measureText(itemText).width)
|
|
2732
|
+
});
|
|
2733
|
+
} else {
|
|
2734
|
+
let lineText = "";
|
|
2735
|
+
let splitStr = "";
|
|
2736
|
+
let tempStrList = itemText.split(splitStr);
|
|
2737
|
+
if (detail.wordBreak === "normal") {
|
|
2738
|
+
const splitStr2 = " ";
|
|
2739
|
+
const wordList = itemText.split(splitStr2);
|
|
2740
|
+
tempStrList = [];
|
|
2741
|
+
wordList.forEach((word, idx2) => {
|
|
2742
|
+
tempStrList.push(word);
|
|
2743
|
+
if (idx2 < wordList.length - 1) {
|
|
2744
|
+
tempStrList.push(splitStr2);
|
|
2745
|
+
}
|
|
2746
|
+
});
|
|
2747
|
+
}
|
|
2748
|
+
if (tempStrList.length === 1 && detail.overflow === "visible") {
|
|
2718
2749
|
lines.push({
|
|
2719
|
-
text:
|
|
2720
|
-
width: ctx.$undoPixelRatio(ctx.measureText(
|
|
2750
|
+
text: tempStrList[0],
|
|
2751
|
+
width: ctx.$undoPixelRatio(ctx.measureText(tempStrList[0]).width)
|
|
2721
2752
|
});
|
|
2722
|
-
} else {
|
|
2723
|
-
let
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
tempStrList
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
text: tempStrList[0],
|
|
2740
|
-
width: ctx.$undoPixelRatio(ctx.measureText(tempStrList[0]).width)
|
|
2741
|
-
});
|
|
2742
|
-
} else if (tempStrList.length > 0) {
|
|
2743
|
-
for (let i = 0; i < tempStrList.length; i++) {
|
|
2744
|
-
if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(w2), ctx.measureText(lineText + tempStrList[i]).width, viewScaleInfo.scale)) {
|
|
2745
|
-
lineText += tempStrList[i] || "";
|
|
2746
|
-
} else {
|
|
2753
|
+
} else if (tempStrList.length > 0) {
|
|
2754
|
+
for (let i = 0; i < tempStrList.length; i++) {
|
|
2755
|
+
if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(w2), ctx.measureText(lineText + tempStrList[i]).width, viewScaleInfo.scale)) {
|
|
2756
|
+
lineText += tempStrList[i] || "";
|
|
2757
|
+
} else {
|
|
2758
|
+
lines.push({
|
|
2759
|
+
text: lineText,
|
|
2760
|
+
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2761
|
+
});
|
|
2762
|
+
lineText = tempStrList[i] || "";
|
|
2763
|
+
lineNum++;
|
|
2764
|
+
}
|
|
2765
|
+
if ((lineNum + 1) * fontHeight > h2 && detail.overflow === "hidden") {
|
|
2766
|
+
break;
|
|
2767
|
+
}
|
|
2768
|
+
if (tempStrList.length - 1 === i) {
|
|
2769
|
+
if ((lineNum + 1) * fontHeight <= h2) {
|
|
2747
2770
|
lines.push({
|
|
2748
2771
|
text: lineText,
|
|
2749
2772
|
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2750
2773
|
});
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
}
|
|
2754
|
-
if ((lineNum + 1) * fontHeight > h2 && detail.overflow === "hidden") {
|
|
2755
|
-
break;
|
|
2756
|
-
}
|
|
2757
|
-
if (tempStrList.length - 1 === i) {
|
|
2758
|
-
if ((lineNum + 1) * fontHeight <= h2) {
|
|
2759
|
-
lines.push({
|
|
2760
|
-
text: lineText,
|
|
2761
|
-
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2762
|
-
});
|
|
2763
|
-
if (idx < detailTextList.length - 1) {
|
|
2764
|
-
lineNum++;
|
|
2765
|
-
}
|
|
2766
|
-
break;
|
|
2774
|
+
if (idx < detailTextList.length - 1) {
|
|
2775
|
+
lineNum++;
|
|
2767
2776
|
}
|
|
2777
|
+
break;
|
|
2768
2778
|
}
|
|
2769
2779
|
}
|
|
2770
|
-
} else {
|
|
2771
|
-
lines.push({
|
|
2772
|
-
text: "",
|
|
2773
|
-
width: 0
|
|
2774
|
-
});
|
|
2775
2780
|
}
|
|
2776
|
-
}
|
|
2777
|
-
});
|
|
2778
|
-
let startY = 0;
|
|
2779
|
-
let eachLineStartY = 0;
|
|
2780
|
-
if (fontHeight > fontSize2) {
|
|
2781
|
-
eachLineStartY = (fontHeight - fontSize2) / 2;
|
|
2782
|
-
}
|
|
2783
|
-
if (lines.length * fontHeight < h2) {
|
|
2784
|
-
if (elem.detail.verticalAlign === "top") {
|
|
2785
|
-
startY = 0;
|
|
2786
|
-
} else if (elem.detail.verticalAlign === "bottom") {
|
|
2787
|
-
startY += h2 - lines.length * fontHeight;
|
|
2788
2781
|
} else {
|
|
2789
|
-
|
|
2782
|
+
lines.push({
|
|
2783
|
+
text: "",
|
|
2784
|
+
width: 0
|
|
2785
|
+
});
|
|
2790
2786
|
}
|
|
2791
2787
|
}
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
}
|
|
2806
|
-
lines.forEach((line, i) => {
|
|
2807
|
-
let _x = x2;
|
|
2808
|
-
if (detail.textAlign === "center") {
|
|
2809
|
-
_x = x2 + (w2 - line.width) / 2;
|
|
2810
|
-
} else if (detail.textAlign === "right") {
|
|
2811
|
-
_x = x2 + (w2 - line.width);
|
|
2812
|
-
}
|
|
2813
|
-
ctx.fillText(line.text, _x, _y + fontHeight * i + eachLineStartY);
|
|
2814
|
-
});
|
|
2788
|
+
});
|
|
2789
|
+
let startY = 0;
|
|
2790
|
+
let eachLineStartY = 0;
|
|
2791
|
+
if (fontHeight > fontSize2) {
|
|
2792
|
+
eachLineStartY = (fontHeight - fontSize2) / 2;
|
|
2793
|
+
}
|
|
2794
|
+
if (lines.length * fontHeight < h2) {
|
|
2795
|
+
if (elem.detail.verticalAlign === "top") {
|
|
2796
|
+
startY = 0;
|
|
2797
|
+
} else if (elem.detail.verticalAlign === "bottom") {
|
|
2798
|
+
startY += h2 - lines.length * fontHeight;
|
|
2799
|
+
} else {
|
|
2800
|
+
startY += (h2 - lines.length * fontHeight) / 2;
|
|
2815
2801
|
}
|
|
2816
2802
|
}
|
|
2817
|
-
|
|
2803
|
+
{
|
|
2804
|
+
const _y = y2 + startY;
|
|
2805
|
+
if (detail.textShadowColor !== void 0 && isColorStr(detail.textShadowColor)) {
|
|
2806
|
+
ctx.shadowColor = detail.textShadowColor;
|
|
2807
|
+
}
|
|
2808
|
+
if (detail.textShadowOffsetX !== void 0 && is.number(detail.textShadowOffsetX)) {
|
|
2809
|
+
ctx.shadowOffsetX = detail.textShadowOffsetX;
|
|
2810
|
+
}
|
|
2811
|
+
if (detail.textShadowOffsetY !== void 0 && is.number(detail.textShadowOffsetY)) {
|
|
2812
|
+
ctx.shadowOffsetY = detail.textShadowOffsetY;
|
|
2813
|
+
}
|
|
2814
|
+
if (detail.textShadowBlur !== void 0 && is.number(detail.textShadowBlur)) {
|
|
2815
|
+
ctx.shadowBlur = detail.textShadowBlur;
|
|
2816
|
+
}
|
|
2817
|
+
lines.forEach((line, i) => {
|
|
2818
|
+
let _x = x2;
|
|
2819
|
+
if (detail.textAlign === "center") {
|
|
2820
|
+
_x = x2 + (w2 - line.width) / 2;
|
|
2821
|
+
} else if (detail.textAlign === "right") {
|
|
2822
|
+
_x = x2 + (w2 - line.width);
|
|
2823
|
+
}
|
|
2824
|
+
ctx.fillText(line.text, _x, _y + fontHeight * i + eachLineStartY);
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2818
2828
|
});
|
|
2819
2829
|
}
|
|
2820
2830
|
var __rest = function(s, e) {
|
|
@@ -4589,7 +4599,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4589
4599
|
const areaBorderWidth = 1;
|
|
4590
4600
|
const wrapperColor = "#1973ba";
|
|
4591
4601
|
const lockColor = "#5b5959b5";
|
|
4592
|
-
const controllerSize = 10;
|
|
4602
|
+
const controllerSize$1 = 10;
|
|
4593
4603
|
const referenceColor = "#f7276e";
|
|
4594
4604
|
const middlewareEventSelect = "@middleware/select";
|
|
4595
4605
|
const middlewareEventSelectClear = "@middleware/select-clear";
|
|
@@ -4740,7 +4750,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4740
4750
|
drawVertexes(ctx, calcViewVertexes(topRight.vertexes, opts), ctrlOpts);
|
|
4741
4751
|
drawVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
|
|
4742
4752
|
drawVertexes(ctx, calcViewVertexes(bottomRight.vertexes, opts), ctrlOpts);
|
|
4743
|
-
drawCircleController(ctx, calcViewPointSize(rotate.center, opts), { ...ctrlOpts, size: controllerSize, borderWidth: 2 });
|
|
4753
|
+
drawCircleController(ctx, calcViewPointSize(rotate.center, opts), { ...ctrlOpts, size: controllerSize$1, borderWidth: 2 });
|
|
4744
4754
|
}
|
|
4745
4755
|
}
|
|
4746
4756
|
function drawArea(ctx, opts) {
|
|
@@ -5972,7 +5982,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5972
5982
|
textarea.style.resize = "none";
|
|
5973
5983
|
textarea.style.overflow = "hidden";
|
|
5974
5984
|
textarea.style.wordBreak = "break-all";
|
|
5975
|
-
textarea.style.
|
|
5985
|
+
textarea.style.borderRadius = `${(typeof detail.borderRadius === "number" ? detail.borderRadius : 0) * scale}px`;
|
|
5986
|
+
textarea.style.background = `${detail.background || "transparent"}`;
|
|
5976
5987
|
textarea.style.color = `${detail.color || "#333333"}`;
|
|
5977
5988
|
textarea.style.fontSize = `${detail.fontSize * scale}px`;
|
|
5978
5989
|
textarea.style.lineHeight = `${(detail.lineHeight || detail.fontSize) * scale}px`;
|
|
@@ -6059,71 +6070,495 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6059
6070
|
}
|
|
6060
6071
|
};
|
|
6061
6072
|
};
|
|
6062
|
-
const
|
|
6063
|
-
|
|
6073
|
+
const key$2 = "LAYOUT_SELECT";
|
|
6074
|
+
const keyLayoutActionType = Symbol(`${key$2}_layoutActionType`);
|
|
6075
|
+
const keyLayoutControlType = Symbol(`${key$2}_layoutControlType`);
|
|
6076
|
+
const keyLayoutController = Symbol(`${key$2}_layoutController`);
|
|
6077
|
+
const keyLayoutIsHover = Symbol(`${key$2}_layoutIsHover`);
|
|
6078
|
+
const keyLayoutIsSelected = Symbol(`${key$2}_layoutIsSelected`);
|
|
6079
|
+
const selectColor = "#b331c9";
|
|
6080
|
+
const disableColor = "#5b5959b5";
|
|
6081
|
+
const controllerSize = 10;
|
|
6082
|
+
function drawControllerBox(ctx, boxVertexes) {
|
|
6083
|
+
ctx.setLineDash([]);
|
|
6084
|
+
ctx.fillStyle = "#FFFFFF";
|
|
6085
|
+
ctx.beginPath();
|
|
6086
|
+
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
6087
|
+
ctx.lineTo(boxVertexes[1].x, boxVertexes[1].y);
|
|
6088
|
+
ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
|
|
6089
|
+
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
6090
|
+
ctx.closePath();
|
|
6091
|
+
ctx.fill();
|
|
6092
|
+
ctx.strokeStyle = selectColor;
|
|
6093
|
+
ctx.lineWidth = 2;
|
|
6094
|
+
ctx.beginPath();
|
|
6095
|
+
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
6096
|
+
ctx.lineTo(boxVertexes[1].x, boxVertexes[1].y);
|
|
6097
|
+
ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
|
|
6098
|
+
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
6099
|
+
ctx.closePath();
|
|
6100
|
+
ctx.stroke();
|
|
6101
|
+
}
|
|
6102
|
+
function drawControllerCross(ctx, opts) {
|
|
6103
|
+
const { vertexes, strokeStyle, lineWidth } = opts;
|
|
6104
|
+
ctx.setLineDash([]);
|
|
6105
|
+
ctx.strokeStyle = strokeStyle;
|
|
6106
|
+
ctx.lineWidth = lineWidth;
|
|
6107
|
+
ctx.beginPath();
|
|
6108
|
+
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
6109
|
+
ctx.lineTo(vertexes[2].x, vertexes[2].y);
|
|
6110
|
+
ctx.closePath();
|
|
6111
|
+
ctx.stroke();
|
|
6112
|
+
ctx.beginPath();
|
|
6113
|
+
ctx.moveTo(vertexes[1].x, vertexes[1].y);
|
|
6114
|
+
ctx.lineTo(vertexes[3].x, vertexes[3].y);
|
|
6115
|
+
ctx.closePath();
|
|
6116
|
+
ctx.stroke();
|
|
6117
|
+
}
|
|
6118
|
+
function drawControllerLine(ctx, opts) {
|
|
6119
|
+
const { start, end, centerVertexes, disabled } = opts;
|
|
6120
|
+
const lineWidth = disabled === true ? 1 : 2;
|
|
6121
|
+
const strokeStyle = disabled === true ? disableColor : selectColor;
|
|
6122
|
+
ctx.setLineDash([]);
|
|
6123
|
+
ctx.strokeStyle = strokeStyle;
|
|
6124
|
+
ctx.lineWidth = lineWidth;
|
|
6125
|
+
ctx.beginPath();
|
|
6126
|
+
ctx.moveTo(start.x, start.y);
|
|
6127
|
+
ctx.lineTo(end.x, end.y);
|
|
6128
|
+
ctx.closePath();
|
|
6129
|
+
ctx.stroke();
|
|
6130
|
+
if (disabled === true) {
|
|
6131
|
+
drawControllerCross(ctx, {
|
|
6132
|
+
vertexes: centerVertexes,
|
|
6133
|
+
lineWidth,
|
|
6134
|
+
strokeStyle
|
|
6135
|
+
});
|
|
6136
|
+
}
|
|
6137
|
+
}
|
|
6138
|
+
function drawLayoutController(ctx, opts) {
|
|
6139
|
+
const { controller, operations } = opts;
|
|
6140
|
+
const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, rightMiddle, bottomMiddle, leftMiddle } = controller;
|
|
6141
|
+
drawControllerLine(ctx, { start: topLeft.center, end: topRight.center, centerVertexes: topMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disabledTop) });
|
|
6142
|
+
drawControllerLine(ctx, { start: topRight.center, end: bottomRight.center, centerVertexes: rightMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disabledRight) });
|
|
6143
|
+
drawControllerLine(ctx, { start: bottomRight.center, end: bottomLeft.center, centerVertexes: bottomMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disabledBottom) });
|
|
6144
|
+
drawControllerLine(ctx, { start: bottomLeft.center, end: topLeft.center, centerVertexes: leftMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disabledLeft) });
|
|
6145
|
+
const disabledOpts = {
|
|
6146
|
+
lineWidth: 1,
|
|
6147
|
+
strokeStyle: disableColor
|
|
6148
|
+
};
|
|
6149
|
+
if ((operations == null ? void 0 : operations.disabledTopLeft) === true) {
|
|
6150
|
+
drawControllerCross(ctx, { vertexes: topLeft.vertexes, ...disabledOpts });
|
|
6151
|
+
} else {
|
|
6152
|
+
drawControllerBox(ctx, topLeft.vertexes);
|
|
6153
|
+
}
|
|
6154
|
+
if ((operations == null ? void 0 : operations.disabledTopRight) === true) {
|
|
6155
|
+
drawControllerCross(ctx, { vertexes: topRight.vertexes, ...disabledOpts });
|
|
6156
|
+
} else {
|
|
6157
|
+
drawControllerBox(ctx, topRight.vertexes);
|
|
6158
|
+
}
|
|
6159
|
+
if ((operations == null ? void 0 : operations.disabledBottomRight) === true) {
|
|
6160
|
+
drawControllerCross(ctx, { vertexes: bottomRight.vertexes, ...disabledOpts });
|
|
6161
|
+
} else {
|
|
6162
|
+
drawControllerBox(ctx, bottomRight.vertexes);
|
|
6163
|
+
}
|
|
6164
|
+
if ((operations == null ? void 0 : operations.disabledBottomLeft) === true) {
|
|
6165
|
+
drawControllerCross(ctx, { vertexes: bottomLeft.vertexes, ...disabledOpts });
|
|
6166
|
+
} else {
|
|
6167
|
+
drawControllerBox(ctx, bottomLeft.vertexes);
|
|
6168
|
+
}
|
|
6169
|
+
}
|
|
6170
|
+
function drawLayoutHover(ctx, opts) {
|
|
6171
|
+
const { layoutSize } = opts;
|
|
6172
|
+
const { x: x2, y: y2, w: w2, h: h2 } = layoutSize;
|
|
6173
|
+
ctx.setLineDash([]);
|
|
6174
|
+
ctx.strokeStyle = selectColor;
|
|
6175
|
+
ctx.lineWidth = 1;
|
|
6176
|
+
ctx.beginPath();
|
|
6177
|
+
ctx.moveTo(x2, y2);
|
|
6178
|
+
ctx.lineTo(x2 + w2, y2);
|
|
6179
|
+
ctx.lineTo(x2 + w2, y2 + h2);
|
|
6180
|
+
ctx.lineTo(x2, y2 + h2);
|
|
6181
|
+
ctx.lineTo(x2, y2);
|
|
6182
|
+
ctx.closePath();
|
|
6183
|
+
ctx.stroke();
|
|
6184
|
+
}
|
|
6185
|
+
const MiddlewareLayoutSelector = (opts) => {
|
|
6186
|
+
const { sharer, boardContent, calculator, viewer, eventHub } = opts;
|
|
6064
6187
|
const { overlayContext } = boardContent;
|
|
6065
6188
|
let prevPoint = null;
|
|
6066
|
-
let
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
const
|
|
6070
|
-
|
|
6189
|
+
let prevIsHover = null;
|
|
6190
|
+
let prevIsSelected = null;
|
|
6191
|
+
let isBusy = null;
|
|
6192
|
+
const clear = () => {
|
|
6193
|
+
prevPoint = null;
|
|
6194
|
+
sharer.setSharedStorage(keyLayoutActionType, null);
|
|
6195
|
+
sharer.setSharedStorage(keyLayoutControlType, null);
|
|
6196
|
+
sharer.setSharedStorage(keyLayoutController, null);
|
|
6197
|
+
sharer.setSharedStorage(keyLayoutIsHover, null);
|
|
6198
|
+
sharer.setSharedStorage(keyLayoutIsSelected, null);
|
|
6199
|
+
prevIsHover = null;
|
|
6200
|
+
prevIsSelected = null;
|
|
6201
|
+
isBusy = null;
|
|
6071
6202
|
};
|
|
6072
|
-
const
|
|
6073
|
-
|
|
6074
|
-
if (
|
|
6075
|
-
|
|
6203
|
+
const isInElementHover = () => {
|
|
6204
|
+
const hoverElement = sharer.getSharedStorage(keyHoverElement);
|
|
6205
|
+
if (hoverElement) {
|
|
6206
|
+
clear();
|
|
6207
|
+
return true;
|
|
6076
6208
|
}
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
groupQueue.push(elem);
|
|
6209
|
+
return false;
|
|
6210
|
+
};
|
|
6211
|
+
const isInElementAction = () => {
|
|
6212
|
+
const elementActionType = sharer.getSharedStorage(keyActionType);
|
|
6213
|
+
if (elementActionType && elementActionType !== "area") {
|
|
6214
|
+
clear();
|
|
6215
|
+
return true;
|
|
6085
6216
|
}
|
|
6086
|
-
|
|
6087
|
-
sharer.setSharedStorage(keyGroupQueue, groupQueue);
|
|
6088
|
-
sharer.setSharedStorage(keyGroupQueueVertexesList, vertexesList);
|
|
6089
|
-
return groupQueue.length > 0;
|
|
6217
|
+
return false;
|
|
6090
6218
|
};
|
|
6091
|
-
const
|
|
6092
|
-
sharer.
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
groupQueue: sharer.getSharedStorage(keyGroupQueue)
|
|
6097
|
-
});
|
|
6219
|
+
const getLayoutSize = () => {
|
|
6220
|
+
const data = sharer.getActiveStorage("data");
|
|
6221
|
+
if (data == null ? void 0 : data.layout) {
|
|
6222
|
+
const { x: x2, y: y2, w: w2, h: h2 } = data.layout;
|
|
6223
|
+
return { x: x2, y: y2, w: w2, h: h2 };
|
|
6098
6224
|
}
|
|
6099
|
-
|
|
6225
|
+
return null;
|
|
6100
6226
|
};
|
|
6101
|
-
const
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
const
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6227
|
+
const isInLayout = (p) => {
|
|
6228
|
+
const size = getLayoutSize();
|
|
6229
|
+
if (size) {
|
|
6230
|
+
const { x: x2, y: y2, w: w2, h: h2 } = size;
|
|
6231
|
+
const viewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
6232
|
+
const viewSize = calcViewElementSize(
|
|
6233
|
+
{
|
|
6234
|
+
x: x2 - controllerSize / 2,
|
|
6235
|
+
y: y2 - controllerSize / 2,
|
|
6236
|
+
w: w2 + controllerSize,
|
|
6237
|
+
h: h2 + controllerSize
|
|
6238
|
+
},
|
|
6239
|
+
{ viewScaleInfo }
|
|
6240
|
+
);
|
|
6241
|
+
return isViewPointInElementSize(p, viewSize);
|
|
6115
6242
|
}
|
|
6116
|
-
|
|
6117
|
-
|
|
6243
|
+
return false;
|
|
6244
|
+
};
|
|
6245
|
+
const resetController = () => {
|
|
6246
|
+
const viewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
6247
|
+
const size = getLayoutSize();
|
|
6248
|
+
if (size) {
|
|
6249
|
+
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize: 10 });
|
|
6250
|
+
sharer.setSharedStorage(keyLayoutController, controller);
|
|
6251
|
+
} else {
|
|
6252
|
+
sharer.setSharedStorage(keyLayoutController, null);
|
|
6118
6253
|
}
|
|
6119
6254
|
};
|
|
6120
|
-
const
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6255
|
+
const resetControlType = (e) => {
|
|
6256
|
+
const data = sharer.getActiveStorage("data");
|
|
6257
|
+
const controller = sharer.getSharedStorage(keyLayoutController);
|
|
6258
|
+
if (controller && (data == null ? void 0 : data.layout) && (e == null ? void 0 : e.point)) {
|
|
6259
|
+
let layoutControlType = null;
|
|
6260
|
+
if (controller) {
|
|
6261
|
+
const { topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left } = controller;
|
|
6262
|
+
const list = [topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left];
|
|
6263
|
+
for (let i = 0; i < list.length; i++) {
|
|
6264
|
+
const item = list[i];
|
|
6265
|
+
if (isViewPointInVertexes(e.point, item.vertexes)) {
|
|
6266
|
+
layoutControlType = `${item.type}`;
|
|
6267
|
+
break;
|
|
6268
|
+
}
|
|
6269
|
+
}
|
|
6270
|
+
if (layoutControlType) {
|
|
6271
|
+
sharer.setSharedStorage(keyLayoutControlType, layoutControlType);
|
|
6272
|
+
eventHub.trigger(middlewareEventSelectClear, {});
|
|
6273
|
+
return layoutControlType;
|
|
6274
|
+
}
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
return null;
|
|
6278
|
+
};
|
|
6279
|
+
const updateCursor = (controlType) => {
|
|
6280
|
+
if (isBusy === true) {
|
|
6281
|
+
return;
|
|
6282
|
+
}
|
|
6283
|
+
eventHub.trigger("cursor", {
|
|
6284
|
+
type: controlType ? `resize-${controlType}` : controlType,
|
|
6285
|
+
groupQueue: [],
|
|
6286
|
+
element: getLayoutSize()
|
|
6287
|
+
});
|
|
6288
|
+
};
|
|
6289
|
+
return {
|
|
6290
|
+
name: "@middleware/layout-selector",
|
|
6291
|
+
use: () => {
|
|
6292
|
+
clear();
|
|
6293
|
+
resetController();
|
|
6294
|
+
},
|
|
6295
|
+
hover: (e) => {
|
|
6296
|
+
if (isBusy === true) {
|
|
6297
|
+
return;
|
|
6298
|
+
}
|
|
6299
|
+
if (isInElementAction()) {
|
|
6300
|
+
return;
|
|
6301
|
+
}
|
|
6302
|
+
if (isInElementHover()) {
|
|
6303
|
+
return;
|
|
6304
|
+
}
|
|
6305
|
+
if (isInLayout(e.point)) {
|
|
6306
|
+
sharer.setSharedStorage(keyLayoutIsHover, true);
|
|
6307
|
+
} else {
|
|
6308
|
+
sharer.setSharedStorage(keyLayoutIsHover, false);
|
|
6309
|
+
if (prevIsHover === true) {
|
|
6310
|
+
viewer.drawFrame();
|
|
6311
|
+
prevIsHover = false;
|
|
6312
|
+
}
|
|
6313
|
+
}
|
|
6314
|
+
if (sharer.getSharedStorage(keyLayoutIsSelected) === true) {
|
|
6315
|
+
const prevLayoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
6316
|
+
const data = sharer.getActiveStorage("data");
|
|
6317
|
+
if (data == null ? void 0 : data.layout) {
|
|
6318
|
+
if (prevLayoutActionType !== "resize") {
|
|
6319
|
+
resetController();
|
|
6320
|
+
const layoutControlType = resetControlType(e);
|
|
6321
|
+
if (layoutControlType) {
|
|
6322
|
+
updateCursor(layoutControlType);
|
|
6323
|
+
} else {
|
|
6324
|
+
updateCursor();
|
|
6325
|
+
sharer.setSharedStorage(keyLayoutActionType, null);
|
|
6326
|
+
}
|
|
6327
|
+
} else {
|
|
6328
|
+
const layoutControlType = resetControlType(e);
|
|
6329
|
+
updateCursor(layoutControlType);
|
|
6330
|
+
}
|
|
6331
|
+
}
|
|
6332
|
+
return;
|
|
6333
|
+
}
|
|
6334
|
+
if (sharer.getSharedStorage(keyLayoutIsHover) && !prevIsHover) {
|
|
6335
|
+
viewer.drawFrame();
|
|
6336
|
+
}
|
|
6337
|
+
prevIsHover = sharer.getSharedStorage(keyLayoutIsHover);
|
|
6338
|
+
},
|
|
6339
|
+
pointStart: (e) => {
|
|
6340
|
+
if (isInElementAction()) {
|
|
6341
|
+
return;
|
|
6342
|
+
}
|
|
6343
|
+
if (isInLayout(e.point)) {
|
|
6344
|
+
sharer.setSharedStorage(keyLayoutIsSelected, true);
|
|
6345
|
+
} else {
|
|
6346
|
+
if (prevIsSelected === true) {
|
|
6347
|
+
clear();
|
|
6348
|
+
viewer.drawFrame();
|
|
6349
|
+
}
|
|
6350
|
+
sharer.setSharedStorage(keyLayoutIsSelected, false);
|
|
6351
|
+
}
|
|
6352
|
+
resetController();
|
|
6353
|
+
const layoutControlType = resetControlType(e);
|
|
6354
|
+
prevPoint = e.point;
|
|
6355
|
+
if (layoutControlType) {
|
|
6356
|
+
sharer.setSharedStorage(keyLayoutActionType, "resize");
|
|
6357
|
+
}
|
|
6358
|
+
if (sharer.getSharedStorage(keyLayoutIsSelected) === true && !prevIsSelected) {
|
|
6359
|
+
viewer.drawFrame();
|
|
6360
|
+
}
|
|
6361
|
+
prevIsSelected = sharer.getSharedStorage(keyLayoutIsSelected);
|
|
6362
|
+
},
|
|
6363
|
+
pointMove: (e) => {
|
|
6364
|
+
if (!sharer.getSharedStorage(keyLayoutIsSelected)) {
|
|
6365
|
+
if (isInElementAction()) {
|
|
6366
|
+
return;
|
|
6367
|
+
}
|
|
6368
|
+
}
|
|
6369
|
+
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
6370
|
+
const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
|
|
6371
|
+
const data = sharer.getActiveStorage("data");
|
|
6372
|
+
if (layoutActionType === "resize" && layoutControlType && (data == null ? void 0 : data.layout)) {
|
|
6373
|
+
if (prevPoint) {
|
|
6374
|
+
isBusy = true;
|
|
6375
|
+
const scale = sharer.getActiveStorage("scale");
|
|
6376
|
+
const viewMoveX = e.point.x - prevPoint.x;
|
|
6377
|
+
const viewMoveY = e.point.y - prevPoint.y;
|
|
6378
|
+
const moveX = viewMoveX / scale;
|
|
6379
|
+
const moveY = viewMoveY / scale;
|
|
6380
|
+
const { x: x2, y: y2, w: w2, h: h2, operations = {} } = data.layout;
|
|
6381
|
+
const { position = "absolute" } = operations;
|
|
6382
|
+
if (layoutControlType === "top") {
|
|
6383
|
+
if (position === "relative") {
|
|
6384
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
6385
|
+
viewer.scroll({ moveY: viewMoveY });
|
|
6386
|
+
} else {
|
|
6387
|
+
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
6388
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
6389
|
+
}
|
|
6390
|
+
} else if (layoutControlType === "right") {
|
|
6391
|
+
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
6392
|
+
} else if (layoutControlType === "bottom") {
|
|
6393
|
+
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
6394
|
+
} else if (layoutControlType === "left") {
|
|
6395
|
+
if (position === "relative") {
|
|
6396
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
6397
|
+
viewer.scroll({ moveX: viewMoveX });
|
|
6398
|
+
} else {
|
|
6399
|
+
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
6400
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
6401
|
+
}
|
|
6402
|
+
} else if (layoutControlType === "top-left") {
|
|
6403
|
+
if (position === "relative") {
|
|
6404
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
6405
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
6406
|
+
viewer.scroll({ moveX: viewMoveX, moveY: viewMoveY });
|
|
6407
|
+
} else {
|
|
6408
|
+
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
6409
|
+
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
6410
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
6411
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
6412
|
+
}
|
|
6413
|
+
} else if (layoutControlType === "top-right") {
|
|
6414
|
+
if (position === "relative") {
|
|
6415
|
+
viewer.scroll({
|
|
6416
|
+
moveY: viewMoveY
|
|
6417
|
+
});
|
|
6418
|
+
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
6419
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
6420
|
+
} else {
|
|
6421
|
+
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
6422
|
+
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
6423
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
6424
|
+
}
|
|
6425
|
+
} else if (layoutControlType === "bottom-right") {
|
|
6426
|
+
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
6427
|
+
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
6428
|
+
} else if (layoutControlType === "bottom-left") {
|
|
6429
|
+
if (position === "relative") {
|
|
6430
|
+
viewer.scroll({
|
|
6431
|
+
moveX: viewMoveX
|
|
6432
|
+
});
|
|
6433
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
6434
|
+
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
6435
|
+
} else {
|
|
6436
|
+
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
6437
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
6438
|
+
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
6439
|
+
}
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
prevPoint = e.point;
|
|
6443
|
+
resetController();
|
|
6444
|
+
viewer.drawFrame();
|
|
6445
|
+
return false;
|
|
6446
|
+
}
|
|
6447
|
+
if (["resize"].includes(layoutActionType)) {
|
|
6448
|
+
return false;
|
|
6449
|
+
}
|
|
6450
|
+
},
|
|
6451
|
+
pointEnd: () => {
|
|
6452
|
+
isBusy = false;
|
|
6453
|
+
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
6454
|
+
const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
|
|
6455
|
+
const data = sharer.getActiveStorage("data");
|
|
6456
|
+
if (data && layoutActionType === "resize" && layoutControlType) {
|
|
6457
|
+
eventHub.trigger(eventChange, {
|
|
6458
|
+
type: "changeLayout",
|
|
6459
|
+
data
|
|
6460
|
+
});
|
|
6461
|
+
}
|
|
6462
|
+
},
|
|
6463
|
+
beforeDrawFrame: ({ snapshot }) => {
|
|
6464
|
+
var _a;
|
|
6465
|
+
if (isInElementAction()) {
|
|
6466
|
+
return;
|
|
6467
|
+
}
|
|
6468
|
+
const { sharedStore, activeStore } = snapshot;
|
|
6469
|
+
const layoutActionType = sharedStore[keyLayoutActionType];
|
|
6470
|
+
const layoutIsHover = sharedStore[keyLayoutIsHover];
|
|
6471
|
+
const layoutIsSelected = sharedStore[keyLayoutIsSelected];
|
|
6472
|
+
if ((_a = activeStore.data) == null ? void 0 : _a.layout) {
|
|
6473
|
+
const { x: x2, y: y2, w: w2, h: h2 } = activeStore.data.layout;
|
|
6474
|
+
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
6475
|
+
const size = { x: x2, y: y2, w: w2, h: h2 };
|
|
6476
|
+
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize });
|
|
6477
|
+
if (layoutIsHover === true) {
|
|
6478
|
+
const viewSize = calcViewElementSize(size, { viewScaleInfo });
|
|
6479
|
+
drawLayoutHover(overlayContext, { layoutSize: viewSize });
|
|
6480
|
+
}
|
|
6481
|
+
if (layoutActionType && ["resize"].includes(layoutActionType) || layoutIsSelected === true) {
|
|
6482
|
+
drawLayoutController(overlayContext, { controller, operations: activeStore.data.layout.operations || {} });
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
},
|
|
6486
|
+
scrollX: () => {
|
|
6487
|
+
clear();
|
|
6488
|
+
},
|
|
6489
|
+
scrollY: () => {
|
|
6490
|
+
clear();
|
|
6491
|
+
},
|
|
6492
|
+
wheelScale: () => {
|
|
6493
|
+
clear();
|
|
6494
|
+
}
|
|
6495
|
+
};
|
|
6496
|
+
};
|
|
6497
|
+
const MiddlewareSelector = (opts) => {
|
|
6498
|
+
const { viewer, sharer, boardContent, calculator, eventHub } = opts;
|
|
6499
|
+
const { overlayContext } = boardContent;
|
|
6500
|
+
let prevPoint = null;
|
|
6501
|
+
let inBusyMode = null;
|
|
6502
|
+
sharer.setSharedStorage(keyActionType, null);
|
|
6503
|
+
sharer.setSharedStorage(keyEnableSnapToGrid, true);
|
|
6504
|
+
const getActiveElements = () => {
|
|
6505
|
+
return sharer.getSharedStorage(keySelectedElementList);
|
|
6506
|
+
};
|
|
6507
|
+
const pushGroupQueue = (elem) => {
|
|
6508
|
+
let groupQueue = sharer.getSharedStorage(keyGroupQueue);
|
|
6509
|
+
if (!Array.isArray(groupQueue)) {
|
|
6510
|
+
groupQueue = [];
|
|
6511
|
+
}
|
|
6512
|
+
if (groupQueue.length > 0) {
|
|
6513
|
+
if (isElementInGroup(elem, groupQueue[groupQueue.length - 1])) {
|
|
6514
|
+
groupQueue.push(elem);
|
|
6515
|
+
} else {
|
|
6516
|
+
groupQueue = [];
|
|
6517
|
+
}
|
|
6518
|
+
} else if (groupQueue.length === 0) {
|
|
6519
|
+
groupQueue.push(elem);
|
|
6520
|
+
}
|
|
6521
|
+
const vertexesList = calcElementQueueVertexesQueueInGroup(groupQueue);
|
|
6522
|
+
sharer.setSharedStorage(keyGroupQueue, groupQueue);
|
|
6523
|
+
sharer.setSharedStorage(keyGroupQueueVertexesList, vertexesList);
|
|
6524
|
+
return groupQueue.length > 0;
|
|
6525
|
+
};
|
|
6526
|
+
const updateHoverElement = (elem) => {
|
|
6527
|
+
sharer.setSharedStorage(keyHoverElement, elem);
|
|
6528
|
+
let vertexes = null;
|
|
6529
|
+
if (elem) {
|
|
6530
|
+
vertexes = calcElementVertexesInGroup(elem, {
|
|
6531
|
+
groupQueue: sharer.getSharedStorage(keyGroupQueue)
|
|
6532
|
+
});
|
|
6533
|
+
}
|
|
6534
|
+
sharer.setSharedStorage(keyHoverElementVertexes, vertexes);
|
|
6535
|
+
};
|
|
6536
|
+
const updateSelectedElementList = (list, opts2) => {
|
|
6537
|
+
var _a;
|
|
6538
|
+
sharer.setSharedStorage(keySelectedElementList, list);
|
|
6539
|
+
if (list.length === 1) {
|
|
6540
|
+
const controller = calcElementSizeController(list[0], {
|
|
6541
|
+
groupQueue: sharer.getSharedStorage(keyGroupQueue),
|
|
6542
|
+
controllerSize: controllerSize$1,
|
|
6543
|
+
viewScaleInfo: sharer.getActiveViewScaleInfo()
|
|
6544
|
+
});
|
|
6545
|
+
sharer.setSharedStorage(keySelectedElementController, controller);
|
|
6546
|
+
sharer.setSharedStorage(keySelectedElementPosition, getElementPositionFromList(list[0].uuid, ((_a = sharer.getActiveStorage("data")) == null ? void 0 : _a.elements) || []));
|
|
6547
|
+
} else {
|
|
6548
|
+
sharer.setSharedStorage(keySelectedElementController, null);
|
|
6549
|
+
sharer.setSharedStorage(keySelectedElementPosition, []);
|
|
6550
|
+
}
|
|
6551
|
+
if ((opts2 == null ? void 0 : opts2.triggerEvent) === true) {
|
|
6552
|
+
eventHub.trigger(middlewareEventSelect, { uuids: list.map((elem) => elem.uuid) });
|
|
6553
|
+
}
|
|
6554
|
+
};
|
|
6555
|
+
const pointTargetBaseOptions = () => {
|
|
6556
|
+
return {
|
|
6557
|
+
ctx: overlayContext,
|
|
6558
|
+
calculator,
|
|
6559
|
+
data: sharer.getActiveStorage("data"),
|
|
6560
|
+
selectedElements: getActiveElements(),
|
|
6561
|
+
viewScaleInfo: sharer.getActiveViewScaleInfo(),
|
|
6127
6562
|
viewSizeInfo: sharer.getActiveViewSizeInfo(),
|
|
6128
6563
|
groupQueue: sharer.getSharedStorage(keyGroupQueue),
|
|
6129
6564
|
areaSize: null,
|
|
@@ -6198,10 +6633,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6198
6633
|
},
|
|
6199
6634
|
hover: (e) => {
|
|
6200
6635
|
var _a, _b, _c, _d, _e;
|
|
6636
|
+
const layoutIsSelected = sharer.getSharedStorage(keyLayoutIsSelected);
|
|
6201
6637
|
const resizeType = sharer.getSharedStorage(keyResizeType);
|
|
6202
6638
|
const actionType = sharer.getSharedStorage(keyActionType);
|
|
6203
6639
|
const groupQueue = sharer.getSharedStorage(keyGroupQueue);
|
|
6204
6640
|
const triggerCursor = (target2) => {
|
|
6641
|
+
if (layoutIsSelected === true) {
|
|
6642
|
+
return;
|
|
6643
|
+
}
|
|
6205
6644
|
const cursor = target2.type;
|
|
6206
6645
|
if (inBusyMode === null) {
|
|
6207
6646
|
eventHub.trigger("cursor", {
|
|
@@ -6736,18 +7175,21 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6736
7175
|
}
|
|
6737
7176
|
};
|
|
6738
7177
|
};
|
|
6739
|
-
const key$
|
|
6740
|
-
const keyXThumbRect = Symbol(`${key$
|
|
6741
|
-
const keyYThumbRect = Symbol(`${key$
|
|
6742
|
-
const
|
|
6743
|
-
const
|
|
6744
|
-
const
|
|
7178
|
+
const key$1 = "SCROLL";
|
|
7179
|
+
const keyXThumbRect = Symbol(`${key$1}_xThumbRect`);
|
|
7180
|
+
const keyYThumbRect = Symbol(`${key$1}_yThumbRect`);
|
|
7181
|
+
const keyHoverXThumbRect = Symbol(`${key$1}_hoverXThumbRect`);
|
|
7182
|
+
const keyHoverYThumbRect = Symbol(`${key$1}_hoverYThumbRect`);
|
|
7183
|
+
const keyPrevPoint$1 = Symbol(`${key$1}_prevPoint`);
|
|
7184
|
+
const keyActivePoint = Symbol(`${key$1}_activePoint`);
|
|
7185
|
+
const keyActiveThumbType = Symbol(`${key$1}_activeThumbType`);
|
|
6745
7186
|
const minScrollerWidth = 12;
|
|
6746
7187
|
const scrollerLineWidth = 16;
|
|
6747
7188
|
const scrollerThumbAlpha = 0.3;
|
|
6748
7189
|
const scrollConfig = {
|
|
6749
7190
|
width: minScrollerWidth,
|
|
6750
|
-
thumbColor: "#
|
|
7191
|
+
thumbColor: "#0000008A",
|
|
7192
|
+
thumbHoverColor: "#000000EE",
|
|
6751
7193
|
scrollBarColor: "#FFFFFF60",
|
|
6752
7194
|
showScrollBar: false
|
|
6753
7195
|
};
|
|
@@ -6779,11 +7221,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6779
7221
|
prevPoint: sharedStore[keyPrevPoint$1] || null,
|
|
6780
7222
|
activeThumbType: sharedStore[keyActiveThumbType] || null,
|
|
6781
7223
|
xThumbRect: sharedStore[keyXThumbRect] || null,
|
|
6782
|
-
yThumbRect: sharedStore[keyYThumbRect] || null
|
|
7224
|
+
yThumbRect: sharedStore[keyYThumbRect] || null,
|
|
7225
|
+
hoverXThumb: sharedStore[keyHoverXThumbRect],
|
|
7226
|
+
hoverYThumb: sharedStore[keyHoverYThumbRect]
|
|
6783
7227
|
};
|
|
6784
7228
|
return info;
|
|
6785
7229
|
}
|
|
6786
|
-
function calcScrollerInfo(
|
|
7230
|
+
function calcScrollerInfo(opts) {
|
|
7231
|
+
const { viewScaleInfo, viewSizeInfo, hoverXThumb, hoverYThumb } = opts;
|
|
6787
7232
|
const { width, height } = viewSizeInfo;
|
|
6788
7233
|
const { offsetTop, offsetBottom, offsetLeft, offsetRight } = viewScaleInfo;
|
|
6789
7234
|
const sliderMinSize = scrollerLineWidth * 2.5;
|
|
@@ -6838,7 +7283,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6838
7283
|
ySize,
|
|
6839
7284
|
translateY,
|
|
6840
7285
|
translateX,
|
|
6841
|
-
|
|
7286
|
+
xThumbColor: hoverXThumb ? scrollConfig.thumbHoverColor : scrollConfig.thumbColor,
|
|
7287
|
+
yThumbColor: hoverYThumb ? scrollConfig.thumbHoverColor : scrollConfig.thumbColor,
|
|
6842
7288
|
scrollBarColor: scrollConfig.scrollBarColor,
|
|
6843
7289
|
xThumbRect,
|
|
6844
7290
|
yThumbRect
|
|
@@ -6894,8 +7340,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6894
7340
|
function drawScrollerInfo(overlayContext, opts) {
|
|
6895
7341
|
const ctx = overlayContext;
|
|
6896
7342
|
const { viewScaleInfo, viewSizeInfo, scrollInfo } = opts;
|
|
6897
|
-
const { activeThumbType, prevPoint, activePoint } = scrollInfo;
|
|
6898
|
-
const wrapper = calcScrollerInfo(viewScaleInfo, viewSizeInfo);
|
|
7343
|
+
const { activeThumbType, prevPoint, activePoint, hoverXThumb, hoverYThumb } = scrollInfo;
|
|
7344
|
+
const wrapper = calcScrollerInfo({ viewScaleInfo, viewSizeInfo, hoverXThumb, hoverYThumb });
|
|
6899
7345
|
let xThumbRect = { ...wrapper.xThumbRect };
|
|
6900
7346
|
let yThumbRect = { ...wrapper.yThumbRect };
|
|
6901
7347
|
if (activeThumbType && prevPoint && activePoint) {
|
|
@@ -6911,13 +7357,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6911
7357
|
axis: "X",
|
|
6912
7358
|
...xThumbRect,
|
|
6913
7359
|
r: wrapper.lineSize / 2,
|
|
6914
|
-
color: wrapper.
|
|
7360
|
+
color: wrapper.xThumbColor
|
|
6915
7361
|
});
|
|
6916
7362
|
drawScrollerThumb(ctx, {
|
|
6917
7363
|
axis: "Y",
|
|
6918
7364
|
...yThumbRect,
|
|
6919
7365
|
r: wrapper.lineSize / 2,
|
|
6920
|
-
color: wrapper.
|
|
7366
|
+
color: wrapper.yThumbColor
|
|
6921
7367
|
});
|
|
6922
7368
|
ctx.globalAlpha = 1;
|
|
6923
7369
|
return {
|
|
@@ -6934,14 +7380,18 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6934
7380
|
return { xThumbRect, yThumbRect };
|
|
6935
7381
|
}
|
|
6936
7382
|
const MiddlewareScroller = (opts) => {
|
|
6937
|
-
const { viewer, boardContent, sharer } = opts;
|
|
7383
|
+
const { viewer, boardContent, sharer, eventHub } = opts;
|
|
6938
7384
|
const { overlayContext } = boardContent;
|
|
6939
7385
|
sharer.setSharedStorage(keyXThumbRect, null);
|
|
6940
7386
|
sharer.setSharedStorage(keyYThumbRect, null);
|
|
7387
|
+
let isBusy = false;
|
|
6941
7388
|
const clear = () => {
|
|
6942
7389
|
sharer.setSharedStorage(keyPrevPoint$1, null);
|
|
6943
7390
|
sharer.setSharedStorage(keyActivePoint, null);
|
|
6944
7391
|
sharer.setSharedStorage(keyActiveThumbType, null);
|
|
7392
|
+
sharer.setSharedStorage(keyHoverXThumbRect, null);
|
|
7393
|
+
sharer.setSharedStorage(keyHoverYThumbRect, null);
|
|
7394
|
+
isBusy = false;
|
|
6945
7395
|
};
|
|
6946
7396
|
clear();
|
|
6947
7397
|
const scrollX = (p) => {
|
|
@@ -6983,10 +7433,31 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6983
7433
|
});
|
|
6984
7434
|
viewer.drawFrame();
|
|
6985
7435
|
},
|
|
7436
|
+
hover: (e) => {
|
|
7437
|
+
if (isBusy === true) {
|
|
7438
|
+
return false;
|
|
7439
|
+
}
|
|
7440
|
+
const { point } = e;
|
|
7441
|
+
const thumbType = getThumbType(point);
|
|
7442
|
+
if (thumbType === "X" || thumbType === "Y") {
|
|
7443
|
+
if (thumbType === "X") {
|
|
7444
|
+
sharer.setSharedStorage(keyHoverXThumbRect, true);
|
|
7445
|
+
sharer.setSharedStorage(keyHoverYThumbRect, false);
|
|
7446
|
+
} else {
|
|
7447
|
+
sharer.setSharedStorage(keyHoverXThumbRect, false);
|
|
7448
|
+
sharer.setSharedStorage(keyHoverYThumbRect, true);
|
|
7449
|
+
}
|
|
7450
|
+
eventHub.trigger("cursor", { type: "default" });
|
|
7451
|
+
return false;
|
|
7452
|
+
}
|
|
7453
|
+
sharer.setSharedStorage(keyHoverXThumbRect, false);
|
|
7454
|
+
sharer.setSharedStorage(keyHoverYThumbRect, false);
|
|
7455
|
+
},
|
|
6986
7456
|
pointStart: (e) => {
|
|
6987
7457
|
const { point } = e;
|
|
6988
7458
|
const thumbType = getThumbType(point);
|
|
6989
7459
|
if (thumbType === "X" || thumbType === "Y") {
|
|
7460
|
+
isBusy = true;
|
|
6990
7461
|
sharer.setSharedStorage(keyActiveThumbType, thumbType);
|
|
6991
7462
|
sharer.setSharedStorage(keyPrevPoint$1, point);
|
|
6992
7463
|
return false;
|
|
@@ -7007,6 +7478,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
7007
7478
|
}
|
|
7008
7479
|
},
|
|
7009
7480
|
pointEnd: () => {
|
|
7481
|
+
isBusy = false;
|
|
7010
7482
|
const activeThumbType = sharer.getSharedStorage(keyActiveThumbType);
|
|
7011
7483
|
clear();
|
|
7012
7484
|
if (activeThumbType === "X" || activeThumbType === "Y") {
|
|
@@ -7357,8 +7829,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
7357
7829
|
}
|
|
7358
7830
|
};
|
|
7359
7831
|
};
|
|
7360
|
-
const key
|
|
7361
|
-
const keyPrevPoint = Symbol(`${key
|
|
7832
|
+
const key = "DRAG";
|
|
7833
|
+
const keyPrevPoint = Symbol(`${key}_prevPoint`);
|
|
7362
7834
|
const MiddlewareDragger = (opts) => {
|
|
7363
7835
|
const { eventHub, sharer, viewer } = opts;
|
|
7364
7836
|
let isDragging = false;
|
|
@@ -7616,337 +8088,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
7616
8088
|
}
|
|
7617
8089
|
};
|
|
7618
8090
|
};
|
|
7619
|
-
const key = "LAYOUT_SELECT";
|
|
7620
|
-
const keyLayoutActionType = Symbol(`${key}_layoutActionType`);
|
|
7621
|
-
const keyLayoutControlType = Symbol(`${key}_layoutControlType`);
|
|
7622
|
-
const keyLayoutController = Symbol(`${key}_layoutController`);
|
|
7623
|
-
const selectColor = "#1973ba";
|
|
7624
|
-
const disableColor = "#5b5959b5";
|
|
7625
|
-
function drawControllerBox(ctx, boxVertexes) {
|
|
7626
|
-
ctx.setLineDash([]);
|
|
7627
|
-
ctx.fillStyle = "#FFFFFF";
|
|
7628
|
-
ctx.beginPath();
|
|
7629
|
-
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
7630
|
-
ctx.lineTo(boxVertexes[1].x, boxVertexes[1].y);
|
|
7631
|
-
ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
|
|
7632
|
-
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
7633
|
-
ctx.closePath();
|
|
7634
|
-
ctx.fill();
|
|
7635
|
-
ctx.strokeStyle = selectColor;
|
|
7636
|
-
ctx.lineWidth = 2;
|
|
7637
|
-
ctx.beginPath();
|
|
7638
|
-
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
7639
|
-
ctx.lineTo(boxVertexes[1].x, boxVertexes[1].y);
|
|
7640
|
-
ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
|
|
7641
|
-
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
7642
|
-
ctx.closePath();
|
|
7643
|
-
ctx.stroke();
|
|
7644
|
-
}
|
|
7645
|
-
function drawControllerCross(ctx, opts) {
|
|
7646
|
-
const { vertexes, strokeStyle, lineWidth } = opts;
|
|
7647
|
-
ctx.setLineDash([]);
|
|
7648
|
-
ctx.strokeStyle = strokeStyle;
|
|
7649
|
-
ctx.lineWidth = lineWidth;
|
|
7650
|
-
ctx.beginPath();
|
|
7651
|
-
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
7652
|
-
ctx.lineTo(vertexes[2].x, vertexes[2].y);
|
|
7653
|
-
ctx.closePath();
|
|
7654
|
-
ctx.stroke();
|
|
7655
|
-
ctx.beginPath();
|
|
7656
|
-
ctx.moveTo(vertexes[1].x, vertexes[1].y);
|
|
7657
|
-
ctx.lineTo(vertexes[3].x, vertexes[3].y);
|
|
7658
|
-
ctx.closePath();
|
|
7659
|
-
ctx.stroke();
|
|
7660
|
-
}
|
|
7661
|
-
function drawControllerLine(ctx, opts) {
|
|
7662
|
-
const { start, end, centerVertexes, disabled } = opts;
|
|
7663
|
-
const lineWidth = disabled === true ? 1 : 2;
|
|
7664
|
-
const strokeStyle = disabled === true ? disableColor : selectColor;
|
|
7665
|
-
ctx.setLineDash([]);
|
|
7666
|
-
ctx.strokeStyle = strokeStyle;
|
|
7667
|
-
ctx.lineWidth = lineWidth;
|
|
7668
|
-
ctx.beginPath();
|
|
7669
|
-
ctx.moveTo(start.x, start.y);
|
|
7670
|
-
ctx.lineTo(end.x, end.y);
|
|
7671
|
-
ctx.closePath();
|
|
7672
|
-
ctx.stroke();
|
|
7673
|
-
if (disabled === true) {
|
|
7674
|
-
drawControllerCross(ctx, {
|
|
7675
|
-
vertexes: centerVertexes,
|
|
7676
|
-
lineWidth,
|
|
7677
|
-
strokeStyle
|
|
7678
|
-
});
|
|
7679
|
-
}
|
|
7680
|
-
}
|
|
7681
|
-
function drawLayoutController(ctx, opts) {
|
|
7682
|
-
const { controller, operations } = opts;
|
|
7683
|
-
const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, rightMiddle, bottomMiddle, leftMiddle } = controller;
|
|
7684
|
-
drawControllerLine(ctx, { start: topLeft.center, end: topRight.center, centerVertexes: topMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disabledTop) });
|
|
7685
|
-
drawControllerLine(ctx, { start: topRight.center, end: bottomRight.center, centerVertexes: rightMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disabledRight) });
|
|
7686
|
-
drawControllerLine(ctx, { start: bottomRight.center, end: bottomLeft.center, centerVertexes: bottomMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disabledBottom) });
|
|
7687
|
-
drawControllerLine(ctx, { start: bottomLeft.center, end: topLeft.center, centerVertexes: leftMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disabledLeft) });
|
|
7688
|
-
const disabledOpts = {
|
|
7689
|
-
lineWidth: 1,
|
|
7690
|
-
strokeStyle: disableColor
|
|
7691
|
-
};
|
|
7692
|
-
if ((operations == null ? void 0 : operations.disabledTopLeft) === true) {
|
|
7693
|
-
drawControllerCross(ctx, { vertexes: topLeft.vertexes, ...disabledOpts });
|
|
7694
|
-
} else {
|
|
7695
|
-
drawControllerBox(ctx, topLeft.vertexes);
|
|
7696
|
-
}
|
|
7697
|
-
if ((operations == null ? void 0 : operations.disabledTopRight) === true) {
|
|
7698
|
-
drawControllerCross(ctx, { vertexes: topRight.vertexes, ...disabledOpts });
|
|
7699
|
-
} else {
|
|
7700
|
-
drawControllerBox(ctx, topRight.vertexes);
|
|
7701
|
-
}
|
|
7702
|
-
if ((operations == null ? void 0 : operations.disabledBottomRight) === true) {
|
|
7703
|
-
drawControllerCross(ctx, { vertexes: bottomRight.vertexes, ...disabledOpts });
|
|
7704
|
-
} else {
|
|
7705
|
-
drawControllerBox(ctx, bottomRight.vertexes);
|
|
7706
|
-
}
|
|
7707
|
-
if ((operations == null ? void 0 : operations.disabledBottomLeft) === true) {
|
|
7708
|
-
drawControllerCross(ctx, { vertexes: bottomLeft.vertexes, ...disabledOpts });
|
|
7709
|
-
} else {
|
|
7710
|
-
drawControllerBox(ctx, bottomLeft.vertexes);
|
|
7711
|
-
}
|
|
7712
|
-
}
|
|
7713
|
-
const MiddlewareLayoutSelector = (opts) => {
|
|
7714
|
-
const { sharer, boardContent, calculator, viewer, eventHub } = opts;
|
|
7715
|
-
const { overlayContext } = boardContent;
|
|
7716
|
-
let prevPoint = null;
|
|
7717
|
-
const clear = () => {
|
|
7718
|
-
prevPoint = null;
|
|
7719
|
-
sharer.setSharedStorage(keyLayoutActionType, null);
|
|
7720
|
-
sharer.setSharedStorage(keyLayoutControlType, null);
|
|
7721
|
-
sharer.setSharedStorage(keyLayoutController, null);
|
|
7722
|
-
};
|
|
7723
|
-
const isInElementAction = () => {
|
|
7724
|
-
const elementType = sharer.getSharedStorage(keyActionType);
|
|
7725
|
-
if (elementType) {
|
|
7726
|
-
return true;
|
|
7727
|
-
}
|
|
7728
|
-
return false;
|
|
7729
|
-
};
|
|
7730
|
-
const isDisbaledControl = (controlType) => {
|
|
7731
|
-
var _a;
|
|
7732
|
-
const data = sharer.getActiveStorage("data");
|
|
7733
|
-
if ((_a = data == null ? void 0 : data.layout) == null ? void 0 : _a.operations) {
|
|
7734
|
-
const operations = data.layout.operations;
|
|
7735
|
-
if (controlType === "left" && operations.disabledLeft === true) {
|
|
7736
|
-
return true;
|
|
7737
|
-
}
|
|
7738
|
-
if (controlType === "top" && operations.disabledTop === true) {
|
|
7739
|
-
return true;
|
|
7740
|
-
}
|
|
7741
|
-
if (controlType === "right" && operations.disabledRight === true) {
|
|
7742
|
-
return true;
|
|
7743
|
-
}
|
|
7744
|
-
if (controlType === "bottom" && operations.disabledBottom === true) {
|
|
7745
|
-
return true;
|
|
7746
|
-
}
|
|
7747
|
-
if (controlType === "top-left" && operations.disabledTopLeft === true) {
|
|
7748
|
-
return true;
|
|
7749
|
-
}
|
|
7750
|
-
if (controlType === "top-right" && operations.disabledTopRight === true) {
|
|
7751
|
-
return true;
|
|
7752
|
-
}
|
|
7753
|
-
if (controlType === "bottom-left" && operations.disabledBottomLeft === true) {
|
|
7754
|
-
return true;
|
|
7755
|
-
}
|
|
7756
|
-
if (controlType === "bottom-right" && operations.disabledBottomRight === true) {
|
|
7757
|
-
return true;
|
|
7758
|
-
}
|
|
7759
|
-
}
|
|
7760
|
-
return false;
|
|
7761
|
-
};
|
|
7762
|
-
const getLayoutSize = () => {
|
|
7763
|
-
const data = sharer.getActiveStorage("data");
|
|
7764
|
-
if (data == null ? void 0 : data.layout) {
|
|
7765
|
-
const { x: x2, y: y2, w: w2, h: h2 } = data.layout;
|
|
7766
|
-
return { x: x2, y: y2, w: w2, h: h2 };
|
|
7767
|
-
}
|
|
7768
|
-
return null;
|
|
7769
|
-
};
|
|
7770
|
-
const resetController = () => {
|
|
7771
|
-
const viewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
7772
|
-
const size = getLayoutSize();
|
|
7773
|
-
if (size) {
|
|
7774
|
-
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize: 10 });
|
|
7775
|
-
sharer.setSharedStorage(keyLayoutController, controller);
|
|
7776
|
-
} else {
|
|
7777
|
-
sharer.setSharedStorage(keyLayoutController, null);
|
|
7778
|
-
}
|
|
7779
|
-
};
|
|
7780
|
-
const resetControlType = (e) => {
|
|
7781
|
-
const data = sharer.getActiveStorage("data");
|
|
7782
|
-
const controller = sharer.getSharedStorage(keyLayoutController);
|
|
7783
|
-
if (controller && (data == null ? void 0 : data.layout) && (e == null ? void 0 : e.point)) {
|
|
7784
|
-
let layoutControlType = null;
|
|
7785
|
-
if (controller) {
|
|
7786
|
-
const { topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left } = controller;
|
|
7787
|
-
const list = [topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left];
|
|
7788
|
-
for (let i = 0; i < list.length; i++) {
|
|
7789
|
-
const item = list[i];
|
|
7790
|
-
if (isViewPointInVertexes(e.point, item.vertexes)) {
|
|
7791
|
-
layoutControlType = `${item.type}`;
|
|
7792
|
-
break;
|
|
7793
|
-
}
|
|
7794
|
-
}
|
|
7795
|
-
if (layoutControlType) {
|
|
7796
|
-
sharer.setSharedStorage(keyLayoutControlType, layoutControlType);
|
|
7797
|
-
eventHub.trigger(middlewareEventSelectClear, {});
|
|
7798
|
-
return layoutControlType;
|
|
7799
|
-
}
|
|
7800
|
-
}
|
|
7801
|
-
}
|
|
7802
|
-
return null;
|
|
7803
|
-
};
|
|
7804
|
-
return {
|
|
7805
|
-
name: "@middleware/layout-selector",
|
|
7806
|
-
use: () => {
|
|
7807
|
-
clear();
|
|
7808
|
-
resetController();
|
|
7809
|
-
},
|
|
7810
|
-
hover: (e) => {
|
|
7811
|
-
if (isInElementAction()) {
|
|
7812
|
-
return;
|
|
7813
|
-
}
|
|
7814
|
-
const prevLayoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
7815
|
-
const data = sharer.getActiveStorage("data");
|
|
7816
|
-
if ((data == null ? void 0 : data.layout) && prevLayoutActionType !== "resize") {
|
|
7817
|
-
resetController();
|
|
7818
|
-
const layoutControlType = resetControlType(e);
|
|
7819
|
-
if (layoutControlType) {
|
|
7820
|
-
sharer.setSharedStorage(keyLayoutActionType, "hover");
|
|
7821
|
-
if (!isDisbaledControl(layoutControlType)) {
|
|
7822
|
-
eventHub.trigger("cursor", {
|
|
7823
|
-
type: `resize-${layoutControlType}`,
|
|
7824
|
-
groupQueue: [],
|
|
7825
|
-
element: getLayoutSize()
|
|
7826
|
-
});
|
|
7827
|
-
}
|
|
7828
|
-
viewer.drawFrame();
|
|
7829
|
-
} else {
|
|
7830
|
-
sharer.setSharedStorage(keyLayoutActionType, null);
|
|
7831
|
-
}
|
|
7832
|
-
}
|
|
7833
|
-
if (["hover", "resize"].includes(sharer.getSharedStorage(keyLayoutActionType))) {
|
|
7834
|
-
return false;
|
|
7835
|
-
}
|
|
7836
|
-
if (prevLayoutActionType === "hover" && !sharer.getSharedStorage(keyLayoutActionType)) {
|
|
7837
|
-
viewer.drawFrame();
|
|
7838
|
-
}
|
|
7839
|
-
},
|
|
7840
|
-
pointStart: (e) => {
|
|
7841
|
-
if (isInElementAction()) {
|
|
7842
|
-
return;
|
|
7843
|
-
}
|
|
7844
|
-
resetController();
|
|
7845
|
-
const layoutControlType = resetControlType(e);
|
|
7846
|
-
prevPoint = e.point;
|
|
7847
|
-
if (layoutControlType) {
|
|
7848
|
-
if (isDisbaledControl(layoutControlType)) {
|
|
7849
|
-
return;
|
|
7850
|
-
}
|
|
7851
|
-
sharer.setSharedStorage(keyLayoutActionType, "resize");
|
|
7852
|
-
return false;
|
|
7853
|
-
}
|
|
7854
|
-
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
7855
|
-
if (["hover", "resize"].includes(layoutActionType)) {
|
|
7856
|
-
return false;
|
|
7857
|
-
}
|
|
7858
|
-
},
|
|
7859
|
-
pointMove: (e) => {
|
|
7860
|
-
if (isInElementAction()) {
|
|
7861
|
-
return;
|
|
7862
|
-
}
|
|
7863
|
-
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
7864
|
-
const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
|
|
7865
|
-
const data = sharer.getActiveStorage("data");
|
|
7866
|
-
if (layoutControlType && isDisbaledControl(layoutControlType)) {
|
|
7867
|
-
return;
|
|
7868
|
-
}
|
|
7869
|
-
if (layoutActionType === "resize" && layoutControlType && (data == null ? void 0 : data.layout)) {
|
|
7870
|
-
if (prevPoint) {
|
|
7871
|
-
const scale = sharer.getActiveStorage("scale");
|
|
7872
|
-
const moveX = (e.point.x - prevPoint.x) / scale;
|
|
7873
|
-
const moveY = (e.point.y - prevPoint.y) / scale;
|
|
7874
|
-
const { x: x2, y: y2, w: w2, h: h2 } = data.layout;
|
|
7875
|
-
if (layoutControlType === "top") {
|
|
7876
|
-
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
7877
|
-
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
7878
|
-
} else if (layoutControlType === "right") {
|
|
7879
|
-
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
7880
|
-
} else if (layoutControlType === "bottom") {
|
|
7881
|
-
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
7882
|
-
} else if (layoutControlType === "left") {
|
|
7883
|
-
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
7884
|
-
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
7885
|
-
} else if (layoutControlType === "top-left") {
|
|
7886
|
-
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
7887
|
-
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
7888
|
-
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
7889
|
-
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
7890
|
-
} else if (layoutControlType === "top-right") {
|
|
7891
|
-
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
7892
|
-
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
7893
|
-
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
7894
|
-
} else if (layoutControlType === "bottom-right") {
|
|
7895
|
-
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
7896
|
-
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
7897
|
-
} else if (layoutControlType === "bottom-left") {
|
|
7898
|
-
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
7899
|
-
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
7900
|
-
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
7901
|
-
}
|
|
7902
|
-
}
|
|
7903
|
-
prevPoint = e.point;
|
|
7904
|
-
resetController();
|
|
7905
|
-
viewer.drawFrame();
|
|
7906
|
-
return false;
|
|
7907
|
-
}
|
|
7908
|
-
if (["hover", "resize"].includes(layoutActionType)) {
|
|
7909
|
-
return false;
|
|
7910
|
-
}
|
|
7911
|
-
},
|
|
7912
|
-
pointEnd: () => {
|
|
7913
|
-
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
7914
|
-
const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
|
|
7915
|
-
const data = sharer.getActiveStorage("data");
|
|
7916
|
-
if (data && layoutActionType === "resize" && layoutControlType && !isDisbaledControl(layoutControlType)) {
|
|
7917
|
-
eventHub.trigger(eventChange, {
|
|
7918
|
-
type: "changeLayout",
|
|
7919
|
-
data
|
|
7920
|
-
});
|
|
7921
|
-
}
|
|
7922
|
-
clear();
|
|
7923
|
-
},
|
|
7924
|
-
beforeDrawFrame: ({ snapshot }) => {
|
|
7925
|
-
var _a;
|
|
7926
|
-
const { sharedStore, activeStore } = snapshot;
|
|
7927
|
-
const layoutActionType = sharedStore[keyLayoutActionType];
|
|
7928
|
-
const layoutControlType = sharedStore[keyLayoutControlType];
|
|
7929
|
-
if (((_a = activeStore.data) == null ? void 0 : _a.layout) && layoutActionType && layoutControlType) {
|
|
7930
|
-
if (["hover", "resize"].includes(layoutActionType)) {
|
|
7931
|
-
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
7932
|
-
const { x: x2, y: y2, w: w2, h: h2 } = activeStore.data.layout;
|
|
7933
|
-
const size = { x: x2, y: y2, w: w2, h: h2 };
|
|
7934
|
-
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize: 10 });
|
|
7935
|
-
drawLayoutController(overlayContext, { controller, operations: activeStore.data.layout.operations || {} });
|
|
7936
|
-
}
|
|
7937
|
-
}
|
|
7938
|
-
},
|
|
7939
|
-
scrollX: () => {
|
|
7940
|
-
clear();
|
|
7941
|
-
},
|
|
7942
|
-
scrollY: () => {
|
|
7943
|
-
clear();
|
|
7944
|
-
},
|
|
7945
|
-
wheelScale: () => {
|
|
7946
|
-
clear();
|
|
7947
|
-
}
|
|
7948
|
-
};
|
|
7949
|
-
};
|
|
7950
8091
|
class Core {
|
|
7951
8092
|
constructor(container, opts) {
|
|
7952
8093
|
__privateAdd(this, _initContainer);
|