@idraw/core 0.4.0-alpha.3 → 0.4.0-alpha.4

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.
@@ -1,7 +1,8 @@
1
1
  import type { Data, PointSize, CoreOptions, BoardMiddleware, ViewSizeInfo, CoreEvent } from '@idraw/types';
2
- export { MiddlewareSelector } from './middleware/selector';
2
+ export { MiddlewareSelector, middlewareEventSelect } from './middleware/selector';
3
3
  export { MiddlewareScroller } from './middleware/scroller';
4
- export { MiddlewareScaler } from './middleware/scaler';
4
+ export { MiddlewareScaler, middlewareEventScale } from './middleware/scaler';
5
+ export { MiddlewareRuler, middlewareEventRuler } from './middleware/ruler';
5
6
  export declare class Core {
6
7
  private _board;
7
8
  private _opts;
package/dist/esm/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Board } from '@idraw/board';
2
2
  import { createBoardContexts, validateElements } from '@idraw/util';
3
3
  import { Cursor } from './lib/cursor';
4
- export { MiddlewareSelector } from './middleware/selector';
4
+ export { MiddlewareSelector, middlewareEventSelect } from './middleware/selector';
5
5
  export { MiddlewareScroller } from './middleware/scroller';
6
- export { MiddlewareScaler } from './middleware/scaler';
6
+ export { MiddlewareScaler, middlewareEventScale } from './middleware/scaler';
7
+ export { MiddlewareRuler, middlewareEventRuler } from './middleware/ruler';
7
8
  export class Core {
8
9
  constructor(container, opts) {
9
10
  const { devicePixelRatio = 1, width, height } = opts;
@@ -42,6 +43,8 @@ export class Core {
42
43
  }
43
44
  scale(opts) {
44
45
  this._board.scale(opts);
46
+ const viewer = this._board.getViewer();
47
+ viewer.drawFrame();
45
48
  }
46
49
  resize(newViewSize) {
47
50
  const { _board: board } = this;
@@ -0,0 +1,3 @@
1
+ import type { BoardMiddleware, CoreEvent } from '@idraw/types';
2
+ export declare const middlewareEventRuler = "@middleware/show-ruler";
3
+ export declare const MiddlewareRuler: BoardMiddleware<Record<string, any>, CoreEvent>;
@@ -0,0 +1,36 @@
1
+ import { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from '@idraw/util';
2
+ import { drawRulerBackground, drawXRuler, drawYRuler, calcXRulerScaleList, calcYRulerScaleList, drawUnderGrid } from './util';
3
+ export const middlewareEventRuler = '@middleware/show-ruler';
4
+ export const MiddlewareRuler = (opts) => {
5
+ const key = 'RULE';
6
+ const { viewContent, viewer, eventHub } = opts;
7
+ const { helperContext, underContext } = viewContent;
8
+ let showRuler = true;
9
+ eventHub.on(middlewareEventRuler, (e) => {
10
+ if (typeof (e === null || e === void 0 ? void 0 : e.show) === 'boolean') {
11
+ showRuler = e.show;
12
+ viewer.drawFrame();
13
+ }
14
+ });
15
+ return {
16
+ mode: key,
17
+ isDefault: true,
18
+ beforeDrawFrame: ({ snapshot }) => {
19
+ if (showRuler === true) {
20
+ const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
21
+ const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
22
+ drawRulerBackground(helperContext, { viewScaleInfo, viewSizeInfo });
23
+ const xList = calcXRulerScaleList({ viewScaleInfo, viewSizeInfo });
24
+ drawXRuler(helperContext, { scaleList: xList });
25
+ const yList = calcYRulerScaleList({ viewScaleInfo, viewSizeInfo });
26
+ drawYRuler(helperContext, { scaleList: yList });
27
+ drawUnderGrid(underContext, {
28
+ xList,
29
+ yList,
30
+ viewScaleInfo,
31
+ viewSizeInfo
32
+ });
33
+ }
34
+ }
35
+ };
36
+ };
@@ -0,0 +1,33 @@
1
+ import type { ViewScaleInfo, ViewSizeInfo, ViewContext2D } from '@idraw/types';
2
+ interface RulerScale {
3
+ num: number;
4
+ showNum: boolean;
5
+ position: number;
6
+ isKeyNum: boolean;
7
+ isSubKeyNum: boolean;
8
+ }
9
+ export declare function calcXRulerScaleList(opts: {
10
+ viewScaleInfo: ViewScaleInfo;
11
+ viewSizeInfo: ViewSizeInfo;
12
+ }): RulerScale[];
13
+ export declare function calcYRulerScaleList(opts: {
14
+ viewScaleInfo: ViewScaleInfo;
15
+ viewSizeInfo: ViewSizeInfo;
16
+ }): RulerScale[];
17
+ export declare function drawXRuler(ctx: ViewContext2D, opts: {
18
+ scaleList: RulerScale[];
19
+ }): void;
20
+ export declare function drawYRuler(ctx: ViewContext2D, opts: {
21
+ scaleList: RulerScale[];
22
+ }): void;
23
+ export declare function drawRulerBackground(ctx: ViewContext2D, opts: {
24
+ viewScaleInfo: ViewScaleInfo;
25
+ viewSizeInfo: ViewSizeInfo;
26
+ }): void;
27
+ export declare function drawUnderGrid(ctx: ViewContext2D, opts: {
28
+ xList: RulerScale[];
29
+ yList: RulerScale[];
30
+ viewScaleInfo: ViewScaleInfo;
31
+ viewSizeInfo: ViewSizeInfo;
32
+ }): void;
33
+ export {};
@@ -0,0 +1,179 @@
1
+ import { formatNumber, rotateByCenter } from '@idraw/util';
2
+ const rulerSize = 16;
3
+ const background = '#FFFFFFA8';
4
+ const borderColor = '#00000080';
5
+ const scaleColor = '#000000';
6
+ const textColor = '#00000080';
7
+ const fontFamily = 'monospace';
8
+ const fontSize = 10;
9
+ const fontWeight = 100;
10
+ const gridColor = '#AAAAAA30';
11
+ const gridKeyColor = '#AAAAAA70';
12
+ function calcRulerScaleList(opts) {
13
+ const { scale, viewLength, viewOffset } = opts;
14
+ const list = [];
15
+ let rulerUnit = 10;
16
+ rulerUnit = formatNumber(rulerUnit / scale, { decimalPlaces: 0 });
17
+ rulerUnit = Math.max(1, Math.min(rulerUnit, 1000));
18
+ const rulerKeyUnit = rulerUnit * 10;
19
+ const rulerSubKeyUnit = rulerUnit * 5;
20
+ let index = 0;
21
+ const viewUnit = rulerUnit * scale;
22
+ const startNum = 0 - viewOffset;
23
+ const startPosition = 0;
24
+ const remainderNum = startNum % viewUnit;
25
+ const firstNum = (startNum - remainderNum + viewUnit) / scale;
26
+ const firstPosition = startPosition + (viewUnit - remainderNum);
27
+ while (firstPosition + index * viewUnit < viewLength) {
28
+ const num = formatNumber(firstNum + index * rulerUnit, { decimalPlaces: 0 });
29
+ const position = formatNumber(firstPosition + index * viewUnit, { decimalPlaces: 0 });
30
+ const rulerScale = {
31
+ num,
32
+ position,
33
+ showNum: num % rulerKeyUnit === 0,
34
+ isKeyNum: num % rulerKeyUnit === 0,
35
+ isSubKeyNum: num % rulerSubKeyUnit === 0
36
+ };
37
+ list.push(rulerScale);
38
+ index++;
39
+ }
40
+ return list;
41
+ }
42
+ export function calcXRulerScaleList(opts) {
43
+ const { viewScaleInfo, viewSizeInfo } = opts;
44
+ const { scale, offsetLeft } = viewScaleInfo;
45
+ const { width } = viewSizeInfo;
46
+ return calcRulerScaleList({
47
+ axis: 'X',
48
+ scale,
49
+ viewLength: width,
50
+ viewOffset: offsetLeft
51
+ });
52
+ }
53
+ export function calcYRulerScaleList(opts) {
54
+ const { viewScaleInfo, viewSizeInfo } = opts;
55
+ const { scale, offsetTop } = viewScaleInfo;
56
+ const { height } = viewSizeInfo;
57
+ return calcRulerScaleList({
58
+ axis: 'Y',
59
+ scale,
60
+ viewLength: height,
61
+ viewOffset: offsetTop
62
+ });
63
+ }
64
+ export function drawXRuler(ctx, opts) {
65
+ const { scaleList } = opts;
66
+ const scaleDrawStart = rulerSize;
67
+ const scaleDrawEnd = (rulerSize * 4) / 5;
68
+ const subKeyScaleDrawEnd = (rulerSize * 2) / 5;
69
+ const keyScaleDrawEnd = (rulerSize * 1) / 5;
70
+ const fontStart = rulerSize / 5;
71
+ for (let i = 0; i < scaleList.length; i++) {
72
+ const item = scaleList[i];
73
+ if (item.position < rulerSize) {
74
+ continue;
75
+ }
76
+ ctx.beginPath();
77
+ ctx.moveTo(item.position, scaleDrawStart);
78
+ ctx.lineTo(item.position, item.isKeyNum ? keyScaleDrawEnd : item.isSubKeyNum ? subKeyScaleDrawEnd : scaleDrawEnd);
79
+ ctx.closePath();
80
+ ctx.fillStyle = scaleColor;
81
+ ctx.stroke();
82
+ if (item.isKeyNum) {
83
+ ctx.fillStyle = textColor;
84
+ ctx.textBaseline = 'top';
85
+ ctx.$setFont({
86
+ fontWeight,
87
+ fontSize,
88
+ fontFamily
89
+ });
90
+ ctx.fillText(`${item.num}`, item.position + fontStart, fontStart);
91
+ }
92
+ }
93
+ }
94
+ export function drawYRuler(ctx, opts) {
95
+ const { scaleList } = opts;
96
+ const scaleDrawStart = rulerSize;
97
+ const scaleDrawEnd = (rulerSize * 4) / 5;
98
+ const subKeyScaleDrawEnd = (rulerSize * 2) / 5;
99
+ const keyScaleDrawEnd = (rulerSize * 1) / 5;
100
+ const fontStart = rulerSize / 5;
101
+ for (let i = 0; i < scaleList.length; i++) {
102
+ const item = scaleList[i];
103
+ if (item.position < rulerSize) {
104
+ continue;
105
+ }
106
+ ctx.beginPath();
107
+ ctx.moveTo(scaleDrawStart, item.position);
108
+ ctx.lineTo(item.isKeyNum ? keyScaleDrawEnd : item.isSubKeyNum ? subKeyScaleDrawEnd : scaleDrawEnd, item.position);
109
+ ctx.closePath();
110
+ ctx.fillStyle = scaleColor;
111
+ ctx.stroke();
112
+ if (item.showNum === true) {
113
+ const textX = fontStart;
114
+ const textY = item.position + fontStart;
115
+ const numText = `${item.num}`;
116
+ rotateByCenter(ctx, -90, { x: textX, y: textY }, () => {
117
+ ctx.fillStyle = textColor;
118
+ ctx.textBaseline = 'top';
119
+ ctx.$setFont({
120
+ fontWeight,
121
+ fontSize,
122
+ fontFamily
123
+ });
124
+ ctx.fillText(numText, fontStart + fontSize, item.position + fontStart);
125
+ });
126
+ }
127
+ }
128
+ }
129
+ export function drawRulerBackground(ctx, opts) {
130
+ const { viewSizeInfo } = opts;
131
+ const { width, height } = viewSizeInfo;
132
+ ctx.beginPath();
133
+ ctx.moveTo(0, 0);
134
+ ctx.lineTo(width + 1, 0);
135
+ ctx.lineTo(width + 1, rulerSize);
136
+ ctx.lineTo(rulerSize, rulerSize);
137
+ ctx.lineTo(rulerSize, height + 1);
138
+ ctx.lineTo(0, height + 1);
139
+ ctx.lineTo(0, 0);
140
+ ctx.closePath();
141
+ ctx.fillStyle = background;
142
+ ctx.fill();
143
+ ctx.strokeStyle = borderColor;
144
+ ctx.stroke();
145
+ }
146
+ export function drawUnderGrid(ctx, opts) {
147
+ const { xList, yList, viewSizeInfo } = opts;
148
+ const { width, height } = viewSizeInfo;
149
+ for (let i = 0; i < xList.length; i++) {
150
+ const item = xList[i];
151
+ ctx.beginPath();
152
+ ctx.moveTo(item.position, 0);
153
+ ctx.lineTo(item.position, height);
154
+ if (item.isKeyNum === true || item.isSubKeyNum === true) {
155
+ ctx.strokeStyle = gridKeyColor;
156
+ }
157
+ else {
158
+ ctx.strokeStyle = gridColor;
159
+ }
160
+ ctx.lineWidth = 1;
161
+ ctx.closePath();
162
+ ctx.stroke();
163
+ }
164
+ for (let i = 0; i < yList.length; i++) {
165
+ const item = yList[i];
166
+ ctx.beginPath();
167
+ ctx.moveTo(0, item.position);
168
+ ctx.lineTo(width, item.position);
169
+ if (item.isKeyNum === true || item.isSubKeyNum === true) {
170
+ ctx.strokeStyle = gridKeyColor;
171
+ }
172
+ else {
173
+ ctx.strokeStyle = gridColor;
174
+ }
175
+ ctx.lineWidth = 1;
176
+ ctx.closePath();
177
+ ctx.stroke();
178
+ }
179
+ }
@@ -1,2 +1,3 @@
1
- import type { BoardMiddleware } from '@idraw/types';
2
- export declare const MiddlewareScaler: BoardMiddleware;
1
+ import type { BoardMiddleware, CoreEvent } from '@idraw/types';
2
+ export declare const middlewareEventScale = "@middleware/scale";
3
+ export declare const MiddlewareScaler: BoardMiddleware<Record<string, any>, CoreEvent>;
@@ -1,6 +1,8 @@
1
+ import { formatNumber } from '@idraw/util';
2
+ export const middlewareEventScale = '@middleware/scale';
1
3
  export const MiddlewareScaler = (opts) => {
2
4
  const key = 'SCALE';
3
- const { viewer, sharer } = opts;
5
+ const { viewer, sharer, eventHub } = opts;
4
6
  return {
5
7
  mode: key,
6
8
  isDefault: true,
@@ -17,6 +19,8 @@ export const MiddlewareScaler = (opts) => {
17
19
  const { moveX, moveY } = viewer.scale({ scale: newScaleNum, point });
18
20
  viewer.scroll({ moveX, moveY });
19
21
  viewer.drawFrame();
22
+ const scaleNum = formatNumber(scale);
23
+ eventHub.trigger(middlewareEventScale, { scale: scaleNum });
20
24
  }
21
25
  };
22
26
  };
@@ -2,12 +2,12 @@ import { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from '@idra
2
2
  import { keyActivePoint, keyActiveThumbType, keyPrevPoint, keyXThumbRect, keyYThumbRect } from './config';
3
3
  const minScrollerWidth = 12;
4
4
  const scrollerLineWidth = 16;
5
- const scrollerAlpha = 0.12;
6
5
  const scrollerThumbAlpha = 0.36;
7
6
  const scrollConfig = {
8
7
  width: minScrollerWidth,
9
- color: '#000000',
10
- showBackground: true
8
+ thumbColor: '#000000AA',
9
+ scrollBarColor: '#FFFFFF60',
10
+ showScrollBar: false
11
11
  };
12
12
  function isPointAtRect(helperContext, p, rect) {
13
13
  const ctx = helperContext;
@@ -57,7 +57,7 @@ function calcScrollerInfo(viewScaleInfo, viewSizeInfo) {
57
57
  if (ySize >= height) {
58
58
  ySize = height;
59
59
  }
60
- const xStart = lineSize / 2;
60
+ const xStart = lineSize;
61
61
  const xEnd = width - xSize - lineSize;
62
62
  let translateX = xStart;
63
63
  if (offsetLeft > 0) {
@@ -67,10 +67,10 @@ function calcScrollerInfo(viewScaleInfo, viewSizeInfo) {
67
67
  translateX = xEnd;
68
68
  }
69
69
  else if (offsetLeft <= 0 && xSize > 0 && !(offsetLeft === 0 && offsetRight === 0)) {
70
- translateX = xSize / 2 + ((width - xSize) * Math.abs(offsetLeft)) / (Math.abs(offsetLeft) + Math.abs(offsetRight));
71
- translateX = Math.min(Math.max(0, translateX - xSize / 2), width - xSize);
70
+ translateX = xStart + ((width - xSize) * Math.abs(offsetLeft)) / (Math.abs(offsetLeft) + Math.abs(offsetRight));
71
+ translateX = Math.min(Math.max(0, translateX - xStart), width - xSize);
72
72
  }
73
- const yStart = lineSize / 2;
73
+ const yStart = lineSize;
74
74
  const yEnd = height - ySize - lineSize;
75
75
  let translateY = yStart;
76
76
  if (offsetTop > 0) {
@@ -80,8 +80,8 @@ function calcScrollerInfo(viewScaleInfo, viewSizeInfo) {
80
80
  translateY = yEnd;
81
81
  }
82
82
  else if (offsetTop <= 0 && ySize > 0 && !(offsetTop === 0 && offsetBottom === 0)) {
83
- translateY = ySize / 2 + ((height - ySize) * Math.abs(offsetTop)) / (Math.abs(offsetTop) + Math.abs(offsetBottom));
84
- translateY = Math.min(Math.max(0, translateY - ySize / 2), height - ySize);
83
+ translateY = yStart + ((height - ySize) * Math.abs(offsetTop)) / (Math.abs(offsetTop) + Math.abs(offsetBottom));
84
+ translateY = Math.min(Math.max(0, translateY - yStart), height - ySize);
85
85
  }
86
86
  const xThumbRect = {
87
87
  x: translateX,
@@ -101,7 +101,8 @@ function calcScrollerInfo(viewScaleInfo, viewSizeInfo) {
101
101
  ySize,
102
102
  translateY,
103
103
  translateX,
104
- color: '#0000007A',
104
+ thumbColor: scrollConfig.thumbColor,
105
+ scrollBarColor: scrollConfig.scrollBarColor,
105
106
  xThumbRect,
106
107
  yThumbRect
107
108
  };
@@ -109,42 +110,50 @@ function calcScrollerInfo(viewScaleInfo, viewSizeInfo) {
109
110
  }
110
111
  function drawScrollerThumb(ctx, opts) {
111
112
  let { x, y, h, w } = opts;
112
- const { color, axis } = opts;
113
- if (axis === 'X') {
114
- y = y + h / 4 + 0;
115
- h = h / 2;
116
- }
117
- else if (axis === 'Y') {
118
- x = x + w / 4 + 0;
119
- w = w / 2;
120
- }
121
- let r = opts.r;
122
- r = Math.min(r, w / 2, h / 2);
123
- if (w < r * 2 || h < r * 2) {
124
- r = 0;
125
- }
126
- ctx.globalAlpha = scrollerThumbAlpha;
127
- ctx.beginPath();
128
- ctx.moveTo(x + r, y);
129
- ctx.arcTo(x + w, y, x + w, y + h, r);
130
- ctx.arcTo(x + w, y + h, x, y + h, r);
131
- ctx.arcTo(x, y + h, x, y, r);
132
- ctx.arcTo(x, y, x + w, y, r);
133
- ctx.closePath();
134
- ctx.fillStyle = color;
135
- ctx.fill();
136
- ctx.globalAlpha = 1;
137
- ctx.beginPath();
138
- ctx.lineWidth = 1;
139
- ctx.strokeStyle = color;
140
- ctx.setLineDash([]);
141
- ctx.moveTo(x + r, y);
142
- ctx.arcTo(x + w, y, x + w, y + h, r);
143
- ctx.arcTo(x + w, y + h, x, y + h, r);
144
- ctx.arcTo(x, y + h, x, y, r);
145
- ctx.arcTo(x, y, x + w, y, r);
146
- ctx.closePath();
147
- ctx.stroke();
113
+ ctx.save();
114
+ ctx.shadowColor = '#FFFFFF';
115
+ ctx.shadowOffsetX = 0;
116
+ ctx.shadowOffsetY = 0;
117
+ ctx.shadowBlur = 1;
118
+ {
119
+ const { color, axis } = opts;
120
+ if (axis === 'X') {
121
+ y = y + h / 4 + 0;
122
+ h = h / 2;
123
+ }
124
+ else if (axis === 'Y') {
125
+ x = x + w / 4 + 0;
126
+ w = w / 2;
127
+ }
128
+ let r = opts.r;
129
+ r = Math.min(r, w / 2, h / 2);
130
+ if (w < r * 2 || h < r * 2) {
131
+ r = 0;
132
+ }
133
+ ctx.globalAlpha = scrollerThumbAlpha;
134
+ ctx.beginPath();
135
+ ctx.moveTo(x + r, y);
136
+ ctx.arcTo(x + w, y, x + w, y + h, r);
137
+ ctx.arcTo(x + w, y + h, x, y + h, r);
138
+ ctx.arcTo(x, y + h, x, y, r);
139
+ ctx.arcTo(x, y, x + w, y, r);
140
+ ctx.closePath();
141
+ ctx.fillStyle = color;
142
+ ctx.fill();
143
+ ctx.globalAlpha = 1;
144
+ ctx.beginPath();
145
+ ctx.lineWidth = 1;
146
+ ctx.strokeStyle = color;
147
+ ctx.setLineDash([]);
148
+ ctx.moveTo(x + r, y);
149
+ ctx.arcTo(x + w, y, x + w, y + h, r);
150
+ ctx.arcTo(x + w, y + h, x, y + h, r);
151
+ ctx.arcTo(x, y + h, x, y, r);
152
+ ctx.arcTo(x, y, x + w, y, r);
153
+ ctx.closePath();
154
+ ctx.stroke();
155
+ }
156
+ ctx.restore();
148
157
  }
149
158
  function drawScrollerInfo(helperContext, opts) {
150
159
  const ctx = helperContext;
@@ -164,18 +173,16 @@ function drawScrollerInfo(helperContext, opts) {
164
173
  yThumbRect.y = yThumbRect.y + (activePoint.y - prevPoint.y);
165
174
  }
166
175
  }
167
- if (scrollConfig.showBackground === true) {
168
- ctx.globalAlpha = scrollerAlpha;
169
- ctx.fillStyle = wrapper.color;
176
+ if (scrollConfig.showScrollBar === true) {
177
+ ctx.fillStyle = wrapper.scrollBarColor;
170
178
  ctx.fillRect(0, height - wrapper.lineSize, width, wrapper.lineSize);
171
179
  }
172
- drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'X' }, xThumbRect), { r: wrapper.lineSize / 2, color: wrapper.color }));
173
- if (scrollConfig.showBackground === true) {
174
- ctx.globalAlpha = scrollerAlpha;
175
- ctx.fillStyle = wrapper.color;
180
+ drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'X' }, xThumbRect), { r: wrapper.lineSize / 2, color: wrapper.thumbColor }));
181
+ if (scrollConfig.showScrollBar === true) {
182
+ ctx.fillStyle = wrapper.scrollBarColor;
176
183
  ctx.fillRect(width - wrapper.lineSize, 0, wrapper.lineSize, height);
177
184
  }
178
- drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'Y' }, yThumbRect), { r: wrapper.lineSize / 2, color: wrapper.color }));
185
+ drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'Y' }, yThumbRect), { r: wrapper.lineSize / 2, color: wrapper.thumbColor }));
179
186
  ctx.globalAlpha = 1;
180
187
  return {
181
188
  xThumbRect,
@@ -32,10 +32,6 @@ export function drawSelectedElementControllersVertexes(ctx, controller, opts) {
32
32
  const wrapperOpts = { borderColor: wrapperColor, borderWidth: 1, background: 'transparent', lineDash: [] };
33
33
  const ctrlOpts = Object.assign(Object.assign({}, wrapperOpts), { borderWidth: resizeControllerBorderWidth, background: '#FFFFFF' });
34
34
  drawVertexes(ctx, calcViewVertexes(elementWrapper, opts), wrapperOpts);
35
- drawVertexes(ctx, calcViewVertexes(left.vertexes, opts), ctrlOpts);
36
- drawVertexes(ctx, calcViewVertexes(right.vertexes, opts), ctrlOpts);
37
- drawVertexes(ctx, calcViewVertexes(top.vertexes, opts), ctrlOpts);
38
- drawVertexes(ctx, calcViewVertexes(bottom.vertexes, opts), ctrlOpts);
39
35
  drawVertexes(ctx, calcViewVertexes(topLeft.vertexes, opts), ctrlOpts);
40
36
  drawVertexes(ctx, calcViewVertexes(topRight.vertexes, opts), ctrlOpts);
41
37
  drawVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
@@ -1,3 +1,4 @@
1
1
  import type { CoreEvent } from '@idraw/types';
2
2
  import type { BoardMiddleware, DeepSelectorSharedStorage } from './types';
3
+ export declare const middlewareEventSelect: string;
3
4
  export declare const MiddlewareSelector: BoardMiddleware<DeepSelectorSharedStorage, CoreEvent>;
@@ -2,12 +2,13 @@ import { calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVerte
2
2
  import { drawHoverVertexesWrapper, drawArea, drawListArea, drawGroupQueueVertexesWrappers, drawSelectedElementControllersVertexes } from './draw-wrapper';
3
3
  import { getPointTarget, resizeElement, getSelectedListArea, calcSelectedElementsArea, isElementInGroup, isPointInViewActiveGroup, calcMoveInGroup } from './util';
4
4
  import { key, keyActionType, keyResizeType, keyAreaStart, keyAreaEnd, keyGroupQueue, keyGroupQueueVertexesList, keyHoverElement, keyHoverElementVertexes, keySelectedElementList, keySelectedElementListVertexes, keySelectedElementController } from './config';
5
+ export const middlewareEventSelect = '@middleware/select';
5
6
  export const MiddlewareSelector = (opts) => {
6
7
  const { viewer, sharer, viewContent, calculator, eventHub } = opts;
7
8
  const { helperContext } = viewContent;
8
9
  let prevPoint = null;
9
10
  let inBusyMode = null;
10
- eventHub.on('select', ({ uuids }) => {
11
+ eventHub.on(middlewareEventSelect, ({ uuids }) => {
11
12
  const actionType = sharer.getSharedStorage(keyActionType);
12
13
  const data = sharer.getActiveStorage('data');
13
14
  const elements = findElementsFromList(uuids, (data === null || data === void 0 ? void 0 : data.elements) || []);
@@ -76,7 +77,7 @@ export const MiddlewareSelector = (opts) => {
76
77
  sharer.setSharedStorage(keySelectedElementController, null);
77
78
  }
78
79
  if ((opts === null || opts === void 0 ? void 0 : opts.triggerEvent) === true) {
79
- eventHub.trigger('select', { uuids: list.map((elem) => elem.uuid) });
80
+ eventHub.trigger(middlewareEventSelect, { uuids: list.map((elem) => elem.uuid) });
80
81
  }
81
82
  };
82
83
  const pointTargetBaseOptions = () => {