@idraw/core 0.4.0-beta.18 → 0.4.0-beta.19
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/config.d.ts +1 -0
- package/dist/esm/config.js +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/middleware/layout-selector/config.d.ts +6 -0
- package/dist/esm/middleware/layout-selector/config.js +6 -0
- package/dist/esm/middleware/layout-selector/index.d.ts +3 -0
- package/dist/esm/middleware/layout-selector/index.js +251 -0
- package/dist/esm/middleware/layout-selector/types.d.ts +12 -0
- package/dist/esm/middleware/layout-selector/types.js +2 -0
- package/dist/esm/middleware/layout-selector/util.d.ts +5 -0
- package/dist/esm/middleware/layout-selector/util.js +93 -0
- package/dist/esm/middleware/selector/index.d.ts +2 -2
- package/dist/esm/middleware/selector/index.js +7 -1
- package/dist/index.global.js +487 -35
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const eventChange = "change";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const eventChange = 'change';
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Data, PointSize, CoreOptions, BoardMiddleware, ViewSizeInfo, CoreEventMap, ViewScaleInfo, LoadItemMap, ModifyOptions } from '@idraw/types';
|
|
2
|
+
export { eventChange } from './config';
|
|
2
3
|
export { MiddlewareSelector, middlewareEventSelect, middlewareEventSelectClear } from './middleware/selector';
|
|
3
4
|
export { MiddlewareScroller } from './middleware/scroller';
|
|
4
5
|
export { MiddlewareScaler, middlewareEventScale } from './middleware/scaler';
|
|
@@ -6,6 +7,7 @@ export { MiddlewareRuler, middlewareEventRuler } from './middleware/ruler';
|
|
|
6
7
|
export { MiddlewareTextEditor, middlewareEventTextEdit, middlewareEventTextChange } from './middleware/text-editor';
|
|
7
8
|
export { MiddlewareDragger } from './middleware/dragger';
|
|
8
9
|
export { MiddlewareInfo } from './middleware/info';
|
|
10
|
+
export { MiddlewareLayoutSelector } from './middleware/layout-selector';
|
|
9
11
|
export declare class Core<E extends CoreEventMap = CoreEventMap> {
|
|
10
12
|
#private;
|
|
11
13
|
constructor(container: HTMLDivElement, opts: CoreOptions);
|
package/dist/esm/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var _Core_instances, _Core_board, _Core_canvas, _Core_container, _Core_initConta
|
|
|
13
13
|
import { Board } from '@idraw/board';
|
|
14
14
|
import { createBoardContent, validateElements } from '@idraw/util';
|
|
15
15
|
import { Cursor } from './lib/cursor';
|
|
16
|
+
export { eventChange } from './config';
|
|
16
17
|
export { MiddlewareSelector, middlewareEventSelect, middlewareEventSelectClear } from './middleware/selector';
|
|
17
18
|
export { MiddlewareScroller } from './middleware/scroller';
|
|
18
19
|
export { MiddlewareScaler, middlewareEventScale } from './middleware/scaler';
|
|
@@ -20,6 +21,7 @@ export { MiddlewareRuler, middlewareEventRuler } from './middleware/ruler';
|
|
|
20
21
|
export { MiddlewareTextEditor, middlewareEventTextEdit, middlewareEventTextChange } from './middleware/text-editor';
|
|
21
22
|
export { MiddlewareDragger } from './middleware/dragger';
|
|
22
23
|
export { MiddlewareInfo } from './middleware/info';
|
|
24
|
+
export { MiddlewareLayoutSelector } from './middleware/layout-selector';
|
|
23
25
|
export class Core {
|
|
24
26
|
constructor(container, opts) {
|
|
25
27
|
_Core_instances.add(this);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const key = "LAYOUT_SELECT";
|
|
2
|
+
export declare const keyLayoutActionType: unique symbol;
|
|
3
|
+
export declare const keyLayoutControlType: unique symbol;
|
|
4
|
+
export declare const keyLayoutController: unique symbol;
|
|
5
|
+
export declare const selectColor = "#1973ba";
|
|
6
|
+
export declare const disableColor = "#5b5959b5";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const key = 'LAYOUT_SELECT';
|
|
2
|
+
export const keyLayoutActionType = Symbol(`${key}_layoutActionType`);
|
|
3
|
+
export const keyLayoutControlType = Symbol(`${key}_layoutControlType`);
|
|
4
|
+
export const keyLayoutController = Symbol(`${key}_layoutController`);
|
|
5
|
+
export const selectColor = '#1973ba';
|
|
6
|
+
export const disableColor = '#5b5959b5';
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { calcLayoutSizeController, isViewPointInVertexes, getViewScaleInfoFromSnapshot } from '@idraw/util';
|
|
2
|
+
import { keyLayoutActionType, keyLayoutController, keyLayoutControlType } from './config';
|
|
3
|
+
import { keyActionType as keyElementActionType, middlewareEventSelectClear } from '../selector';
|
|
4
|
+
import { drawLayoutController } from './util';
|
|
5
|
+
import { eventChange } from '../../config';
|
|
6
|
+
export const MiddlewareLayoutSelector = (opts) => {
|
|
7
|
+
const { sharer, boardContent, calculator, viewer, eventHub } = opts;
|
|
8
|
+
const { helperContext } = boardContent;
|
|
9
|
+
let prevPoint = null;
|
|
10
|
+
const clear = () => {
|
|
11
|
+
prevPoint = null;
|
|
12
|
+
sharer.setSharedStorage(keyLayoutActionType, null);
|
|
13
|
+
sharer.setSharedStorage(keyLayoutControlType, null);
|
|
14
|
+
sharer.setSharedStorage(keyLayoutController, null);
|
|
15
|
+
};
|
|
16
|
+
const isInElementAction = () => {
|
|
17
|
+
const elementType = sharer.getSharedStorage(keyElementActionType);
|
|
18
|
+
if (elementType) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
const isDisbaledControl = (controlType) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const data = sharer.getActiveStorage('data');
|
|
26
|
+
if ((_a = data === null || data === void 0 ? void 0 : data.layout) === null || _a === void 0 ? void 0 : _a.operations) {
|
|
27
|
+
const operations = data.layout.operations;
|
|
28
|
+
if (controlType === 'left' && operations.disableLeft === true) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (controlType === 'top' && operations.disableTop === true) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (controlType === 'right' && operations.disableRight === true) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (controlType === 'bottom' && operations.disableBottom === true) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (controlType === 'top-left' && operations.disableTopLeft === true) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (controlType === 'top-right' && operations.disableTopRight === true) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (controlType === 'bottom-left' && operations.disableBottomLeft === true) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (controlType === 'bottom-right' && operations.disableBottomRight === true) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
};
|
|
55
|
+
const getLayoutSize = () => {
|
|
56
|
+
const data = sharer.getActiveStorage('data');
|
|
57
|
+
if (data === null || data === void 0 ? void 0 : data.layout) {
|
|
58
|
+
const { x, y, w, h } = data.layout;
|
|
59
|
+
return { x, y, w, h };
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
};
|
|
63
|
+
const resetController = () => {
|
|
64
|
+
const viewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
65
|
+
const size = getLayoutSize();
|
|
66
|
+
if (size) {
|
|
67
|
+
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize: 10 });
|
|
68
|
+
sharer.setSharedStorage(keyLayoutController, controller);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
sharer.setSharedStorage(keyLayoutController, null);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const resetControlType = (e) => {
|
|
75
|
+
const data = sharer.getActiveStorage('data');
|
|
76
|
+
const controller = sharer.getSharedStorage(keyLayoutController);
|
|
77
|
+
if (controller && (data === null || data === void 0 ? void 0 : data.layout) && (e === null || e === void 0 ? void 0 : e.point)) {
|
|
78
|
+
let layoutControlType = null;
|
|
79
|
+
if (controller) {
|
|
80
|
+
const { topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left } = controller;
|
|
81
|
+
const list = [topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left];
|
|
82
|
+
for (let i = 0; i < list.length; i++) {
|
|
83
|
+
const item = list[i];
|
|
84
|
+
if (isViewPointInVertexes(e.point, item.vertexes)) {
|
|
85
|
+
layoutControlType = `${item.type}`;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (layoutControlType) {
|
|
90
|
+
sharer.setSharedStorage(keyLayoutControlType, layoutControlType);
|
|
91
|
+
eventHub.trigger(middlewareEventSelectClear, {});
|
|
92
|
+
return layoutControlType;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
name: '@middleware/layout-selector',
|
|
100
|
+
use: () => {
|
|
101
|
+
clear();
|
|
102
|
+
resetController();
|
|
103
|
+
},
|
|
104
|
+
hover: (e) => {
|
|
105
|
+
if (isInElementAction()) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const prevLayoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
109
|
+
const data = sharer.getActiveStorage('data');
|
|
110
|
+
if ((data === null || data === void 0 ? void 0 : data.layout) && prevLayoutActionType !== 'resize') {
|
|
111
|
+
resetController();
|
|
112
|
+
const layoutControlType = resetControlType(e);
|
|
113
|
+
if (layoutControlType) {
|
|
114
|
+
sharer.setSharedStorage(keyLayoutActionType, 'hover');
|
|
115
|
+
if (!isDisbaledControl(layoutControlType)) {
|
|
116
|
+
eventHub.trigger('cursor', {
|
|
117
|
+
type: `resize-${layoutControlType}`,
|
|
118
|
+
groupQueue: [],
|
|
119
|
+
element: getLayoutSize()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
viewer.drawFrame();
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
sharer.setSharedStorage(keyLayoutActionType, null);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (['hover', 'resize'].includes(sharer.getSharedStorage(keyLayoutActionType))) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (prevLayoutActionType === 'hover' && !sharer.getSharedStorage(keyLayoutActionType)) {
|
|
132
|
+
viewer.drawFrame();
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
pointStart: (e) => {
|
|
136
|
+
if (isInElementAction()) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
resetController();
|
|
140
|
+
const layoutControlType = resetControlType(e);
|
|
141
|
+
prevPoint = e.point;
|
|
142
|
+
if (layoutControlType) {
|
|
143
|
+
if (isDisbaledControl(layoutControlType)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
sharer.setSharedStorage(keyLayoutActionType, 'resize');
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
150
|
+
if (['hover', 'resize'].includes(layoutActionType)) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
pointMove: (e) => {
|
|
155
|
+
if (isInElementAction()) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
159
|
+
const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
|
|
160
|
+
const data = sharer.getActiveStorage('data');
|
|
161
|
+
if (layoutControlType && isDisbaledControl(layoutControlType)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (layoutActionType === 'resize' && layoutControlType && (data === null || data === void 0 ? void 0 : data.layout)) {
|
|
165
|
+
if (prevPoint) {
|
|
166
|
+
const scale = sharer.getActiveStorage('scale');
|
|
167
|
+
const moveX = (e.point.x - prevPoint.x) / scale;
|
|
168
|
+
const moveY = (e.point.y - prevPoint.y) / scale;
|
|
169
|
+
const { x, y, w, h } = data.layout;
|
|
170
|
+
if (layoutControlType === 'top') {
|
|
171
|
+
data.layout.y = calculator.toGridNum(y + moveY);
|
|
172
|
+
data.layout.h = calculator.toGridNum(h - moveY);
|
|
173
|
+
}
|
|
174
|
+
else if (layoutControlType === 'right') {
|
|
175
|
+
data.layout.w = calculator.toGridNum(w + moveX);
|
|
176
|
+
}
|
|
177
|
+
else if (layoutControlType === 'bottom') {
|
|
178
|
+
data.layout.h = calculator.toGridNum(h + moveY);
|
|
179
|
+
}
|
|
180
|
+
else if (layoutControlType === 'left') {
|
|
181
|
+
data.layout.x = calculator.toGridNum(x + moveX);
|
|
182
|
+
data.layout.w = calculator.toGridNum(w - moveX);
|
|
183
|
+
}
|
|
184
|
+
else if (layoutControlType === 'top-left') {
|
|
185
|
+
data.layout.x = calculator.toGridNum(x + moveX);
|
|
186
|
+
data.layout.y = calculator.toGridNum(y + moveY);
|
|
187
|
+
data.layout.w = calculator.toGridNum(w - moveX);
|
|
188
|
+
data.layout.h = calculator.toGridNum(h - moveY);
|
|
189
|
+
}
|
|
190
|
+
else if (layoutControlType === 'top-right') {
|
|
191
|
+
data.layout.y = calculator.toGridNum(y + moveY);
|
|
192
|
+
data.layout.w = calculator.toGridNum(w + moveX);
|
|
193
|
+
data.layout.h = calculator.toGridNum(h - moveY);
|
|
194
|
+
}
|
|
195
|
+
else if (layoutControlType === 'bottom-right') {
|
|
196
|
+
data.layout.w = calculator.toGridNum(w + moveX);
|
|
197
|
+
data.layout.h = calculator.toGridNum(h + moveY);
|
|
198
|
+
}
|
|
199
|
+
else if (layoutControlType === 'bottom-left') {
|
|
200
|
+
data.layout.x = calculator.toGridNum(x + moveX);
|
|
201
|
+
data.layout.w = calculator.toGridNum(w - moveX);
|
|
202
|
+
data.layout.h = calculator.toGridNum(h + moveY);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
prevPoint = e.point;
|
|
206
|
+
resetController();
|
|
207
|
+
viewer.drawFrame();
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
if (['hover', 'resize'].includes(layoutActionType)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
pointEnd: () => {
|
|
215
|
+
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
216
|
+
const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
|
|
217
|
+
const data = sharer.getActiveStorage('data');
|
|
218
|
+
if (data && layoutActionType === 'resize' && layoutControlType && !isDisbaledControl(layoutControlType)) {
|
|
219
|
+
eventHub.trigger(eventChange, {
|
|
220
|
+
type: 'changeLayout',
|
|
221
|
+
data
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
clear();
|
|
225
|
+
},
|
|
226
|
+
beforeDrawFrame: ({ snapshot }) => {
|
|
227
|
+
var _a;
|
|
228
|
+
const { sharedStore, activeStore } = snapshot;
|
|
229
|
+
const layoutActionType = sharedStore[keyLayoutActionType];
|
|
230
|
+
const layoutControlType = sharedStore[keyLayoutControlType];
|
|
231
|
+
if (((_a = activeStore.data) === null || _a === void 0 ? void 0 : _a.layout) && layoutActionType && layoutControlType) {
|
|
232
|
+
if (['hover', 'resize'].includes(layoutActionType)) {
|
|
233
|
+
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
234
|
+
const { x, y, w, h } = activeStore.data.layout;
|
|
235
|
+
const size = { x, y, w, h };
|
|
236
|
+
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize: 10 });
|
|
237
|
+
drawLayoutController(helperContext, { controller, operations: activeStore.data.layout.operations || {} });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
scrollX: () => {
|
|
242
|
+
clear();
|
|
243
|
+
},
|
|
244
|
+
scrollY: () => {
|
|
245
|
+
clear();
|
|
246
|
+
},
|
|
247
|
+
wheelScale: () => {
|
|
248
|
+
clear();
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LayoutSizeController } from '@idraw/types';
|
|
2
|
+
import { keyLayoutActionType, keyLayoutControlType, keyLayoutController } from './config';
|
|
3
|
+
import { keyActionType as keyElementActionType } from '../selector';
|
|
4
|
+
import type { ActionType as ElementActionType } from '../selector';
|
|
5
|
+
export type ActionType = 'hover' | 'resize' | null;
|
|
6
|
+
export type ControlType = 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
7
|
+
export type LayoutSelectorSharedStorage = {
|
|
8
|
+
[keyLayoutActionType]: ActionType | null;
|
|
9
|
+
[keyLayoutControlType]: ControlType | null;
|
|
10
|
+
[keyLayoutController]: LayoutSizeController | null;
|
|
11
|
+
[keyElementActionType]: ElementActionType | null;
|
|
12
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { selectColor, disableColor } from './config';
|
|
2
|
+
function drawControllerBox(ctx, boxVertexes) {
|
|
3
|
+
ctx.setLineDash([]);
|
|
4
|
+
ctx.fillStyle = '#FFFFFF';
|
|
5
|
+
ctx.beginPath();
|
|
6
|
+
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
7
|
+
ctx.lineTo(boxVertexes[1].x, boxVertexes[1].y);
|
|
8
|
+
ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
|
|
9
|
+
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
10
|
+
ctx.closePath();
|
|
11
|
+
ctx.fill();
|
|
12
|
+
ctx.strokeStyle = selectColor;
|
|
13
|
+
ctx.lineWidth = 2;
|
|
14
|
+
ctx.beginPath();
|
|
15
|
+
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
16
|
+
ctx.lineTo(boxVertexes[1].x, boxVertexes[1].y);
|
|
17
|
+
ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
|
|
18
|
+
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
19
|
+
ctx.closePath();
|
|
20
|
+
ctx.stroke();
|
|
21
|
+
}
|
|
22
|
+
function drawControllerCross(ctx, opts) {
|
|
23
|
+
const { vertexes, strokeStyle, lineWidth } = opts;
|
|
24
|
+
ctx.setLineDash([]);
|
|
25
|
+
ctx.strokeStyle = strokeStyle;
|
|
26
|
+
ctx.lineWidth = lineWidth;
|
|
27
|
+
ctx.beginPath();
|
|
28
|
+
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
29
|
+
ctx.lineTo(vertexes[2].x, vertexes[2].y);
|
|
30
|
+
ctx.closePath();
|
|
31
|
+
ctx.stroke();
|
|
32
|
+
ctx.beginPath();
|
|
33
|
+
ctx.moveTo(vertexes[1].x, vertexes[1].y);
|
|
34
|
+
ctx.lineTo(vertexes[3].x, vertexes[3].y);
|
|
35
|
+
ctx.closePath();
|
|
36
|
+
ctx.stroke();
|
|
37
|
+
}
|
|
38
|
+
function drawControllerLine(ctx, opts) {
|
|
39
|
+
const { start, end, centerVertexes, disabled } = opts;
|
|
40
|
+
const lineWidth = disabled === true ? 1 : 2;
|
|
41
|
+
const strokeStyle = disabled === true ? disableColor : selectColor;
|
|
42
|
+
ctx.setLineDash([]);
|
|
43
|
+
ctx.strokeStyle = strokeStyle;
|
|
44
|
+
ctx.lineWidth = lineWidth;
|
|
45
|
+
ctx.beginPath();
|
|
46
|
+
ctx.moveTo(start.x, start.y);
|
|
47
|
+
ctx.lineTo(end.x, end.y);
|
|
48
|
+
ctx.closePath();
|
|
49
|
+
ctx.stroke();
|
|
50
|
+
if (disabled === true) {
|
|
51
|
+
drawControllerCross(ctx, {
|
|
52
|
+
vertexes: centerVertexes,
|
|
53
|
+
lineWidth,
|
|
54
|
+
strokeStyle
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function drawLayoutController(ctx, opts) {
|
|
59
|
+
const { controller, operations } = opts;
|
|
60
|
+
const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, rightMiddle, bottomMiddle, leftMiddle } = controller;
|
|
61
|
+
drawControllerLine(ctx, { start: topLeft.center, end: topRight.center, centerVertexes: topMiddle.vertexes, disabled: !!(operations === null || operations === void 0 ? void 0 : operations.disableTop) });
|
|
62
|
+
drawControllerLine(ctx, { start: topRight.center, end: bottomRight.center, centerVertexes: rightMiddle.vertexes, disabled: !!(operations === null || operations === void 0 ? void 0 : operations.disableRight) });
|
|
63
|
+
drawControllerLine(ctx, { start: bottomRight.center, end: bottomLeft.center, centerVertexes: bottomMiddle.vertexes, disabled: !!(operations === null || operations === void 0 ? void 0 : operations.disableBottom) });
|
|
64
|
+
drawControllerLine(ctx, { start: bottomLeft.center, end: topLeft.center, centerVertexes: leftMiddle.vertexes, disabled: !!(operations === null || operations === void 0 ? void 0 : operations.disableLeft) });
|
|
65
|
+
const disabledOpts = {
|
|
66
|
+
lineWidth: 1,
|
|
67
|
+
strokeStyle: disableColor
|
|
68
|
+
};
|
|
69
|
+
if ((operations === null || operations === void 0 ? void 0 : operations.disableTopLeft) === true) {
|
|
70
|
+
drawControllerCross(ctx, Object.assign({ vertexes: topLeft.vertexes }, disabledOpts));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
drawControllerBox(ctx, topLeft.vertexes);
|
|
74
|
+
}
|
|
75
|
+
if ((operations === null || operations === void 0 ? void 0 : operations.disableTopRight) === true) {
|
|
76
|
+
drawControllerCross(ctx, Object.assign({ vertexes: topRight.vertexes }, disabledOpts));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
drawControllerBox(ctx, topRight.vertexes);
|
|
80
|
+
}
|
|
81
|
+
if ((operations === null || operations === void 0 ? void 0 : operations.disableBottomRight) === true) {
|
|
82
|
+
drawControllerCross(ctx, Object.assign({ vertexes: bottomRight.vertexes }, disabledOpts));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
drawControllerBox(ctx, bottomRight.vertexes);
|
|
86
|
+
}
|
|
87
|
+
if ((operations === null || operations === void 0 ? void 0 : operations.disableBottomLeft) === true) {
|
|
88
|
+
drawControllerCross(ctx, Object.assign({ vertexes: bottomLeft.vertexes }, disabledOpts));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
drawControllerBox(ctx, bottomLeft.vertexes);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CoreEventMap } from '@idraw/types';
|
|
2
|
-
import type { BoardMiddleware, DeepSelectorSharedStorage } from './types';
|
|
2
|
+
import type { BoardMiddleware, ActionType, DeepSelectorSharedStorage } from './types';
|
|
3
3
|
import { keyActionType, keyResizeType, keyGroupQueue, keySelectedElementList } from './config';
|
|
4
4
|
export { keySelectedElementList, keyActionType, keyResizeType, keyGroupQueue };
|
|
5
|
-
export type { DeepSelectorSharedStorage };
|
|
5
|
+
export type { DeepSelectorSharedStorage, ActionType };
|
|
6
6
|
export declare const middlewareEventSelect: string;
|
|
7
7
|
export declare const middlewareEventSelectClear: string;
|
|
8
8
|
export declare const MiddlewareSelector: BoardMiddleware<DeepSelectorSharedStorage, CoreEventMap>;
|
|
@@ -5,6 +5,7 @@ import { getPointTarget, resizeElement, rotateElement, getSelectedListArea, calc
|
|
|
5
5
|
import { keyActionType, keyResizeType, keyAreaStart, keyAreaEnd, keyGroupQueue, keyGroupQueueVertexesList, keyHoverElement, keyHoverElementVertexes, keySelectedElementList, keySelectedElementListVertexes, keySelectedElementController, keySelectedElementPosition, keySelectedReferenceXLines, keySelectedReferenceYLines, keyIsMoving, controllerSize } from './config';
|
|
6
6
|
import { calcReferenceInfo } from './reference';
|
|
7
7
|
import { middlewareEventTextEdit } from '../text-editor';
|
|
8
|
+
import { eventChange } from '../../config';
|
|
8
9
|
export { keySelectedElementList, keyActionType, keyResizeType, keyGroupQueue };
|
|
9
10
|
export const middlewareEventSelect = '@middleware/select';
|
|
10
11
|
export const middlewareEventSelectClear = '@middleware/select-clear';
|
|
@@ -201,6 +202,11 @@ export const MiddlewareSelector = (opts) => {
|
|
|
201
202
|
}) }));
|
|
202
203
|
triggerCursor(target);
|
|
203
204
|
if (target.type === null) {
|
|
205
|
+
if (sharer.getSharedStorage(keyHoverElement) || sharer.getSharedStorage(keyHoverElementVertexes)) {
|
|
206
|
+
sharer.setSharedStorage(keyHoverElement, null);
|
|
207
|
+
sharer.setSharedStorage(keyHoverElementVertexes, null);
|
|
208
|
+
viewer.drawFrame();
|
|
209
|
+
}
|
|
204
210
|
return;
|
|
205
211
|
}
|
|
206
212
|
if (target.type === 'over-element' &&
|
|
@@ -530,7 +536,7 @@ export const MiddlewareSelector = (opts) => {
|
|
|
530
536
|
if (type === 'resize') {
|
|
531
537
|
type = 'resizeElement';
|
|
532
538
|
}
|
|
533
|
-
eventHub.trigger(
|
|
539
|
+
eventHub.trigger(eventChange, { data, type });
|
|
534
540
|
}
|
|
535
541
|
viewer.drawFrame();
|
|
536
542
|
};
|