@idraw/core 0.4.0-beta.24 → 0.4.0-beta.26
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 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/middleware/selector/config.d.ts +2 -0
- package/dist/esm/middleware/selector/config.js +3 -1
- package/dist/esm/middleware/selector/index.d.ts +2 -2
- package/dist/esm/middleware/selector/index.js +46 -32
- package/dist/esm/middleware/selector/types.d.ts +2 -1
- package/dist/esm/middleware/selector/types.js +1 -1
- package/dist/esm/middleware/text-editor/index.js +22 -6
- package/dist/index.global.js +254 -71
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -1932,6 +1932,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1932
1932
|
fontSize: 16,
|
|
1933
1933
|
fontFamily: "sans-serif",
|
|
1934
1934
|
fontWeight: 400,
|
|
1935
|
+
minInlineSize: "auto",
|
|
1936
|
+
wordBreak: "break-all",
|
|
1935
1937
|
overflow: "hidden"
|
|
1936
1938
|
};
|
|
1937
1939
|
return config;
|
|
@@ -2084,6 +2086,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2084
2086
|
resizeElementBaseDetail(elem, opts);
|
|
2085
2087
|
return elem;
|
|
2086
2088
|
}
|
|
2089
|
+
const baseFontFamilyList = ["-apple-system", '"system-ui"', ' "Segoe UI"', " Roboto", '"Helvetica Neue"', "Arial", '"Noto Sans"', " sans-serif"];
|
|
2090
|
+
function enhanceFontFamliy(fontFamily2) {
|
|
2091
|
+
return [fontFamily2, ...baseFontFamilyList].join(", ");
|
|
2092
|
+
}
|
|
2087
2093
|
function createColorStyle(ctx, color2, opts) {
|
|
2088
2094
|
if (typeof color2 === "string") {
|
|
2089
2095
|
return color2;
|
|
@@ -2140,19 +2146,36 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2140
2146
|
const { pattern, renderContent, originElem, calcElemSize, viewScaleInfo, viewSizeInfo } = opts || {};
|
|
2141
2147
|
const { parentOpacity } = opts;
|
|
2142
2148
|
const opacity = getOpacity(originElem) * parentOpacity;
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
viewScaleInfo,
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2149
|
+
const { clipPath, clipPathStrokeColor, clipPathStrokeWidth } = originElem.detail;
|
|
2150
|
+
const mainRender = () => {
|
|
2151
|
+
ctx.globalAlpha = opacity;
|
|
2152
|
+
drawBoxBackground(ctx, viewElem, { pattern, viewScaleInfo, viewSizeInfo });
|
|
2153
|
+
renderContent === null || renderContent === void 0 ? void 0 : renderContent();
|
|
2154
|
+
drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
2155
|
+
ctx.globalAlpha = parentOpacity;
|
|
2156
|
+
};
|
|
2157
|
+
if (clipPath) {
|
|
2158
|
+
drawClipPath(ctx, viewElem, {
|
|
2159
|
+
originElem,
|
|
2160
|
+
calcElemSize,
|
|
2161
|
+
viewScaleInfo,
|
|
2162
|
+
viewSizeInfo,
|
|
2163
|
+
renderContent: () => {
|
|
2164
|
+
mainRender();
|
|
2165
|
+
}
|
|
2166
|
+
});
|
|
2167
|
+
if (typeof clipPathStrokeWidth === "number" && clipPathStrokeWidth > 0 && clipPathStrokeColor) {
|
|
2168
|
+
drawClipPathStroke(ctx, viewElem, {
|
|
2169
|
+
originElem,
|
|
2170
|
+
calcElemSize,
|
|
2171
|
+
viewScaleInfo,
|
|
2172
|
+
viewSizeInfo,
|
|
2173
|
+
parentOpacity
|
|
2174
|
+
});
|
|
2154
2175
|
}
|
|
2155
|
-
}
|
|
2176
|
+
} else {
|
|
2177
|
+
mainRender();
|
|
2178
|
+
}
|
|
2156
2179
|
}
|
|
2157
2180
|
function drawClipPath(ctx, viewElem, opts) {
|
|
2158
2181
|
const { renderContent, originElem, calcElemSize, viewSizeInfo } = opts;
|
|
@@ -2183,6 +2206,38 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2183
2206
|
renderContent === null || renderContent === void 0 ? void 0 : renderContent();
|
|
2184
2207
|
}
|
|
2185
2208
|
}
|
|
2209
|
+
function drawClipPathStroke(ctx, viewElem, opts) {
|
|
2210
|
+
const { renderContent, originElem, calcElemSize, viewSizeInfo, parentOpacity } = opts;
|
|
2211
|
+
const totalScale = viewSizeInfo.devicePixelRatio;
|
|
2212
|
+
const { clipPath, clipPathStrokeColor, clipPathStrokeWidth } = (originElem === null || originElem === void 0 ? void 0 : originElem.detail) || {};
|
|
2213
|
+
if (clipPath && calcElemSize && clipPath.commands && typeof clipPathStrokeWidth === "number" && clipPathStrokeWidth > 0 && clipPathStrokeColor) {
|
|
2214
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcElemSize;
|
|
2215
|
+
const { originW, originH, originX, originY } = clipPath;
|
|
2216
|
+
const scaleW = w2 / originW;
|
|
2217
|
+
const scaleH = h2 / originH;
|
|
2218
|
+
const viewOriginX = originX * scaleW;
|
|
2219
|
+
const viewOriginY = originY * scaleH;
|
|
2220
|
+
const internalX = x2 - viewOriginX;
|
|
2221
|
+
const internalY = y2 - viewOriginY;
|
|
2222
|
+
ctx.save();
|
|
2223
|
+
ctx.globalAlpha = parentOpacity;
|
|
2224
|
+
ctx.translate(internalX, internalY);
|
|
2225
|
+
ctx.scale(totalScale * scaleW, totalScale * scaleH);
|
|
2226
|
+
const pathStr = generateSVGPath(clipPath.commands || []);
|
|
2227
|
+
const path2d = new Path2D(pathStr);
|
|
2228
|
+
ctx.strokeStyle = clipPathStrokeColor;
|
|
2229
|
+
ctx.lineWidth = clipPathStrokeWidth;
|
|
2230
|
+
ctx.stroke(path2d);
|
|
2231
|
+
ctx.translate(0 - internalX, 0 - internalY);
|
|
2232
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
2233
|
+
rotateElement$1(ctx, Object.assign({}, viewElem), () => {
|
|
2234
|
+
renderContent === null || renderContent === void 0 ? void 0 : renderContent();
|
|
2235
|
+
});
|
|
2236
|
+
ctx.restore();
|
|
2237
|
+
} else {
|
|
2238
|
+
renderContent === null || renderContent === void 0 ? void 0 : renderContent();
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2186
2241
|
function drawBoxBackground(ctx, viewElem, opts) {
|
|
2187
2242
|
var _a, _b;
|
|
2188
2243
|
const { pattern, viewScaleInfo, viewSizeInfo } = opts;
|
|
@@ -2465,7 +2520,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2465
2520
|
}
|
|
2466
2521
|
function drawRect(ctx, elem, opts) {
|
|
2467
2522
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2468
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
2523
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
2469
2524
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2470
2525
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2471
2526
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -2601,6 +2656,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2601
2656
|
});
|
|
2602
2657
|
}
|
|
2603
2658
|
const detailConfig = getDefaultElementDetailConfig();
|
|
2659
|
+
function isTextWidthWithinErrorRange(w0, w1, scale) {
|
|
2660
|
+
if (scale < 0.5) {
|
|
2661
|
+
if (w0 < w1 && (w0 - w1) / w0 > -0.15) {
|
|
2662
|
+
return true;
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
return w0 >= w1;
|
|
2666
|
+
}
|
|
2604
2667
|
function drawText(ctx, elem, opts) {
|
|
2605
2668
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2606
2669
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
@@ -2616,6 +2679,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2616
2679
|
const detail = Object.assign(Object.assign({}, detailConfig), elem.detail);
|
|
2617
2680
|
const originFontSize = detail.fontSize || detailConfig.fontSize;
|
|
2618
2681
|
const fontSize2 = originFontSize * viewScaleInfo.scale;
|
|
2682
|
+
if (fontSize2 < 2) {
|
|
2683
|
+
return;
|
|
2684
|
+
}
|
|
2619
2685
|
const originLineHeight = detail.lineHeight || originFontSize;
|
|
2620
2686
|
const lineHeight2 = originLineHeight * viewScaleInfo.scale;
|
|
2621
2687
|
ctx.fillStyle = elem.detail.color || detailConfig.color;
|
|
@@ -2623,7 +2689,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2623
2689
|
ctx.$setFont({
|
|
2624
2690
|
fontWeight: detail.fontWeight,
|
|
2625
2691
|
fontSize: fontSize2,
|
|
2626
|
-
fontFamily: detail.fontFamily
|
|
2692
|
+
fontFamily: enhanceFontFamliy(detail.fontFamily)
|
|
2627
2693
|
});
|
|
2628
2694
|
let detailText = detail.text.replace(/\r\n/gi, "\n");
|
|
2629
2695
|
if (detail.textTransform === "lowercase") {
|
|
@@ -2635,30 +2701,48 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2635
2701
|
const detailTextList = detailText.split("\n");
|
|
2636
2702
|
const lines = [];
|
|
2637
2703
|
let lineNum = 0;
|
|
2638
|
-
detailTextList.forEach((
|
|
2704
|
+
detailTextList.forEach((itemText, idx) => {
|
|
2639
2705
|
if (detail.minInlineSize === "maxContent") {
|
|
2640
2706
|
lines.push({
|
|
2641
|
-
text:
|
|
2642
|
-
width: ctx.$undoPixelRatio(ctx.measureText(
|
|
2707
|
+
text: itemText,
|
|
2708
|
+
width: ctx.$undoPixelRatio(ctx.measureText(itemText).width)
|
|
2643
2709
|
});
|
|
2644
2710
|
} else {
|
|
2645
2711
|
let lineText = "";
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2712
|
+
let splitStr = "";
|
|
2713
|
+
let tempStrList = itemText.split(splitStr);
|
|
2714
|
+
if (detail.wordBreak === "normal") {
|
|
2715
|
+
const splitStr2 = " ";
|
|
2716
|
+
const wordList = itemText.split(splitStr2);
|
|
2717
|
+
tempStrList = [];
|
|
2718
|
+
wordList.forEach((word, idx2) => {
|
|
2719
|
+
tempStrList.push(word);
|
|
2720
|
+
if (idx2 < wordList.length - 1) {
|
|
2721
|
+
tempStrList.push(splitStr2);
|
|
2722
|
+
}
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
if (tempStrList.length === 1 && detail.overflow === "visible") {
|
|
2726
|
+
lines.push({
|
|
2727
|
+
text: tempStrList[0],
|
|
2728
|
+
width: ctx.$undoPixelRatio(ctx.measureText(tempStrList[0]).width)
|
|
2729
|
+
});
|
|
2730
|
+
} else if (tempStrList.length > 0) {
|
|
2731
|
+
for (let i = 0; i < tempStrList.length; i++) {
|
|
2732
|
+
if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(w2), ctx.measureText(lineText + tempStrList[i]).width, viewScaleInfo.scale)) {
|
|
2733
|
+
lineText += tempStrList[i] || "";
|
|
2650
2734
|
} else {
|
|
2651
2735
|
lines.push({
|
|
2652
2736
|
text: lineText,
|
|
2653
2737
|
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2654
2738
|
});
|
|
2655
|
-
lineText =
|
|
2739
|
+
lineText = tempStrList[i] || "";
|
|
2656
2740
|
lineNum++;
|
|
2657
2741
|
}
|
|
2658
|
-
if ((lineNum + 1) * fontHeight > h2) {
|
|
2742
|
+
if ((lineNum + 1) * fontHeight > h2 && detail.overflow === "hidden") {
|
|
2659
2743
|
break;
|
|
2660
2744
|
}
|
|
2661
|
-
if (
|
|
2745
|
+
if (tempStrList.length - 1 === i) {
|
|
2662
2746
|
if ((lineNum + 1) * fontHeight <= h2) {
|
|
2663
2747
|
lines.push({
|
|
2664
2748
|
text: lineText,
|
|
@@ -2680,6 +2764,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2680
2764
|
}
|
|
2681
2765
|
});
|
|
2682
2766
|
let startY = 0;
|
|
2767
|
+
let eachLineStartY = 0;
|
|
2768
|
+
if (fontHeight > fontSize2) {
|
|
2769
|
+
eachLineStartY = (fontHeight - fontSize2) / 2;
|
|
2770
|
+
}
|
|
2683
2771
|
if (lines.length * fontHeight < h2) {
|
|
2684
2772
|
if (elem.detail.verticalAlign === "top") {
|
|
2685
2773
|
startY = 0;
|
|
@@ -2710,14 +2798,27 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2710
2798
|
} else if (detail.textAlign === "right") {
|
|
2711
2799
|
_x = x2 + (w2 - line.width);
|
|
2712
2800
|
}
|
|
2713
|
-
ctx.fillText(line.text, _x, _y + fontHeight * i);
|
|
2801
|
+
ctx.fillText(line.text, _x, _y + fontHeight * i + eachLineStartY);
|
|
2714
2802
|
});
|
|
2715
2803
|
}
|
|
2716
2804
|
}
|
|
2717
2805
|
});
|
|
2718
2806
|
});
|
|
2719
2807
|
}
|
|
2808
|
+
var __rest = function(s, e) {
|
|
2809
|
+
var t = {};
|
|
2810
|
+
for (var p in s)
|
|
2811
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2812
|
+
t[p] = s[p];
|
|
2813
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2814
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2815
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2816
|
+
t[p[i]] = s[p[i]];
|
|
2817
|
+
}
|
|
2818
|
+
return t;
|
|
2819
|
+
};
|
|
2720
2820
|
function drawPath(ctx, elem, opts) {
|
|
2821
|
+
var _a, _b;
|
|
2721
2822
|
const { detail } = elem;
|
|
2722
2823
|
const { originX, originY, originW, originH, fillRule } = detail;
|
|
2723
2824
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
@@ -2728,11 +2829,31 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2728
2829
|
const viewOriginY = originY * scaleH;
|
|
2729
2830
|
const internalX = x2 - viewOriginX;
|
|
2730
2831
|
const internalY = y2 - viewOriginY;
|
|
2832
|
+
const _c = elem.detail, restDetail = __rest(_c, ["clipPath", "clipPathStrokeColor", "clipPathStrokeWidth"]);
|
|
2731
2833
|
const scaleNum = viewScaleInfo.scale * viewSizeInfo.devicePixelRatio;
|
|
2732
2834
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2835
|
+
let boxViewElem = Object.assign({}, viewElem);
|
|
2836
|
+
boxViewElem.detail = restDetail;
|
|
2837
|
+
let boxOriginElem = Object.assign({}, elem);
|
|
2838
|
+
boxOriginElem.detail = restDetail;
|
|
2839
|
+
if (detail.fill && detail.fill !== "string" && ((_b = (_a = detail.fill) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.includes("gradient"))) {
|
|
2840
|
+
boxViewElem = Object.assign(Object.assign({}, viewElem), {
|
|
2841
|
+
detail: Object.assign(Object.assign({}, viewElem.detail), {
|
|
2842
|
+
background: detail.fill,
|
|
2843
|
+
clipPath: {
|
|
2844
|
+
commands: detail.commands,
|
|
2845
|
+
originX,
|
|
2846
|
+
originY,
|
|
2847
|
+
originW,
|
|
2848
|
+
originH
|
|
2849
|
+
}
|
|
2850
|
+
})
|
|
2851
|
+
});
|
|
2852
|
+
boxOriginElem.detail = Object.assign({}, boxViewElem.detail);
|
|
2853
|
+
}
|
|
2733
2854
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2734
|
-
drawBox(ctx,
|
|
2735
|
-
originElem:
|
|
2855
|
+
drawBox(ctx, boxViewElem, {
|
|
2856
|
+
originElem: boxOriginElem,
|
|
2736
2857
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2737
2858
|
viewScaleInfo,
|
|
2738
2859
|
viewSizeInfo,
|
|
@@ -2748,7 +2869,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2748
2869
|
const pathStr = generateSVGPath(detail.commands || []);
|
|
2749
2870
|
const path2d = new Path2D(pathStr);
|
|
2750
2871
|
if (detail.fill) {
|
|
2751
|
-
|
|
2872
|
+
if (typeof detail.fill === "string") {
|
|
2873
|
+
ctx.fillStyle = detail.fill;
|
|
2874
|
+
} else {
|
|
2875
|
+
ctx.fillStyle = "transparent";
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
if (detail.fill) {
|
|
2752
2879
|
ctx.fill(path2d, fillRule);
|
|
2753
2880
|
}
|
|
2754
2881
|
if (detail.stroke && detail.strokeWidth !== 0) {
|
|
@@ -2765,14 +2892,19 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2765
2892
|
});
|
|
2766
2893
|
});
|
|
2767
2894
|
}
|
|
2895
|
+
const visiableMinSize = 0.4;
|
|
2768
2896
|
function drawElement(ctx, elem, opts) {
|
|
2769
|
-
var _a;
|
|
2897
|
+
var _a, _b, _c;
|
|
2770
2898
|
if (((_a = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _a === void 0 ? void 0 : _a.invisible) === true) {
|
|
2771
2899
|
return;
|
|
2772
2900
|
}
|
|
2773
2901
|
const { w: w2, h: h2 } = elem;
|
|
2774
2902
|
const { scale } = opts.viewScaleInfo;
|
|
2775
|
-
if (scale < 1 && (w2 * scale <
|
|
2903
|
+
if (scale < 1 && (w2 * scale < visiableMinSize || h2 * scale < visiableMinSize) || opts.parentOpacity === 0) {
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
const { overrideElementMap } = opts;
|
|
2907
|
+
if ((_c = (_b = overrideElementMap === null || overrideElementMap === void 0 ? void 0 : overrideElementMap[elem.uuid]) === null || _b === void 0 ? void 0 : _b.operations) === null || _c === void 0 ? void 0 : _c.invisible) {
|
|
2776
2908
|
return;
|
|
2777
2909
|
}
|
|
2778
2910
|
try {
|
|
@@ -2820,7 +2952,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2820
2952
|
}
|
|
2821
2953
|
function drawGroup(ctx, elem, opts) {
|
|
2822
2954
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2823
|
-
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
|
|
2955
|
+
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 }) || elem;
|
|
2824
2956
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2825
2957
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2826
2958
|
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
@@ -2917,7 +3049,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2917
3049
|
function drawLayout(ctx, layout, opts, renderContent) {
|
|
2918
3050
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2919
3051
|
const elem = Object.assign({ uuid: "layout", type: "group" }, layout);
|
|
2920
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
3052
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
2921
3053
|
const angle2 = 0;
|
|
2922
3054
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2923
3055
|
ctx.globalAlpha = 1;
|
|
@@ -2931,7 +3063,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2931
3063
|
if (layout.detail.overflow === "hidden") {
|
|
2932
3064
|
const { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 } = opts;
|
|
2933
3065
|
const elem2 = Object.assign({ uuid: "layout", type: "group" }, layout);
|
|
2934
|
-
const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2
|
|
3066
|
+
const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2 }) || elem2;
|
|
2935
3067
|
const viewElem2 = Object.assign(Object.assign({}, elem2), viewElemSize);
|
|
2936
3068
|
const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem2, {
|
|
2937
3069
|
viewScaleInfo: viewScaleInfo2,
|
|
@@ -2956,6 +3088,15 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2956
3088
|
drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
2957
3089
|
ctx.globalAlpha = parentOpacity;
|
|
2958
3090
|
}
|
|
3091
|
+
function drawGlobalBackground(ctx, global, opts) {
|
|
3092
|
+
if (typeof (global === null || global === void 0 ? void 0 : global.background) === "string") {
|
|
3093
|
+
const { viewSizeInfo } = opts;
|
|
3094
|
+
const { width, height } = viewSizeInfo;
|
|
3095
|
+
ctx.globalAlpha = 1;
|
|
3096
|
+
ctx.fillStyle = global.background;
|
|
3097
|
+
ctx.fillRect(0, 0, width, height);
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
2959
3100
|
var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
2960
3101
|
function adopt(value) {
|
|
2961
3102
|
return value instanceof P ? value : new P(function(resolve) {
|
|
@@ -3222,7 +3363,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3222
3363
|
}
|
|
3223
3364
|
drawData(data, opts) {
|
|
3224
3365
|
const loader = __classPrivateFieldGet$5(this, _Renderer_loader, "f");
|
|
3225
|
-
const { calculator } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
|
|
3366
|
+
const { calculator, sharer } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
|
|
3226
3367
|
const viewContext = __classPrivateFieldGet$5(this, _Renderer_opts, "f").viewContext;
|
|
3227
3368
|
viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
|
|
3228
3369
|
const parentElementSize = {
|
|
@@ -3236,8 +3377,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3236
3377
|
calculator,
|
|
3237
3378
|
parentElementSize,
|
|
3238
3379
|
elementAssets: data.assets,
|
|
3239
|
-
parentOpacity: 1
|
|
3380
|
+
parentOpacity: 1,
|
|
3381
|
+
overrideElementMap: sharer === null || sharer === void 0 ? void 0 : sharer.getActiveOverrideElemenentMap()
|
|
3240
3382
|
}, opts);
|
|
3383
|
+
drawGlobalBackground(viewContext, data.global, drawOpts);
|
|
3241
3384
|
if (data.layout) {
|
|
3242
3385
|
drawLayout(viewContext, data.layout, drawOpts, () => {
|
|
3243
3386
|
drawElementList(viewContext, data, drawOpts);
|
|
@@ -3665,7 +3808,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3665
3808
|
offsetLeft: 0,
|
|
3666
3809
|
offsetRight: 0,
|
|
3667
3810
|
offsetTop: 0,
|
|
3668
|
-
offsetBottom: 0
|
|
3811
|
+
offsetBottom: 0,
|
|
3812
|
+
overrideElementMap: null
|
|
3669
3813
|
};
|
|
3670
3814
|
class Sharer {
|
|
3671
3815
|
constructor() {
|
|
@@ -3733,6 +3877,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3733
3877
|
};
|
|
3734
3878
|
return sizeInfo;
|
|
3735
3879
|
}
|
|
3880
|
+
getActiveOverrideElemenentMap() {
|
|
3881
|
+
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("overrideElementMap");
|
|
3882
|
+
}
|
|
3883
|
+
setActiveOverrideElemenentMap(map) {
|
|
3884
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("overrideElementMap", map);
|
|
3885
|
+
}
|
|
3736
3886
|
}
|
|
3737
3887
|
_Sharer_activeStore = /* @__PURE__ */ new WeakMap(), _Sharer_sharedStore = /* @__PURE__ */ new WeakMap();
|
|
3738
3888
|
var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
|
|
@@ -4405,7 +4555,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4405
4555
|
const keyGroupQueue = Symbol(`${key$3}_groupQueue`);
|
|
4406
4556
|
const keyGroupQueueVertexesList = Symbol(`${key$3}_groupQueueVertexesList`);
|
|
4407
4557
|
const keyIsMoving = Symbol(`${key$3}_isMoving`);
|
|
4408
|
-
const keyEnableSelectInGroup = Symbol(`${key$3}
|
|
4558
|
+
const keyEnableSelectInGroup = Symbol(`${key$3}_enableSelectInGroup`);
|
|
4559
|
+
const keyEnableSnapToGrid = Symbol(`${key$3}_enableSnapToGrid`);
|
|
4409
4560
|
const selectWrapperBorderWidth = 2;
|
|
4410
4561
|
const resizeControllerBorderWidth = 4;
|
|
4411
4562
|
const areaBorderWidth = 1;
|
|
@@ -4416,6 +4567,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4416
4567
|
const middlewareEventSelect = "@middleware/select";
|
|
4417
4568
|
const middlewareEventSelectClear = "@middleware/select-clear";
|
|
4418
4569
|
const middlewareEventSelectInGroup = "@middleware/select-in-group";
|
|
4570
|
+
const middlewareEventSnapToGrid = "@middleware/snap-to-grid";
|
|
4419
4571
|
function drawVertexes(ctx, vertexes, opts) {
|
|
4420
4572
|
const { borderColor: borderColor2, borderWidth: borderWidth2, background: background2, lineDash } = opts;
|
|
4421
4573
|
ctx.setLineDash([]);
|
|
@@ -5669,7 +5821,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5669
5821
|
const middlewareEventTextChange = "@middleware/text-change";
|
|
5670
5822
|
const defaultElementDetail = getDefaultElementDetailConfig();
|
|
5671
5823
|
const MiddlewareTextEditor = (opts) => {
|
|
5672
|
-
const { eventHub, boardContent, viewer } = opts;
|
|
5824
|
+
const { eventHub, boardContent, viewer, sharer } = opts;
|
|
5673
5825
|
const canvas = boardContent.boardContext.canvas;
|
|
5674
5826
|
const textarea = document.createElement("div");
|
|
5675
5827
|
textarea.setAttribute("contenteditable", "true");
|
|
@@ -5692,8 +5844,24 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5692
5844
|
resetCanvasWrapper();
|
|
5693
5845
|
resetTextArea(e);
|
|
5694
5846
|
mask.style.display = "block";
|
|
5847
|
+
if (activeElem == null ? void 0 : activeElem.uuid) {
|
|
5848
|
+
sharer.setActiveOverrideElemenentMap({
|
|
5849
|
+
[activeElem.uuid]: {
|
|
5850
|
+
operations: { invisible: true }
|
|
5851
|
+
}
|
|
5852
|
+
});
|
|
5853
|
+
viewer.drawFrame();
|
|
5854
|
+
}
|
|
5695
5855
|
};
|
|
5696
5856
|
const hideTextArea = () => {
|
|
5857
|
+
if (activeElem == null ? void 0 : activeElem.uuid) {
|
|
5858
|
+
const map = sharer.getActiveOverrideElemenentMap();
|
|
5859
|
+
if (map) {
|
|
5860
|
+
delete map[activeElem.uuid];
|
|
5861
|
+
}
|
|
5862
|
+
sharer.setActiveOverrideElemenentMap(map);
|
|
5863
|
+
viewer.drawFrame();
|
|
5864
|
+
}
|
|
5697
5865
|
mask.style.display = "none";
|
|
5698
5866
|
activeElem = null;
|
|
5699
5867
|
activePosition = [];
|
|
@@ -5783,11 +5951,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5783
5951
|
textarea.style.resize = "none";
|
|
5784
5952
|
textarea.style.overflow = "hidden";
|
|
5785
5953
|
textarea.style.wordBreak = "break-all";
|
|
5786
|
-
textarea.style.background = "
|
|
5787
|
-
textarea.style.color = "#333333"
|
|
5954
|
+
textarea.style.background = "transparent";
|
|
5955
|
+
textarea.style.color = `${detail.color || "#333333"}`;
|
|
5788
5956
|
textarea.style.fontSize = `${detail.fontSize * scale}px`;
|
|
5789
|
-
textarea.style.lineHeight = `${detail.lineHeight * scale}px`;
|
|
5790
|
-
textarea.style.fontFamily = detail.fontFamily;
|
|
5957
|
+
textarea.style.lineHeight = `${(detail.lineHeight || detail.fontSize) * scale}px`;
|
|
5958
|
+
textarea.style.fontFamily = enhanceFontFamliy(detail.fontFamily);
|
|
5791
5959
|
textarea.style.fontWeight = `${detail.fontWeight}`;
|
|
5792
5960
|
textarea.style.padding = "0";
|
|
5793
5961
|
textarea.style.margin = "0";
|
|
@@ -5876,6 +6044,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5876
6044
|
let prevPoint = null;
|
|
5877
6045
|
let inBusyMode = null;
|
|
5878
6046
|
sharer.setSharedStorage(keyActionType, null);
|
|
6047
|
+
sharer.setSharedStorage(keyEnableSnapToGrid, true);
|
|
5879
6048
|
const getActiveElements = () => {
|
|
5880
6049
|
return sharer.getSharedStorage(keySelectedElementList);
|
|
5881
6050
|
};
|
|
@@ -5988,6 +6157,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5988
6157
|
clear();
|
|
5989
6158
|
viewer.drawFrame();
|
|
5990
6159
|
};
|
|
6160
|
+
const setSnapToSnapCallback = (e) => {
|
|
6161
|
+
sharer.setSharedStorage(keyEnableSnapToGrid, !!e.enable);
|
|
6162
|
+
};
|
|
5991
6163
|
const selectInGroupCallback = (e) => {
|
|
5992
6164
|
sharer.setSharedStorage(keyEnableSelectInGroup, !!e.enable);
|
|
5993
6165
|
};
|
|
@@ -5997,11 +6169,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5997
6169
|
eventHub.on(middlewareEventSelect, selectCallback);
|
|
5998
6170
|
eventHub.on(middlewareEventSelectClear, selectClearCallback);
|
|
5999
6171
|
eventHub.on(middlewareEventSelectInGroup, selectInGroupCallback);
|
|
6172
|
+
eventHub.on(middlewareEventSnapToGrid, setSnapToSnapCallback);
|
|
6000
6173
|
},
|
|
6001
6174
|
disuse() {
|
|
6002
6175
|
eventHub.off(middlewareEventSelect, selectCallback);
|
|
6003
6176
|
eventHub.off(middlewareEventSelectClear, selectClearCallback);
|
|
6004
6177
|
eventHub.off(middlewareEventSelectInGroup, selectInGroupCallback);
|
|
6178
|
+
eventHub.off(middlewareEventSnapToGrid, setSnapToSnapCallback);
|
|
6005
6179
|
},
|
|
6006
6180
|
hover: (e) => {
|
|
6007
6181
|
var _a, _b, _c, _d, _e;
|
|
@@ -6169,32 +6343,35 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6169
6343
|
const resizeType = sharer.getSharedStorage(keyResizeType);
|
|
6170
6344
|
const actionType = sharer.getSharedStorage(keyActionType);
|
|
6171
6345
|
const groupQueue = sharer.getSharedStorage(keyGroupQueue);
|
|
6346
|
+
const enableSnapToGrid = sharer.getSharedStorage(keyEnableSnapToGrid);
|
|
6172
6347
|
if (actionType === "drag") {
|
|
6173
6348
|
inBusyMode = "drag";
|
|
6174
6349
|
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) {
|
|
6175
6350
|
const { moveX, moveY } = calcMoveInGroup(start, end, groupQueue);
|
|
6176
6351
|
let totalMoveX = calculator.toGridNum(moveX / scale);
|
|
6177
6352
|
let totalMoveY = calculator.toGridNum(moveY / scale);
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
if (
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6353
|
+
if (enableSnapToGrid === true) {
|
|
6354
|
+
const referenceInfo = calcReferenceInfo(elems[0].uuid, {
|
|
6355
|
+
calculator,
|
|
6356
|
+
data,
|
|
6357
|
+
groupQueue,
|
|
6358
|
+
viewScaleInfo,
|
|
6359
|
+
viewSizeInfo
|
|
6360
|
+
});
|
|
6361
|
+
try {
|
|
6362
|
+
if (referenceInfo) {
|
|
6363
|
+
if (is.x(referenceInfo.offsetX) && referenceInfo.offsetX !== null) {
|
|
6364
|
+
totalMoveX = calculator.toGridNum(totalMoveX + referenceInfo.offsetX);
|
|
6365
|
+
}
|
|
6366
|
+
if (is.y(referenceInfo.offsetY) && referenceInfo.offsetY !== null) {
|
|
6367
|
+
totalMoveY = calculator.toGridNum(totalMoveY + referenceInfo.offsetY);
|
|
6368
|
+
}
|
|
6369
|
+
sharer.setSharedStorage(keySelectedReferenceXLines, referenceInfo.xLines);
|
|
6370
|
+
sharer.setSharedStorage(keySelectedReferenceYLines, referenceInfo.yLines);
|
|
6192
6371
|
}
|
|
6193
|
-
|
|
6194
|
-
|
|
6372
|
+
} catch (err) {
|
|
6373
|
+
console.error(err);
|
|
6195
6374
|
}
|
|
6196
|
-
} catch (err) {
|
|
6197
|
-
console.error(err);
|
|
6198
6375
|
}
|
|
6199
6376
|
elems[0].x = calculator.toGridNum(elems[0].x + totalMoveX);
|
|
6200
6377
|
elems[0].y = calculator.toGridNum(elems[0].y + totalMoveY);
|
|
@@ -6390,7 +6567,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6390
6567
|
viewer.drawFrame();
|
|
6391
6568
|
},
|
|
6392
6569
|
doubleClick(e) {
|
|
6393
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6570
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6394
6571
|
if (sharer.getSharedStorage(keyEnableSelectInGroup) === false) {
|
|
6395
6572
|
return;
|
|
6396
6573
|
}
|
|
@@ -6407,11 +6584,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6407
6584
|
viewer.drawFrame();
|
|
6408
6585
|
return;
|
|
6409
6586
|
}
|
|
6410
|
-
} else if (target.elements.length === 1 && ((_d = target.elements[0]) == null ? void 0 : _d.type) === "text") {
|
|
6587
|
+
} else if (target.elements.length === 1 && ((_d = target.elements[0]) == null ? void 0 : _d.type) === "text" && !((_f = (_e = target.elements[0]) == null ? void 0 : _e.operations) == null ? void 0 : _f.invisible)) {
|
|
6411
6588
|
eventHub.trigger(middlewareEventTextEdit, {
|
|
6412
6589
|
element: target.elements[0],
|
|
6413
6590
|
groupQueue: sharer.getSharedStorage(keyGroupQueue) || [],
|
|
6414
|
-
position: getElementPositionFromList((
|
|
6591
|
+
position: getElementPositionFromList((_g = target.elements[0]) == null ? void 0 : _g.uuid, ((_h = sharer.getActiveStorage("data")) == null ? void 0 : _h.elements) || []),
|
|
6415
6592
|
viewScaleInfo: sharer.getActiveViewScaleInfo()
|
|
6416
6593
|
});
|
|
6417
6594
|
}
|
|
@@ -6434,6 +6611,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6434
6611
|
const groupQueue = sharedStore[keyGroupQueue];
|
|
6435
6612
|
const groupQueueVertexesList = sharedStore[keyGroupQueueVertexesList];
|
|
6436
6613
|
const isMoving = sharedStore[keyIsMoving];
|
|
6614
|
+
const enableSnapToGrid = sharedStore[keyEnableSnapToGrid];
|
|
6437
6615
|
const drawBaseOpts = { calculator, viewScaleInfo, viewSizeInfo };
|
|
6438
6616
|
const selectedElementController = elem ? calcElementSizeController(elem, {
|
|
6439
6617
|
groupQueue,
|
|
@@ -6467,10 +6645,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6467
6645
|
if (actionType === "drag") {
|
|
6468
6646
|
const xLines = sharer2.getSharedStorage(keySelectedReferenceXLines);
|
|
6469
6647
|
const yLines = sharer2.getSharedStorage(keySelectedReferenceYLines);
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6648
|
+
if (enableSnapToGrid === true) {
|
|
6649
|
+
drawReferenceLines(overlayContext, {
|
|
6650
|
+
xLines,
|
|
6651
|
+
yLines
|
|
6652
|
+
});
|
|
6653
|
+
}
|
|
6474
6654
|
}
|
|
6475
6655
|
}
|
|
6476
6656
|
} else {
|
|
@@ -6498,10 +6678,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6498
6678
|
if (actionType === "drag") {
|
|
6499
6679
|
const xLines = sharer2.getSharedStorage(keySelectedReferenceXLines);
|
|
6500
6680
|
const yLines = sharer2.getSharedStorage(keySelectedReferenceYLines);
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6681
|
+
if (enableSnapToGrid === true) {
|
|
6682
|
+
drawReferenceLines(overlayContext, {
|
|
6683
|
+
xLines,
|
|
6684
|
+
yLines
|
|
6685
|
+
});
|
|
6686
|
+
}
|
|
6505
6687
|
}
|
|
6506
6688
|
} else if (actionType === "area" && areaStart && areaEnd) {
|
|
6507
6689
|
drawArea(overlayContext, { start: areaStart, end: areaEnd });
|
|
@@ -7858,6 +8040,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
7858
8040
|
exports.middlewareEventSelect = middlewareEventSelect;
|
|
7859
8041
|
exports.middlewareEventSelectClear = middlewareEventSelectClear;
|
|
7860
8042
|
exports.middlewareEventSelectInGroup = middlewareEventSelectInGroup;
|
|
8043
|
+
exports.middlewareEventSnapToGrid = middlewareEventSnapToGrid;
|
|
7861
8044
|
exports.middlewareEventTextChange = middlewareEventTextChange;
|
|
7862
8045
|
exports.middlewareEventTextEdit = middlewareEventTextEdit;
|
|
7863
8046
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|