@idraw/core 0.4.0-beta.44 → 0.4.0-beta.45
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/board/index.js
CHANGED
|
@@ -189,25 +189,33 @@ export class Board {
|
|
|
189
189
|
return __classPrivateFieldGet(this, _Board_eventHub, "f");
|
|
190
190
|
}
|
|
191
191
|
onWatcherEvents() {
|
|
192
|
+
if (__classPrivateFieldGet(this, _Board_opts, "f").disableWatcher === true) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
192
195
|
__classPrivateFieldGet(this, _Board_watcher, "f").onEvents();
|
|
193
196
|
}
|
|
194
197
|
offWatcherEvents() {
|
|
198
|
+
if (__classPrivateFieldGet(this, _Board_opts, "f").disableWatcher === true) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
195
201
|
__classPrivateFieldGet(this, _Board_watcher, "f").offEvents();
|
|
196
202
|
}
|
|
197
203
|
}
|
|
198
204
|
_Board_opts = new WeakMap(), _Board_middlewareMap = new WeakMap(), _Board_activeMiddlewareObjs = new WeakMap(), _Board_watcher = new WeakMap(), _Board_renderer = new WeakMap(), _Board_sharer = new WeakMap(), _Board_viewer = new WeakMap(), _Board_calculator = new WeakMap(), _Board_eventHub = new WeakMap(), _Board_hasDestroyed = new WeakMap(), _Board_instances = new WeakSet(), _Board_init = function _Board_init() {
|
|
199
|
-
__classPrivateFieldGet(this,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
if (__classPrivateFieldGet(this, _Board_opts, "f").disableWatcher !== true) {
|
|
206
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('pointStart', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointStart).bind(this));
|
|
207
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('pointEnd', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointEnd).bind(this));
|
|
208
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('pointMove', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointMove).bind(this));
|
|
209
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('pointLeave', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointLeave).bind(this));
|
|
210
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('hover', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleHover).bind(this));
|
|
211
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('wheel', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheel).bind(this));
|
|
212
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('wheelScale', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheelScale).bind(this));
|
|
213
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('scrollX', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleScrollX).bind(this));
|
|
214
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('scrollY', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleScrollY).bind(this));
|
|
215
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('resize', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleResize).bind(this));
|
|
216
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('doubleClick', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleDoubleClick).bind(this));
|
|
217
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on('contextMenu', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleContextMenu).bind(this));
|
|
218
|
+
}
|
|
211
219
|
__classPrivateFieldGet(this, _Board_renderer, "f").on('load', () => {
|
|
212
220
|
__classPrivateFieldGet(this, _Board_eventHub, "f").trigger('loadResource');
|
|
213
221
|
});
|
package/dist/esm/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export class Core {
|
|
|
43
43
|
_Core_board.set(this, void 0);
|
|
44
44
|
_Core_canvas.set(this, void 0);
|
|
45
45
|
_Core_container.set(this, void 0);
|
|
46
|
-
const { devicePixelRatio = 1, width, height } = opts;
|
|
46
|
+
const { devicePixelRatio = 1, width, height, disableWatcher = false } = opts;
|
|
47
47
|
__classPrivateFieldSet(this, _Core_container, container, "f");
|
|
48
48
|
const canvas = document.createElement('canvas');
|
|
49
49
|
canvas.setAttribute('tabindex', '0');
|
|
@@ -51,7 +51,7 @@ export class Core {
|
|
|
51
51
|
__classPrivateFieldGet(this, _Core_instances, "m", _Core_initContainer).call(this);
|
|
52
52
|
container.appendChild(canvas);
|
|
53
53
|
const boardContent = createBoardContent(canvas, { width, height, devicePixelRatio });
|
|
54
|
-
const board = new Board({ boardContent, container });
|
|
54
|
+
const board = new Board({ boardContent, container, disableWatcher });
|
|
55
55
|
const sharer = board.getSharer();
|
|
56
56
|
sharer.setActiveViewSizeInfo({
|
|
57
57
|
width,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcElementSizeController, calcElementCenterFromVertexes, rotatePointInGroup, getGroupQueueFromList, findElementsFromList, findElementsFromListByPositions, getElementPositionFromList, getElementPositionMapFromList,
|
|
1
|
+
import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcElementSizeController, calcElementCenterFromVertexes, rotatePointInGroup, getGroupQueueFromList, findElementsFromList, findElementsFromListByPositions, getElementPositionFromList, getElementPositionMapFromList, resizeEffectGroupElement, getElementSize, calcPointMoveElementInGroup, isSameElementSize, toFlattenElement } from '@idraw/util';
|
|
2
2
|
import { drawHoverVertexesWrapper, drawLockedVertexesWrapper, drawArea, drawListArea, drawGroupQueueVertexesWrappers, drawSelectedElementControllersVertexes } from './draw-wrapper';
|
|
3
3
|
import { drawReferenceLines } from './draw-reference';
|
|
4
4
|
import { getPointTarget, resizeElement, rotateElement, getSelectedListArea, calcSelectedElementsArea, isElementInGroup, isPointInViewActiveGroup } from './util';
|
|
@@ -503,17 +503,25 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
503
503
|
else {
|
|
504
504
|
const resizedElemSize = resizeElement(Object.assign(Object.assign({}, moveOriginalStartElementSize), { operations: elems[0].operations }), { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
|
|
505
505
|
const calcOpts = { ignore: !!moveOriginalStartElementSize.angle };
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
506
|
+
const gridX = calculator.toGridNum(resizedElemSize.x, calcOpts);
|
|
507
|
+
const gridY = calculator.toGridNum(resizedElemSize.y, calcOpts);
|
|
508
|
+
const gridW = calculator.toGridNum(resizedElemSize.w, calcOpts);
|
|
509
|
+
const gridH = calculator.toGridNum(resizedElemSize.h, calcOpts);
|
|
510
|
+
if (elems[0].type === 'group') {
|
|
511
|
+
resizeEffectGroupElement(elems[0], {
|
|
512
|
+
x: gridX,
|
|
513
|
+
y: gridY,
|
|
514
|
+
w: gridW,
|
|
515
|
+
h: gridH
|
|
516
|
+
}, { resizeEffect: (_c = elems[0].operations) === null || _c === void 0 ? void 0 : _c.resizeEffect });
|
|
517
|
+
elems[0].x = gridX;
|
|
518
|
+
elems[0].y = gridY;
|
|
513
519
|
}
|
|
514
520
|
else {
|
|
515
|
-
elems[0].
|
|
516
|
-
elems[0].
|
|
521
|
+
elems[0].x = gridX;
|
|
522
|
+
elems[0].y = gridY;
|
|
523
|
+
elems[0].w = gridW;
|
|
524
|
+
elems[0].h = gridH;
|
|
517
525
|
}
|
|
518
526
|
}
|
|
519
527
|
updateSelectedElementList([elems[0]]);
|
|
@@ -61,6 +61,7 @@ export function getPointTarget(p, opts) {
|
|
|
61
61
|
if (selectedElements && (selectedElements === null || selectedElements === void 0 ? void 0 : selectedElements.length) > 0) {
|
|
62
62
|
target.groupQueue = groupQueue || [];
|
|
63
63
|
target.elements = [selectedElements[0]];
|
|
64
|
+
return target;
|
|
64
65
|
}
|
|
65
66
|
break;
|
|
66
67
|
}
|
package/dist/index.global.js
CHANGED
|
@@ -2135,94 +2135,247 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2135
2135
|
const doNum = (n) => {
|
|
2136
2136
|
return formatNumber(n, { decimalPlaces: 4 });
|
|
2137
2137
|
};
|
|
2138
|
-
function
|
|
2138
|
+
function resizeElementBaseDetailByRatio(elem, opts) {
|
|
2139
|
+
const beforeElem = { detail: {} };
|
|
2140
|
+
const afterElem = { detail: {} };
|
|
2141
|
+
const record = {
|
|
2142
|
+
type: "modifyElement",
|
|
2143
|
+
time: Date.now(),
|
|
2144
|
+
content: {
|
|
2145
|
+
method: "modifyElement",
|
|
2146
|
+
uuid: elem.uuid,
|
|
2147
|
+
before: null,
|
|
2148
|
+
after: null
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2139
2151
|
const { detail } = elem;
|
|
2140
2152
|
const { xRatio, yRatio, maxRatio } = opts;
|
|
2141
2153
|
const middleRatio = (xRatio + yRatio) / 2;
|
|
2142
2154
|
const { borderWidth: borderWidth2, borderRadius: borderRadius2, borderDash, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
|
|
2143
2155
|
if (typeof borderWidth2 === "number") {
|
|
2144
2156
|
detail.borderWidth = doNum(borderWidth2 * middleRatio);
|
|
2157
|
+
beforeElem.detail.borderWidth = borderWidth2;
|
|
2158
|
+
afterElem.detail.borderWidth = detail.borderWidth;
|
|
2145
2159
|
} else if (Array.isArray(detail.borderWidth)) {
|
|
2146
2160
|
const bw = borderWidth2;
|
|
2147
2161
|
detail.borderWidth = [doNum(bw[0] * yRatio), doNum(bw[1] * xRatio), doNum(bw[2] * yRatio), doNum(bw[3] * xRatio)];
|
|
2162
|
+
beforeElem.detail.borderWidth = [...bw];
|
|
2163
|
+
afterElem.detail.borderWidth = [...detail.borderWidth];
|
|
2148
2164
|
}
|
|
2149
2165
|
if (typeof borderRadius2 === "number") {
|
|
2150
2166
|
detail.borderRadius = doNum(borderRadius2 * middleRatio);
|
|
2167
|
+
beforeElem.detail.borderRadius = borderRadius2;
|
|
2168
|
+
afterElem.detail.borderRadius = detail.borderRadius;
|
|
2151
2169
|
} else if (Array.isArray(detail.borderRadius)) {
|
|
2152
2170
|
const br = borderRadius2;
|
|
2153
2171
|
detail.borderRadius = [br[0] * xRatio, br[1] * xRatio, br[2] * yRatio, br[3] * yRatio];
|
|
2172
|
+
beforeElem.detail.borderRadius = [...br];
|
|
2173
|
+
afterElem.detail.borderRadius = [...detail.borderRadius];
|
|
2154
2174
|
}
|
|
2155
2175
|
if (Array.isArray(borderDash)) {
|
|
2156
2176
|
borderDash.forEach((dash, i) => {
|
|
2157
2177
|
detail.borderDash[i] = doNum(dash * maxRatio);
|
|
2158
2178
|
});
|
|
2179
|
+
beforeElem.detail.borderDash = [...borderDash];
|
|
2180
|
+
afterElem.detail.borderDash = [...detail.borderDash];
|
|
2159
2181
|
}
|
|
2160
2182
|
if (typeof shadowOffsetX === "number") {
|
|
2161
2183
|
detail.shadowOffsetX = doNum(shadowOffsetX * maxRatio);
|
|
2184
|
+
beforeElem.detail.shadowOffsetX = shadowOffsetX;
|
|
2185
|
+
afterElem.detail.shadowOffsetX = detail.shadowOffsetX;
|
|
2162
2186
|
}
|
|
2163
2187
|
if (typeof shadowOffsetY === "number") {
|
|
2164
|
-
detail.
|
|
2188
|
+
detail.shadowOffsetY = doNum(shadowOffsetY * maxRatio);
|
|
2189
|
+
beforeElem.detail.shadowOffsetY = shadowOffsetY;
|
|
2190
|
+
afterElem.detail.shadowOffsetY = detail.shadowOffsetY;
|
|
2165
2191
|
}
|
|
2166
2192
|
if (typeof shadowBlur === "number") {
|
|
2167
|
-
detail.
|
|
2193
|
+
detail.shadowBlur = doNum(shadowBlur * maxRatio);
|
|
2194
|
+
beforeElem.detail.shadowBlur = shadowBlur;
|
|
2195
|
+
afterElem.detail.shadowBlur = detail.shadowBlur;
|
|
2168
2196
|
}
|
|
2197
|
+
record.content.before = toFlattenElement(beforeElem);
|
|
2198
|
+
record.content.after = toFlattenElement(afterElem);
|
|
2199
|
+
return record;
|
|
2169
2200
|
}
|
|
2170
|
-
function
|
|
2201
|
+
function resizeElementBaseByRatio(elem, opts) {
|
|
2171
2202
|
const { xRatio, yRatio } = opts;
|
|
2172
|
-
const { x: x2, y: y2, w: w2, h: h2 } = elem;
|
|
2203
|
+
const { uuid, x: x2, y: y2, w: w2, h: h2 } = elem;
|
|
2204
|
+
const record = {
|
|
2205
|
+
type: "modifyElement",
|
|
2206
|
+
time: Date.now(),
|
|
2207
|
+
content: {
|
|
2208
|
+
method: "modifyElement",
|
|
2209
|
+
uuid,
|
|
2210
|
+
before: { x: x2, y: y2, w: w2, h: h2 },
|
|
2211
|
+
after: { x: x2, y: y2, w: w2, h: h2 }
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2173
2214
|
elem.x = doNum(x2 * xRatio);
|
|
2174
2215
|
elem.y = doNum(y2 * yRatio);
|
|
2175
2216
|
elem.w = doNum(w2 * xRatio);
|
|
2176
2217
|
elem.h = doNum(h2 * yRatio);
|
|
2177
|
-
|
|
2218
|
+
const detailRecord = resizeElementBaseDetailByRatio(elem, opts);
|
|
2219
|
+
record.content.before = Object.assign(Object.assign({}, record.content.before), detailRecord.content.before);
|
|
2220
|
+
record.content.after = Object.assign(Object.assign({}, record.content.after), detailRecord.content.after);
|
|
2221
|
+
return record;
|
|
2178
2222
|
}
|
|
2179
|
-
function
|
|
2223
|
+
function resizeTextElementDetailByRatio(elem, opts) {
|
|
2180
2224
|
const { minRatio, maxRatio } = opts;
|
|
2181
2225
|
const { fontSize: fontSize2, lineHeight: lineHeight2 } = elem.detail;
|
|
2182
2226
|
const ratio = (minRatio + maxRatio) / 2;
|
|
2227
|
+
const beforeFlattenElem = {};
|
|
2228
|
+
const afterFlattenElem = {};
|
|
2183
2229
|
if (fontSize2 && fontSize2 > 0) {
|
|
2184
2230
|
elem.detail.fontSize = doNum(fontSize2 * ratio);
|
|
2231
|
+
beforeFlattenElem["detail.fontSize"] = fontSize2;
|
|
2232
|
+
afterFlattenElem["detail.fontSize"] = elem.detail.fontSize;
|
|
2185
2233
|
}
|
|
2186
2234
|
if (lineHeight2 && lineHeight2 > 0) {
|
|
2187
2235
|
elem.detail.lineHeight = doNum(lineHeight2 * ratio);
|
|
2236
|
+
beforeFlattenElem["detail.lineHeight"] = lineHeight2;
|
|
2237
|
+
afterFlattenElem["detail.lineHeight"] = elem.detail.lineHeight;
|
|
2188
2238
|
}
|
|
2239
|
+
const record = {
|
|
2240
|
+
type: "modifyElement",
|
|
2241
|
+
time: Date.now(),
|
|
2242
|
+
content: {
|
|
2243
|
+
method: "modifyElement",
|
|
2244
|
+
uuid: elem.uuid,
|
|
2245
|
+
before: beforeFlattenElem,
|
|
2246
|
+
after: afterFlattenElem
|
|
2247
|
+
}
|
|
2248
|
+
};
|
|
2249
|
+
return record;
|
|
2189
2250
|
}
|
|
2190
|
-
function
|
|
2191
|
-
const { type } = elem;
|
|
2192
|
-
|
|
2251
|
+
function deepResizeElementByRatio(elem, opts, record) {
|
|
2252
|
+
const { type, uuid } = elem;
|
|
2253
|
+
const rootRecord = resizeElementBaseByRatio(elem, opts);
|
|
2254
|
+
const rootRecordBefore = Object.assign(Object.assign({}, rootRecord.content.before), { uuid });
|
|
2255
|
+
const rootRecordAfter = Object.assign(Object.assign({}, rootRecord.content.after), { uuid });
|
|
2256
|
+
record === null || record === void 0 ? void 0 : record.content.before.push(rootRecordBefore);
|
|
2257
|
+
record === null || record === void 0 ? void 0 : record.content.after.push(rootRecordAfter);
|
|
2193
2258
|
if (type === "circle") ;
|
|
2194
2259
|
else if (type === "text") {
|
|
2195
|
-
|
|
2260
|
+
const textRecord = resizeTextElementDetailByRatio(elem, opts);
|
|
2261
|
+
Object.keys(textRecord.content.before || {}).forEach((key2) => {
|
|
2262
|
+
var _a;
|
|
2263
|
+
rootRecordBefore[key2] = (_a = textRecord.content.before) === null || _a === void 0 ? void 0 : _a[key2];
|
|
2264
|
+
});
|
|
2265
|
+
Object.keys(textRecord.content.after || {}).forEach((key2) => {
|
|
2266
|
+
var _a;
|
|
2267
|
+
rootRecordAfter[key2] = (_a = textRecord.content.after) === null || _a === void 0 ? void 0 : _a[key2];
|
|
2268
|
+
});
|
|
2196
2269
|
} else if (type === "image") ;
|
|
2197
2270
|
else if (type === "svg") ;
|
|
2198
2271
|
else if (type === "html") ;
|
|
2199
2272
|
else if (type === "path") ;
|
|
2200
2273
|
else if (type === "group" && Array.isArray(elem.detail.children)) {
|
|
2201
2274
|
elem.detail.children.forEach((child) => {
|
|
2202
|
-
|
|
2275
|
+
deepResizeElementByRatio(child, opts, record);
|
|
2203
2276
|
});
|
|
2204
2277
|
}
|
|
2205
2278
|
}
|
|
2206
|
-
function
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
const xRatio = resizeW / elem.w;
|
|
2210
|
-
const yRatio = resizeH / elem.h;
|
|
2211
|
-
if (xRatio === yRatio && xRatio === 1) {
|
|
2212
|
-
return elem;
|
|
2279
|
+
function fixedResizeGroupElementChildren(elem, opts, record) {
|
|
2280
|
+
if (!(elem.type === "group" && Array.isArray(elem.detail.children))) {
|
|
2281
|
+
return;
|
|
2213
2282
|
}
|
|
2214
|
-
const
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2283
|
+
const { moveX, moveY, moveH, moveW } = opts;
|
|
2284
|
+
let childChangedX = 0;
|
|
2285
|
+
let childChangedY = 0;
|
|
2286
|
+
let needReszieChildren = false;
|
|
2287
|
+
if ((moveX !== 0 || moveY !== 0) && (moveH !== 0 || moveW !== 0)) {
|
|
2288
|
+
needReszieChildren = true;
|
|
2289
|
+
childChangedX = -moveX;
|
|
2290
|
+
childChangedY = -moveY;
|
|
2291
|
+
}
|
|
2292
|
+
if (needReszieChildren !== true) {
|
|
2293
|
+
return;
|
|
2294
|
+
}
|
|
2295
|
+
elem.detail.children.forEach((child) => {
|
|
2296
|
+
const { uuid, x: x2, y: y2 } = child;
|
|
2297
|
+
const afterX = x2 + childChangedX;
|
|
2298
|
+
const afterY = y2 + childChangedY;
|
|
2299
|
+
const before = { uuid, x: x2, y: y2 };
|
|
2300
|
+
const after = { uuid, x: afterX, y: afterY };
|
|
2301
|
+
child.x = afterX;
|
|
2302
|
+
child.y = afterY;
|
|
2303
|
+
record === null || record === void 0 ? void 0 : record.content.before.push(before);
|
|
2304
|
+
record === null || record === void 0 ? void 0 : record.content.after.push(after);
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2307
|
+
function resizeEffectGroupElement(elem, size, opts) {
|
|
2308
|
+
if (!istype.number(size.x) && !istype.number(size.y)) {
|
|
2309
|
+
return null;
|
|
2310
|
+
}
|
|
2311
|
+
const record = {
|
|
2312
|
+
type: "modifyElements",
|
|
2313
|
+
time: Date.now(),
|
|
2314
|
+
content: {
|
|
2315
|
+
method: "modifyElements",
|
|
2316
|
+
before: [],
|
|
2317
|
+
after: []
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
const uuid = elem.uuid;
|
|
2321
|
+
const originX = elem.x;
|
|
2322
|
+
const originY = elem.y;
|
|
2323
|
+
const originW = elem.w;
|
|
2324
|
+
const originH = elem.h;
|
|
2325
|
+
const resizeX = istype.number(size.x) ? size.x : elem.x;
|
|
2326
|
+
const resizeY = istype.number(size.y) ? size.y : elem.y;
|
|
2327
|
+
const resizeW = (size.w && size.w > 0 ? size.w : elem.w) || 0;
|
|
2328
|
+
const resizeH = (size.h && size.h > 0 ? size.h : elem.h) || 0;
|
|
2329
|
+
const beforeGroupElem = { uuid, x: originX, y: originY, w: originW, h: originH };
|
|
2330
|
+
const afterGroupElem = { uuid, x: resizeX, y: resizeY, w: resizeW, h: resizeH };
|
|
2331
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.resizeEffect) === "deepResize") {
|
|
2332
|
+
const xRatio = resizeW / elem.w;
|
|
2333
|
+
const yRatio = resizeH / elem.h;
|
|
2334
|
+
if (xRatio === yRatio && xRatio === 1) {
|
|
2335
|
+
return record;
|
|
2336
|
+
}
|
|
2337
|
+
const minRatio = Math.min(xRatio, yRatio);
|
|
2338
|
+
const maxRatio = Math.max(xRatio, yRatio);
|
|
2339
|
+
elem.w = resizeW;
|
|
2340
|
+
elem.h = resizeH;
|
|
2341
|
+
const resizeRadioOpts = { xRatio, yRatio, minRatio, maxRatio };
|
|
2342
|
+
if (elem.type === "group" && Array.isArray(elem.detail.children)) {
|
|
2343
|
+
elem.detail.children.forEach((child) => {
|
|
2344
|
+
deepResizeElementByRatio(child, resizeRadioOpts, record);
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
const groupDetailRecord = resizeElementBaseDetailByRatio(elem, resizeRadioOpts);
|
|
2348
|
+
Object.keys(groupDetailRecord.content.before || {}).forEach((key2) => {
|
|
2349
|
+
var _a;
|
|
2350
|
+
beforeGroupElem[key2] = (_a = groupDetailRecord.content.before) === null || _a === void 0 ? void 0 : _a[key2];
|
|
2222
2351
|
});
|
|
2352
|
+
Object.keys(groupDetailRecord.content.after || {}).forEach((key2) => {
|
|
2353
|
+
var _a;
|
|
2354
|
+
afterGroupElem[key2] = (_a = groupDetailRecord.content.after) === null || _a === void 0 ? void 0 : _a[key2];
|
|
2355
|
+
});
|
|
2356
|
+
return record;
|
|
2357
|
+
}
|
|
2358
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.resizeEffect) === "fixed") {
|
|
2359
|
+
record.content.before.push(beforeGroupElem);
|
|
2360
|
+
record.content.after.push(afterGroupElem);
|
|
2361
|
+
const moveX = resizeX - elem.x;
|
|
2362
|
+
const moveY = resizeY - elem.y;
|
|
2363
|
+
const moveW = resizeW - elem.w;
|
|
2364
|
+
const moveH = resizeH - elem.h;
|
|
2365
|
+
fixedResizeGroupElementChildren(elem, { moveX, moveY, moveH, moveW }, record);
|
|
2366
|
+
elem.w = resizeW;
|
|
2367
|
+
elem.h = resizeH;
|
|
2368
|
+
elem.x = resizeX;
|
|
2369
|
+
elem.y = resizeY;
|
|
2370
|
+
return record;
|
|
2223
2371
|
}
|
|
2224
|
-
|
|
2225
|
-
|
|
2372
|
+
elem.w = resizeW;
|
|
2373
|
+
elem.h = resizeH;
|
|
2374
|
+
elem.x = resizeX;
|
|
2375
|
+
elem.y = resizeY;
|
|
2376
|
+
record.content.before.push(beforeGroupElem);
|
|
2377
|
+
record.content.after.push(afterGroupElem);
|
|
2378
|
+
return record;
|
|
2226
2379
|
}
|
|
2227
2380
|
const defaultViewWidth = 200;
|
|
2228
2381
|
const defaultViewHeight = 200;
|
|
@@ -2446,39 +2599,33 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2446
2599
|
return originElem;
|
|
2447
2600
|
}
|
|
2448
2601
|
function updateElementInList(uuid, updateContent, elements) {
|
|
2449
|
-
var _a, _b;
|
|
2602
|
+
var _a, _b, _c;
|
|
2450
2603
|
let targetElement = null;
|
|
2451
2604
|
for (let i = 0; i < elements.length; i++) {
|
|
2452
2605
|
const elem = elements[i];
|
|
2453
2606
|
if (elem.uuid === uuid) {
|
|
2454
|
-
if (elem.type === "group" && ((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
h: updateContent.h
|
|
2459
|
-
});
|
|
2460
|
-
}
|
|
2607
|
+
if (elem.type === "group" && ((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.resizeEffect)) {
|
|
2608
|
+
resizeEffectGroupElement(elem, Object.assign({}, updateContent), {
|
|
2609
|
+
resizeEffect: (_b = elem.operations) === null || _b === void 0 ? void 0 : _b.resizeEffect
|
|
2610
|
+
});
|
|
2461
2611
|
}
|
|
2462
2612
|
mergeElement(elem, updateContent);
|
|
2463
2613
|
targetElement = elem;
|
|
2464
2614
|
break;
|
|
2465
2615
|
} else if (elem.type === "group") {
|
|
2466
|
-
targetElement = updateElementInList(uuid, updateContent, ((
|
|
2616
|
+
targetElement = updateElementInList(uuid, updateContent, ((_c = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _c === void 0 ? void 0 : _c.children) || []);
|
|
2467
2617
|
}
|
|
2468
2618
|
}
|
|
2469
2619
|
return targetElement;
|
|
2470
2620
|
}
|
|
2471
2621
|
function updateElementInListByPosition(position, updateContent, elements, opts) {
|
|
2472
|
-
var _a;
|
|
2622
|
+
var _a, _b;
|
|
2473
2623
|
const elem = findElementFromListByPosition(position, elements);
|
|
2474
2624
|
if (elem) {
|
|
2475
|
-
if (elem.type === "group" && ((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
h: updateContent.h
|
|
2480
|
-
});
|
|
2481
|
-
}
|
|
2625
|
+
if (elem.type === "group" && ((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.resizeEffect)) {
|
|
2626
|
+
resizeEffectGroupElement(elem, Object.assign({}, updateContent), {
|
|
2627
|
+
resizeEffect: (_b = elem.operations) === null || _b === void 0 ? void 0 : _b.resizeEffect
|
|
2628
|
+
});
|
|
2482
2629
|
}
|
|
2483
2630
|
mergeElement(elem, updateContent, opts);
|
|
2484
2631
|
}
|
|
@@ -3563,14 +3710,15 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3563
3710
|
__classPrivateFieldSet$2(this, _Loader_storageLoadItemMap, {}, "f");
|
|
3564
3711
|
}
|
|
3565
3712
|
resetElementAsset(element) {
|
|
3713
|
+
var _a, _b, _c;
|
|
3566
3714
|
if (supportElementTypes.includes(element.type)) {
|
|
3567
3715
|
let assetId = null;
|
|
3568
3716
|
let resource = null;
|
|
3569
|
-
if (element.type === "image" && typeof element.detail.src === "string") {
|
|
3717
|
+
if (element.type === "image" && typeof ((_a = element === null || element === void 0 ? void 0 : element.detail) === null || _a === void 0 ? void 0 : _a.src) === "string") {
|
|
3570
3718
|
resource = element.detail.src;
|
|
3571
|
-
} else if (element.type === "svg" && typeof element.detail.svg === "string") {
|
|
3719
|
+
} else if (element.type === "svg" && typeof ((_b = element === null || element === void 0 ? void 0 : element.detail) === null || _b === void 0 ? void 0 : _b.svg) === "string") {
|
|
3572
3720
|
resource = element.detail.svg;
|
|
3573
|
-
} else if (element.type === "html" && typeof element.detail.html === "string") {
|
|
3721
|
+
} else if (element.type === "html" && typeof ((_c = element === null || element === void 0 ? void 0 : element.detail) === null || _c === void 0 ? void 0 : _c.html) === "string") {
|
|
3574
3722
|
resource = element.detail.html;
|
|
3575
3723
|
}
|
|
3576
3724
|
if (typeof resource === "string") {
|
|
@@ -4876,9 +5024,15 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4876
5024
|
return __privateGet(this, _eventHub);
|
|
4877
5025
|
}
|
|
4878
5026
|
onWatcherEvents() {
|
|
5027
|
+
if (__privateGet(this, _opts3).disableWatcher === true) {
|
|
5028
|
+
return;
|
|
5029
|
+
}
|
|
4879
5030
|
__privateGet(this, _watcher).onEvents();
|
|
4880
5031
|
}
|
|
4881
5032
|
offWatcherEvents() {
|
|
5033
|
+
if (__privateGet(this, _opts3).disableWatcher === true) {
|
|
5034
|
+
return;
|
|
5035
|
+
}
|
|
4882
5036
|
__privateGet(this, _watcher).offEvents();
|
|
4883
5037
|
}
|
|
4884
5038
|
}
|
|
@@ -4894,18 +5048,20 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4894
5048
|
_hasDestroyed2 = new WeakMap();
|
|
4895
5049
|
_Board_instances = new WeakSet();
|
|
4896
5050
|
init_fn3 = function() {
|
|
4897
|
-
__privateGet(this,
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
5051
|
+
if (__privateGet(this, _opts3).disableWatcher !== true) {
|
|
5052
|
+
__privateGet(this, _watcher).on("pointStart", __privateMethod(this, _Board_instances, handlePointStart_fn).bind(this));
|
|
5053
|
+
__privateGet(this, _watcher).on("pointEnd", __privateMethod(this, _Board_instances, handlePointEnd_fn).bind(this));
|
|
5054
|
+
__privateGet(this, _watcher).on("pointMove", __privateMethod(this, _Board_instances, handlePointMove_fn).bind(this));
|
|
5055
|
+
__privateGet(this, _watcher).on("pointLeave", __privateMethod(this, _Board_instances, handlePointLeave_fn).bind(this));
|
|
5056
|
+
__privateGet(this, _watcher).on("hover", __privateMethod(this, _Board_instances, handleHover_fn).bind(this));
|
|
5057
|
+
__privateGet(this, _watcher).on("wheel", __privateMethod(this, _Board_instances, handleWheel_fn).bind(this));
|
|
5058
|
+
__privateGet(this, _watcher).on("wheelScale", __privateMethod(this, _Board_instances, handleWheelScale_fn).bind(this));
|
|
5059
|
+
__privateGet(this, _watcher).on("scrollX", __privateMethod(this, _Board_instances, handleScrollX_fn).bind(this));
|
|
5060
|
+
__privateGet(this, _watcher).on("scrollY", __privateMethod(this, _Board_instances, handleScrollY_fn).bind(this));
|
|
5061
|
+
__privateGet(this, _watcher).on("resize", __privateMethod(this, _Board_instances, handleResize_fn).bind(this));
|
|
5062
|
+
__privateGet(this, _watcher).on("doubleClick", __privateMethod(this, _Board_instances, handleDoubleClick_fn).bind(this));
|
|
5063
|
+
__privateGet(this, _watcher).on("contextMenu", __privateMethod(this, _Board_instances, handleContextMenu_fn).bind(this));
|
|
5064
|
+
}
|
|
4909
5065
|
__privateGet(this, _renderer).on("load", () => {
|
|
4910
5066
|
__privateGet(this, _eventHub).trigger("loadResource");
|
|
4911
5067
|
});
|
|
@@ -5617,6 +5773,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
5617
5773
|
if (selectedElements && (selectedElements == null ? void 0 : selectedElements.length) > 0) {
|
|
5618
5774
|
target.groupQueue = groupQueue || [];
|
|
5619
5775
|
target.elements = [selectedElements[0]];
|
|
5776
|
+
return target;
|
|
5620
5777
|
}
|
|
5621
5778
|
break;
|
|
5622
5779
|
}
|
|
@@ -7951,16 +8108,28 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
7951
8108
|
{ scale, start: resizeStart, end: resizeEnd, resizeType }
|
|
7952
8109
|
);
|
|
7953
8110
|
const calcOpts = { ignore: !!moveOriginalStartElementSize.angle };
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
8111
|
+
const gridX = calculator.toGridNum(resizedElemSize.x, calcOpts);
|
|
8112
|
+
const gridY = calculator.toGridNum(resizedElemSize.y, calcOpts);
|
|
8113
|
+
const gridW = calculator.toGridNum(resizedElemSize.w, calcOpts);
|
|
8114
|
+
const gridH = calculator.toGridNum(resizedElemSize.h, calcOpts);
|
|
8115
|
+
if (elems[0].type === "group") {
|
|
8116
|
+
resizeEffectGroupElement(
|
|
8117
|
+
elems[0],
|
|
8118
|
+
{
|
|
8119
|
+
x: gridX,
|
|
8120
|
+
y: gridY,
|
|
8121
|
+
w: gridW,
|
|
8122
|
+
h: gridH
|
|
8123
|
+
},
|
|
8124
|
+
{ resizeEffect: (_c = elems[0].operations) == null ? void 0 : _c.resizeEffect }
|
|
8125
|
+
);
|
|
8126
|
+
elems[0].x = gridX;
|
|
8127
|
+
elems[0].y = gridY;
|
|
7961
8128
|
} else {
|
|
7962
|
-
elems[0].
|
|
7963
|
-
elems[0].
|
|
8129
|
+
elems[0].x = gridX;
|
|
8130
|
+
elems[0].y = gridY;
|
|
8131
|
+
elems[0].w = gridW;
|
|
8132
|
+
elems[0].h = gridH;
|
|
7964
8133
|
}
|
|
7965
8134
|
}
|
|
7966
8135
|
updateSelectedElementList([elems[0]]);
|
|
@@ -9416,7 +9585,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
9416
9585
|
// #opts: CoreOptions;
|
|
9417
9586
|
__privateAdd(this, _canvas);
|
|
9418
9587
|
__privateAdd(this, _container2);
|
|
9419
|
-
const { devicePixelRatio = 1, width, height } = opts;
|
|
9588
|
+
const { devicePixelRatio = 1, width, height, disableWatcher = false } = opts;
|
|
9420
9589
|
__privateSet(this, _container2, container);
|
|
9421
9590
|
const canvas = document.createElement("canvas");
|
|
9422
9591
|
canvas.setAttribute("tabindex", "0");
|
|
@@ -9424,7 +9593,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
9424
9593
|
__privateMethod(this, _Core_instances, initContainer_fn).call(this);
|
|
9425
9594
|
container.appendChild(canvas);
|
|
9426
9595
|
const boardContent = createBoardContent(canvas, { width, height, devicePixelRatio });
|
|
9427
|
-
const board = new Board({ boardContent, container });
|
|
9596
|
+
const board = new Board({ boardContent, container, disableWatcher });
|
|
9428
9597
|
const sharer = board.getSharer();
|
|
9429
9598
|
sharer.setActiveViewSizeInfo({
|
|
9430
9599
|
width,
|