@idraw/core 0.4.0-beta.36 → 0.4.0-beta.38

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.js CHANGED
@@ -32,6 +32,7 @@ export class Core {
32
32
  const { devicePixelRatio = 1, width, height, createCustomContext2D } = opts;
33
33
  __classPrivateFieldSet(this, _Core_container, container, "f");
34
34
  const canvas = document.createElement('canvas');
35
+ canvas.setAttribute('tabindex', '0');
35
36
  __classPrivateFieldSet(this, _Core_canvas, canvas, "f");
36
37
  __classPrivateFieldGet(this, _Core_instances, "m", _Core_initContainer).call(this);
37
38
  container.appendChild(canvas);
@@ -27,6 +27,7 @@ export const MiddlewareInfo = (opts, config) => {
27
27
  eventHub.off(MIDDLEWARE_INTERNAL_EVENT_SHOW_INFO_ANGLE, showInfoAngleCallback);
28
28
  },
29
29
  beforeDrawFrame({ snapshot }) {
30
+ var _a;
30
31
  const { sharedStore } = snapshot;
31
32
  const selectedElementList = sharedStore[keySelectedElementList];
32
33
  const actionType = sharedStore[keyActionType];
@@ -104,18 +105,20 @@ export const MiddlewareInfo = (opts, config) => {
104
105
  style
105
106
  });
106
107
  if (showAngleInfo) {
107
- drawAngleInfoText(overlayContext, {
108
- point: {
109
- x: rectInfo.top.x + infoFontSize + 4,
110
- y: rectInfo.top.y - infoFontSize * 2 - 18
111
- },
112
- rotateCenter: rectInfo.center,
113
- angle: totalAngle,
114
- text: angleText,
115
- fontSize: infoFontSize,
116
- lineHeight: infoLineHeight,
117
- style
118
- });
108
+ if (((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.rotatable) !== false) {
109
+ drawAngleInfoText(overlayContext, {
110
+ point: {
111
+ x: rectInfo.top.x + infoFontSize + 4,
112
+ y: rectInfo.top.y - infoFontSize * 2 - 18
113
+ },
114
+ rotateCenter: rectInfo.center,
115
+ angle: totalAngle,
116
+ text: angleText,
117
+ fontSize: infoFontSize,
118
+ lineHeight: infoLineHeight,
119
+ style
120
+ });
121
+ }
119
122
  }
120
123
  }
121
124
  }
@@ -3,7 +3,9 @@ export declare const key = "LAYOUT_SELECT";
3
3
  export declare const keyLayoutActionType: unique symbol;
4
4
  export declare const keyLayoutControlType: unique symbol;
5
5
  export declare const keyLayoutController: unique symbol;
6
- export declare const keyLayoutIsHover: unique symbol;
6
+ export declare const keyLayoutIsHoverContent: unique symbol;
7
+ export declare const keyLayoutIsHoverController: unique symbol;
7
8
  export declare const keyLayoutIsSelected: unique symbol;
9
+ export declare const keyLayoutIsBusyMoving: unique symbol;
8
10
  export declare const controllerSize = 10;
9
11
  export declare const defaultStyle: MiddlewareLayoutSelectorStyle;
@@ -2,8 +2,10 @@ export const key = 'LAYOUT_SELECT';
2
2
  export const keyLayoutActionType = Symbol(`${key}_layoutActionType`);
3
3
  export const keyLayoutControlType = Symbol(`${key}_layoutControlType`);
4
4
  export const keyLayoutController = Symbol(`${key}_layoutController`);
5
- export const keyLayoutIsHover = Symbol(`${key}_layoutIsHover`);
5
+ export const keyLayoutIsHoverContent = Symbol(`${key}_layoutIsHoverContent`);
6
+ export const keyLayoutIsHoverController = Symbol(`${key}_layoutIsHoverController`);
6
7
  export const keyLayoutIsSelected = Symbol(`${key}_layoutIsSelected`);
8
+ export const keyLayoutIsBusyMoving = Symbol(`${key}_layoutIsSelected`);
7
9
  export const controllerSize = 10;
8
10
  export const defaultStyle = {
9
11
  activeColor: '#b331c9'
@@ -1,5 +1,5 @@
1
1
  import type { BoardMiddleware, MiddlewareLayoutSelectorConfig, CoreEventMap } from '@idraw/types';
2
2
  import type { LayoutSelectorSharedStorage } from './types';
3
- import { keyLayoutIsSelected } from './config';
4
- export { keyLayoutIsSelected };
3
+ import { keyLayoutIsSelected, keyLayoutIsBusyMoving } from './config';
4
+ export { keyLayoutIsSelected, keyLayoutIsBusyMoving };
5
5
  export declare const MiddlewareLayoutSelector: BoardMiddleware<LayoutSelectorSharedStorage, CoreEventMap, MiddlewareLayoutSelectorConfig>;
@@ -1,9 +1,9 @@
1
1
  import { calcLayoutSizeController, isViewPointInVertexes, getViewScaleInfoFromSnapshot, isViewPointInElementSize, calcViewElementSize } from '@idraw/util';
2
- import { keyLayoutActionType, keyLayoutController, keyLayoutControlType, keyLayoutIsHover, keyLayoutIsSelected, controllerSize, defaultStyle } from './config';
3
- import { keyActionType as keyElementActionType, keyHoverElement } from '../selector';
2
+ import { keyLayoutActionType, keyLayoutController, keyLayoutControlType, keyLayoutIsHoverContent, keyLayoutIsHoverController, keyLayoutIsSelected, keyLayoutIsBusyMoving, controllerSize, defaultStyle } from './config';
3
+ import { keyActionType as keyElementActionType } from '../selector';
4
4
  import { drawLayoutController, drawLayoutHover } from './util';
5
5
  import { coreEventKeys } from '../../config';
6
- export { keyLayoutIsSelected };
6
+ export { keyLayoutIsSelected, keyLayoutIsBusyMoving };
7
7
  export const MiddlewareLayoutSelector = (opts, config) => {
8
8
  const { sharer, boardContent, calculator, viewer, eventHub } = opts;
9
9
  const { overlayContext } = boardContent;
@@ -11,27 +11,19 @@ export const MiddlewareLayoutSelector = (opts, config) => {
11
11
  const { activeColor } = innerConfig;
12
12
  const style = { activeColor };
13
13
  let prevPoint = null;
14
- let prevIsHover = null;
14
+ let prevIsHoverContent = null;
15
15
  let prevIsSelected = null;
16
- let isBusy = null;
17
16
  const clear = () => {
18
17
  prevPoint = null;
19
18
  sharer.setSharedStorage(keyLayoutActionType, null);
20
19
  sharer.setSharedStorage(keyLayoutControlType, null);
21
20
  sharer.setSharedStorage(keyLayoutController, null);
22
- sharer.setSharedStorage(keyLayoutIsHover, null);
21
+ sharer.setSharedStorage(keyLayoutIsHoverContent, null);
22
+ sharer.setSharedStorage(keyLayoutIsHoverController, null);
23
23
  sharer.setSharedStorage(keyLayoutIsSelected, null);
24
- prevIsHover = null;
24
+ sharer.setSharedStorage(keyLayoutIsBusyMoving, null);
25
+ prevIsHoverContent = null;
25
26
  prevIsSelected = null;
26
- isBusy = null;
27
- };
28
- const isInElementHover = () => {
29
- const hoverElement = sharer.getSharedStorage(keyHoverElement);
30
- if (hoverElement) {
31
- clear();
32
- return true;
33
- }
34
- return false;
35
27
  };
36
28
  const isInElementAction = () => {
37
29
  const elementActionType = sharer.getSharedStorage(keyElementActionType);
@@ -78,6 +70,7 @@ export const MiddlewareLayoutSelector = (opts, config) => {
78
70
  const resetControlType = (e) => {
79
71
  const data = sharer.getActiveStorage('data');
80
72
  const controller = sharer.getSharedStorage(keyLayoutController);
73
+ let controllerType = null;
81
74
  if (controller && (data === null || data === void 0 ? void 0 : data.layout) && (e === null || e === void 0 ? void 0 : e.point)) {
82
75
  let layoutControlType = null;
83
76
  if (controller) {
@@ -93,14 +86,20 @@ export const MiddlewareLayoutSelector = (opts, config) => {
93
86
  if (layoutControlType) {
94
87
  sharer.setSharedStorage(keyLayoutControlType, layoutControlType);
95
88
  eventHub.trigger(coreEventKeys.CLEAR_SELECT);
96
- return layoutControlType;
89
+ controllerType = layoutControlType;
97
90
  }
98
91
  }
99
92
  }
100
- return null;
93
+ if (controllerType) {
94
+ sharer.setSharedStorage(keyLayoutIsHoverController, true);
95
+ }
96
+ else {
97
+ sharer.setSharedStorage(keyLayoutIsHoverController, false);
98
+ }
99
+ return controllerType;
101
100
  };
102
101
  const updateCursor = (controlType) => {
103
- if (isBusy === true) {
102
+ if (sharer.getSharedStorage(keyLayoutIsBusyMoving) === true) {
104
103
  return;
105
104
  }
106
105
  eventHub.trigger(coreEventKeys.CURSOR, {
@@ -116,23 +115,20 @@ export const MiddlewareLayoutSelector = (opts, config) => {
116
115
  resetController();
117
116
  },
118
117
  hover: (e) => {
119
- if (isBusy === true) {
118
+ if (sharer.getSharedStorage(keyLayoutIsBusyMoving) === true) {
120
119
  return;
121
120
  }
122
121
  if (isInElementAction()) {
123
122
  return;
124
123
  }
125
- if (isInElementHover()) {
126
- return;
127
- }
128
124
  if (isInLayout(e.point)) {
129
- sharer.setSharedStorage(keyLayoutIsHover, true);
125
+ sharer.setSharedStorage(keyLayoutIsHoverContent, true);
130
126
  }
131
127
  else {
132
- sharer.setSharedStorage(keyLayoutIsHover, false);
133
- if (prevIsHover === true) {
128
+ sharer.setSharedStorage(keyLayoutIsHoverContent, false);
129
+ if (prevIsHoverContent === true) {
134
130
  viewer.drawFrame();
135
- prevIsHover = false;
131
+ prevIsHoverContent = false;
136
132
  }
137
133
  }
138
134
  if (sharer.getSharedStorage(keyLayoutIsSelected) === true) {
@@ -155,12 +151,18 @@ export const MiddlewareLayoutSelector = (opts, config) => {
155
151
  updateCursor(layoutControlType);
156
152
  }
157
153
  }
154
+ if (sharer.getSharedStorage(keyLayoutIsHoverController) === true) {
155
+ return false;
156
+ }
158
157
  return;
159
158
  }
160
- if (sharer.getSharedStorage(keyLayoutIsHover) && !prevIsHover) {
159
+ if (sharer.getSharedStorage(keyLayoutIsHoverContent) && !prevIsHoverContent) {
161
160
  viewer.drawFrame();
162
161
  }
163
- prevIsHover = sharer.getSharedStorage(keyLayoutIsHover);
162
+ prevIsHoverContent = sharer.getSharedStorage(keyLayoutIsHoverContent);
163
+ if (sharer.getSharedStorage(keyLayoutIsHoverController) === true) {
164
+ return false;
165
+ }
164
166
  },
165
167
  pointStart: (e) => {
166
168
  if (isInElementAction()) {
@@ -186,6 +188,9 @@ export const MiddlewareLayoutSelector = (opts, config) => {
186
188
  viewer.drawFrame();
187
189
  }
188
190
  prevIsSelected = sharer.getSharedStorage(keyLayoutIsSelected);
191
+ if (sharer.getSharedStorage(keyLayoutIsHoverController) === true) {
192
+ return false;
193
+ }
189
194
  },
190
195
  pointMove: (e) => {
191
196
  if (!sharer.getSharedStorage(keyLayoutIsSelected)) {
@@ -198,7 +203,7 @@ export const MiddlewareLayoutSelector = (opts, config) => {
198
203
  const data = sharer.getActiveStorage('data');
199
204
  if (layoutActionType === 'resize' && layoutControlType && (data === null || data === void 0 ? void 0 : data.layout)) {
200
205
  if (prevPoint) {
201
- isBusy = true;
206
+ sharer.setSharedStorage(keyLayoutIsBusyMoving, true);
202
207
  const scale = sharer.getActiveStorage('scale');
203
208
  const viewMoveX = e.point.x - prevPoint.x;
204
209
  const viewMoveY = e.point.y - prevPoint.y;
@@ -288,7 +293,7 @@ export const MiddlewareLayoutSelector = (opts, config) => {
288
293
  }
289
294
  },
290
295
  pointEnd: () => {
291
- isBusy = false;
296
+ sharer.setSharedStorage(keyLayoutIsBusyMoving, false);
292
297
  const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
293
298
  const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
294
299
  const data = sharer.getActiveStorage('data');
@@ -298,6 +303,9 @@ export const MiddlewareLayoutSelector = (opts, config) => {
298
303
  data
299
304
  });
300
305
  }
306
+ if (sharer.getSharedStorage(keyLayoutIsHoverController) === true) {
307
+ return false;
308
+ }
301
309
  },
302
310
  beforeDrawFrame: ({ snapshot }) => {
303
311
  var _a;
@@ -306,7 +314,7 @@ export const MiddlewareLayoutSelector = (opts, config) => {
306
314
  }
307
315
  const { sharedStore, activeStore } = snapshot;
308
316
  const layoutActionType = sharedStore[keyLayoutActionType];
309
- const layoutIsHover = sharedStore[keyLayoutIsHover];
317
+ const layoutIsHover = sharedStore[keyLayoutIsHoverContent];
310
318
  const layoutIsSelected = sharedStore[keyLayoutIsSelected];
311
319
  if ((_a = activeStore.data) === null || _a === void 0 ? void 0 : _a.layout) {
312
320
  const { x, y, w, h } = activeStore.data.layout;
@@ -1,5 +1,5 @@
1
1
  import type { LayoutSizeController, Element } from '@idraw/types';
2
- import { keyLayoutActionType, keyLayoutControlType, keyLayoutController, keyLayoutIsHover, keyLayoutIsSelected } from './config';
2
+ import { keyLayoutActionType, keyLayoutControlType, keyLayoutController, keyLayoutIsHoverContent, keyLayoutIsHoverController, keyLayoutIsSelected, keyLayoutIsBusyMoving } from './config';
3
3
  import { keyActionType as keyElementActionType, keyHoverElement } from '../selector';
4
4
  import type { ActionType as ElementActionType } from '../selector';
5
5
  export type ActionType = 'resize' | null;
@@ -10,6 +10,8 @@ export type LayoutSelectorSharedStorage = {
10
10
  [keyLayoutController]: LayoutSizeController | null;
11
11
  [keyElementActionType]: ElementActionType | null;
12
12
  [keyHoverElement]: Element | null;
13
- [keyLayoutIsHover]: boolean | null;
13
+ [keyLayoutIsHoverContent]: boolean | null;
14
+ [keyLayoutIsHoverController]: boolean | null;
14
15
  [keyLayoutIsSelected]: boolean | null;
16
+ [keyLayoutIsBusyMoving]: boolean | null;
15
17
  };
@@ -1,2 +1,2 @@
1
- import { keyLayoutActionType, keyLayoutControlType, keyLayoutController, keyLayoutIsHover, keyLayoutIsSelected } from './config';
1
+ import { keyLayoutActionType, keyLayoutControlType, keyLayoutController, keyLayoutIsHoverContent, keyLayoutIsHoverController, keyLayoutIsSelected, keyLayoutIsBusyMoving } from './config';
2
2
  import { keyActionType as keyElementActionType, keyHoverElement } from '../selector';
@@ -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
- drawCircleController(ctx, calcViewPointSize(rotate.center, opts), Object.assign(Object.assign({}, ctrlOpts), { size: rotate.size, borderWidth: 0 }));
52
- const rotateCenter = calcViewPointSize(rotate.center, opts);
53
- 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);
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,11 +1,11 @@
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, calcMoveInGroup } from './util';
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';
8
- import { keyLayoutIsSelected } from '../layout-selector';
8
+ import { keyLayoutIsSelected, keyLayoutIsBusyMoving } from '../layout-selector';
9
9
  import { createRotateControllerPattern } from './pattern';
10
10
  import { MIDDLEWARE_INTERNAL_EVENT_SHOW_INFO_ANGLE } from '../info';
11
11
  export { keySelectedElementList, keyHoverElement, keyActionType, keyResizeType, keyGroupQueue };
@@ -174,6 +174,10 @@ export const MiddlewareSelector = (opts, config) => {
174
174
  hover: (e) => {
175
175
  var _a, _b, _c, _d, _e;
176
176
  const layoutIsSelected = sharer.getSharedStorage(keyLayoutIsSelected);
177
+ const layoutIsBusyMoving = sharer.getSharedStorage(keyLayoutIsBusyMoving);
178
+ if (layoutIsBusyMoving === true) {
179
+ return;
180
+ }
177
181
  const resizeType = sharer.getSharedStorage(keyResizeType);
178
182
  const actionType = sharer.getSharedStorage(keyActionType);
179
183
  const groupQueue = sharer.getSharedStorage(keyGroupQueue);
@@ -361,7 +365,7 @@ export const MiddlewareSelector = (opts, config) => {
361
365
  inBusyMode = 'drag';
362
366
  eventHub.trigger(MIDDLEWARE_INTERNAL_EVENT_SHOW_INFO_ANGLE, { show: false });
363
367
  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) {
364
- const { moveX, moveY } = calcMoveInGroup(originalStart, end, groupQueue);
368
+ const { moveX, moveY } = calcPointMoveElementInGroup(originalStart, end, groupQueue);
365
369
  let totalMoveX = calculator.toGridNum(moveX / scale);
366
370
  let totalMoveY = calculator.toGridNum(moveY / scale);
367
371
  if (enableSnapToGrid === true) {
@@ -695,7 +699,19 @@ export const MiddlewareSelector = (opts, config) => {
695
699
  const isMoving = sharedStore[keyIsMoving];
696
700
  const enableSnapToGrid = sharedStore[keyEnableSnapToGrid];
697
701
  const drawBaseOpts = { calculator, viewScaleInfo, viewSizeInfo, style };
698
- const selectedElementController = sharedStore[keySelectedElementController];
702
+ let selectedElementController = sharedStore[keySelectedElementController];
703
+ if (selectedElementController && selectedElements.length === 1 && elem) {
704
+ if (!isSameElementSize(elem, selectedElementController.originalElementSize)) {
705
+ selectedElementController = calcElementSizeController(elem, {
706
+ groupQueue: groupQueue || [],
707
+ controllerSize,
708
+ viewScaleInfo,
709
+ rotateControllerPosition,
710
+ rotateControllerSize
711
+ });
712
+ sharer.setSharedStorage(keySelectedElementController, selectedElementController);
713
+ }
714
+ }
699
715
  const isHoverLocked = !!((_a = hoverElement === null || hoverElement === void 0 ? void 0 : hoverElement.operations) === null || _a === void 0 ? void 0 : _a.locked);
700
716
  if ((groupQueue === null || groupQueue === void 0 ? void 0 : groupQueue.length) > 0) {
701
717
  drawGroupQueueVertexesWrappers(overlayContext, groupQueueVertexesList, drawBaseOpts);
@@ -1,6 +1,6 @@
1
1
  import { Data, ElementSize, ElementType, Element, ViewContext2D, Point, PointSize, ViewScaleInfo, ViewSizeInfo, ViewCalculator, PointWatcherEvent, BoardMiddleware, ViewRectVertexes, ElementSizeController, ElementPosition } from '@idraw/types';
2
2
  import { keyActionType, keyResizeType, keyAreaStart, keyAreaEnd, keyGroupQueue, keyGroupQueueVertexesList, keyHoverElement, keyHoverElementVertexes, keySelectedElementList, keySelectedElementListVertexes, keySelectedElementController, keySelectedElementPosition, keyIsMoving, keyEnableSelectInGroup, keyEnableSnapToGrid, keyDebugElemCenter, keyDebugEnd0, keyDebugEndHorizontal, keyDebugEndVertical, keyDebugStartHorizontal, keyDebugStartVertical } from './config';
3
- import { keyLayoutIsSelected } from '../layout-selector';
3
+ import { keyLayoutIsSelected, keyLayoutIsBusyMoving } from '../layout-selector';
4
4
  export { Data, ElementType, Element, ElementSize, ViewContext2D, Point, PointSize, ViewScaleInfo, ViewSizeInfo, ViewCalculator, PointWatcherEvent, BoardMiddleware };
5
5
  export type ControllerStyle = ElementSize & {
6
6
  borderWidth: number;
@@ -42,4 +42,5 @@ export type DeepSelectorSharedStorage = {
42
42
  [keyDebugStartHorizontal]: PointSize | null;
43
43
  [keyDebugStartVertical]: PointSize | null;
44
44
  [keyLayoutIsSelected]: boolean | null;
45
+ [keyLayoutIsBusyMoving]: boolean | null;
45
46
  };
@@ -1,2 +1,2 @@
1
1
  import { keyActionType, keyResizeType, keyAreaStart, keyAreaEnd, keyGroupQueue, keyGroupQueueVertexesList, keyHoverElement, keyHoverElementVertexes, keySelectedElementList, keySelectedElementListVertexes, keySelectedElementController, keySelectedElementPosition, keyIsMoving, keyEnableSelectInGroup, keyEnableSnapToGrid, keyDebugElemCenter, keyDebugEnd0, keyDebugEndHorizontal, keyDebugEndVertical, keyDebugStartHorizontal, keyDebugStartVertical } from './config';
2
- import { keyLayoutIsSelected } from '../layout-selector';
2
+ import { keyLayoutIsSelected, keyLayoutIsBusyMoving } from '../layout-selector';
@@ -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, rotatePointInGroup, rotatePoint, parseAngleToRadian, parseRadianToAngle, limitAngle, calcRadian } from '@idraw/util';
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, rotate];
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 (((_a = lastGroup === null || lastGroup === void 0 ? void 0 : lastGroup.detail) === null || _a === void 0 ? void 0 : _a.children) && Array.isArray((_b = lastGroup === null || lastGroup === void 0 ? void 0 : lastGroup.detail) === null || _b === void 0 ? void 0 : _b.children)) {
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 && ((_c = element === null || element === void 0 ? void 0 : element.operations) === null || _c === void 0 ? void 0 : _c.invisible) !== true) {
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
- }