@idraw/core 0.4.0-beta.37 → 0.4.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/middleware/info/index.js +24 -18
- package/dist/esm/middleware/layout-selector/index.js +6 -3
- package/dist/esm/middleware/ruler/index.js +14 -11
- package/dist/esm/middleware/ruler/util.d.ts +2 -2
- package/dist/esm/middleware/ruler/util.js +5 -4
- package/dist/esm/middleware/scroller/index.js +13 -10
- package/dist/esm/middleware/selector/draw-wrapper.js +7 -4
- package/dist/esm/middleware/selector/index.js +32 -13
- package/dist/esm/middleware/selector/pattern/index.d.ts +4 -1
- package/dist/esm/middleware/selector/pattern/index.js +1 -1
- package/dist/esm/middleware/selector/util.d.ts +0 -4
- package/dist/esm/middleware/selector/util.js +8 -30
- package/dist/index.global.js +161 -100
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/esm/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class Core<E extends CoreEventMap = CoreEventMap> {
|
|
|
17
17
|
destroy(): void;
|
|
18
18
|
use<C extends any = any>(middleware: BoardMiddleware<any, any, any>, config?: C): void;
|
|
19
19
|
disuse(middleware: BoardMiddleware<any, any, any>): void;
|
|
20
|
+
resetMiddlewareConfig<C extends any = any>(middleware: BoardMiddleware<any, any, any>, config?: Partial<C>): void;
|
|
20
21
|
setData(data: Data, opts?: {
|
|
21
22
|
modifiedOptions?: ModifyOptions;
|
|
22
23
|
}): void;
|
package/dist/esm/index.js
CHANGED
|
@@ -66,6 +66,9 @@ export class Core {
|
|
|
66
66
|
disuse(middleware) {
|
|
67
67
|
__classPrivateFieldGet(this, _Core_board, "f").disuse(middleware);
|
|
68
68
|
}
|
|
69
|
+
resetMiddlewareConfig(middleware, config) {
|
|
70
|
+
__classPrivateFieldGet(this, _Core_board, "f").resetMiddlewareConfig(middleware, config);
|
|
71
|
+
}
|
|
69
72
|
setData(data, opts) {
|
|
70
73
|
validateElements((data === null || data === void 0 ? void 0 : data.elements) || []);
|
|
71
74
|
__classPrivateFieldGet(this, _Core_board, "f").setData(data, opts);
|
|
@@ -8,12 +8,7 @@ const infoLineHeight = 16;
|
|
|
8
8
|
export const MiddlewareInfo = (opts, config) => {
|
|
9
9
|
const { boardContent, calculator, eventHub } = opts;
|
|
10
10
|
const { overlayContext } = boardContent;
|
|
11
|
-
|
|
12
|
-
const { textBackground, textColor } = innerConfig;
|
|
13
|
-
const style = {
|
|
14
|
-
textBackground,
|
|
15
|
-
textColor
|
|
16
|
-
};
|
|
11
|
+
let innerConfig = Object.assign(Object.assign({}, defaltStyle), config);
|
|
17
12
|
let showAngleInfo = true;
|
|
18
13
|
const showInfoAngleCallback = ({ show }) => {
|
|
19
14
|
showAngleInfo = show;
|
|
@@ -26,7 +21,16 @@ export const MiddlewareInfo = (opts, config) => {
|
|
|
26
21
|
disuse() {
|
|
27
22
|
eventHub.off(MIDDLEWARE_INTERNAL_EVENT_SHOW_INFO_ANGLE, showInfoAngleCallback);
|
|
28
23
|
},
|
|
24
|
+
resetConfig(config) {
|
|
25
|
+
innerConfig = Object.assign(Object.assign({}, innerConfig), config);
|
|
26
|
+
},
|
|
29
27
|
beforeDrawFrame({ snapshot }) {
|
|
28
|
+
var _a;
|
|
29
|
+
const { textBackground, textColor } = innerConfig;
|
|
30
|
+
const style = {
|
|
31
|
+
textBackground,
|
|
32
|
+
textColor
|
|
33
|
+
};
|
|
30
34
|
const { sharedStore } = snapshot;
|
|
31
35
|
const selectedElementList = sharedStore[keySelectedElementList];
|
|
32
36
|
const actionType = sharedStore[keyActionType];
|
|
@@ -104,18 +108,20 @@ export const MiddlewareInfo = (opts, config) => {
|
|
|
104
108
|
style
|
|
105
109
|
});
|
|
106
110
|
if (showAngleInfo) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
if (((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.rotatable) !== false) {
|
|
112
|
+
drawAngleInfoText(overlayContext, {
|
|
113
|
+
point: {
|
|
114
|
+
x: rectInfo.top.x + infoFontSize + 4,
|
|
115
|
+
y: rectInfo.top.y - infoFontSize * 2 - 18
|
|
116
|
+
},
|
|
117
|
+
rotateCenter: rectInfo.center,
|
|
118
|
+
angle: totalAngle,
|
|
119
|
+
text: angleText,
|
|
120
|
+
fontSize: infoFontSize,
|
|
121
|
+
lineHeight: infoLineHeight,
|
|
122
|
+
style
|
|
123
|
+
});
|
|
124
|
+
}
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
}
|
|
@@ -7,9 +7,7 @@ export { keyLayoutIsSelected, keyLayoutIsBusyMoving };
|
|
|
7
7
|
export const MiddlewareLayoutSelector = (opts, config) => {
|
|
8
8
|
const { sharer, boardContent, calculator, viewer, eventHub } = opts;
|
|
9
9
|
const { overlayContext } = boardContent;
|
|
10
|
-
|
|
11
|
-
const { activeColor } = innerConfig;
|
|
12
|
-
const style = { activeColor };
|
|
10
|
+
let innerConfig = Object.assign(Object.assign({}, defaultStyle), config);
|
|
13
11
|
let prevPoint = null;
|
|
14
12
|
let prevIsHoverContent = null;
|
|
15
13
|
let prevIsSelected = null;
|
|
@@ -114,6 +112,9 @@ export const MiddlewareLayoutSelector = (opts, config) => {
|
|
|
114
112
|
clear();
|
|
115
113
|
resetController();
|
|
116
114
|
},
|
|
115
|
+
resetConfig(config) {
|
|
116
|
+
innerConfig = Object.assign(Object.assign({}, innerConfig), config);
|
|
117
|
+
},
|
|
117
118
|
hover: (e) => {
|
|
118
119
|
if (sharer.getSharedStorage(keyLayoutIsBusyMoving) === true) {
|
|
119
120
|
return;
|
|
@@ -312,6 +313,8 @@ export const MiddlewareLayoutSelector = (opts, config) => {
|
|
|
312
313
|
if (isInElementAction()) {
|
|
313
314
|
return;
|
|
314
315
|
}
|
|
316
|
+
const { activeColor } = innerConfig;
|
|
317
|
+
const style = { activeColor };
|
|
315
318
|
const { sharedStore, activeStore } = snapshot;
|
|
316
319
|
const layoutActionType = sharedStore[keyLayoutActionType];
|
|
317
320
|
const layoutIsHover = sharedStore[keyLayoutIsHoverContent];
|
|
@@ -5,17 +5,7 @@ import { coreEventKeys } from '../../config';
|
|
|
5
5
|
export const MiddlewareRuler = (opts, config) => {
|
|
6
6
|
const { boardContent, viewer, eventHub, calculator } = opts;
|
|
7
7
|
const { overlayContext, underlayContext } = boardContent;
|
|
8
|
-
|
|
9
|
-
const { background, borderColor, scaleColor, textColor, gridColor, gridPrimaryColor, selectedAreaColor } = innerConfig;
|
|
10
|
-
const style = {
|
|
11
|
-
background,
|
|
12
|
-
borderColor,
|
|
13
|
-
scaleColor,
|
|
14
|
-
textColor,
|
|
15
|
-
gridColor,
|
|
16
|
-
gridPrimaryColor,
|
|
17
|
-
selectedAreaColor
|
|
18
|
-
};
|
|
8
|
+
let innerConfig = Object.assign(Object.assign({}, defaultStyle), config);
|
|
19
9
|
let show = true;
|
|
20
10
|
let showGrid = true;
|
|
21
11
|
const rulerCallback = (e) => {
|
|
@@ -37,7 +27,20 @@ export const MiddlewareRuler = (opts, config) => {
|
|
|
37
27
|
disuse() {
|
|
38
28
|
eventHub.off(coreEventKeys.RULER, rulerCallback);
|
|
39
29
|
},
|
|
30
|
+
resetConfig(config) {
|
|
31
|
+
innerConfig = Object.assign(Object.assign({}, innerConfig), config);
|
|
32
|
+
},
|
|
40
33
|
beforeDrawFrame: ({ snapshot }) => {
|
|
34
|
+
const { background, borderColor, scaleColor, textColor, gridColor, gridPrimaryColor, selectedAreaColor } = innerConfig;
|
|
35
|
+
const style = {
|
|
36
|
+
background,
|
|
37
|
+
borderColor,
|
|
38
|
+
scaleColor,
|
|
39
|
+
textColor,
|
|
40
|
+
gridColor,
|
|
41
|
+
gridPrimaryColor,
|
|
42
|
+
selectedAreaColor
|
|
43
|
+
};
|
|
41
44
|
if (show === true) {
|
|
42
45
|
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
43
46
|
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ViewScaleInfo, ViewSizeInfo, ViewContext2D, BoardViewerFrameSnapshot, ViewCalculator } from '@idraw/types';
|
|
2
|
-
import type { DeepRulerSharedStorage
|
|
1
|
+
import type { ViewScaleInfo, ViewSizeInfo, ViewContext2D, BoardViewerFrameSnapshot, ViewCalculator, MiddlewareRulerStyle } from '@idraw/types';
|
|
2
|
+
import type { DeepRulerSharedStorage } from './types';
|
|
3
3
|
interface RulerScale {
|
|
4
4
|
num: number;
|
|
5
5
|
showNum: boolean;
|
|
@@ -152,13 +152,14 @@ export function drawRulerBackground(ctx, opts) {
|
|
|
152
152
|
const { width, height } = viewSizeInfo;
|
|
153
153
|
const { background, borderColor } = style;
|
|
154
154
|
ctx.beginPath();
|
|
155
|
-
|
|
156
|
-
ctx.
|
|
155
|
+
const basePosition = -1;
|
|
156
|
+
ctx.moveTo(basePosition, basePosition);
|
|
157
|
+
ctx.lineTo(width + 1, basePosition);
|
|
157
158
|
ctx.lineTo(width + 1, rulerSize);
|
|
158
159
|
ctx.lineTo(rulerSize, rulerSize);
|
|
159
160
|
ctx.lineTo(rulerSize, height + 1);
|
|
160
|
-
ctx.lineTo(
|
|
161
|
-
ctx.lineTo(
|
|
161
|
+
ctx.lineTo(basePosition, height + 1);
|
|
162
|
+
ctx.lineTo(basePosition, basePosition);
|
|
162
163
|
ctx.closePath();
|
|
163
164
|
ctx.fillStyle = background;
|
|
164
165
|
ctx.fill();
|
|
@@ -7,16 +7,7 @@ export const MiddlewareScroller = (opts, config) => {
|
|
|
7
7
|
sharer.setSharedStorage(keyXThumbRect, null);
|
|
8
8
|
sharer.setSharedStorage(keyYThumbRect, null);
|
|
9
9
|
let isBusy = false;
|
|
10
|
-
|
|
11
|
-
const { thumbBackground, thumbBorderColor, hoverThumbBackground, hoverThumbBorderColor, activeThumbBackground, activeThumbBorderColor } = innerConfig;
|
|
12
|
-
const style = {
|
|
13
|
-
thumbBackground,
|
|
14
|
-
thumbBorderColor,
|
|
15
|
-
hoverThumbBackground,
|
|
16
|
-
hoverThumbBorderColor,
|
|
17
|
-
activeThumbBackground,
|
|
18
|
-
activeThumbBorderColor
|
|
19
|
-
};
|
|
10
|
+
let innerConfig = Object.assign(Object.assign({}, defaultStyle), config);
|
|
20
11
|
const clear = () => {
|
|
21
12
|
sharer.setSharedStorage(keyPrevPoint, null);
|
|
22
13
|
sharer.setSharedStorage(keyActivePoint, null);
|
|
@@ -58,6 +49,9 @@ export const MiddlewareScroller = (opts, config) => {
|
|
|
58
49
|
};
|
|
59
50
|
return {
|
|
60
51
|
name: '@middleware/scroller',
|
|
52
|
+
resetConfig(config) {
|
|
53
|
+
innerConfig = Object.assign(Object.assign({}, innerConfig), config);
|
|
54
|
+
},
|
|
61
55
|
wheel: (e) => {
|
|
62
56
|
viewer.scroll({
|
|
63
57
|
moveX: 0 - e.deltaX,
|
|
@@ -122,6 +116,15 @@ export const MiddlewareScroller = (opts, config) => {
|
|
|
122
116
|
}
|
|
123
117
|
},
|
|
124
118
|
beforeDrawFrame({ snapshot }) {
|
|
119
|
+
const { thumbBackground, thumbBorderColor, hoverThumbBackground, hoverThumbBorderColor, activeThumbBackground, activeThumbBorderColor } = innerConfig;
|
|
120
|
+
const style = {
|
|
121
|
+
thumbBackground,
|
|
122
|
+
thumbBorderColor,
|
|
123
|
+
hoverThumbBackground,
|
|
124
|
+
hoverThumbBorderColor,
|
|
125
|
+
activeThumbBackground,
|
|
126
|
+
activeThumbBorderColor
|
|
127
|
+
};
|
|
125
128
|
const { xThumbRect, yThumbRect } = drawScroller(overlayContext, { snapshot, style });
|
|
126
129
|
sharer.setSharedStorage(keyXThumbRect, xThumbRect);
|
|
127
130
|
sharer.setSharedStorage(keyYThumbRect, yThumbRect);
|
|
@@ -33,10 +33,11 @@ export function drawLockedVertexesWrapper(ctx, vertexes, opts) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
export function drawSelectedElementControllersVertexes(ctx, controller, opts) {
|
|
36
|
+
var _a;
|
|
36
37
|
if (!controller) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
|
-
const { hideControllers, style, rotateControllerPattern, viewSizeInfo } = opts;
|
|
40
|
+
const { hideControllers, style, rotateControllerPattern, viewSizeInfo, element } = opts;
|
|
40
41
|
const { devicePixelRatio = 1 } = viewSizeInfo;
|
|
41
42
|
const { activeColor } = style;
|
|
42
43
|
const { elementWrapper, topLeft, topRight, bottomLeft, bottomRight, rotate } = controller;
|
|
@@ -48,9 +49,11 @@ export function drawSelectedElementControllersVertexes(ctx, controller, opts) {
|
|
|
48
49
|
drawVertexes(ctx, calcViewVertexes(topRight.vertexes, opts), ctrlOpts);
|
|
49
50
|
drawVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
|
|
50
51
|
drawVertexes(ctx, calcViewVertexes(bottomRight.vertexes, opts), ctrlOpts);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
if (((_a = element === null || element === void 0 ? void 0 : element.operations) === null || _a === void 0 ? void 0 : _a.rotatable) !== false) {
|
|
53
|
+
drawCircleController(ctx, calcViewPointSize(rotate.center, opts), Object.assign(Object.assign({}, ctrlOpts), { size: rotate.size, borderWidth: 0 }));
|
|
54
|
+
const rotateCenter = calcViewPointSize(rotate.center, opts);
|
|
55
|
+
ctx.drawImage(rotateControllerPattern.canvas, 0, 0, rotateControllerPattern.canvas.width / devicePixelRatio, rotateControllerPattern.canvas.height / devicePixelRatio, rotateCenter.x - rotate.size / 2, rotateCenter.y - rotate.size / 2, rotate.size, rotate.size);
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
export function drawElementListShadows(ctx, elements, opts) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcElementSizeController, calcElementCenterFromVertexes, rotatePointInGroup, getGroupQueueFromList, findElementsFromList, findElementsFromListByPositions, getElementPositionFromList, getElementPositionMapFromList, deepResizeGroupElement, getElementSize } from '@idraw/util';
|
|
1
|
+
import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcElementSizeController, calcElementCenterFromVertexes, rotatePointInGroup, getGroupQueueFromList, findElementsFromList, findElementsFromListByPositions, getElementPositionFromList, getElementPositionMapFromList, deepResizeGroupElement, getElementSize, calcPointMoveElementInGroup, isSameElementSize } from '@idraw/util';
|
|
2
2
|
import { drawHoverVertexesWrapper, drawLockedVertexesWrapper, drawArea, drawListArea, drawGroupQueueVertexesWrappers, drawSelectedElementControllersVertexes } from './draw-wrapper';
|
|
3
3
|
import { drawReferenceLines } from './draw-reference';
|
|
4
|
-
import { getPointTarget, resizeElement, rotateElement, getSelectedListArea, calcSelectedElementsArea, isElementInGroup, isPointInViewActiveGroup
|
|
4
|
+
import { getPointTarget, resizeElement, rotateElement, getSelectedListArea, calcSelectedElementsArea, isElementInGroup, isPointInViewActiveGroup } from './util';
|
|
5
5
|
import { keyActionType, keyResizeType, keyAreaStart, keyAreaEnd, keyGroupQueue, keyGroupQueueVertexesList, keyHoverElement, keyHoverElementVertexes, keySelectedElementList, keySelectedElementListVertexes, keySelectedElementController, keySelectedElementPosition, keyIsMoving, keyEnableSelectInGroup, keyEnableSnapToGrid, controllerSize, rotateControllerSize, rotateControllerPosition, defaultStyle } from './config';
|
|
6
6
|
import { calcReferenceInfo } from './reference';
|
|
7
7
|
import { coreEventKeys } from '../../config';
|
|
@@ -10,9 +10,7 @@ import { createRotateControllerPattern } from './pattern';
|
|
|
10
10
|
import { MIDDLEWARE_INTERNAL_EVENT_SHOW_INFO_ANGLE } from '../info';
|
|
11
11
|
export { keySelectedElementList, keyHoverElement, keyActionType, keyResizeType, keyGroupQueue };
|
|
12
12
|
export const MiddlewareSelector = (opts, config) => {
|
|
13
|
-
|
|
14
|
-
const { activeColor, activeAreaColor, lockedColor, referenceColor } = innerConfig;
|
|
15
|
-
const style = { activeColor, activeAreaColor, lockedColor, referenceColor };
|
|
13
|
+
let innerConfig = Object.assign(Object.assign({}, defaultStyle), config);
|
|
16
14
|
const { viewer, sharer, boardContent, calculator, eventHub } = opts;
|
|
17
15
|
const { overlayContext } = boardContent;
|
|
18
16
|
let prevPoint = null;
|
|
@@ -20,8 +18,8 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
20
18
|
let moveOriginalStartElementSize = null;
|
|
21
19
|
let inBusyMode = null;
|
|
22
20
|
let hasChangedData = null;
|
|
23
|
-
|
|
24
|
-
fill:
|
|
21
|
+
let rotateControllerPattern = createRotateControllerPattern({
|
|
22
|
+
fill: innerConfig.activeColor,
|
|
25
23
|
devicePixelRatio: sharer.getActiveViewSizeInfo().devicePixelRatio
|
|
26
24
|
});
|
|
27
25
|
sharer.setSharedStorage(keyActionType, null);
|
|
@@ -171,6 +169,9 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
171
169
|
eventHub.off(coreEventKeys.SELECT_IN_GROUP, selectInGroupCallback);
|
|
172
170
|
eventHub.off(coreEventKeys.SNAP_TO_GRID, setSnapToSnapCallback);
|
|
173
171
|
},
|
|
172
|
+
resetConfig(config) {
|
|
173
|
+
innerConfig = Object.assign(Object.assign({}, innerConfig), config);
|
|
174
|
+
},
|
|
174
175
|
hover: (e) => {
|
|
175
176
|
var _a, _b, _c, _d, _e;
|
|
176
177
|
const layoutIsSelected = sharer.getSharedStorage(keyLayoutIsSelected);
|
|
@@ -365,7 +366,7 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
365
366
|
inBusyMode = 'drag';
|
|
366
367
|
eventHub.trigger(MIDDLEWARE_INTERNAL_EVENT_SHOW_INFO_ANGLE, { show: false });
|
|
367
368
|
if (data && (elems === null || elems === void 0 ? void 0 : elems.length) === 1 && moveOriginalStartElementSize && originalStart && end && ((_b = (_a = elems[0]) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.locked) !== true) {
|
|
368
|
-
const { moveX, moveY } =
|
|
369
|
+
const { moveX, moveY } = calcPointMoveElementInGroup(originalStart, end, groupQueue);
|
|
369
370
|
let totalMoveX = calculator.toGridNum(moveX / scale);
|
|
370
371
|
let totalMoveY = calculator.toGridNum(moveY / scale);
|
|
371
372
|
if (enableSnapToGrid === true) {
|
|
@@ -682,8 +683,16 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
682
683
|
},
|
|
683
684
|
beforeDrawFrame({ snapshot }) {
|
|
684
685
|
var _a;
|
|
686
|
+
const { activeColor, activeAreaColor, lockedColor, referenceColor } = innerConfig;
|
|
687
|
+
const style = { activeColor, activeAreaColor, lockedColor, referenceColor };
|
|
685
688
|
const { activeStore, sharedStore } = snapshot;
|
|
686
689
|
const { scale, offsetLeft, offsetTop, offsetRight, offsetBottom, width, height, contextHeight, contextWidth, devicePixelRatio } = activeStore;
|
|
690
|
+
if (rotateControllerPattern.fill !== activeColor) {
|
|
691
|
+
rotateControllerPattern = createRotateControllerPattern({
|
|
692
|
+
fill: innerConfig.activeColor,
|
|
693
|
+
devicePixelRatio
|
|
694
|
+
});
|
|
695
|
+
}
|
|
687
696
|
const sharer = opts.sharer;
|
|
688
697
|
const viewScaleInfo = { scale, offsetLeft, offsetTop, offsetRight, offsetBottom };
|
|
689
698
|
const viewSizeInfo = { width, height, contextHeight, contextWidth, devicePixelRatio };
|
|
@@ -699,7 +708,19 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
699
708
|
const isMoving = sharedStore[keyIsMoving];
|
|
700
709
|
const enableSnapToGrid = sharedStore[keyEnableSnapToGrid];
|
|
701
710
|
const drawBaseOpts = { calculator, viewScaleInfo, viewSizeInfo, style };
|
|
702
|
-
|
|
711
|
+
let selectedElementController = sharedStore[keySelectedElementController];
|
|
712
|
+
if (selectedElementController && selectedElements.length === 1 && elem) {
|
|
713
|
+
if (!isSameElementSize(elem, selectedElementController.originalElementSize)) {
|
|
714
|
+
selectedElementController = calcElementSizeController(elem, {
|
|
715
|
+
groupQueue: groupQueue || [],
|
|
716
|
+
controllerSize,
|
|
717
|
+
viewScaleInfo,
|
|
718
|
+
rotateControllerPosition,
|
|
719
|
+
rotateControllerSize
|
|
720
|
+
});
|
|
721
|
+
sharer.setSharedStorage(keySelectedElementController, selectedElementController);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
703
724
|
const isHoverLocked = !!((_a = hoverElement === null || hoverElement === void 0 ? void 0 : hoverElement.operations) === null || _a === void 0 ? void 0 : _a.locked);
|
|
704
725
|
if ((groupQueue === null || groupQueue === void 0 ? void 0 : groupQueue.length) > 0) {
|
|
705
726
|
drawGroupQueueVertexesWrappers(overlayContext, groupQueueVertexesList, drawBaseOpts);
|
|
@@ -712,8 +733,7 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
712
733
|
}
|
|
713
734
|
}
|
|
714
735
|
if (elem && ['select', 'drag', 'resize'].includes(actionType)) {
|
|
715
|
-
drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag', rotateControllerPattern,
|
|
716
|
-
style }));
|
|
736
|
+
drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag', rotateControllerPattern: rotateControllerPattern.context2d, style }));
|
|
717
737
|
if (actionType === 'drag') {
|
|
718
738
|
if (enableSnapToGrid === true) {
|
|
719
739
|
const referenceInfo = calcReferenceInfo(elem.uuid, {
|
|
@@ -747,8 +767,7 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
747
767
|
}
|
|
748
768
|
}
|
|
749
769
|
if (elem && ['select', 'drag', 'resize'].includes(actionType)) {
|
|
750
|
-
drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag', rotateControllerPattern,
|
|
751
|
-
style }));
|
|
770
|
+
drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag', rotateControllerPattern: rotateControllerPattern.context2d, style }));
|
|
752
771
|
if (actionType === 'drag') {
|
|
753
772
|
if (enableSnapToGrid === true) {
|
|
754
773
|
const referenceInfo = calcReferenceInfo(elem.uuid, {
|
|
@@ -56,7 +56,3 @@ export declare function calcSelectedElementsArea(elements: Element<ElementType>[
|
|
|
56
56
|
calculator: ViewCalculator;
|
|
57
57
|
}): AreaSize | null;
|
|
58
58
|
export declare function isElementInGroup(elem: Element<ElementType>, group: Element<'group'>): boolean;
|
|
59
|
-
export declare function calcMoveInGroup(start: PointSize, end: PointSize, groupQueue: Element<'group'>[]): {
|
|
60
|
-
moveX: number;
|
|
61
|
-
moveY: number;
|
|
62
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { calcElementCenter, rotateElementVertexes, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcViewPointSize, calcViewElementSize,
|
|
1
|
+
import { calcElementCenter, rotateElementVertexes, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcViewPointSize, calcViewElementSize, rotatePoint, parseAngleToRadian, parseRadianToAngle, limitAngle, calcRadian } from '@idraw/util';
|
|
2
2
|
function parseRadian(angle) {
|
|
3
3
|
return (angle * Math.PI) / 180;
|
|
4
4
|
}
|
|
@@ -39,7 +39,7 @@ export function isPointInViewActiveGroup(p, opts) {
|
|
|
39
39
|
return isPointInViewActiveVertexes(p, { ctx, vertexes, viewScaleInfo, viewSizeInfo });
|
|
40
40
|
}
|
|
41
41
|
export function getPointTarget(p, opts) {
|
|
42
|
-
var _a, _b, _c;
|
|
42
|
+
var _a, _b, _c, _d, _e;
|
|
43
43
|
const target = {
|
|
44
44
|
type: null,
|
|
45
45
|
elements: [],
|
|
@@ -50,7 +50,10 @@ export function getPointTarget(p, opts) {
|
|
|
50
50
|
const { ctx, data, calculator, selectedElements, viewScaleInfo, viewSizeInfo, areaSize, groupQueue, selectedElementController } = opts;
|
|
51
51
|
if (selectedElementController) {
|
|
52
52
|
const { left, right, top, bottom, topLeft, topRight, bottomLeft, bottomRight, rotate } = selectedElementController;
|
|
53
|
-
const ctrls = [left, right, top, bottom, topLeft, topRight, bottomLeft, bottomRight
|
|
53
|
+
const ctrls = [left, right, top, bottom, topLeft, topRight, bottomLeft, bottomRight];
|
|
54
|
+
if ((selectedElements === null || selectedElements === void 0 ? void 0 : selectedElements.length) === 1 && ((_b = (_a = selectedElements === null || selectedElements === void 0 ? void 0 : selectedElements[0]) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.rotatable) !== false) {
|
|
55
|
+
ctrls.push(rotate);
|
|
56
|
+
}
|
|
54
57
|
for (let i = 0; i < ctrls.length; i++) {
|
|
55
58
|
const ctrl = ctrls[i];
|
|
56
59
|
if (isPointInViewActiveVertexes(p, { ctx, vertexes: ctrl.vertexes, viewSizeInfo, viewScaleInfo })) {
|
|
@@ -65,7 +68,7 @@ export function getPointTarget(p, opts) {
|
|
|
65
68
|
}
|
|
66
69
|
if (groupQueue && Array.isArray(groupQueue) && groupQueue.length > 0) {
|
|
67
70
|
const lastGroup = groupQueue[groupQueue.length - 1];
|
|
68
|
-
if (((
|
|
71
|
+
if (((_c = lastGroup === null || lastGroup === void 0 ? void 0 : lastGroup.detail) === null || _c === void 0 ? void 0 : _c.children) && Array.isArray((_d = lastGroup === null || lastGroup === void 0 ? void 0 : lastGroup.detail) === null || _d === void 0 ? void 0 : _d.children)) {
|
|
69
72
|
for (let i = lastGroup.detail.children.length - 1; i >= 0; i--) {
|
|
70
73
|
const child = lastGroup.detail.children[i];
|
|
71
74
|
const vertexes = calcElementVertexesInGroup(child, { groupQueue });
|
|
@@ -94,7 +97,7 @@ export function getPointTarget(p, opts) {
|
|
|
94
97
|
}
|
|
95
98
|
if (data) {
|
|
96
99
|
const { index, element } = calculator.getPointElement(p, { data, viewScaleInfo, viewSizeInfo });
|
|
97
|
-
if (index >= 0 && element && ((
|
|
100
|
+
if (index >= 0 && element && ((_e = element === null || element === void 0 ? void 0 : element.operations) === null || _e === void 0 ? void 0 : _e.invisible) !== true) {
|
|
98
101
|
target.elements = [element];
|
|
99
102
|
target.type = 'over-element';
|
|
100
103
|
return target;
|
|
@@ -784,28 +787,3 @@ export function isElementInGroup(elem, group) {
|
|
|
784
787
|
}
|
|
785
788
|
return false;
|
|
786
789
|
}
|
|
787
|
-
export function calcMoveInGroup(start, end, groupQueue) {
|
|
788
|
-
let moveX = end.x - start.x;
|
|
789
|
-
let moveY = end.y - start.y;
|
|
790
|
-
const pointGroupQueue = [];
|
|
791
|
-
groupQueue.forEach((group) => {
|
|
792
|
-
const { x, y, w, h, angle = 0 } = group;
|
|
793
|
-
pointGroupQueue.push({
|
|
794
|
-
x,
|
|
795
|
-
y,
|
|
796
|
-
w,
|
|
797
|
-
h,
|
|
798
|
-
angle: 0 - angle
|
|
799
|
-
});
|
|
800
|
-
});
|
|
801
|
-
if ((groupQueue === null || groupQueue === void 0 ? void 0 : groupQueue.length) > 0) {
|
|
802
|
-
const startInGroup = rotatePointInGroup(start, pointGroupQueue);
|
|
803
|
-
const endInGroup = rotatePointInGroup(end, pointGroupQueue);
|
|
804
|
-
moveX = endInGroup.x - startInGroup.x;
|
|
805
|
-
moveY = endInGroup.y - startInGroup.y;
|
|
806
|
-
}
|
|
807
|
-
return {
|
|
808
|
-
moveX,
|
|
809
|
-
moveY
|
|
810
|
-
};
|
|
811
|
-
}
|