@idraw/core 0.4.0-beta.30 → 0.4.0-beta.32

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.
Files changed (39) hide show
  1. package/dist/esm/index.d.ts +2 -2
  2. package/dist/esm/index.js +2 -2
  3. package/dist/esm/middleware/info/config.d.ts +4 -0
  4. package/dist/esm/middleware/info/config.js +8 -0
  5. package/dist/esm/middleware/info/draw-info.d.ts +4 -6
  6. package/dist/esm/middleware/info/draw-info.js +12 -9
  7. package/dist/esm/middleware/info/index.d.ts +2 -2
  8. package/dist/esm/middleware/info/index.js +11 -9
  9. package/dist/esm/middleware/layout-selector/config.d.ts +2 -2
  10. package/dist/esm/middleware/layout-selector/config.js +3 -2
  11. package/dist/esm/middleware/layout-selector/index.d.ts +2 -2
  12. package/dist/esm/middleware/layout-selector/index.js +7 -4
  13. package/dist/esm/middleware/layout-selector/util.d.ts +3 -2
  14. package/dist/esm/middleware/layout-selector/util.js +19 -64
  15. package/dist/esm/middleware/ruler/config.d.ts +7 -0
  16. package/dist/esm/middleware/ruler/config.js +21 -0
  17. package/dist/esm/middleware/ruler/index.d.ts +2 -2
  18. package/dist/esm/middleware/ruler/index.js +19 -6
  19. package/dist/esm/middleware/ruler/util.d.ts +6 -1
  20. package/dist/esm/middleware/ruler/util.js +13 -19
  21. package/dist/esm/middleware/scroller/config.d.ts +2 -0
  22. package/dist/esm/middleware/scroller/config.js +8 -0
  23. package/dist/esm/middleware/scroller/index.d.ts +2 -2
  24. package/dist/esm/middleware/scroller/index.js +13 -3
  25. package/dist/esm/middleware/scroller/util.d.ts +2 -1
  26. package/dist/esm/middleware/scroller/util.js +19 -36
  27. package/dist/esm/middleware/selector/config.d.ts +2 -4
  28. package/dist/esm/middleware/selector/config.js +10 -4
  29. package/dist/esm/middleware/selector/draw-auxiliary.d.ts +1 -7
  30. package/dist/esm/middleware/selector/draw-auxiliary.js +1 -35
  31. package/dist/esm/middleware/selector/draw-reference.d.ts +2 -0
  32. package/dist/esm/middleware/selector/draw-reference.js +2 -2
  33. package/dist/esm/middleware/selector/draw-wrapper.d.ts +7 -1
  34. package/dist/esm/middleware/selector/draw-wrapper.js +22 -13
  35. package/dist/esm/middleware/selector/index.d.ts +2 -2
  36. package/dist/esm/middleware/selector/index.js +16 -12
  37. package/dist/index.global.js +224 -169
  38. package/dist/index.global.min.js +1 -1
  39. package/package.json +5 -5
@@ -1,11 +1,21 @@
1
1
  import { drawScroller, isPointInScrollThumb } from './util';
2
- import { keyXThumbRect, keyYThumbRect, keyPrevPoint, keyActivePoint, keyActiveThumbType, keyHoverXThumbRect, keyHoverYThumbRect } from './config';
3
- export const MiddlewareScroller = (opts) => {
2
+ import { keyXThumbRect, keyYThumbRect, keyPrevPoint, keyActivePoint, keyActiveThumbType, keyHoverXThumbRect, keyHoverYThumbRect, defaultStyle } from './config';
3
+ export const MiddlewareScroller = (opts, config) => {
4
4
  const { viewer, boardContent, sharer, eventHub } = opts;
5
5
  const { overlayContext } = boardContent;
6
6
  sharer.setSharedStorage(keyXThumbRect, null);
7
7
  sharer.setSharedStorage(keyYThumbRect, null);
8
8
  let isBusy = false;
9
+ const innerConfig = Object.assign(Object.assign({}, defaultStyle), config);
10
+ const { thumbBackground, thumbBorderColor, hoverThumbBackground, hoverThumbBorderColor, activeThumbBackground, activeThumbBorderColor } = innerConfig;
11
+ const style = {
12
+ thumbBackground,
13
+ thumbBorderColor,
14
+ hoverThumbBackground,
15
+ hoverThumbBorderColor,
16
+ activeThumbBackground,
17
+ activeThumbBorderColor
18
+ };
9
19
  const clear = () => {
10
20
  sharer.setSharedStorage(keyPrevPoint, null);
11
21
  sharer.setSharedStorage(keyActivePoint, null);
@@ -111,7 +121,7 @@ export const MiddlewareScroller = (opts) => {
111
121
  }
112
122
  },
113
123
  beforeDrawFrame({ snapshot }) {
114
- const { xThumbRect, yThumbRect } = drawScroller(overlayContext, { snapshot });
124
+ const { xThumbRect, yThumbRect } = drawScroller(overlayContext, { snapshot, style });
115
125
  sharer.setSharedStorage(keyXThumbRect, xThumbRect);
116
126
  sharer.setSharedStorage(keyYThumbRect, yThumbRect);
117
127
  }
@@ -1,4 +1,4 @@
1
- import type { Point, BoardViewerFrameSnapshot, ViewContext2D, ElementSize } from '@idraw/types';
1
+ import type { Point, BoardViewerFrameSnapshot, ViewContext2D, ElementSize, MiddlewareScrollerStyle } from '@idraw/types';
2
2
  export type ScrollbarThumbType = 'X' | 'Y';
3
3
  export declare function isPointInScrollThumb(overlayContext: ViewContext2D, p: Point, opts: {
4
4
  xThumbRect?: ElementSize | null;
@@ -6,6 +6,7 @@ export declare function isPointInScrollThumb(overlayContext: ViewContext2D, p: P
6
6
  }): ScrollbarThumbType | null;
7
7
  export declare function drawScroller(ctx: ViewContext2D, opts: {
8
8
  snapshot: BoardViewerFrameSnapshot;
9
+ style: MiddlewareScrollerStyle;
9
10
  }): {
10
11
  xThumbRect: ElementSize;
11
12
  yThumbRect: ElementSize;
@@ -1,15 +1,7 @@
1
1
  import { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from '@idraw/util';
2
2
  import { keyActivePoint, keyActiveThumbType, keyPrevPoint, keyXThumbRect, keyYThumbRect, keyHoverXThumbRect, keyHoverYThumbRect } from './config';
3
- const minScrollerWidth = 12;
4
3
  const scrollerLineWidth = 16;
5
- const scrollerThumbAlpha = 0.3;
6
- const scrollConfig = {
7
- width: minScrollerWidth,
8
- thumbColor: '#0000008A',
9
- thumbHoverColor: '#000000EE',
10
- scrollBarColor: '#FFFFFF60',
11
- showScrollBar: false
12
- };
4
+ const minThumbLength = scrollerLineWidth * 2.5;
13
5
  function isPointAtRect(overlayContext, p, rect) {
14
6
  const ctx = overlayContext;
15
7
  const { x, y, w, h } = rect;
@@ -46,11 +38,12 @@ function getScrollInfoFromSnapshot(snapshot) {
46
38
  return info;
47
39
  }
48
40
  function calcScrollerInfo(opts) {
49
- const { viewScaleInfo, viewSizeInfo, hoverXThumb, hoverYThumb } = opts;
41
+ const { viewScaleInfo, viewSizeInfo, hoverXThumb, hoverYThumb, style } = opts;
50
42
  const { width, height } = viewSizeInfo;
51
43
  const { offsetTop, offsetBottom, offsetLeft, offsetRight } = viewScaleInfo;
52
- const sliderMinSize = scrollerLineWidth * 2.5;
44
+ const sliderMinSize = minThumbLength;
53
45
  const lineSize = scrollerLineWidth;
46
+ const { thumbBackground, thumbBorderColor, hoverThumbBackground, hoverThumbBorderColor } = style;
54
47
  let xSize = 0;
55
48
  let ySize = 0;
56
49
  xSize = Math.max(sliderMinSize, width - lineSize * 2 - (Math.abs(offsetLeft) + Math.abs(offsetRight)));
@@ -105,23 +98,24 @@ function calcScrollerInfo(opts) {
105
98
  ySize,
106
99
  translateY,
107
100
  translateX,
108
- xThumbColor: hoverXThumb ? scrollConfig.thumbHoverColor : scrollConfig.thumbColor,
109
- yThumbColor: hoverYThumb ? scrollConfig.thumbHoverColor : scrollConfig.thumbColor,
110
- scrollBarColor: scrollConfig.scrollBarColor,
101
+ xThumbBackground: hoverXThumb ? hoverThumbBackground : thumbBackground,
102
+ yThumbBackground: hoverYThumb ? hoverThumbBackground : thumbBackground,
103
+ xThumbBorderColor: hoverXThumb ? hoverThumbBorderColor : thumbBorderColor,
104
+ yThumbBorderColor: hoverYThumb ? hoverThumbBorderColor : thumbBorderColor,
111
105
  xThumbRect,
112
106
  yThumbRect
113
107
  };
114
108
  return scrollWrapper;
115
109
  }
116
110
  function drawScrollerThumb(ctx, opts) {
117
- let { x, y, h, w } = opts;
111
+ let { x, y, h, w, background, borderColor } = opts;
118
112
  ctx.save();
119
113
  ctx.shadowColor = '#FFFFFF';
120
114
  ctx.shadowOffsetX = 0;
121
115
  ctx.shadowOffsetY = 0;
122
116
  ctx.shadowBlur = 1;
123
117
  {
124
- const { color, axis } = opts;
118
+ const { axis } = opts;
125
119
  if (axis === 'X') {
126
120
  y = y + h / 4 + 0;
127
121
  h = h / 2;
@@ -135,7 +129,7 @@ function drawScrollerThumb(ctx, opts) {
135
129
  if (w < r * 2 || h < r * 2) {
136
130
  r = 0;
137
131
  }
138
- ctx.globalAlpha = scrollerThumbAlpha;
132
+ ctx.globalAlpha = 1;
139
133
  ctx.beginPath();
140
134
  ctx.moveTo(x + r, y);
141
135
  ctx.arcTo(x + w, y, x + w, y + h, r);
@@ -143,12 +137,11 @@ function drawScrollerThumb(ctx, opts) {
143
137
  ctx.arcTo(x, y + h, x, y, r);
144
138
  ctx.arcTo(x, y, x + w, y, r);
145
139
  ctx.closePath();
146
- ctx.fillStyle = color;
140
+ ctx.fillStyle = background;
147
141
  ctx.fill();
148
- ctx.globalAlpha = 1;
149
142
  ctx.beginPath();
150
143
  ctx.lineWidth = 1;
151
- ctx.strokeStyle = color;
144
+ ctx.strokeStyle = borderColor;
152
145
  ctx.setLineDash([]);
153
146
  ctx.moveTo(x + r, y);
154
147
  ctx.arcTo(x + w, y, x + w, y + h, r);
@@ -162,10 +155,9 @@ function drawScrollerThumb(ctx, opts) {
162
155
  }
163
156
  function drawScrollerInfo(overlayContext, opts) {
164
157
  const ctx = overlayContext;
165
- const { viewScaleInfo, viewSizeInfo, scrollInfo } = opts;
158
+ const { viewScaleInfo, viewSizeInfo, scrollInfo, style } = opts;
166
159
  const { activeThumbType, prevPoint, activePoint, hoverXThumb, hoverYThumb } = scrollInfo;
167
- const { width, height } = viewSizeInfo;
168
- const wrapper = calcScrollerInfo({ viewScaleInfo, viewSizeInfo, hoverXThumb, hoverYThumb });
160
+ const wrapper = calcScrollerInfo({ viewScaleInfo, viewSizeInfo, hoverXThumb, hoverYThumb, style });
169
161
  let xThumbRect = Object.assign({}, wrapper.xThumbRect);
170
162
  let yThumbRect = Object.assign({}, wrapper.yThumbRect);
171
163
  if (activeThumbType && prevPoint && activePoint) {
@@ -178,27 +170,18 @@ function drawScrollerInfo(overlayContext, opts) {
178
170
  yThumbRect.y = yThumbRect.y + (activePoint.y - prevPoint.y);
179
171
  }
180
172
  }
181
- if (scrollConfig.showScrollBar === true) {
182
- ctx.fillStyle = wrapper.scrollBarColor;
183
- ctx.fillRect(0, height - wrapper.lineSize, width, wrapper.lineSize);
184
- }
185
- drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'X' }, xThumbRect), { r: wrapper.lineSize / 2, color: wrapper.xThumbColor }));
186
- if (scrollConfig.showScrollBar === true) {
187
- ctx.fillStyle = wrapper.scrollBarColor;
188
- ctx.fillRect(width - wrapper.lineSize, 0, wrapper.lineSize, height);
189
- }
190
- drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'Y' }, yThumbRect), { r: wrapper.lineSize / 2, color: wrapper.yThumbColor }));
191
- ctx.globalAlpha = 1;
173
+ drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'X' }, xThumbRect), { r: wrapper.lineSize / 2, background: wrapper.xThumbBackground, borderColor: wrapper.xThumbBorderColor }));
174
+ drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'Y' }, yThumbRect), { r: wrapper.lineSize / 2, background: wrapper.yThumbBackground, borderColor: wrapper.yThumbBorderColor }));
192
175
  return {
193
176
  xThumbRect,
194
177
  yThumbRect
195
178
  };
196
179
  }
197
180
  export function drawScroller(ctx, opts) {
198
- const { snapshot } = opts;
181
+ const { snapshot, style } = opts;
199
182
  const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
200
183
  const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
201
184
  const scrollInfo = getScrollInfoFromSnapshot(snapshot);
202
- const { xThumbRect, yThumbRect } = drawScrollerInfo(ctx, { viewSizeInfo, viewScaleInfo, scrollInfo });
185
+ const { xThumbRect, yThumbRect } = drawScrollerInfo(ctx, { viewSizeInfo, viewScaleInfo, scrollInfo, style });
203
186
  return { xThumbRect, yThumbRect };
204
187
  }
@@ -1,3 +1,4 @@
1
+ import type { MiddlewareSelectorStyle } from '@idraw/types';
1
2
  export declare const key = "SELECT";
2
3
  export declare const keyActionType: unique symbol;
3
4
  export declare const keyResizeType: unique symbol;
@@ -23,11 +24,8 @@ export declare const keyDebugEnd0: unique symbol;
23
24
  export declare const selectWrapperBorderWidth = 2;
24
25
  export declare const resizeControllerBorderWidth = 4;
25
26
  export declare const areaBorderWidth = 1;
26
- export declare const wrapperColor = "#1973ba";
27
- export declare const lockColor = "#5b5959b5";
28
27
  export declare const controllerSize = 10;
29
- export declare const auxiliaryColor = "#f7276e";
30
- export declare const referenceColor = "#f7276e";
28
+ export declare const defaultStyle: MiddlewareSelectorStyle;
31
29
  export declare const middlewareEventSelect: string;
32
30
  export declare const middlewareEventSelectClear: string;
33
31
  export declare const middlewareEventSelectInGroup: string;
@@ -23,11 +23,17 @@ export const keyDebugEnd0 = Symbol(`${key}_debug_end0`);
23
23
  export const selectWrapperBorderWidth = 2;
24
24
  export const resizeControllerBorderWidth = 4;
25
25
  export const areaBorderWidth = 1;
26
- export const wrapperColor = '#1973ba';
27
- export const lockColor = '#5b5959b5';
28
26
  export const controllerSize = 10;
29
- export const auxiliaryColor = '#f7276e';
30
- export const referenceColor = '#f7276e';
27
+ const activeColor = '#1973ba';
28
+ const activeAreaColor = '#1976d21c';
29
+ const lockedColor = '#5b5959b5';
30
+ const referenceColor = '#f7276e';
31
+ export const defaultStyle = {
32
+ activeColor,
33
+ activeAreaColor,
34
+ lockedColor,
35
+ referenceColor
36
+ };
31
37
  export const middlewareEventSelect = '@middleware/select';
32
38
  export const middlewareEventSelectClear = '@middleware/select-clear';
33
39
  export const middlewareEventSelectInGroup = '@middleware/select-in-group';
@@ -1,7 +1 @@
1
- import type { ViewContext2D, Element, ViewScaleInfo, ViewSizeInfo, ViewCalculator } from '@idraw/types';
2
- export declare function drawAuxiliaryExperimentBox(ctx: ViewContext2D, opts: {
3
- calculator: ViewCalculator;
4
- element: Element | null;
5
- viewScaleInfo: ViewScaleInfo;
6
- viewSizeInfo: ViewSizeInfo;
7
- }): void;
1
+ export {};
@@ -1,5 +1,3 @@
1
- import { auxiliaryColor } from './config';
2
- import { drawLine, drawCrossByCenter } from './draw-base';
3
1
  function getViewBoxInfo(rectInfo) {
4
2
  const boxInfo = {
5
3
  minX: rectInfo.topLeft.x,
@@ -11,36 +9,4 @@ function getViewBoxInfo(rectInfo) {
11
9
  };
12
10
  return boxInfo;
13
11
  }
14
- export function drawAuxiliaryExperimentBox(ctx, opts) {
15
- const { element, viewScaleInfo, viewSizeInfo, calculator } = opts;
16
- if (!element) {
17
- return;
18
- }
19
- const viewRectInfo = calculator.calcViewRectInfoFromRange(element.uuid, { viewScaleInfo, viewSizeInfo });
20
- if (!viewRectInfo) {
21
- return;
22
- }
23
- const lineOpts = {
24
- borderColor: auxiliaryColor,
25
- borderWidth: 1,
26
- lineDash: []
27
- };
28
- const boxInfo = getViewBoxInfo(viewRectInfo);
29
- const { width, height } = viewSizeInfo;
30
- drawLine(ctx, { x: boxInfo.minX, y: 0 }, { x: boxInfo.minX, y: height }, lineOpts);
31
- drawLine(ctx, { x: boxInfo.midX, y: 0 }, { x: boxInfo.midX, y: height }, lineOpts);
32
- drawLine(ctx, { x: boxInfo.maxX, y: 0 }, { x: boxInfo.maxX, y: height }, lineOpts);
33
- drawLine(ctx, { x: 0, y: boxInfo.minY }, { x: width, y: boxInfo.minY }, lineOpts);
34
- drawLine(ctx, { x: 0, y: boxInfo.midY }, { x: width, y: boxInfo.midY }, lineOpts);
35
- drawLine(ctx, { x: 0, y: boxInfo.maxY }, { x: width, y: boxInfo.maxY }, lineOpts);
36
- const crossOpts = Object.assign(Object.assign({}, lineOpts), { size: 6 });
37
- drawCrossByCenter(ctx, viewRectInfo.center, crossOpts);
38
- drawCrossByCenter(ctx, viewRectInfo.topLeft, crossOpts);
39
- drawCrossByCenter(ctx, viewRectInfo.topRight, crossOpts);
40
- drawCrossByCenter(ctx, viewRectInfo.bottomLeft, crossOpts);
41
- drawCrossByCenter(ctx, viewRectInfo.bottomRight, crossOpts);
42
- drawCrossByCenter(ctx, viewRectInfo.top, crossOpts);
43
- drawCrossByCenter(ctx, viewRectInfo.right, crossOpts);
44
- drawCrossByCenter(ctx, viewRectInfo.bottom, crossOpts);
45
- drawCrossByCenter(ctx, viewRectInfo.left, crossOpts);
46
- }
12
+ export {};
@@ -1,5 +1,7 @@
1
1
  import type { ViewContext2D, PointSize } from '@idraw/types';
2
+ import { MiddlewareSelectorStyle } from './types';
2
3
  export declare function drawReferenceLines(ctx: ViewContext2D, opts: {
3
4
  xLines?: Array<PointSize[]>;
4
5
  yLines?: Array<PointSize[]>;
6
+ style: MiddlewareSelectorStyle;
5
7
  }): void;
@@ -1,7 +1,7 @@
1
- import { referenceColor } from './config';
2
1
  import { drawLine, drawCrossByCenter } from './draw-base';
3
2
  export function drawReferenceLines(ctx, opts) {
4
- const { xLines, yLines } = opts;
3
+ const { xLines, yLines, style } = opts;
4
+ const { referenceColor } = style;
5
5
  const lineOpts = {
6
6
  borderColor: referenceColor,
7
7
  borderWidth: 1,
@@ -1,13 +1,15 @@
1
1
  import type { Element, ElementType, PointSize, RendererDrawElementOptions, ViewContext2D, ViewRectVertexes, ViewScaleInfo, ViewSizeInfo, ElementSizeController, ViewCalculator } from '@idraw/types';
2
- import type { AreaSize } from './types';
2
+ import type { AreaSize, MiddlewareSelectorStyle } from './types';
3
3
  export declare function drawHoverVertexesWrapper(ctx: ViewContext2D, vertexes: ViewRectVertexes | null, opts: {
4
4
  viewScaleInfo: ViewScaleInfo;
5
5
  viewSizeInfo: ViewSizeInfo;
6
+ style: MiddlewareSelectorStyle;
6
7
  }): void;
7
8
  export declare function drawLockVertexesWrapper(ctx: ViewContext2D, vertexes: ViewRectVertexes | null, opts: {
8
9
  viewScaleInfo: ViewScaleInfo;
9
10
  viewSizeInfo: ViewSizeInfo;
10
11
  controller?: ElementSizeController | null;
12
+ style: MiddlewareSelectorStyle;
11
13
  }): void;
12
14
  export declare function drawSelectedElementControllersVertexes(ctx: ViewContext2D, controller: ElementSizeController | null, opts: {
13
15
  hideControllers: boolean;
@@ -15,16 +17,20 @@ export declare function drawSelectedElementControllersVertexes(ctx: ViewContext2
15
17
  viewSizeInfo: ViewSizeInfo;
16
18
  element: Element | null;
17
19
  calculator: ViewCalculator;
20
+ style: MiddlewareSelectorStyle;
18
21
  }): void;
19
22
  export declare function drawElementListShadows(ctx: ViewContext2D, elements: Element<ElementType>[], opts?: Omit<RendererDrawElementOptions, 'loader'>): void;
20
23
  export declare function drawArea(ctx: ViewContext2D, opts: {
21
24
  start: PointSize;
22
25
  end: PointSize;
26
+ style: MiddlewareSelectorStyle;
23
27
  }): void;
24
28
  export declare function drawListArea(ctx: ViewContext2D, opts: {
25
29
  areaSize: AreaSize;
30
+ style: MiddlewareSelectorStyle;
26
31
  }): void;
27
32
  export declare function drawGroupQueueVertexesWrappers(ctx: ViewContext2D, vertexesList: ViewRectVertexes[], opts: {
28
33
  viewScaleInfo: ViewScaleInfo;
29
34
  viewSizeInfo: ViewSizeInfo;
35
+ style: MiddlewareSelectorStyle;
30
36
  }): void;
@@ -1,23 +1,27 @@
1
1
  import { rotateElementVertexes, calcViewPointSize, calcViewVertexes, calcViewElementSize } from '@idraw/util';
2
- import { resizeControllerBorderWidth, areaBorderWidth, wrapperColor, selectWrapperBorderWidth, lockColor, controllerSize } from './config';
2
+ import { resizeControllerBorderWidth, areaBorderWidth, selectWrapperBorderWidth, controllerSize } from './config';
3
3
  import { drawVertexes, drawLine, drawCircleController, drawCrossVertexes } from './draw-base';
4
4
  export function drawHoverVertexesWrapper(ctx, vertexes, opts) {
5
5
  if (!vertexes) {
6
6
  return;
7
7
  }
8
- const wrapperOpts = { borderColor: wrapperColor, borderWidth: 1, background: 'transparent', lineDash: [] };
8
+ const { style } = opts;
9
+ const { activeColor } = style;
10
+ const wrapperOpts = { borderColor: activeColor, borderWidth: 1, background: 'transparent', lineDash: [] };
9
11
  drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
10
12
  }
11
13
  export function drawLockVertexesWrapper(ctx, vertexes, opts) {
12
14
  if (!vertexes) {
13
15
  return;
14
16
  }
15
- const wrapperOpts = { borderColor: lockColor, borderWidth: 1, background: 'transparent', lineDash: [] };
17
+ const { style } = opts;
18
+ const { lockedColor } = style;
19
+ const wrapperOpts = { borderColor: lockedColor, borderWidth: 1, background: 'transparent', lineDash: [] };
16
20
  drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
17
21
  const { controller } = opts;
18
22
  if (controller) {
19
23
  const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, bottomMiddle, leftMiddle, rightMiddle } = controller;
20
- const ctrlOpts = Object.assign(Object.assign({}, wrapperOpts), { borderWidth: 1, background: lockColor });
24
+ const ctrlOpts = Object.assign(Object.assign({}, wrapperOpts), { borderWidth: 1, background: lockedColor });
21
25
  drawCrossVertexes(ctx, calcViewVertexes(topMiddle.vertexes, opts), ctrlOpts);
22
26
  drawCrossVertexes(ctx, calcViewVertexes(bottomMiddle.vertexes, opts), ctrlOpts);
23
27
  drawCrossVertexes(ctx, calcViewVertexes(leftMiddle.vertexes, opts), ctrlOpts);
@@ -32,9 +36,10 @@ export function drawSelectedElementControllersVertexes(ctx, controller, opts) {
32
36
  if (!controller) {
33
37
  return;
34
38
  }
35
- const { hideControllers } = opts;
39
+ const { hideControllers, style } = opts;
40
+ const { activeColor } = style;
36
41
  const { elementWrapper, topLeft, topRight, bottomLeft, bottomRight, top, rotate } = controller;
37
- const wrapperOpts = { borderColor: wrapperColor, borderWidth: selectWrapperBorderWidth, background: 'transparent', lineDash: [] };
42
+ const wrapperOpts = { borderColor: activeColor, borderWidth: selectWrapperBorderWidth, background: 'transparent', lineDash: [] };
38
43
  const ctrlOpts = Object.assign(Object.assign({}, wrapperOpts), { borderWidth: resizeControllerBorderWidth, background: '#FFFFFF' });
39
44
  drawVertexes(ctx, calcViewVertexes(elementWrapper, opts), wrapperOpts);
40
45
  if (!hideControllers) {
@@ -76,11 +81,12 @@ export function drawElementListShadows(ctx, elements, opts) {
76
81
  });
77
82
  }
78
83
  export function drawArea(ctx, opts) {
79
- const { start, end } = opts;
84
+ const { start, end, style } = opts;
85
+ const { activeColor, activeAreaColor } = style;
80
86
  ctx.setLineDash([]);
81
87
  ctx.lineWidth = areaBorderWidth;
82
- ctx.strokeStyle = wrapperColor;
83
- ctx.fillStyle = '#1976d24f';
88
+ ctx.strokeStyle = activeColor;
89
+ ctx.fillStyle = activeAreaColor;
84
90
  ctx.beginPath();
85
91
  ctx.moveTo(start.x, start.y);
86
92
  ctx.lineTo(end.x, start.y);
@@ -91,12 +97,13 @@ export function drawArea(ctx, opts) {
91
97
  ctx.fill();
92
98
  }
93
99
  export function drawListArea(ctx, opts) {
94
- const { areaSize } = opts;
100
+ const { areaSize, style } = opts;
101
+ const { activeColor, activeAreaColor } = style;
95
102
  const { x, y, w, h } = areaSize;
96
103
  ctx.setLineDash([]);
97
104
  ctx.lineWidth = areaBorderWidth;
98
- ctx.strokeStyle = wrapperColor;
99
- ctx.fillStyle = '#1976d21c';
105
+ ctx.strokeStyle = activeColor;
106
+ ctx.fillStyle = activeAreaColor;
100
107
  ctx.beginPath();
101
108
  ctx.moveTo(x, y);
102
109
  ctx.lineTo(x + w, y);
@@ -107,9 +114,11 @@ export function drawListArea(ctx, opts) {
107
114
  ctx.fill();
108
115
  }
109
116
  export function drawGroupQueueVertexesWrappers(ctx, vertexesList, opts) {
117
+ const { style } = opts;
118
+ const { activeColor } = style;
110
119
  for (let i = 0; i < vertexesList.length; i++) {
111
120
  const vertexes = vertexesList[i];
112
- const wrapperOpts = { borderColor: wrapperColor, borderWidth: selectWrapperBorderWidth, background: 'transparent', lineDash: [4, 4] };
121
+ const wrapperOpts = { borderColor: activeColor, borderWidth: selectWrapperBorderWidth, background: 'transparent', lineDash: [4, 4] };
113
122
  drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
114
123
  }
115
124
  }
@@ -1,7 +1,7 @@
1
- import type { CoreEventMap } from '@idraw/types';
1
+ import type { CoreEventMap, MiddlewareSelectorConfig } from '@idraw/types';
2
2
  import type { BoardMiddleware, ActionType, DeepSelectorSharedStorage } from './types';
3
3
  import { middlewareEventSelect, middlewareEventSelectClear, middlewareEventSelectInGroup, middlewareEventSnapToGrid, keyActionType, keyResizeType, keyGroupQueue, keyHoverElement, keySelectedElementList } from './config';
4
4
  export { keySelectedElementList, keyHoverElement, keyActionType, keyResizeType, keyGroupQueue };
5
5
  export type { DeepSelectorSharedStorage, ActionType };
6
6
  export { middlewareEventSelect, middlewareEventSelectClear, middlewareEventSelectInGroup, middlewareEventSnapToGrid };
7
- export declare const MiddlewareSelector: BoardMiddleware<DeepSelectorSharedStorage, CoreEventMap>;
7
+ export declare const MiddlewareSelector: BoardMiddleware<DeepSelectorSharedStorage, CoreEventMap, MiddlewareSelectorConfig>;
@@ -2,14 +2,17 @@ import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueV
2
2
  import { drawHoverVertexesWrapper, drawLockVertexesWrapper, drawArea, drawListArea, drawGroupQueueVertexesWrappers, drawSelectedElementControllersVertexes } from './draw-wrapper';
3
3
  import { drawReferenceLines } from './draw-reference';
4
4
  import { getPointTarget, resizeElement, rotateElement, getSelectedListArea, calcSelectedElementsArea, isElementInGroup, isPointInViewActiveGroup, calcMoveInGroup } from './util';
5
- import { middlewareEventSelect, middlewareEventSelectClear, middlewareEventSelectInGroup, middlewareEventSnapToGrid, keyActionType, keyResizeType, keyAreaStart, keyAreaEnd, keyGroupQueue, keyGroupQueueVertexesList, keyHoverElement, keyHoverElementVertexes, keySelectedElementList, keySelectedElementListVertexes, keySelectedElementController, keySelectedElementPosition, keyIsMoving, keyEnableSelectInGroup, keyEnableSnapToGrid, controllerSize } from './config';
5
+ import { middlewareEventSelect, middlewareEventSelectClear, middlewareEventSelectInGroup, middlewareEventSnapToGrid, keyActionType, keyResizeType, keyAreaStart, keyAreaEnd, keyGroupQueue, keyGroupQueueVertexesList, keyHoverElement, keyHoverElementVertexes, keySelectedElementList, keySelectedElementListVertexes, keySelectedElementController, keySelectedElementPosition, keyIsMoving, keyEnableSelectInGroup, keyEnableSnapToGrid, controllerSize, defaultStyle } from './config';
6
6
  import { calcReferenceInfo } from './reference';
7
7
  import { middlewareEventTextEdit } from '../text-editor';
8
8
  import { eventChange } from '../../config';
9
9
  import { keyLayoutIsSelected } from '../layout-selector';
10
10
  export { keySelectedElementList, keyHoverElement, keyActionType, keyResizeType, keyGroupQueue };
11
11
  export { middlewareEventSelect, middlewareEventSelectClear, middlewareEventSelectInGroup, middlewareEventSnapToGrid };
12
- export const MiddlewareSelector = (opts) => {
12
+ export const MiddlewareSelector = (opts, config) => {
13
+ const innerConfig = Object.assign(Object.assign({}, defaultStyle), config);
14
+ const { activeColor, activeAreaColor, lockedColor, referenceColor } = innerConfig;
15
+ const style = { activeColor, activeAreaColor, lockedColor, referenceColor };
13
16
  const { viewer, sharer, boardContent, calculator, eventHub } = opts;
14
17
  const { overlayContext } = boardContent;
15
18
  let prevPoint = null;
@@ -98,7 +101,6 @@ export const MiddlewareSelector = (opts) => {
98
101
  sharer.setSharedStorage(keySelectedElementController, null);
99
102
  sharer.setSharedStorage(keySelectedElementPosition, []);
100
103
  sharer.setSharedStorage(keyIsMoving, null);
101
- sharer.setSharedStorage(keyEnableSelectInGroup, null);
102
104
  };
103
105
  clear();
104
106
  const selectCallback = ({ uuids, positions }) => {
@@ -607,7 +609,7 @@ export const MiddlewareSelector = (opts) => {
607
609
  const groupQueueVertexesList = sharedStore[keyGroupQueueVertexesList];
608
610
  const isMoving = sharedStore[keyIsMoving];
609
611
  const enableSnapToGrid = sharedStore[keyEnableSnapToGrid];
610
- const drawBaseOpts = { calculator, viewScaleInfo, viewSizeInfo };
612
+ const drawBaseOpts = { calculator, viewScaleInfo, viewSizeInfo, style };
611
613
  const selectedElementController = elem
612
614
  ? calcElementSizeController(elem, {
613
615
  groupQueue,
@@ -624,14 +626,14 @@ export const MiddlewareSelector = (opts) => {
624
626
  groupQueue,
625
627
  controllerSize: 10,
626
628
  viewScaleInfo
627
- }) }));
629
+ }), style }));
628
630
  }
629
631
  else {
630
632
  drawHoverVertexesWrapper(overlayContext, hoverElementVertexes, drawBaseOpts);
631
633
  }
632
634
  }
633
635
  if (!isLock && elem && ['select', 'drag', 'resize'].includes(actionType)) {
634
- drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag' }));
636
+ drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag', style }));
635
637
  if (actionType === 'drag') {
636
638
  if (enableSnapToGrid === true) {
637
639
  const referenceInfo = calcReferenceInfo(elem.uuid, {
@@ -646,7 +648,8 @@ export const MiddlewareSelector = (opts) => {
646
648
  if (offsetX === 0 || offsetY === 0) {
647
649
  drawReferenceLines(overlayContext, {
648
650
  xLines,
649
- yLines
651
+ yLines,
652
+ style
650
653
  });
651
654
  }
652
655
  }
@@ -661,14 +664,14 @@ export const MiddlewareSelector = (opts) => {
661
664
  groupQueue,
662
665
  controllerSize: 10,
663
666
  viewScaleInfo
664
- }) }));
667
+ }), style }));
665
668
  }
666
669
  else {
667
670
  drawHoverVertexesWrapper(overlayContext, hoverElementVertexes, drawBaseOpts);
668
671
  }
669
672
  }
670
673
  if (!isLock && elem && ['select', 'drag', 'resize'].includes(actionType)) {
671
- drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag' }));
674
+ drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag', style }));
672
675
  if (actionType === 'drag') {
673
676
  if (enableSnapToGrid === true) {
674
677
  const referenceInfo = calcReferenceInfo(elem.uuid, {
@@ -683,7 +686,8 @@ export const MiddlewareSelector = (opts) => {
683
686
  if (offsetX === 0 || offsetY === 0) {
684
687
  drawReferenceLines(overlayContext, {
685
688
  xLines,
686
- yLines
689
+ yLines,
690
+ style
687
691
  });
688
692
  }
689
693
  }
@@ -691,7 +695,7 @@ export const MiddlewareSelector = (opts) => {
691
695
  }
692
696
  }
693
697
  else if (actionType === 'area' && areaStart && areaEnd) {
694
- drawArea(overlayContext, { start: areaStart, end: areaEnd });
698
+ drawArea(overlayContext, { start: areaStart, end: areaEnd, style });
695
699
  }
696
700
  else if (['drag-list', 'drag-list-end'].includes(actionType)) {
697
701
  const listAreaSize = calcSelectedElementsArea(getActiveElements(), {
@@ -700,7 +704,7 @@ export const MiddlewareSelector = (opts) => {
700
704
  calculator
701
705
  });
702
706
  if (listAreaSize) {
703
- drawListArea(overlayContext, { areaSize: listAreaSize });
707
+ drawListArea(overlayContext, { areaSize: listAreaSize, style });
704
708
  }
705
709
  }
706
710
  }