@hprint/plugins 0.0.1-alpha.2 → 0.0.1-alpha.3
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/index.js +17 -17
- package/dist/index.mjs +1071 -1057
- package/dist/src/plugins/AlignGuidLinePlugin.d.ts +7 -2
- package/dist/src/plugins/AlignGuidLinePlugin.d.ts.map +1 -1
- package/dist/src/plugins/GroupAlignPlugin.d.ts.map +1 -1
- package/dist/src/plugins/LockPlugin.d.ts.map +1 -1
- package/dist/src/plugins/QrCodePlugin.d.ts +5 -0
- package/dist/src/plugins/QrCodePlugin.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/assets/style/resizePlugin.css +27 -27
- package/src/objects/Arrow.js +47 -47
- package/src/objects/ThinTailArrow.js +50 -50
- package/src/plugins/AlignGuidLinePlugin.ts +1152 -1141
- package/src/plugins/BarCodePlugin.ts +2 -2
- package/src/plugins/ControlsPlugin.ts +251 -251
- package/src/plugins/ControlsRotatePlugin.ts +111 -111
- package/src/plugins/CopyPlugin.ts +255 -255
- package/src/plugins/DeleteHotKeyPlugin.ts +57 -57
- package/src/plugins/DrawLinePlugin.ts +162 -162
- package/src/plugins/DrawPolygonPlugin.ts +205 -205
- package/src/plugins/DringPlugin.ts +125 -125
- package/src/plugins/FlipPlugin.ts +59 -59
- package/src/plugins/FontPlugin.ts +165 -165
- package/src/plugins/FreeDrawPlugin.ts +49 -49
- package/src/plugins/GroupAlignPlugin.ts +365 -365
- package/src/plugins/GroupPlugin.ts +82 -82
- package/src/plugins/GroupTextEditorPlugin.ts +198 -198
- package/src/plugins/HistoryPlugin.ts +181 -181
- package/src/plugins/ImageStroke.ts +121 -121
- package/src/plugins/LayerPlugin.ts +108 -108
- package/src/plugins/LockPlugin.ts +242 -240
- package/src/plugins/MaskPlugin.ts +155 -155
- package/src/plugins/MaterialPlugin.ts +224 -224
- package/src/plugins/MiddleMousePlugin.ts +45 -45
- package/src/plugins/MoveHotKeyPlugin.ts +46 -46
- package/src/plugins/PathTextPlugin.ts +89 -89
- package/src/plugins/PolygonModifyPlugin.ts +224 -224
- package/src/plugins/PrintPlugin.ts +81 -81
- package/src/plugins/PsdPlugin.ts +52 -52
- package/src/plugins/QrCodePlugin.ts +322 -329
- package/src/plugins/ResizePlugin.ts +278 -278
- package/src/plugins/RulerPlugin.ts +78 -78
- package/src/plugins/SimpleClipImagePlugin.ts +244 -244
- package/src/plugins/UnitPlugin.ts +326 -326
- package/src/plugins/WaterMarkPlugin.ts +257 -257
- package/src/types/eventType.ts +11 -11
- package/src/utils/psd.js +432 -432
- package/src/utils/ruler/guideline.ts +145 -145
- package/src/utils/ruler/index.ts +91 -91
- package/src/utils/ruler/ruler.ts +924 -924
- package/src/utils/ruler/utils.ts +162 -162
- package/tsconfig.json +10 -10
- package/vite.config.ts +29 -29
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
-
import { fabric } from '@hprint/core';
|
|
4
|
-
|
|
5
|
-
export function setupGuideLine() {
|
|
6
|
-
if (fabric.GuideLine) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
fabric.GuideLine = fabric.util.createClass(fabric.Line, {
|
|
11
|
-
type: 'GuideLine',
|
|
12
|
-
selectable: false,
|
|
13
|
-
hasControls: false,
|
|
14
|
-
hasBorders: false,
|
|
15
|
-
stroke: '#4bec13',
|
|
16
|
-
originX: 'center',
|
|
17
|
-
originY: 'center',
|
|
18
|
-
padding: 4, // 填充,让辅助线选择范围更大,方便选中
|
|
19
|
-
globalCompositeOperation: 'difference',
|
|
20
|
-
axis: 'horizontal',
|
|
21
|
-
// excludeFromExport: true,
|
|
22
|
-
|
|
23
|
-
initialize(points: number, options: fabric.IGuideLineOptions) {
|
|
24
|
-
const isHorizontal = options.axis === 'horizontal';
|
|
25
|
-
// 指针
|
|
26
|
-
this.hoverCursor = isHorizontal ? 'ns-resize' : 'ew-resize';
|
|
27
|
-
// 设置新的点
|
|
28
|
-
const newPoints = isHorizontal
|
|
29
|
-
? [-999999, points, 999999, points]
|
|
30
|
-
: [points, -999999, points, 999999];
|
|
31
|
-
// 锁定移动
|
|
32
|
-
options[isHorizontal ? 'lockMovementX' : 'lockMovementY'] = true;
|
|
33
|
-
// 调用父类初始化
|
|
34
|
-
this.callSuper('initialize', newPoints, options);
|
|
35
|
-
|
|
36
|
-
// 绑定事件
|
|
37
|
-
this.on('mousedown:before', (e: fabric.IEvent<MouseEvent>) => {
|
|
38
|
-
if (this.activeOn === 'down') {
|
|
39
|
-
// 设置selectable:false后激活对象才能进行移动
|
|
40
|
-
this.canvas && this.canvas.setActiveObject(this, e.e);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
this.on('moving', (e) => {
|
|
45
|
-
if (
|
|
46
|
-
this.canvas &&
|
|
47
|
-
this.canvas.ruler.options.enabled &&
|
|
48
|
-
this.isPointOnRuler(e.e)
|
|
49
|
-
) {
|
|
50
|
-
this.moveCursor = 'not-allowed';
|
|
51
|
-
} else {
|
|
52
|
-
this.moveCursor = this.isHorizontal()
|
|
53
|
-
? 'ns-resize'
|
|
54
|
-
: 'ew-resize';
|
|
55
|
-
}
|
|
56
|
-
this.canvas &&
|
|
57
|
-
this.canvas.fire('guideline:moving', {
|
|
58
|
-
target: this,
|
|
59
|
-
e: e.e,
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
this.on('mouseup', (e) => {
|
|
64
|
-
// 移动到标尺上,移除辅助线
|
|
65
|
-
if (
|
|
66
|
-
this.canvas &&
|
|
67
|
-
this.canvas.ruler.options.enabled &&
|
|
68
|
-
this.isPointOnRuler(e.e)
|
|
69
|
-
) {
|
|
70
|
-
// console.log('移除辅助线', this);
|
|
71
|
-
this.canvas.remove(this);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
this.moveCursor = this.isHorizontal()
|
|
75
|
-
? 'ns-resize'
|
|
76
|
-
: 'ew-resize';
|
|
77
|
-
this.canvas &&
|
|
78
|
-
this.canvas.fire('guideline:mouseup', {
|
|
79
|
-
target: this,
|
|
80
|
-
e: e.e,
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
this.on('removed', () => {
|
|
85
|
-
this.off('removed');
|
|
86
|
-
this.off('mousedown:before');
|
|
87
|
-
this.off('moving');
|
|
88
|
-
this.off('mouseup');
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
getBoundingRect(absolute, calculate) {
|
|
93
|
-
this.bringToFront();
|
|
94
|
-
|
|
95
|
-
const isHorizontal = this.isHorizontal();
|
|
96
|
-
const rect = this.callSuper('getBoundingRect', absolute, calculate);
|
|
97
|
-
rect[isHorizontal ? 'top' : 'left'] +=
|
|
98
|
-
rect[isHorizontal ? 'height' : 'width'] / 2;
|
|
99
|
-
rect[isHorizontal ? 'height' : 'width'] = 0;
|
|
100
|
-
return rect;
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
isPointOnRuler(e) {
|
|
104
|
-
const isHorizontal = this.isHorizontal();
|
|
105
|
-
const hoveredRuler =
|
|
106
|
-
this.canvas &&
|
|
107
|
-
this.canvas.ruler.isPointOnRuler(
|
|
108
|
-
new fabric.Point(e.offsetX, e.offsetY)
|
|
109
|
-
);
|
|
110
|
-
if (
|
|
111
|
-
(isHorizontal && hoveredRuler === 'horizontal') ||
|
|
112
|
-
(!isHorizontal && hoveredRuler === 'vertical')
|
|
113
|
-
) {
|
|
114
|
-
return hoveredRuler;
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
isHorizontal() {
|
|
120
|
-
return this.height === 0;
|
|
121
|
-
},
|
|
122
|
-
} as fabric.GuideLine);
|
|
123
|
-
|
|
124
|
-
fabric.GuideLine.fromObject = function (object, callback) {
|
|
125
|
-
const clone = fabric.util.object.clone as (
|
|
126
|
-
object: any,
|
|
127
|
-
deep: boolean
|
|
128
|
-
) => any;
|
|
129
|
-
|
|
130
|
-
function _callback(instance: any) {
|
|
131
|
-
delete instance.xy;
|
|
132
|
-
callback && callback(instance);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const options = clone(object, true);
|
|
136
|
-
const isHorizontal = options.height === 0;
|
|
137
|
-
|
|
138
|
-
options.xy = isHorizontal ? options.y1 : options.x1;
|
|
139
|
-
options.axis = isHorizontal ? 'horizontal' : 'vertical';
|
|
140
|
-
|
|
141
|
-
fabric.Object._fromObject(options.type, options, _callback, 'xy');
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export default fabric.GuideLine;
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
import { fabric } from '@hprint/core';
|
|
4
|
+
|
|
5
|
+
export function setupGuideLine() {
|
|
6
|
+
if (fabric.GuideLine) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
fabric.GuideLine = fabric.util.createClass(fabric.Line, {
|
|
11
|
+
type: 'GuideLine',
|
|
12
|
+
selectable: false,
|
|
13
|
+
hasControls: false,
|
|
14
|
+
hasBorders: false,
|
|
15
|
+
stroke: '#4bec13',
|
|
16
|
+
originX: 'center',
|
|
17
|
+
originY: 'center',
|
|
18
|
+
padding: 4, // 填充,让辅助线选择范围更大,方便选中
|
|
19
|
+
globalCompositeOperation: 'difference',
|
|
20
|
+
axis: 'horizontal',
|
|
21
|
+
// excludeFromExport: true,
|
|
22
|
+
|
|
23
|
+
initialize(points: number, options: fabric.IGuideLineOptions) {
|
|
24
|
+
const isHorizontal = options.axis === 'horizontal';
|
|
25
|
+
// 指针
|
|
26
|
+
this.hoverCursor = isHorizontal ? 'ns-resize' : 'ew-resize';
|
|
27
|
+
// 设置新的点
|
|
28
|
+
const newPoints = isHorizontal
|
|
29
|
+
? [-999999, points, 999999, points]
|
|
30
|
+
: [points, -999999, points, 999999];
|
|
31
|
+
// 锁定移动
|
|
32
|
+
options[isHorizontal ? 'lockMovementX' : 'lockMovementY'] = true;
|
|
33
|
+
// 调用父类初始化
|
|
34
|
+
this.callSuper('initialize', newPoints, options);
|
|
35
|
+
|
|
36
|
+
// 绑定事件
|
|
37
|
+
this.on('mousedown:before', (e: fabric.IEvent<MouseEvent>) => {
|
|
38
|
+
if (this.activeOn === 'down') {
|
|
39
|
+
// 设置selectable:false后激活对象才能进行移动
|
|
40
|
+
this.canvas && this.canvas.setActiveObject(this, e.e);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
this.on('moving', (e) => {
|
|
45
|
+
if (
|
|
46
|
+
this.canvas &&
|
|
47
|
+
this.canvas.ruler.options.enabled &&
|
|
48
|
+
this.isPointOnRuler(e.e)
|
|
49
|
+
) {
|
|
50
|
+
this.moveCursor = 'not-allowed';
|
|
51
|
+
} else {
|
|
52
|
+
this.moveCursor = this.isHorizontal()
|
|
53
|
+
? 'ns-resize'
|
|
54
|
+
: 'ew-resize';
|
|
55
|
+
}
|
|
56
|
+
this.canvas &&
|
|
57
|
+
this.canvas.fire('guideline:moving', {
|
|
58
|
+
target: this,
|
|
59
|
+
e: e.e,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
this.on('mouseup', (e) => {
|
|
64
|
+
// 移动到标尺上,移除辅助线
|
|
65
|
+
if (
|
|
66
|
+
this.canvas &&
|
|
67
|
+
this.canvas.ruler.options.enabled &&
|
|
68
|
+
this.isPointOnRuler(e.e)
|
|
69
|
+
) {
|
|
70
|
+
// console.log('移除辅助线', this);
|
|
71
|
+
this.canvas.remove(this);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.moveCursor = this.isHorizontal()
|
|
75
|
+
? 'ns-resize'
|
|
76
|
+
: 'ew-resize';
|
|
77
|
+
this.canvas &&
|
|
78
|
+
this.canvas.fire('guideline:mouseup', {
|
|
79
|
+
target: this,
|
|
80
|
+
e: e.e,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
this.on('removed', () => {
|
|
85
|
+
this.off('removed');
|
|
86
|
+
this.off('mousedown:before');
|
|
87
|
+
this.off('moving');
|
|
88
|
+
this.off('mouseup');
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
getBoundingRect(absolute, calculate) {
|
|
93
|
+
this.bringToFront();
|
|
94
|
+
|
|
95
|
+
const isHorizontal = this.isHorizontal();
|
|
96
|
+
const rect = this.callSuper('getBoundingRect', absolute, calculate);
|
|
97
|
+
rect[isHorizontal ? 'top' : 'left'] +=
|
|
98
|
+
rect[isHorizontal ? 'height' : 'width'] / 2;
|
|
99
|
+
rect[isHorizontal ? 'height' : 'width'] = 0;
|
|
100
|
+
return rect;
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
isPointOnRuler(e) {
|
|
104
|
+
const isHorizontal = this.isHorizontal();
|
|
105
|
+
const hoveredRuler =
|
|
106
|
+
this.canvas &&
|
|
107
|
+
this.canvas.ruler.isPointOnRuler(
|
|
108
|
+
new fabric.Point(e.offsetX, e.offsetY)
|
|
109
|
+
);
|
|
110
|
+
if (
|
|
111
|
+
(isHorizontal && hoveredRuler === 'horizontal') ||
|
|
112
|
+
(!isHorizontal && hoveredRuler === 'vertical')
|
|
113
|
+
) {
|
|
114
|
+
return hoveredRuler;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
isHorizontal() {
|
|
120
|
+
return this.height === 0;
|
|
121
|
+
},
|
|
122
|
+
} as fabric.GuideLine);
|
|
123
|
+
|
|
124
|
+
fabric.GuideLine.fromObject = function (object, callback) {
|
|
125
|
+
const clone = fabric.util.object.clone as (
|
|
126
|
+
object: any,
|
|
127
|
+
deep: boolean
|
|
128
|
+
) => any;
|
|
129
|
+
|
|
130
|
+
function _callback(instance: any) {
|
|
131
|
+
delete instance.xy;
|
|
132
|
+
callback && callback(instance);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const options = clone(object, true);
|
|
136
|
+
const isHorizontal = options.height === 0;
|
|
137
|
+
|
|
138
|
+
options.xy = isHorizontal ? options.y1 : options.x1;
|
|
139
|
+
options.axis = isHorizontal ? 'horizontal' : 'vertical';
|
|
140
|
+
|
|
141
|
+
fabric.Object._fromObject(options.type, options, _callback, 'xy');
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default fabric.GuideLine;
|
package/src/utils/ruler/index.ts
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { fabric, Canvas, IEditor } from '@hprint/core';
|
|
2
|
-
import CanvasRuler, { RulerOptions } from './ruler';
|
|
3
|
-
|
|
4
|
-
function initRuler(canvas: Canvas, editor: IEditor, options?: RulerOptions) {
|
|
5
|
-
const ruler = new CanvasRuler({
|
|
6
|
-
canvas,
|
|
7
|
-
editor,
|
|
8
|
-
...options,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
// 辅助线移动到画板外删除
|
|
12
|
-
let workspace: fabric.Object | undefined = undefined;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 获取workspace
|
|
16
|
-
*/
|
|
17
|
-
const getWorkspace = () => {
|
|
18
|
-
workspace = canvas.getObjects().find((item) => item.id === 'workspace');
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 判断target是否在object矩形外
|
|
23
|
-
* @param object
|
|
24
|
-
* @param target
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
const isRectOut = (
|
|
28
|
-
object: fabric.Object,
|
|
29
|
-
target: fabric.GuideLine
|
|
30
|
-
): boolean => {
|
|
31
|
-
const { top, height, left, width } = object;
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
top === undefined ||
|
|
35
|
-
height === undefined ||
|
|
36
|
-
left === undefined ||
|
|
37
|
-
width === undefined
|
|
38
|
-
) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const targetRect = target.getBoundingRect(true, true);
|
|
43
|
-
const {
|
|
44
|
-
top: targetTop,
|
|
45
|
-
height: targetHeight,
|
|
46
|
-
left: targetLeft,
|
|
47
|
-
width: targetWidth,
|
|
48
|
-
} = targetRect;
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
target.isHorizontal() &&
|
|
52
|
-
(top > targetTop + 1 || top + height < targetTop + targetHeight - 1)
|
|
53
|
-
) {
|
|
54
|
-
return true;
|
|
55
|
-
} else if (
|
|
56
|
-
!target.isHorizontal() &&
|
|
57
|
-
(left > targetLeft + 1 ||
|
|
58
|
-
left + width < targetLeft + targetWidth - 1)
|
|
59
|
-
) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return false;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
canvas.on('guideline:moving', (e) => {
|
|
67
|
-
if (!workspace) {
|
|
68
|
-
getWorkspace();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const { target } = e;
|
|
72
|
-
if (isRectOut(workspace, target)) {
|
|
73
|
-
target.moveCursor = 'not-allowed';
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
canvas.on('guideline:mouseup', (e) => {
|
|
78
|
-
if (!workspace) {
|
|
79
|
-
getWorkspace();
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const { target } = e;
|
|
83
|
-
if (isRectOut(workspace, target)) {
|
|
84
|
-
canvas.remove(target);
|
|
85
|
-
canvas.setCursor(canvas.defaultCursor ?? '');
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
return ruler;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export default initRuler;
|
|
1
|
+
import { fabric, Canvas, IEditor } from '@hprint/core';
|
|
2
|
+
import CanvasRuler, { RulerOptions } from './ruler';
|
|
3
|
+
|
|
4
|
+
function initRuler(canvas: Canvas, editor: IEditor, options?: RulerOptions) {
|
|
5
|
+
const ruler = new CanvasRuler({
|
|
6
|
+
canvas,
|
|
7
|
+
editor,
|
|
8
|
+
...options,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// 辅助线移动到画板外删除
|
|
12
|
+
let workspace: fabric.Object | undefined = undefined;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 获取workspace
|
|
16
|
+
*/
|
|
17
|
+
const getWorkspace = () => {
|
|
18
|
+
workspace = canvas.getObjects().find((item) => item.id === 'workspace');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 判断target是否在object矩形外
|
|
23
|
+
* @param object
|
|
24
|
+
* @param target
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
const isRectOut = (
|
|
28
|
+
object: fabric.Object,
|
|
29
|
+
target: fabric.GuideLine
|
|
30
|
+
): boolean => {
|
|
31
|
+
const { top, height, left, width } = object;
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
top === undefined ||
|
|
35
|
+
height === undefined ||
|
|
36
|
+
left === undefined ||
|
|
37
|
+
width === undefined
|
|
38
|
+
) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const targetRect = target.getBoundingRect(true, true);
|
|
43
|
+
const {
|
|
44
|
+
top: targetTop,
|
|
45
|
+
height: targetHeight,
|
|
46
|
+
left: targetLeft,
|
|
47
|
+
width: targetWidth,
|
|
48
|
+
} = targetRect;
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
target.isHorizontal() &&
|
|
52
|
+
(top > targetTop + 1 || top + height < targetTop + targetHeight - 1)
|
|
53
|
+
) {
|
|
54
|
+
return true;
|
|
55
|
+
} else if (
|
|
56
|
+
!target.isHorizontal() &&
|
|
57
|
+
(left > targetLeft + 1 ||
|
|
58
|
+
left + width < targetLeft + targetWidth - 1)
|
|
59
|
+
) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return false;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
canvas.on('guideline:moving', (e) => {
|
|
67
|
+
if (!workspace) {
|
|
68
|
+
getWorkspace();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const { target } = e;
|
|
72
|
+
if (isRectOut(workspace, target)) {
|
|
73
|
+
target.moveCursor = 'not-allowed';
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
canvas.on('guideline:mouseup', (e) => {
|
|
78
|
+
if (!workspace) {
|
|
79
|
+
getWorkspace();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const { target } = e;
|
|
83
|
+
if (isRectOut(workspace, target)) {
|
|
84
|
+
canvas.remove(target);
|
|
85
|
+
canvas.setCursor(canvas.defaultCursor ?? '');
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return ruler;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default initRuler;
|