@idraw/core 0.4.0-beta.24 → 0.4.0-beta.25
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.
|
@@ -553,7 +553,7 @@ export const MiddlewareSelector = (opts) => {
|
|
|
553
553
|
viewer.drawFrame();
|
|
554
554
|
},
|
|
555
555
|
doubleClick(e) {
|
|
556
|
-
var _a, _b, _c, _d, _e, _f;
|
|
556
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
557
557
|
if (sharer.getSharedStorage(keyEnableSelectInGroup) === false) {
|
|
558
558
|
return;
|
|
559
559
|
}
|
|
@@ -571,11 +571,11 @@ export const MiddlewareSelector = (opts) => {
|
|
|
571
571
|
return;
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
else if (target.elements.length === 1 && ((_d = target.elements[0]) === null || _d === void 0 ? void 0 : _d.type) === 'text') {
|
|
574
|
+
else if (target.elements.length === 1 && ((_d = target.elements[0]) === null || _d === void 0 ? void 0 : _d.type) === 'text' && !((_f = (_e = target.elements[0]) === null || _e === void 0 ? void 0 : _e.operations) === null || _f === void 0 ? void 0 : _f.invisible)) {
|
|
575
575
|
eventHub.trigger(middlewareEventTextEdit, {
|
|
576
576
|
element: target.elements[0],
|
|
577
577
|
groupQueue: sharer.getSharedStorage(keyGroupQueue) || [],
|
|
578
|
-
position: getElementPositionFromList((
|
|
578
|
+
position: getElementPositionFromList((_g = target.elements[0]) === null || _g === void 0 ? void 0 : _g.uuid, ((_h = sharer.getActiveStorage('data')) === null || _h === void 0 ? void 0 : _h.elements) || []),
|
|
579
579
|
viewScaleInfo: sharer.getActiveViewScaleInfo()
|
|
580
580
|
});
|
|
581
581
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { limitAngle, getDefaultElementDetailConfig } from '@idraw/util';
|
|
1
|
+
import { limitAngle, getDefaultElementDetailConfig, enhanceFontFamliy } from '@idraw/util';
|
|
2
2
|
export const middlewareEventTextEdit = '@middleware/text-edit';
|
|
3
3
|
export const middlewareEventTextChange = '@middleware/text-change';
|
|
4
4
|
const defaultElementDetail = getDefaultElementDetailConfig();
|
|
5
5
|
export const MiddlewareTextEditor = (opts) => {
|
|
6
|
-
const { eventHub, boardContent, viewer } = opts;
|
|
6
|
+
const { eventHub, boardContent, viewer, sharer } = opts;
|
|
7
7
|
const canvas = boardContent.boardContext.canvas;
|
|
8
8
|
const textarea = document.createElement('div');
|
|
9
9
|
textarea.setAttribute('contenteditable', 'true');
|
|
@@ -26,8 +26,24 @@ export const MiddlewareTextEditor = (opts) => {
|
|
|
26
26
|
resetCanvasWrapper();
|
|
27
27
|
resetTextArea(e);
|
|
28
28
|
mask.style.display = 'block';
|
|
29
|
+
if (activeElem === null || activeElem === void 0 ? void 0 : activeElem.uuid) {
|
|
30
|
+
sharer.setActiveOverrideElemenentMap({
|
|
31
|
+
[activeElem.uuid]: {
|
|
32
|
+
operations: { invisible: true }
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
viewer.drawFrame();
|
|
36
|
+
}
|
|
29
37
|
};
|
|
30
38
|
const hideTextArea = () => {
|
|
39
|
+
if (activeElem === null || activeElem === void 0 ? void 0 : activeElem.uuid) {
|
|
40
|
+
const map = sharer.getActiveOverrideElemenentMap();
|
|
41
|
+
if (map) {
|
|
42
|
+
delete map[activeElem.uuid];
|
|
43
|
+
}
|
|
44
|
+
sharer.setActiveOverrideElemenentMap(map);
|
|
45
|
+
viewer.drawFrame();
|
|
46
|
+
}
|
|
31
47
|
mask.style.display = 'none';
|
|
32
48
|
activeElem = null;
|
|
33
49
|
activePosition = [];
|
|
@@ -116,11 +132,11 @@ export const MiddlewareTextEditor = (opts) => {
|
|
|
116
132
|
textarea.style.resize = 'none';
|
|
117
133
|
textarea.style.overflow = 'hidden';
|
|
118
134
|
textarea.style.wordBreak = 'break-all';
|
|
119
|
-
textarea.style.background = '
|
|
120
|
-
textarea.style.color = '#333333'
|
|
135
|
+
textarea.style.background = 'transparent';
|
|
136
|
+
textarea.style.color = `${detail.color || '#333333'}`;
|
|
121
137
|
textarea.style.fontSize = `${detail.fontSize * scale}px`;
|
|
122
|
-
textarea.style.lineHeight = `${detail.lineHeight * scale}px`;
|
|
123
|
-
textarea.style.fontFamily = detail.fontFamily;
|
|
138
|
+
textarea.style.lineHeight = `${(detail.lineHeight || detail.fontSize) * scale}px`;
|
|
139
|
+
textarea.style.fontFamily = enhanceFontFamliy(detail.fontFamily);
|
|
124
140
|
textarea.style.fontWeight = `${detail.fontWeight}`;
|
|
125
141
|
textarea.style.padding = '0';
|
|
126
142
|
textarea.style.margin = '0';
|
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;
|
|
@@ -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,7 +2798,7 @@ 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
|
}
|
|
@@ -2766,7 +2854,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2766
2854
|
});
|
|
2767
2855
|
}
|
|
2768
2856
|
function drawElement(ctx, elem, opts) {
|
|
2769
|
-
var _a;
|
|
2857
|
+
var _a, _b, _c;
|
|
2770
2858
|
if (((_a = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _a === void 0 ? void 0 : _a.invisible) === true) {
|
|
2771
2859
|
return;
|
|
2772
2860
|
}
|
|
@@ -2775,6 +2863,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2775
2863
|
if (scale < 1 && (w2 * scale < 1 || h2 * scale < 1) || opts.parentOpacity === 0) {
|
|
2776
2864
|
return;
|
|
2777
2865
|
}
|
|
2866
|
+
const { overrideElementMap } = opts;
|
|
2867
|
+
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) {
|
|
2868
|
+
return;
|
|
2869
|
+
}
|
|
2778
2870
|
try {
|
|
2779
2871
|
switch (elem.type) {
|
|
2780
2872
|
case "rect": {
|
|
@@ -2820,7 +2912,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2820
2912
|
}
|
|
2821
2913
|
function drawGroup(ctx, elem, opts) {
|
|
2822
2914
|
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
|
|
2915
|
+
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
2916
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2825
2917
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2826
2918
|
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
@@ -2917,7 +3009,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2917
3009
|
function drawLayout(ctx, layout, opts, renderContent) {
|
|
2918
3010
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2919
3011
|
const elem = Object.assign({ uuid: "layout", type: "group" }, layout);
|
|
2920
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
3012
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
2921
3013
|
const angle2 = 0;
|
|
2922
3014
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2923
3015
|
ctx.globalAlpha = 1;
|
|
@@ -2931,7 +3023,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2931
3023
|
if (layout.detail.overflow === "hidden") {
|
|
2932
3024
|
const { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 } = opts;
|
|
2933
3025
|
const elem2 = Object.assign({ uuid: "layout", type: "group" }, layout);
|
|
2934
|
-
const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2
|
|
3026
|
+
const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2 }) || elem2;
|
|
2935
3027
|
const viewElem2 = Object.assign(Object.assign({}, elem2), viewElemSize);
|
|
2936
3028
|
const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem2, {
|
|
2937
3029
|
viewScaleInfo: viewScaleInfo2,
|
|
@@ -2956,6 +3048,15 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2956
3048
|
drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
2957
3049
|
ctx.globalAlpha = parentOpacity;
|
|
2958
3050
|
}
|
|
3051
|
+
function drawGlobalBackground(ctx, global, opts) {
|
|
3052
|
+
if (typeof (global === null || global === void 0 ? void 0 : global.background) === "string") {
|
|
3053
|
+
const { viewSizeInfo } = opts;
|
|
3054
|
+
const { width, height } = viewSizeInfo;
|
|
3055
|
+
ctx.globalAlpha = 1;
|
|
3056
|
+
ctx.fillStyle = global.background;
|
|
3057
|
+
ctx.fillRect(0, 0, width, height);
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
2959
3060
|
var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
2960
3061
|
function adopt(value) {
|
|
2961
3062
|
return value instanceof P ? value : new P(function(resolve) {
|
|
@@ -3222,7 +3323,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3222
3323
|
}
|
|
3223
3324
|
drawData(data, opts) {
|
|
3224
3325
|
const loader = __classPrivateFieldGet$5(this, _Renderer_loader, "f");
|
|
3225
|
-
const { calculator } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
|
|
3326
|
+
const { calculator, sharer } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
|
|
3226
3327
|
const viewContext = __classPrivateFieldGet$5(this, _Renderer_opts, "f").viewContext;
|
|
3227
3328
|
viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
|
|
3228
3329
|
const parentElementSize = {
|
|
@@ -3236,8 +3337,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3236
3337
|
calculator,
|
|
3237
3338
|
parentElementSize,
|
|
3238
3339
|
elementAssets: data.assets,
|
|
3239
|
-
parentOpacity: 1
|
|
3340
|
+
parentOpacity: 1,
|
|
3341
|
+
overrideElementMap: sharer === null || sharer === void 0 ? void 0 : sharer.getActiveOverrideElemenentMap()
|
|
3240
3342
|
}, opts);
|
|
3343
|
+
drawGlobalBackground(viewContext, data.global, drawOpts);
|
|
3241
3344
|
if (data.layout) {
|
|
3242
3345
|
drawLayout(viewContext, data.layout, drawOpts, () => {
|
|
3243
3346
|
drawElementList(viewContext, data, drawOpts);
|
|
@@ -3665,7 +3768,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3665
3768
|
offsetLeft: 0,
|
|
3666
3769
|
offsetRight: 0,
|
|
3667
3770
|
offsetTop: 0,
|
|
3668
|
-
offsetBottom: 0
|
|
3771
|
+
offsetBottom: 0,
|
|
3772
|
+
overrideElementMap: null
|
|
3669
3773
|
};
|
|
3670
3774
|
class Sharer {
|
|
3671
3775
|
constructor() {
|
|
@@ -3733,6 +3837,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3733
3837
|
};
|
|
3734
3838
|
return sizeInfo;
|
|
3735
3839
|
}
|
|
3840
|
+
getActiveOverrideElemenentMap() {
|
|
3841
|
+
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("overrideElementMap");
|
|
3842
|
+
}
|
|
3843
|
+
setActiveOverrideElemenentMap(map) {
|
|
3844
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("overrideElementMap", map);
|
|
3845
|
+
}
|
|
3736
3846
|
}
|
|
3737
3847
|
_Sharer_activeStore = /* @__PURE__ */ new WeakMap(), _Sharer_sharedStore = /* @__PURE__ */ new WeakMap();
|
|
3738
3848
|
var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
|
|
@@ -5669,7 +5779,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5669
5779
|
const middlewareEventTextChange = "@middleware/text-change";
|
|
5670
5780
|
const defaultElementDetail = getDefaultElementDetailConfig();
|
|
5671
5781
|
const MiddlewareTextEditor = (opts) => {
|
|
5672
|
-
const { eventHub, boardContent, viewer } = opts;
|
|
5782
|
+
const { eventHub, boardContent, viewer, sharer } = opts;
|
|
5673
5783
|
const canvas = boardContent.boardContext.canvas;
|
|
5674
5784
|
const textarea = document.createElement("div");
|
|
5675
5785
|
textarea.setAttribute("contenteditable", "true");
|
|
@@ -5692,8 +5802,24 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5692
5802
|
resetCanvasWrapper();
|
|
5693
5803
|
resetTextArea(e);
|
|
5694
5804
|
mask.style.display = "block";
|
|
5805
|
+
if (activeElem == null ? void 0 : activeElem.uuid) {
|
|
5806
|
+
sharer.setActiveOverrideElemenentMap({
|
|
5807
|
+
[activeElem.uuid]: {
|
|
5808
|
+
operations: { invisible: true }
|
|
5809
|
+
}
|
|
5810
|
+
});
|
|
5811
|
+
viewer.drawFrame();
|
|
5812
|
+
}
|
|
5695
5813
|
};
|
|
5696
5814
|
const hideTextArea = () => {
|
|
5815
|
+
if (activeElem == null ? void 0 : activeElem.uuid) {
|
|
5816
|
+
const map = sharer.getActiveOverrideElemenentMap();
|
|
5817
|
+
if (map) {
|
|
5818
|
+
delete map[activeElem.uuid];
|
|
5819
|
+
}
|
|
5820
|
+
sharer.setActiveOverrideElemenentMap(map);
|
|
5821
|
+
viewer.drawFrame();
|
|
5822
|
+
}
|
|
5697
5823
|
mask.style.display = "none";
|
|
5698
5824
|
activeElem = null;
|
|
5699
5825
|
activePosition = [];
|
|
@@ -5783,11 +5909,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5783
5909
|
textarea.style.resize = "none";
|
|
5784
5910
|
textarea.style.overflow = "hidden";
|
|
5785
5911
|
textarea.style.wordBreak = "break-all";
|
|
5786
|
-
textarea.style.background = "
|
|
5787
|
-
textarea.style.color = "#333333"
|
|
5912
|
+
textarea.style.background = "transparent";
|
|
5913
|
+
textarea.style.color = `${detail.color || "#333333"}`;
|
|
5788
5914
|
textarea.style.fontSize = `${detail.fontSize * scale}px`;
|
|
5789
|
-
textarea.style.lineHeight = `${detail.lineHeight * scale}px`;
|
|
5790
|
-
textarea.style.fontFamily = detail.fontFamily;
|
|
5915
|
+
textarea.style.lineHeight = `${(detail.lineHeight || detail.fontSize) * scale}px`;
|
|
5916
|
+
textarea.style.fontFamily = enhanceFontFamliy(detail.fontFamily);
|
|
5791
5917
|
textarea.style.fontWeight = `${detail.fontWeight}`;
|
|
5792
5918
|
textarea.style.padding = "0";
|
|
5793
5919
|
textarea.style.margin = "0";
|
|
@@ -6390,7 +6516,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6390
6516
|
viewer.drawFrame();
|
|
6391
6517
|
},
|
|
6392
6518
|
doubleClick(e) {
|
|
6393
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6519
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6394
6520
|
if (sharer.getSharedStorage(keyEnableSelectInGroup) === false) {
|
|
6395
6521
|
return;
|
|
6396
6522
|
}
|
|
@@ -6407,11 +6533,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6407
6533
|
viewer.drawFrame();
|
|
6408
6534
|
return;
|
|
6409
6535
|
}
|
|
6410
|
-
} else if (target.elements.length === 1 && ((_d = target.elements[0]) == null ? void 0 : _d.type) === "text") {
|
|
6536
|
+
} 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
6537
|
eventHub.trigger(middlewareEventTextEdit, {
|
|
6412
6538
|
element: target.elements[0],
|
|
6413
6539
|
groupQueue: sharer.getSharedStorage(keyGroupQueue) || [],
|
|
6414
|
-
position: getElementPositionFromList((
|
|
6540
|
+
position: getElementPositionFromList((_g = target.elements[0]) == null ? void 0 : _g.uuid, ((_h = sharer.getActiveStorage("data")) == null ? void 0 : _h.elements) || []),
|
|
6415
6541
|
viewScaleInfo: sharer.getActiveViewScaleInfo()
|
|
6416
6542
|
});
|
|
6417
6543
|
}
|