@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.
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/middleware/info/config.d.ts +4 -0
- package/dist/esm/middleware/info/config.js +8 -0
- package/dist/esm/middleware/info/draw-info.d.ts +4 -6
- package/dist/esm/middleware/info/draw-info.js +12 -9
- package/dist/esm/middleware/info/index.d.ts +2 -2
- package/dist/esm/middleware/info/index.js +11 -9
- package/dist/esm/middleware/layout-selector/config.d.ts +2 -2
- package/dist/esm/middleware/layout-selector/config.js +3 -2
- package/dist/esm/middleware/layout-selector/index.d.ts +2 -2
- package/dist/esm/middleware/layout-selector/index.js +7 -4
- package/dist/esm/middleware/layout-selector/util.d.ts +3 -2
- package/dist/esm/middleware/layout-selector/util.js +19 -64
- package/dist/esm/middleware/ruler/config.d.ts +7 -0
- package/dist/esm/middleware/ruler/config.js +21 -0
- package/dist/esm/middleware/ruler/index.d.ts +2 -2
- package/dist/esm/middleware/ruler/index.js +19 -6
- package/dist/esm/middleware/ruler/util.d.ts +6 -1
- package/dist/esm/middleware/ruler/util.js +13 -19
- package/dist/esm/middleware/scroller/config.d.ts +2 -0
- package/dist/esm/middleware/scroller/config.js +8 -0
- package/dist/esm/middleware/scroller/index.d.ts +2 -2
- package/dist/esm/middleware/scroller/index.js +13 -3
- package/dist/esm/middleware/scroller/util.d.ts +2 -1
- package/dist/esm/middleware/scroller/util.js +19 -36
- package/dist/esm/middleware/selector/config.d.ts +2 -4
- package/dist/esm/middleware/selector/config.js +10 -4
- package/dist/esm/middleware/selector/draw-auxiliary.d.ts +1 -7
- package/dist/esm/middleware/selector/draw-auxiliary.js +1 -35
- package/dist/esm/middleware/selector/draw-reference.d.ts +2 -0
- package/dist/esm/middleware/selector/draw-reference.js +2 -2
- package/dist/esm/middleware/selector/draw-wrapper.d.ts +7 -1
- package/dist/esm/middleware/selector/draw-wrapper.js +22 -13
- package/dist/esm/middleware/selector/index.d.ts +2 -2
- package/dist/esm/middleware/selector/index.js +16 -12
- package/dist/index.global.js +224 -169
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/esm/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export declare class Core<E extends CoreEventMap = CoreEventMap> {
|
|
|
13
13
|
constructor(container: HTMLDivElement, opts: CoreOptions);
|
|
14
14
|
isDestroyed(): boolean;
|
|
15
15
|
destroy(): void;
|
|
16
|
-
use(middleware: BoardMiddleware<any, any
|
|
17
|
-
disuse(middleware: BoardMiddleware<any, any>): void;
|
|
16
|
+
use<C extends any = any>(middleware: BoardMiddleware<any, any, any>, config?: C): void;
|
|
17
|
+
disuse(middleware: BoardMiddleware<any, any, any>): void;
|
|
18
18
|
setData(data: Data, opts?: {
|
|
19
19
|
modifiedOptions?: ModifyOptions;
|
|
20
20
|
}): void;
|
package/dist/esm/index.js
CHANGED
|
@@ -58,8 +58,8 @@ export class Core {
|
|
|
58
58
|
__classPrivateFieldGet(this, _Core_board, "f").destroy();
|
|
59
59
|
__classPrivateFieldGet(this, _Core_canvas, "f").remove();
|
|
60
60
|
}
|
|
61
|
-
use(middleware) {
|
|
62
|
-
__classPrivateFieldGet(this, _Core_board, "f").use(middleware);
|
|
61
|
+
use(middleware, config) {
|
|
62
|
+
__classPrivateFieldGet(this, _Core_board, "f").use(middleware, config);
|
|
63
63
|
}
|
|
64
64
|
disuse(middleware) {
|
|
65
65
|
__classPrivateFieldGet(this, _Core_board, "f").disuse(middleware);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PointSize, ViewContext2D } from '@idraw/types';
|
|
2
|
+
import type { MiddlewareInfoStyle } from './types';
|
|
2
3
|
export declare function drawSizeInfoText(ctx: ViewContext2D, opts: {
|
|
3
4
|
point: PointSize;
|
|
4
5
|
rotateCenter: PointSize;
|
|
@@ -6,8 +7,7 @@ export declare function drawSizeInfoText(ctx: ViewContext2D, opts: {
|
|
|
6
7
|
text: string;
|
|
7
8
|
fontSize: number;
|
|
8
9
|
lineHeight: number;
|
|
9
|
-
|
|
10
|
-
background: string;
|
|
10
|
+
style: MiddlewareInfoStyle;
|
|
11
11
|
}): void;
|
|
12
12
|
export declare function drawPositionInfoText(ctx: ViewContext2D, opts: {
|
|
13
13
|
point: PointSize;
|
|
@@ -16,8 +16,7 @@ export declare function drawPositionInfoText(ctx: ViewContext2D, opts: {
|
|
|
16
16
|
text: string;
|
|
17
17
|
fontSize: number;
|
|
18
18
|
lineHeight: number;
|
|
19
|
-
|
|
20
|
-
background: string;
|
|
19
|
+
style: MiddlewareInfoStyle;
|
|
21
20
|
}): void;
|
|
22
21
|
export declare function drawAngleInfoText(ctx: ViewContext2D, opts: {
|
|
23
22
|
point: PointSize;
|
|
@@ -26,6 +25,5 @@ export declare function drawAngleInfoText(ctx: ViewContext2D, opts: {
|
|
|
26
25
|
text: string;
|
|
27
26
|
fontSize: number;
|
|
28
27
|
lineHeight: number;
|
|
29
|
-
|
|
30
|
-
background: string;
|
|
28
|
+
style: MiddlewareInfoStyle;
|
|
31
29
|
}): void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { rotateByCenter } from '@idraw/util';
|
|
2
2
|
const fontFamily = 'monospace';
|
|
3
3
|
export function drawSizeInfoText(ctx, opts) {
|
|
4
|
-
const { point, rotateCenter, angle, text,
|
|
4
|
+
const { point, rotateCenter, angle, text, style, fontSize, lineHeight } = opts;
|
|
5
|
+
const { textColor, textBackground } = style;
|
|
5
6
|
rotateByCenter(ctx, angle, rotateCenter, () => {
|
|
6
7
|
ctx.$setFont({
|
|
7
8
|
fontWeight: '300',
|
|
@@ -23,7 +24,7 @@ export function drawSizeInfoText(ctx, opts) {
|
|
|
23
24
|
y: point.y
|
|
24
25
|
};
|
|
25
26
|
ctx.setLineDash([]);
|
|
26
|
-
ctx.fillStyle =
|
|
27
|
+
ctx.fillStyle = textBackground;
|
|
27
28
|
ctx.beginPath();
|
|
28
29
|
ctx.moveTo(bgStart.x, bgStart.y);
|
|
29
30
|
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
@@ -31,13 +32,14 @@ export function drawSizeInfoText(ctx, opts) {
|
|
|
31
32
|
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
32
33
|
ctx.closePath();
|
|
33
34
|
ctx.fill();
|
|
34
|
-
ctx.fillStyle =
|
|
35
|
+
ctx.fillStyle = textColor;
|
|
35
36
|
ctx.textBaseline = 'top';
|
|
36
37
|
ctx.fillText(text, textStart.x, textStart.y + padding);
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
export function drawPositionInfoText(ctx, opts) {
|
|
40
|
-
const { point, rotateCenter, angle, text,
|
|
41
|
+
const { point, rotateCenter, angle, text, style, fontSize, lineHeight } = opts;
|
|
42
|
+
const { textBackground, textColor } = style;
|
|
41
43
|
rotateByCenter(ctx, angle, rotateCenter, () => {
|
|
42
44
|
ctx.$setFont({
|
|
43
45
|
fontWeight: '300',
|
|
@@ -59,7 +61,7 @@ export function drawPositionInfoText(ctx, opts) {
|
|
|
59
61
|
y: point.y
|
|
60
62
|
};
|
|
61
63
|
ctx.setLineDash([]);
|
|
62
|
-
ctx.fillStyle =
|
|
64
|
+
ctx.fillStyle = textBackground;
|
|
63
65
|
ctx.beginPath();
|
|
64
66
|
ctx.moveTo(bgStart.x, bgStart.y);
|
|
65
67
|
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
@@ -67,13 +69,14 @@ export function drawPositionInfoText(ctx, opts) {
|
|
|
67
69
|
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
68
70
|
ctx.closePath();
|
|
69
71
|
ctx.fill();
|
|
70
|
-
ctx.fillStyle =
|
|
72
|
+
ctx.fillStyle = textColor;
|
|
71
73
|
ctx.textBaseline = 'top';
|
|
72
74
|
ctx.fillText(text, textStart.x, textStart.y + padding);
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
77
|
export function drawAngleInfoText(ctx, opts) {
|
|
76
|
-
const { point, rotateCenter, angle, text,
|
|
78
|
+
const { point, rotateCenter, angle, text, style, fontSize, lineHeight } = opts;
|
|
79
|
+
const { textBackground, textColor } = style;
|
|
77
80
|
rotateByCenter(ctx, angle, rotateCenter, () => {
|
|
78
81
|
ctx.$setFont({
|
|
79
82
|
fontWeight: '300',
|
|
@@ -95,7 +98,7 @@ export function drawAngleInfoText(ctx, opts) {
|
|
|
95
98
|
y: point.y
|
|
96
99
|
};
|
|
97
100
|
ctx.setLineDash([]);
|
|
98
|
-
ctx.fillStyle =
|
|
101
|
+
ctx.fillStyle = textBackground;
|
|
99
102
|
ctx.beginPath();
|
|
100
103
|
ctx.moveTo(bgStart.x, bgStart.y);
|
|
101
104
|
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
@@ -103,7 +106,7 @@ export function drawAngleInfoText(ctx, opts) {
|
|
|
103
106
|
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
104
107
|
ctx.closePath();
|
|
105
108
|
ctx.fill();
|
|
106
|
-
ctx.fillStyle =
|
|
109
|
+
ctx.fillStyle = textColor;
|
|
107
110
|
ctx.textBaseline = 'top';
|
|
108
111
|
ctx.fillText(text, textStart.x, textStart.y + padding);
|
|
109
112
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BoardMiddleware } from '@idraw/types';
|
|
1
|
+
import type { BoardMiddleware, MiddlewareInfoConfig } from '@idraw/types';
|
|
2
2
|
import type { DeepInfoSharedStorage } from './types';
|
|
3
|
-
export declare const MiddlewareInfo: BoardMiddleware<DeepInfoSharedStorage>;
|
|
3
|
+
export declare const MiddlewareInfo: BoardMiddleware<DeepInfoSharedStorage, any, MiddlewareInfoConfig>;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { formatNumber, getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot, createUUID, limitAngle, rotatePoint, parseAngleToRadian } from '@idraw/util';
|
|
2
2
|
import { keySelectedElementList, keyActionType, keyGroupQueue } from '../selector';
|
|
3
3
|
import { drawSizeInfoText, drawPositionInfoText, drawAngleInfoText } from './draw-info';
|
|
4
|
-
|
|
5
|
-
const infoTextColor = '#ffffff';
|
|
4
|
+
import { defaltStyle } from './config';
|
|
6
5
|
const infoFontSize = 10;
|
|
7
6
|
const infoLineHeight = 16;
|
|
8
|
-
export const MiddlewareInfo = (opts) => {
|
|
7
|
+
export const MiddlewareInfo = (opts, config) => {
|
|
9
8
|
const { boardContent, calculator } = opts;
|
|
10
9
|
const { overlayContext } = boardContent;
|
|
10
|
+
const innerConfig = Object.assign(Object.assign({}, defaltStyle), config);
|
|
11
|
+
const { textBackground, textColor } = innerConfig;
|
|
12
|
+
const style = {
|
|
13
|
+
textBackground,
|
|
14
|
+
textColor
|
|
15
|
+
};
|
|
11
16
|
return {
|
|
12
17
|
name: '@middleware/info',
|
|
13
18
|
beforeDrawFrame({ snapshot }) {
|
|
@@ -73,8 +78,7 @@ export const MiddlewareInfo = (opts) => {
|
|
|
73
78
|
text: whText,
|
|
74
79
|
fontSize: infoFontSize,
|
|
75
80
|
lineHeight: infoLineHeight,
|
|
76
|
-
|
|
77
|
-
background: infoBackground
|
|
81
|
+
style
|
|
78
82
|
});
|
|
79
83
|
drawPositionInfoText(overlayContext, {
|
|
80
84
|
point: {
|
|
@@ -86,8 +90,7 @@ export const MiddlewareInfo = (opts) => {
|
|
|
86
90
|
text: xyText,
|
|
87
91
|
fontSize: infoFontSize,
|
|
88
92
|
lineHeight: infoLineHeight,
|
|
89
|
-
|
|
90
|
-
background: infoBackground
|
|
93
|
+
style
|
|
91
94
|
});
|
|
92
95
|
drawAngleInfoText(overlayContext, {
|
|
93
96
|
point: {
|
|
@@ -99,8 +102,7 @@ export const MiddlewareInfo = (opts) => {
|
|
|
99
102
|
text: angleText,
|
|
100
103
|
fontSize: infoFontSize,
|
|
101
104
|
lineHeight: infoLineHeight,
|
|
102
|
-
|
|
103
|
-
background: infoBackground
|
|
105
|
+
style
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
108
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { MiddlewareLayoutSelectorStyle } from '@idraw/types';
|
|
1
2
|
export declare const key = "LAYOUT_SELECT";
|
|
2
3
|
export declare const keyLayoutActionType: unique symbol;
|
|
3
4
|
export declare const keyLayoutControlType: unique symbol;
|
|
4
5
|
export declare const keyLayoutController: unique symbol;
|
|
5
6
|
export declare const keyLayoutIsHover: unique symbol;
|
|
6
7
|
export declare const keyLayoutIsSelected: unique symbol;
|
|
7
|
-
export declare const selectColor = "#b331c9";
|
|
8
|
-
export declare const disableColor = "#5b5959b5";
|
|
9
8
|
export declare const controllerSize = 10;
|
|
9
|
+
export declare const defaultStyle: MiddlewareLayoutSelectorStyle;
|
|
@@ -4,6 +4,7 @@ export const keyLayoutControlType = Symbol(`${key}_layoutControlType`);
|
|
|
4
4
|
export const keyLayoutController = Symbol(`${key}_layoutController`);
|
|
5
5
|
export const keyLayoutIsHover = Symbol(`${key}_layoutIsHover`);
|
|
6
6
|
export const keyLayoutIsSelected = Symbol(`${key}_layoutIsSelected`);
|
|
7
|
-
export const selectColor = '#b331c9';
|
|
8
|
-
export const disableColor = '#5b5959b5';
|
|
9
7
|
export const controllerSize = 10;
|
|
8
|
+
export const defaultStyle = {
|
|
9
|
+
activeColor: '#b331c9'
|
|
10
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BoardMiddleware } from '@idraw/types';
|
|
1
|
+
import type { BoardMiddleware, MiddlewareLayoutSelectorConfig } from '@idraw/types';
|
|
2
2
|
import type { LayoutSelectorSharedStorage } from './types';
|
|
3
3
|
import { keyLayoutIsSelected } from './config';
|
|
4
4
|
export { keyLayoutIsSelected };
|
|
5
|
-
export declare const MiddlewareLayoutSelector: BoardMiddleware<LayoutSelectorSharedStorage>;
|
|
5
|
+
export declare const MiddlewareLayoutSelector: BoardMiddleware<LayoutSelectorSharedStorage, any, MiddlewareLayoutSelectorConfig>;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { calcLayoutSizeController, isViewPointInVertexes, getViewScaleInfoFromSnapshot, isViewPointInElementSize, calcViewElementSize } from '@idraw/util';
|
|
2
|
-
import { keyLayoutActionType, keyLayoutController, keyLayoutControlType, keyLayoutIsHover, keyLayoutIsSelected, controllerSize } from './config';
|
|
2
|
+
import { keyLayoutActionType, keyLayoutController, keyLayoutControlType, keyLayoutIsHover, keyLayoutIsSelected, controllerSize, defaultStyle } from './config';
|
|
3
3
|
import { keyActionType as keyElementActionType, keyHoverElement, middlewareEventSelectClear } from '../selector';
|
|
4
4
|
import { drawLayoutController, drawLayoutHover } from './util';
|
|
5
5
|
import { eventChange } from '../../config';
|
|
6
6
|
export { keyLayoutIsSelected };
|
|
7
|
-
export const MiddlewareLayoutSelector = (opts) => {
|
|
7
|
+
export const MiddlewareLayoutSelector = (opts, config) => {
|
|
8
8
|
const { sharer, boardContent, calculator, viewer, eventHub } = opts;
|
|
9
9
|
const { overlayContext } = boardContent;
|
|
10
|
+
const innerConfig = Object.assign(Object.assign({}, defaultStyle), config);
|
|
11
|
+
const { activeColor } = innerConfig;
|
|
12
|
+
const style = { activeColor };
|
|
10
13
|
let prevPoint = null;
|
|
11
14
|
let prevIsHover = null;
|
|
12
15
|
let prevIsSelected = null;
|
|
@@ -312,10 +315,10 @@ export const MiddlewareLayoutSelector = (opts) => {
|
|
|
312
315
|
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize });
|
|
313
316
|
if (layoutIsHover === true) {
|
|
314
317
|
const viewSize = calcViewElementSize(size, { viewScaleInfo });
|
|
315
|
-
drawLayoutHover(overlayContext, { layoutSize: viewSize });
|
|
318
|
+
drawLayoutHover(overlayContext, { layoutSize: viewSize, style });
|
|
316
319
|
}
|
|
317
320
|
if ((layoutActionType && ['resize'].includes(layoutActionType)) || layoutIsSelected === true) {
|
|
318
|
-
drawLayoutController(overlayContext, { controller,
|
|
321
|
+
drawLayoutController(overlayContext, { controller, style });
|
|
319
322
|
}
|
|
320
323
|
}
|
|
321
324
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ViewContext2D, LayoutSizeController,
|
|
1
|
+
import type { ViewContext2D, LayoutSizeController, ElementSize, MiddlewareLayoutSelectorStyle } from '@idraw/types';
|
|
2
2
|
export declare function drawLayoutController(ctx: ViewContext2D, opts: {
|
|
3
3
|
controller: LayoutSizeController;
|
|
4
|
-
|
|
4
|
+
style: MiddlewareLayoutSelectorStyle;
|
|
5
5
|
}): void;
|
|
6
6
|
export declare function drawLayoutHover(ctx: ViewContext2D, opts: {
|
|
7
7
|
layoutSize: ElementSize;
|
|
8
|
+
style: MiddlewareLayoutSelectorStyle;
|
|
8
9
|
}): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
function drawControllerBox(ctx, boxVertexes, style) {
|
|
2
|
+
const { activeColor } = style;
|
|
3
3
|
ctx.setLineDash([]);
|
|
4
4
|
ctx.fillStyle = '#FFFFFF';
|
|
5
5
|
ctx.beginPath();
|
|
@@ -9,7 +9,7 @@ function drawControllerBox(ctx, boxVertexes) {
|
|
|
9
9
|
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
10
10
|
ctx.closePath();
|
|
11
11
|
ctx.fill();
|
|
12
|
-
ctx.strokeStyle =
|
|
12
|
+
ctx.strokeStyle = activeColor;
|
|
13
13
|
ctx.lineWidth = 2;
|
|
14
14
|
ctx.beginPath();
|
|
15
15
|
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
@@ -19,26 +19,11 @@ function drawControllerBox(ctx, boxVertexes) {
|
|
|
19
19
|
ctx.closePath();
|
|
20
20
|
ctx.stroke();
|
|
21
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
22
|
function drawControllerLine(ctx, opts) {
|
|
39
|
-
const { start, end,
|
|
40
|
-
const
|
|
41
|
-
const
|
|
23
|
+
const { start, end, style } = opts;
|
|
24
|
+
const { activeColor } = style;
|
|
25
|
+
const lineWidth = 2;
|
|
26
|
+
const strokeStyle = activeColor;
|
|
42
27
|
ctx.setLineDash([]);
|
|
43
28
|
ctx.strokeStyle = strokeStyle;
|
|
44
29
|
ctx.lineWidth = lineWidth;
|
|
@@ -47,55 +32,25 @@ function drawControllerLine(ctx, opts) {
|
|
|
47
32
|
ctx.lineTo(end.x, end.y);
|
|
48
33
|
ctx.closePath();
|
|
49
34
|
ctx.stroke();
|
|
50
|
-
if (disabled === true) {
|
|
51
|
-
drawControllerCross(ctx, {
|
|
52
|
-
vertexes: centerVertexes,
|
|
53
|
-
lineWidth,
|
|
54
|
-
strokeStyle
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
35
|
}
|
|
58
36
|
export function drawLayoutController(ctx, opts) {
|
|
59
|
-
const { controller,
|
|
37
|
+
const { controller, style } = opts;
|
|
60
38
|
const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, rightMiddle, bottomMiddle, leftMiddle } = controller;
|
|
61
|
-
drawControllerLine(ctx, { start: topLeft.center, end: topRight.center, centerVertexes: topMiddle.vertexes,
|
|
62
|
-
drawControllerLine(ctx, { start: topRight.center, end: bottomRight.center, centerVertexes: rightMiddle.vertexes,
|
|
63
|
-
drawControllerLine(ctx, { start: bottomRight.center, end: bottomLeft.center, centerVertexes: bottomMiddle.vertexes,
|
|
64
|
-
drawControllerLine(ctx, { start: bottomLeft.center, end: topLeft.center, centerVertexes: leftMiddle.vertexes,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if ((operations === null || operations === void 0 ? void 0 : operations.disabledTopLeft) === 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.disabledTopRight) === 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.disabledBottomRight) === 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.disabledBottomLeft) === true) {
|
|
88
|
-
drawControllerCross(ctx, Object.assign({ vertexes: bottomLeft.vertexes }, disabledOpts));
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
drawControllerBox(ctx, bottomLeft.vertexes);
|
|
92
|
-
}
|
|
39
|
+
drawControllerLine(ctx, { start: topLeft.center, end: topRight.center, centerVertexes: topMiddle.vertexes, style });
|
|
40
|
+
drawControllerLine(ctx, { start: topRight.center, end: bottomRight.center, centerVertexes: rightMiddle.vertexes, style });
|
|
41
|
+
drawControllerLine(ctx, { start: bottomRight.center, end: bottomLeft.center, centerVertexes: bottomMiddle.vertexes, style });
|
|
42
|
+
drawControllerLine(ctx, { start: bottomLeft.center, end: topLeft.center, centerVertexes: leftMiddle.vertexes, style });
|
|
43
|
+
drawControllerBox(ctx, topLeft.vertexes, style);
|
|
44
|
+
drawControllerBox(ctx, topRight.vertexes, style);
|
|
45
|
+
drawControllerBox(ctx, bottomRight.vertexes, style);
|
|
46
|
+
drawControllerBox(ctx, bottomLeft.vertexes, style);
|
|
93
47
|
}
|
|
94
48
|
export function drawLayoutHover(ctx, opts) {
|
|
95
|
-
const { layoutSize } = opts;
|
|
49
|
+
const { layoutSize, style } = opts;
|
|
50
|
+
const { activeColor } = style;
|
|
96
51
|
const { x, y, w, h } = layoutSize;
|
|
97
52
|
ctx.setLineDash([]);
|
|
98
|
-
ctx.strokeStyle =
|
|
53
|
+
ctx.strokeStyle = activeColor;
|
|
99
54
|
ctx.lineWidth = 1;
|
|
100
55
|
ctx.beginPath();
|
|
101
56
|
ctx.moveTo(x, y);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MiddlewareRulerStyle } from '@idraw/types';
|
|
2
|
+
export declare const rulerSize = 16;
|
|
3
|
+
export declare const fontSize = 10;
|
|
4
|
+
export declare const fontWeight = 100;
|
|
5
|
+
export declare const lineSize = 1;
|
|
6
|
+
export declare const fontFamily = "monospace";
|
|
7
|
+
export declare const defaultStyle: MiddlewareRulerStyle;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const rulerSize = 16;
|
|
2
|
+
export const fontSize = 10;
|
|
3
|
+
export const fontWeight = 100;
|
|
4
|
+
export const lineSize = 1;
|
|
5
|
+
export const fontFamily = 'monospace';
|
|
6
|
+
const background = '#FFFFFFA8';
|
|
7
|
+
const borderColor = '#00000080';
|
|
8
|
+
const scaleColor = '#000000';
|
|
9
|
+
const textColor = '#00000080';
|
|
10
|
+
const gridColor = '#AAAAAA20';
|
|
11
|
+
const gridPrimaryColor = '#AAAAAA40';
|
|
12
|
+
const selectedAreaColor = '#196097';
|
|
13
|
+
export const defaultStyle = {
|
|
14
|
+
background,
|
|
15
|
+
borderColor,
|
|
16
|
+
scaleColor,
|
|
17
|
+
textColor,
|
|
18
|
+
gridColor,
|
|
19
|
+
gridPrimaryColor,
|
|
20
|
+
selectedAreaColor
|
|
21
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BoardMiddleware, CoreEventMap } from '@idraw/types';
|
|
1
|
+
import type { BoardMiddleware, CoreEventMap, MiddlewareRulerConfig } from '@idraw/types';
|
|
2
2
|
import type { DeepRulerSharedStorage } from './types';
|
|
3
3
|
export declare const middlewareEventRuler = "@middleware/show-ruler";
|
|
4
|
-
export declare const MiddlewareRuler: BoardMiddleware<DeepRulerSharedStorage, CoreEventMap>;
|
|
4
|
+
export declare const MiddlewareRuler: BoardMiddleware<DeepRulerSharedStorage, CoreEventMap, MiddlewareRulerConfig>;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from '@idraw/util';
|
|
2
2
|
import { drawRulerBackground, drawXRuler, drawYRuler, calcXRulerScaleList, calcYRulerScaleList, drawGrid, drawScrollerSelectedArea } from './util';
|
|
3
|
+
import { defaultStyle } from './config';
|
|
3
4
|
export const middlewareEventRuler = '@middleware/show-ruler';
|
|
4
|
-
export const MiddlewareRuler = (opts) => {
|
|
5
|
+
export const MiddlewareRuler = (opts, config) => {
|
|
5
6
|
const { boardContent, viewer, eventHub, calculator } = opts;
|
|
6
7
|
const { overlayContext, underlayContext } = boardContent;
|
|
8
|
+
const innerConfig = Object.assign(Object.assign({}, defaultStyle), config);
|
|
9
|
+
const { background, borderColor, scaleColor, textColor, gridColor, gridPrimaryColor, selectedAreaColor } = innerConfig;
|
|
10
|
+
const style = {
|
|
11
|
+
background,
|
|
12
|
+
borderColor,
|
|
13
|
+
scaleColor,
|
|
14
|
+
textColor,
|
|
15
|
+
gridColor,
|
|
16
|
+
gridPrimaryColor,
|
|
17
|
+
selectedAreaColor
|
|
18
|
+
};
|
|
7
19
|
let show = true;
|
|
8
20
|
let showGrid = true;
|
|
9
21
|
const rulerCallback = (e) => {
|
|
@@ -29,19 +41,20 @@ export const MiddlewareRuler = (opts) => {
|
|
|
29
41
|
if (show === true) {
|
|
30
42
|
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
31
43
|
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
32
|
-
drawScrollerSelectedArea(overlayContext, { snapshot, calculator });
|
|
33
|
-
drawRulerBackground(overlayContext, { viewScaleInfo, viewSizeInfo });
|
|
44
|
+
drawScrollerSelectedArea(overlayContext, { snapshot, calculator, style });
|
|
45
|
+
drawRulerBackground(overlayContext, { viewScaleInfo, viewSizeInfo, style });
|
|
34
46
|
const { list: xList, rulerUnit } = calcXRulerScaleList({ viewScaleInfo, viewSizeInfo });
|
|
35
|
-
drawXRuler(overlayContext, { scaleList: xList });
|
|
47
|
+
drawXRuler(overlayContext, { scaleList: xList, style });
|
|
36
48
|
const { list: yList } = calcYRulerScaleList({ viewScaleInfo, viewSizeInfo });
|
|
37
|
-
drawYRuler(overlayContext, { scaleList: yList });
|
|
49
|
+
drawYRuler(overlayContext, { scaleList: yList, style });
|
|
38
50
|
if (showGrid === true) {
|
|
39
51
|
const ctx = rulerUnit === 1 ? overlayContext : underlayContext;
|
|
40
52
|
drawGrid(ctx, {
|
|
41
53
|
xList,
|
|
42
54
|
yList,
|
|
43
55
|
viewScaleInfo,
|
|
44
|
-
viewSizeInfo
|
|
56
|
+
viewSizeInfo,
|
|
57
|
+
style
|
|
45
58
|
});
|
|
46
59
|
}
|
|
47
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ViewScaleInfo, ViewSizeInfo, ViewContext2D, BoardViewerFrameSnapshot, ViewCalculator } from '@idraw/types';
|
|
2
|
-
import type { DeepRulerSharedStorage } from './types';
|
|
2
|
+
import type { DeepRulerSharedStorage, MiddlewareRulerStyle } from './types';
|
|
3
3
|
interface RulerScale {
|
|
4
4
|
num: number;
|
|
5
5
|
showNum: boolean;
|
|
@@ -23,22 +23,27 @@ export declare function calcYRulerScaleList(opts: {
|
|
|
23
23
|
};
|
|
24
24
|
export declare function drawXRuler(ctx: ViewContext2D, opts: {
|
|
25
25
|
scaleList: RulerScale[];
|
|
26
|
+
style: MiddlewareRulerStyle;
|
|
26
27
|
}): void;
|
|
27
28
|
export declare function drawYRuler(ctx: ViewContext2D, opts: {
|
|
28
29
|
scaleList: RulerScale[];
|
|
30
|
+
style: MiddlewareRulerStyle;
|
|
29
31
|
}): void;
|
|
30
32
|
export declare function drawRulerBackground(ctx: ViewContext2D, opts: {
|
|
31
33
|
viewScaleInfo: ViewScaleInfo;
|
|
32
34
|
viewSizeInfo: ViewSizeInfo;
|
|
35
|
+
style: MiddlewareRulerStyle;
|
|
33
36
|
}): void;
|
|
34
37
|
export declare function drawGrid(ctx: ViewContext2D, opts: {
|
|
35
38
|
xList: RulerScale[];
|
|
36
39
|
yList: RulerScale[];
|
|
37
40
|
viewScaleInfo: ViewScaleInfo;
|
|
38
41
|
viewSizeInfo: ViewSizeInfo;
|
|
42
|
+
style: MiddlewareRulerStyle;
|
|
39
43
|
}): void;
|
|
40
44
|
export declare function drawScrollerSelectedArea(ctx: ViewContext2D, opts: {
|
|
41
45
|
snapshot: BoardViewerFrameSnapshot<DeepRulerSharedStorage>;
|
|
42
46
|
calculator: ViewCalculator;
|
|
47
|
+
style: MiddlewareRulerStyle;
|
|
43
48
|
}): void;
|
|
44
49
|
export {};
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { formatNumber, rotateByCenter, getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from '@idraw/util';
|
|
2
2
|
import { keySelectedElementList, keyActionType } from '../selector';
|
|
3
|
-
|
|
4
|
-
const background = '#FFFFFFA8';
|
|
5
|
-
const borderColor = '#00000080';
|
|
6
|
-
const scaleColor = '#000000';
|
|
7
|
-
const textColor = '#00000080';
|
|
8
|
-
const fontFamily = 'monospace';
|
|
9
|
-
const fontSize = 10;
|
|
10
|
-
const fontWeight = 100;
|
|
11
|
-
const gridColor = '#AAAAAA20';
|
|
12
|
-
const gridKeyColor = '#AAAAAA40';
|
|
13
|
-
const lineSize = 1;
|
|
14
|
-
const selectedAreaColor = '#196097';
|
|
3
|
+
import { rulerSize, fontSize, fontWeight, lineSize, fontFamily } from './config';
|
|
15
4
|
const limitRulerUnitList = [1, 2, 5, 10, 20, 50, 100, 200, 500];
|
|
16
5
|
function limitRulerUnit(unit) {
|
|
17
6
|
unit = Math.max(limitRulerUnitList[0], Math.min(unit, limitRulerUnitList[limitRulerUnitList.length - 1]));
|
|
@@ -88,7 +77,8 @@ export function calcYRulerScaleList(opts) {
|
|
|
88
77
|
});
|
|
89
78
|
}
|
|
90
79
|
export function drawXRuler(ctx, opts) {
|
|
91
|
-
const { scaleList } = opts;
|
|
80
|
+
const { scaleList, style } = opts;
|
|
81
|
+
const { scaleColor, textColor } = style;
|
|
92
82
|
const scaleDrawStart = rulerSize;
|
|
93
83
|
const scaleDrawEnd = (rulerSize * 4) / 5;
|
|
94
84
|
const subKeyScaleDrawEnd = (rulerSize * 2) / 5;
|
|
@@ -120,7 +110,8 @@ export function drawXRuler(ctx, opts) {
|
|
|
120
110
|
}
|
|
121
111
|
}
|
|
122
112
|
export function drawYRuler(ctx, opts) {
|
|
123
|
-
const { scaleList } = opts;
|
|
113
|
+
const { scaleList, style } = opts;
|
|
114
|
+
const { scaleColor, textColor } = style;
|
|
124
115
|
const scaleDrawStart = rulerSize;
|
|
125
116
|
const scaleDrawEnd = (rulerSize * 4) / 5;
|
|
126
117
|
const subKeyScaleDrawEnd = (rulerSize * 2) / 5;
|
|
@@ -157,8 +148,9 @@ export function drawYRuler(ctx, opts) {
|
|
|
157
148
|
}
|
|
158
149
|
}
|
|
159
150
|
export function drawRulerBackground(ctx, opts) {
|
|
160
|
-
const { viewSizeInfo } = opts;
|
|
151
|
+
const { viewSizeInfo, style } = opts;
|
|
161
152
|
const { width, height } = viewSizeInfo;
|
|
153
|
+
const { background, borderColor } = style;
|
|
162
154
|
ctx.beginPath();
|
|
163
155
|
ctx.moveTo(0, 0);
|
|
164
156
|
ctx.lineTo(width + 1, 0);
|
|
@@ -176,15 +168,16 @@ export function drawRulerBackground(ctx, opts) {
|
|
|
176
168
|
ctx.stroke();
|
|
177
169
|
}
|
|
178
170
|
export function drawGrid(ctx, opts) {
|
|
179
|
-
const { xList, yList, viewSizeInfo } = opts;
|
|
171
|
+
const { xList, yList, viewSizeInfo, style } = opts;
|
|
180
172
|
const { width, height } = viewSizeInfo;
|
|
173
|
+
const { gridColor, gridPrimaryColor } = style;
|
|
181
174
|
for (let i = 0; i < xList.length; i++) {
|
|
182
175
|
const item = xList[i];
|
|
183
176
|
ctx.beginPath();
|
|
184
177
|
ctx.moveTo(item.position, 0);
|
|
185
178
|
ctx.lineTo(item.position, height);
|
|
186
179
|
if (item.isKeyNum === true || item.isSubKeyNum === true) {
|
|
187
|
-
ctx.strokeStyle =
|
|
180
|
+
ctx.strokeStyle = gridPrimaryColor;
|
|
188
181
|
}
|
|
189
182
|
else {
|
|
190
183
|
ctx.strokeStyle = gridColor;
|
|
@@ -200,7 +193,7 @@ export function drawGrid(ctx, opts) {
|
|
|
200
193
|
ctx.moveTo(0, item.position);
|
|
201
194
|
ctx.lineTo(width, item.position);
|
|
202
195
|
if (item.isKeyNum === true || item.isSubKeyNum === true) {
|
|
203
|
-
ctx.strokeStyle =
|
|
196
|
+
ctx.strokeStyle = gridPrimaryColor;
|
|
204
197
|
}
|
|
205
198
|
else {
|
|
206
199
|
ctx.strokeStyle = gridColor;
|
|
@@ -211,8 +204,9 @@ export function drawGrid(ctx, opts) {
|
|
|
211
204
|
}
|
|
212
205
|
}
|
|
213
206
|
export function drawScrollerSelectedArea(ctx, opts) {
|
|
214
|
-
const { snapshot, calculator } = opts;
|
|
207
|
+
const { snapshot, calculator, style } = opts;
|
|
215
208
|
const { sharedStore } = snapshot;
|
|
209
|
+
const { selectedAreaColor } = style;
|
|
216
210
|
const selectedElementList = sharedStore[keySelectedElementList];
|
|
217
211
|
const actionType = sharedStore[keyActionType];
|
|
218
212
|
if (['select', 'drag', 'drag-list', 'drag-list-end'].includes(actionType) && selectedElementList.length > 0) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MiddlewareScrollerStyle } from '@idraw/types';
|
|
1
2
|
export declare const key = "SCROLL";
|
|
2
3
|
export declare const keyXThumbRect: unique symbol;
|
|
3
4
|
export declare const keyYThumbRect: unique symbol;
|
|
@@ -6,3 +7,4 @@ export declare const keyHoverYThumbRect: unique symbol;
|
|
|
6
7
|
export declare const keyPrevPoint: unique symbol;
|
|
7
8
|
export declare const keyActivePoint: unique symbol;
|
|
8
9
|
export declare const keyActiveThumbType: unique symbol;
|
|
10
|
+
export declare const defaultStyle: MiddlewareScrollerStyle;
|
|
@@ -6,3 +6,11 @@ export const keyHoverYThumbRect = Symbol(`${key}_hoverYThumbRect`);
|
|
|
6
6
|
export const keyPrevPoint = Symbol(`${key}_prevPoint`);
|
|
7
7
|
export const keyActivePoint = Symbol(`${key}_activePoint`);
|
|
8
8
|
export const keyActiveThumbType = Symbol(`${key}_activeThumbType`);
|
|
9
|
+
export const defaultStyle = {
|
|
10
|
+
thumbBackground: '#0000003A',
|
|
11
|
+
thumbBorderColor: '#0000008A',
|
|
12
|
+
hoverThumbBackground: '#0000005F',
|
|
13
|
+
hoverThumbBorderColor: '#000000EE',
|
|
14
|
+
activeThumbBackground: '#0000005E',
|
|
15
|
+
activeThumbBorderColor: '#000000F0'
|
|
16
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BoardMiddleware } from '@idraw/types';
|
|
1
|
+
import type { BoardMiddleware, MiddlewareScrollerConfig } from '@idraw/types';
|
|
2
2
|
import type { DeepScrollerSharedStorage } from './types';
|
|
3
|
-
export declare const MiddlewareScroller: BoardMiddleware<DeepScrollerSharedStorage>;
|
|
3
|
+
export declare const MiddlewareScroller: BoardMiddleware<DeepScrollerSharedStorage, any, MiddlewareScrollerConfig>;
|