@hprint/plugins 0.0.6 → 0.0.8
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 +15 -15
- package/dist/index.mjs +1864 -1862
- package/dist/src/plugins/BarCodePlugin.d.ts +2 -2
- package/dist/src/plugins/BarCodePlugin.d.ts.map +1 -1
- package/dist/src/plugins/CopyPlugin.d.ts.map +1 -1
- package/dist/src/plugins/CreateElementPlugin.d.ts +2 -2
- package/dist/src/plugins/CreateElementPlugin.d.ts.map +1 -1
- package/dist/src/plugins/QrCodePlugin.d.ts +2 -2
- 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/BarCodePlugin.ts +7 -7
- package/src/plugins/ControlsPlugin.ts +413 -413
- package/src/plugins/ControlsRotatePlugin.ts +111 -111
- package/src/plugins/CopyPlugin.ts +261 -255
- package/src/plugins/CreateElementPlugin.ts +3 -1
- 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/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/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 +6 -6
- package/src/plugins/SimpleClipImagePlugin.ts +244 -244
- 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/utils.ts +162 -162
- package/tsconfig.json +10 -10
- package/vite.config.ts +29 -29
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fabric, IEditor, IPluginTempl } from '@hprint/core';
|
|
2
|
-
type IPlugin = Pick<BarCodePlugin, 'addBarcode' | 'setBarcode' | 'getBarcodeTypes'>;
|
|
2
|
+
type IPlugin = Pick<BarCodePlugin, 'addBarcode' | 'setBarcode' | 'getBarcodeTypes' | 'initBarcodeEvents'>;
|
|
3
3
|
declare module '@hprint/core' {
|
|
4
4
|
interface IEditor extends IPlugin {
|
|
5
5
|
}
|
|
@@ -23,7 +23,7 @@ declare class BarCodePlugin implements IPluginTempl {
|
|
|
23
23
|
originObject: any;
|
|
24
24
|
fabricObject: any;
|
|
25
25
|
}): Promise<void>;
|
|
26
|
-
|
|
26
|
+
initBarcodeEvents(imgEl: fabric.Image): void;
|
|
27
27
|
hookImportAfter(): Promise<void>;
|
|
28
28
|
hookSaveBefore(): Promise<void>;
|
|
29
29
|
_getBase64Str(option: any): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarCodePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/BarCodePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI7D,KAAK,OAAO,GAAG,IAAI,CACf,aAAa,EACb,YAAY,GAAG,YAAY,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"BarCodePlugin.d.ts","sourceRoot":"","s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SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa;IAiB/C,WAAW;;;;;;IAcX,OAAO;IAKP,SAAS;IAIH,aAAa,CAAC,KAAK,EAAE,GAAG;CAwHjC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fabric, IEditor, IPluginTempl } from '@hprint/core';
|
|
2
|
-
type IPlugin = Pick<CreateElementPlugin, 'createRect' | 'createText' | 'createIText' | 'createLine' | 'createEllipse' | 'createPolygon' | 'createImageFromURL' | 'createImage' | 'createBarcode' | 'createQrcode'>;
|
|
2
|
+
type IPlugin = Pick<CreateElementPlugin, 'createRect' | 'createText' | 'createIText' | 'createLine' | 'createEllipse' | 'createPolygon' | 'createImageFromURL' | 'createImage' | 'createBarcode' | 'createQrcode' | 'addSetAndSyncByUnit'>;
|
|
3
3
|
declare module '@hprint/core' {
|
|
4
4
|
interface IEditor extends IPlugin {
|
|
5
5
|
}
|
|
@@ -22,7 +22,7 @@ declare class CreateElementPlugin implements IPluginTempl {
|
|
|
22
22
|
/**
|
|
23
23
|
* 覆盖指定对象实例的 set 方法,仅在本插件创建的元素上生效
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
addSetAndSyncByUnit(obj: fabric.Object): void;
|
|
26
26
|
createRect(opts: {
|
|
27
27
|
left?: number;
|
|
28
28
|
top?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateElementPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/CreateElementPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG1D,KAAK,OAAO,GAAG,IAAI,CACf,mBAAmB,EACjB,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,eAAe,GACf,eAAe,GACf,oBAAoB,GACpB,aAAa,GACb,eAA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;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,EACD,GAAG,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAQxB;;OAEG;IACG,YAAY,CACd,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;QAChC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,EACD,GAAG,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAQxB,OAAO;CAGV;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fabric, IEditor, IPluginTempl } from '@hprint/core';
|
|
2
|
-
type IPlugin = Pick<QrCodePlugin, 'addQrCode' | 'setQrCode'>;
|
|
2
|
+
type IPlugin = Pick<QrCodePlugin, 'addQrCode' | 'setQrCode' | 'initQrcodeEvents'>;
|
|
3
3
|
declare module '@hprint/core' {
|
|
4
4
|
interface IEditor extends IPlugin {
|
|
5
5
|
}
|
|
@@ -39,7 +39,7 @@ declare class QrCodePlugin implements IPluginTempl {
|
|
|
39
39
|
/**
|
|
40
40
|
* 绑定二维码相关事件与方法
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
initQrcodeEvents(imgEl: fabric.Image): void;
|
|
43
43
|
/**
|
|
44
44
|
* 创建二维码,支持传入内容与样式,进行单位转换并存储原始尺寸
|
|
45
45
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QrCodePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/QrCodePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE1D,KAAK,OAAO,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"QrCodePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/QrCodePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE1D,KAAK,OAAO,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,WAAW,GAAG,kBAAkB,CAAC,CAAC;AAElF,OAAO,QAAQ,cAAc,CAAC;IAE1B,UAAU,OAAQ,SAAQ,OAAO;KAAI;CACxC;AAED,cAAM,YAAa,YAAW,YAAY;IAI3B,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,MAAM,EAAE,OAAO;IAJ1B,MAAM,CAAC,UAAU,SAAkB;IACnC,MAAM,CAAC,IAAI,WAAkD;gBAElD,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,MAAM,EAAE,O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4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"qs": "~6.12.3",
|
|
23
23
|
"socket.io-client": "^4.8.1",
|
|
24
24
|
"uuid": "~8.3.2",
|
|
25
|
-
"@hprint/
|
|
26
|
-
"@hprint/
|
|
25
|
+
"@hprint/core": "0.0.8",
|
|
26
|
+
"@hprint/shared": "0.0.8"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/bwip-js": "^3.2.3",
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
.resize-bar {
|
|
2
|
-
border-radius: 3px;
|
|
3
|
-
background-color: rgba(160, 160, 160, 0.6);
|
|
4
|
-
position: absolute;
|
|
5
|
-
}
|
|
6
|
-
.resize-bar:hover {
|
|
7
|
-
background-color: #328cff;
|
|
8
|
-
}
|
|
9
|
-
.resize-bar.horizontal {
|
|
10
|
-
width: 6px;
|
|
11
|
-
height: 30px;
|
|
12
|
-
}
|
|
13
|
-
.resize-bar.vertical {
|
|
14
|
-
width: 30px;
|
|
15
|
-
height: 6px;
|
|
16
|
-
}
|
|
17
|
-
.resize-bar.active {
|
|
18
|
-
background-color: #328cff;
|
|
19
|
-
}
|
|
20
|
-
#resize-left-bar,
|
|
21
|
-
#resize-right-bar {
|
|
22
|
-
cursor: ew-resize;
|
|
23
|
-
}
|
|
24
|
-
#resize-top-bar,
|
|
25
|
-
#resize-bottom-bar {
|
|
26
|
-
cursor: ns-resize;
|
|
27
|
-
}
|
|
1
|
+
.resize-bar {
|
|
2
|
+
border-radius: 3px;
|
|
3
|
+
background-color: rgba(160, 160, 160, 0.6);
|
|
4
|
+
position: absolute;
|
|
5
|
+
}
|
|
6
|
+
.resize-bar:hover {
|
|
7
|
+
background-color: #328cff;
|
|
8
|
+
}
|
|
9
|
+
.resize-bar.horizontal {
|
|
10
|
+
width: 6px;
|
|
11
|
+
height: 30px;
|
|
12
|
+
}
|
|
13
|
+
.resize-bar.vertical {
|
|
14
|
+
width: 30px;
|
|
15
|
+
height: 6px;
|
|
16
|
+
}
|
|
17
|
+
.resize-bar.active {
|
|
18
|
+
background-color: #328cff;
|
|
19
|
+
}
|
|
20
|
+
#resize-left-bar,
|
|
21
|
+
#resize-right-bar {
|
|
22
|
+
cursor: ew-resize;
|
|
23
|
+
}
|
|
24
|
+
#resize-top-bar,
|
|
25
|
+
#resize-bottom-bar {
|
|
26
|
+
cursor: ns-resize;
|
|
27
|
+
}
|
package/src/objects/Arrow.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { fabric } from '@hprint/core';
|
|
2
|
-
|
|
3
|
-
fabric.Arrow = fabric.util.createClass(fabric.Line, {
|
|
4
|
-
type: 'arrow',
|
|
5
|
-
superType: 'drawing',
|
|
6
|
-
initialize(points, options) {
|
|
7
|
-
if (!points) {
|
|
8
|
-
const { x1, x2, y1, y2 } = options;
|
|
9
|
-
points = [x1, y1, x2, y2];
|
|
10
|
-
}
|
|
11
|
-
options = options || {};
|
|
12
|
-
this.callSuper('initialize', points, options);
|
|
13
|
-
},
|
|
14
|
-
_render(ctx) {
|
|
15
|
-
this.callSuper('_render', ctx);
|
|
16
|
-
ctx.save();
|
|
17
|
-
// 乘或除对应的scaleX(Y),抵消元素放缩造成的影响,使箭头不会变形
|
|
18
|
-
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
|
|
19
|
-
const xDiff = (this.x2 - this.x1) * this.scaleX;
|
|
20
|
-
const yDiff = (this.y2 - this.y1) * this.scaleY;
|
|
21
|
-
const angle = Math.atan2(yDiff, xDiff);
|
|
22
|
-
ctx.translate(
|
|
23
|
-
((this.x2 - this.x1) / 2) * this.scaleX,
|
|
24
|
-
((this.y2 - this.y1) / 2) * this.scaleY
|
|
25
|
-
);
|
|
26
|
-
ctx.rotate(angle);
|
|
27
|
-
ctx.beginPath();
|
|
28
|
-
// Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
|
|
29
|
-
ctx.moveTo(0, 0);
|
|
30
|
-
ctx.lineTo(-10, 5);
|
|
31
|
-
ctx.lineTo(-10, -5);
|
|
32
|
-
ctx.closePath();
|
|
33
|
-
ctx.lineWidth = this.lineWidth;
|
|
34
|
-
ctx.strokeStyle = this.stroke;
|
|
35
|
-
ctx.fillStyle = this.fill;
|
|
36
|
-
ctx.stroke();
|
|
37
|
-
ctx.fill();
|
|
38
|
-
ctx.restore();
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
fabric.Arrow.fromObject = (options, callback) => {
|
|
43
|
-
const { x1, x2, y1, y2 } = options;
|
|
44
|
-
return callback(new fabric.Arrow([x1, y1, x2, y2], options));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default fabric.Arrow;
|
|
1
|
+
import { fabric } from '@hprint/core';
|
|
2
|
+
|
|
3
|
+
fabric.Arrow = fabric.util.createClass(fabric.Line, {
|
|
4
|
+
type: 'arrow',
|
|
5
|
+
superType: 'drawing',
|
|
6
|
+
initialize(points, options) {
|
|
7
|
+
if (!points) {
|
|
8
|
+
const { x1, x2, y1, y2 } = options;
|
|
9
|
+
points = [x1, y1, x2, y2];
|
|
10
|
+
}
|
|
11
|
+
options = options || {};
|
|
12
|
+
this.callSuper('initialize', points, options);
|
|
13
|
+
},
|
|
14
|
+
_render(ctx) {
|
|
15
|
+
this.callSuper('_render', ctx);
|
|
16
|
+
ctx.save();
|
|
17
|
+
// 乘或除对应的scaleX(Y),抵消元素放缩造成的影响,使箭头不会变形
|
|
18
|
+
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
|
|
19
|
+
const xDiff = (this.x2 - this.x1) * this.scaleX;
|
|
20
|
+
const yDiff = (this.y2 - this.y1) * this.scaleY;
|
|
21
|
+
const angle = Math.atan2(yDiff, xDiff);
|
|
22
|
+
ctx.translate(
|
|
23
|
+
((this.x2 - this.x1) / 2) * this.scaleX,
|
|
24
|
+
((this.y2 - this.y1) / 2) * this.scaleY
|
|
25
|
+
);
|
|
26
|
+
ctx.rotate(angle);
|
|
27
|
+
ctx.beginPath();
|
|
28
|
+
// Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
|
|
29
|
+
ctx.moveTo(0, 0);
|
|
30
|
+
ctx.lineTo(-10, 5);
|
|
31
|
+
ctx.lineTo(-10, -5);
|
|
32
|
+
ctx.closePath();
|
|
33
|
+
ctx.lineWidth = this.lineWidth;
|
|
34
|
+
ctx.strokeStyle = this.stroke;
|
|
35
|
+
ctx.fillStyle = this.fill;
|
|
36
|
+
ctx.stroke();
|
|
37
|
+
ctx.fill();
|
|
38
|
+
ctx.restore();
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
fabric.Arrow.fromObject = (options, callback) => {
|
|
43
|
+
const { x1, x2, y1, y2 } = options;
|
|
44
|
+
return callback(new fabric.Arrow([x1, y1, x2, y2], options));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default fabric.Arrow;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { fabric } from '@hprint/core';
|
|
2
|
-
|
|
3
|
-
fabric.ThinTailArrow = fabric.util.createClass(fabric.Line, {
|
|
4
|
-
type: 'thinTailArrow',
|
|
5
|
-
superType: 'drawing',
|
|
6
|
-
initialize(points, options) {
|
|
7
|
-
if (!points) {
|
|
8
|
-
const { x1, x2, y1, y2 } = options;
|
|
9
|
-
points = [x1, y1, x2, y2];
|
|
10
|
-
}
|
|
11
|
-
options = options || {};
|
|
12
|
-
this.callSuper('initialize', points, options);
|
|
13
|
-
},
|
|
14
|
-
_render(ctx) {
|
|
15
|
-
ctx.save();
|
|
16
|
-
// 乘或除对应的scaleX(Y),抵消元素放缩造成的影响,使箭头不会变形
|
|
17
|
-
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
|
|
18
|
-
const xDiff = (this.x2 - this.x1) * this.scaleX;
|
|
19
|
-
const yDiff = (this.y2 - this.y1) * this.scaleY;
|
|
20
|
-
ctx.translate(-xDiff / 2, -yDiff / 2);
|
|
21
|
-
// 箭头方位角
|
|
22
|
-
const angle = Math.atan2(yDiff, xDiff);
|
|
23
|
-
ctx.rotate(angle);
|
|
24
|
-
// 箭头总长(最小长度是20)
|
|
25
|
-
let length = Math.hypot(xDiff, yDiff);
|
|
26
|
-
length = length < 20 ? 20 : length;
|
|
27
|
-
// 绘制箭头
|
|
28
|
-
ctx.beginPath();
|
|
29
|
-
ctx.moveTo(0, 0);
|
|
30
|
-
ctx.lineTo(length - 18, -5);
|
|
31
|
-
ctx.lineTo(length - 20, -12);
|
|
32
|
-
ctx.lineTo(length, 0);
|
|
33
|
-
ctx.lineTo(length - 20, 12);
|
|
34
|
-
ctx.lineTo(length - 18, 5);
|
|
35
|
-
ctx.lineTo(0, 0);
|
|
36
|
-
ctx.lineWidth = this.strokeWidth;
|
|
37
|
-
ctx.strokeStyle = this.stroke;
|
|
38
|
-
ctx.fillStyle = this.fill;
|
|
39
|
-
ctx.stroke();
|
|
40
|
-
ctx.fill();
|
|
41
|
-
ctx.restore();
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
fabric.ThinTailArrow.fromObject = (options, callback) => {
|
|
46
|
-
const { x1, x2, y1, y2 } = options;
|
|
47
|
-
return callback(new fabric.ThinTailArrow([x1, y1, x2, y2], options));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default fabric.ThinTailArrow;
|
|
1
|
+
import { fabric } from '@hprint/core';
|
|
2
|
+
|
|
3
|
+
fabric.ThinTailArrow = fabric.util.createClass(fabric.Line, {
|
|
4
|
+
type: 'thinTailArrow',
|
|
5
|
+
superType: 'drawing',
|
|
6
|
+
initialize(points, options) {
|
|
7
|
+
if (!points) {
|
|
8
|
+
const { x1, x2, y1, y2 } = options;
|
|
9
|
+
points = [x1, y1, x2, y2];
|
|
10
|
+
}
|
|
11
|
+
options = options || {};
|
|
12
|
+
this.callSuper('initialize', points, options);
|
|
13
|
+
},
|
|
14
|
+
_render(ctx) {
|
|
15
|
+
ctx.save();
|
|
16
|
+
// 乘或除对应的scaleX(Y),抵消元素放缩造成的影响,使箭头不会变形
|
|
17
|
+
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
|
|
18
|
+
const xDiff = (this.x2 - this.x1) * this.scaleX;
|
|
19
|
+
const yDiff = (this.y2 - this.y1) * this.scaleY;
|
|
20
|
+
ctx.translate(-xDiff / 2, -yDiff / 2);
|
|
21
|
+
// 箭头方位角
|
|
22
|
+
const angle = Math.atan2(yDiff, xDiff);
|
|
23
|
+
ctx.rotate(angle);
|
|
24
|
+
// 箭头总长(最小长度是20)
|
|
25
|
+
let length = Math.hypot(xDiff, yDiff);
|
|
26
|
+
length = length < 20 ? 20 : length;
|
|
27
|
+
// 绘制箭头
|
|
28
|
+
ctx.beginPath();
|
|
29
|
+
ctx.moveTo(0, 0);
|
|
30
|
+
ctx.lineTo(length - 18, -5);
|
|
31
|
+
ctx.lineTo(length - 20, -12);
|
|
32
|
+
ctx.lineTo(length, 0);
|
|
33
|
+
ctx.lineTo(length - 20, 12);
|
|
34
|
+
ctx.lineTo(length - 18, 5);
|
|
35
|
+
ctx.lineTo(0, 0);
|
|
36
|
+
ctx.lineWidth = this.strokeWidth;
|
|
37
|
+
ctx.strokeStyle = this.stroke;
|
|
38
|
+
ctx.fillStyle = this.fill;
|
|
39
|
+
ctx.stroke();
|
|
40
|
+
ctx.fill();
|
|
41
|
+
ctx.restore();
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
fabric.ThinTailArrow.fromObject = (options, callback) => {
|
|
46
|
+
const { x1, x2, y1, y2 } = options;
|
|
47
|
+
return callback(new fabric.ThinTailArrow([x1, y1, x2, y2], options));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default fabric.ThinTailArrow;
|
|
@@ -4,7 +4,7 @@ import { getUnit, processOptions, formatOriginValues } from '../utils/units';
|
|
|
4
4
|
|
|
5
5
|
type IPlugin = Pick<
|
|
6
6
|
BarCodePlugin,
|
|
7
|
-
'addBarcode' | 'setBarcode' | 'getBarcodeTypes'
|
|
7
|
+
'addBarcode' | 'setBarcode' | 'getBarcodeTypes' | 'initBarcodeEvents'
|
|
8
8
|
>;
|
|
9
9
|
|
|
10
10
|
declare module '@hprint/core' {
|
|
@@ -26,7 +26,7 @@ enum CodeType {
|
|
|
26
26
|
|
|
27
27
|
class BarCodePlugin implements IPluginTempl {
|
|
28
28
|
static pluginName = 'BarCodePlugin';
|
|
29
|
-
static apis = ['addBarcode', 'setBarcode', 'getBarcodeTypes'];
|
|
29
|
+
static apis = ['addBarcode', 'setBarcode', 'getBarcodeTypes', 'initBarcodeEvents'];
|
|
30
30
|
constructor(
|
|
31
31
|
public canvas: fabric.Canvas,
|
|
32
32
|
public editor: IEditor
|
|
@@ -49,12 +49,12 @@ class BarCodePlugin implements IPluginTempl {
|
|
|
49
49
|
|
|
50
50
|
async hookTransformObjectEnd({ originObject, fabricObject }: { originObject: any, fabricObject: any }) {
|
|
51
51
|
if (originObject.extensionType === 'barcode') {
|
|
52
|
-
this.
|
|
52
|
+
this.initBarcodeEvents(fabricObject);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// 绑定条形码对象的事件监听器
|
|
57
|
-
|
|
57
|
+
initBarcodeEvents(imgEl: fabric.Image) {
|
|
58
58
|
(imgEl as any).setExtension = async (fields: Record<string, any>) => {
|
|
59
59
|
const currentExt = (imgEl.get('extension') as any) || {};
|
|
60
60
|
const merged = { ...currentExt, ...(fields || {}) };
|
|
@@ -123,7 +123,7 @@ class BarCodePlugin implements IPluginTempl {
|
|
|
123
123
|
(obj as any).extensionType === 'barcode'
|
|
124
124
|
) {
|
|
125
125
|
barcodeObjects.push(obj as fabric.Image);
|
|
126
|
-
this.
|
|
126
|
+
this.initBarcodeEvents(obj as fabric.Image);
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
|
|
@@ -901,7 +901,7 @@ class BarCodePlugin implements IPluginTempl {
|
|
|
901
901
|
|
|
902
902
|
(imgEl as any)._originSize = { [unit]: originMapped };
|
|
903
903
|
|
|
904
|
-
this.
|
|
904
|
+
this.initBarcodeEvents(imgEl);
|
|
905
905
|
resolve(imgEl);
|
|
906
906
|
},
|
|
907
907
|
{ crossOrigin: 'anonymous' }
|
|
@@ -925,7 +925,7 @@ class BarCodePlugin implements IPluginTempl {
|
|
|
925
925
|
imgEl.scaleToWidth(activeObject.getScaledWidth());
|
|
926
926
|
|
|
927
927
|
// 绑定事件监听器
|
|
928
|
-
this.
|
|
928
|
+
this.initBarcodeEvents(imgEl);
|
|
929
929
|
|
|
930
930
|
this.editor.del();
|
|
931
931
|
this.canvas.add(imgEl);
|