@hprint/plugins 0.0.1-alpha.3 → 0.0.1
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 +1282 -1277
- package/dist/src/plugins/CreateElementPlugin.d.ts +4 -0
- package/dist/src/plugins/CreateElementPlugin.d.ts.map +1 -1
- package/dist/src/utils/ruler/ruler.d.ts +1 -0
- package/dist/src/utils/ruler/ruler.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 -1152
- package/src/plugins/ControlsPlugin.ts +251 -251
- package/src/plugins/ControlsRotatePlugin.ts +111 -111
- package/src/plugins/CopyPlugin.ts +255 -255
- package/src/plugins/CreateElementPlugin.ts +23 -2
- 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 -242
- 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/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 +936 -924
- package/src/utils/ruler/utils.ts +162 -162
- package/tsconfig.json +10 -10
- package/vite.config.ts +29 -29
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { fabric } from '@hprint/core';
|
|
2
|
-
import type { IEditor, IPluginTempl } from '@hprint/core';
|
|
3
|
-
|
|
4
|
-
type IPlugin = Pick<LayerPlugin, 'up' | 'down' | 'toFront' | 'toBack'>;
|
|
5
|
-
|
|
6
|
-
declare module '@hprint/core' {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
8
|
-
interface IEditor extends IPlugin {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
class LayerPlugin implements IPluginTempl {
|
|
12
|
-
static pluginName = 'LayerPlugin';
|
|
13
|
-
static apis = ['up', 'down', 'toFront', 'toBack'];
|
|
14
|
-
constructor(
|
|
15
|
-
public canvas: fabric.Canvas,
|
|
16
|
-
public editor: IEditor
|
|
17
|
-
) {}
|
|
18
|
-
|
|
19
|
-
_getWorkspace() {
|
|
20
|
-
return this.canvas.getObjects().find((item) => item.id === 'workspace');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
_workspaceSendToBack() {
|
|
24
|
-
const workspace = this._getWorkspace();
|
|
25
|
-
workspace && workspace.sendToBack();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
up() {
|
|
29
|
-
const actives = this.canvas.getActiveObjects();
|
|
30
|
-
if (actives && actives.length === 1) {
|
|
31
|
-
const activeObject = this.canvas.getActiveObjects()[0];
|
|
32
|
-
activeObject && activeObject.bringForward();
|
|
33
|
-
this.canvas.renderAll();
|
|
34
|
-
this._workspaceSendToBack();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
down() {
|
|
39
|
-
const actives = this.canvas.getActiveObjects();
|
|
40
|
-
if (actives && actives.length === 1) {
|
|
41
|
-
const activeObject = this.canvas.getActiveObjects()[0];
|
|
42
|
-
activeObject && activeObject.sendBackwards();
|
|
43
|
-
this.canvas.renderAll();
|
|
44
|
-
this._workspaceSendToBack();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
toFront() {
|
|
49
|
-
const actives = this.canvas.getActiveObjects();
|
|
50
|
-
if (actives && actives.length === 1) {
|
|
51
|
-
const activeObject = this.canvas.getActiveObjects()[0];
|
|
52
|
-
activeObject && activeObject.bringToFront();
|
|
53
|
-
this.canvas.renderAll();
|
|
54
|
-
this._workspaceSendToBack();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
toBack() {
|
|
59
|
-
const actives = this.canvas.getActiveObjects();
|
|
60
|
-
if (actives && actives.length === 1) {
|
|
61
|
-
const activeObject = this.canvas.getActiveObjects()[0];
|
|
62
|
-
activeObject && activeObject.sendToBack();
|
|
63
|
-
this.canvas.renderAll();
|
|
64
|
-
this._workspaceSendToBack();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
contextMenu() {
|
|
69
|
-
const activeObject = this.canvas.getActiveObject();
|
|
70
|
-
if (activeObject) {
|
|
71
|
-
return [
|
|
72
|
-
{
|
|
73
|
-
text: '图层管理',
|
|
74
|
-
hotkey: '❯',
|
|
75
|
-
subitems: [
|
|
76
|
-
{
|
|
77
|
-
text: '上一个',
|
|
78
|
-
hotkey: '',
|
|
79
|
-
onclick: () => this.up(),
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
text: '下一个',
|
|
83
|
-
hotkey: '',
|
|
84
|
-
onclick: () => this.down(),
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
text: '置顶',
|
|
88
|
-
hotkey: '',
|
|
89
|
-
onclick: () => this.toFront(),
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
text: '置底',
|
|
93
|
-
hotkey: '',
|
|
94
|
-
onclick: () => this.toBack(),
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
// return [{ text: '复制', hotkey: 'Ctrl+V', disabled: false, onclick: () => this.clone() }];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
destroy() {
|
|
104
|
-
console.log('pluginDestroy');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export default LayerPlugin;
|
|
1
|
+
import { fabric } from '@hprint/core';
|
|
2
|
+
import type { IEditor, IPluginTempl } from '@hprint/core';
|
|
3
|
+
|
|
4
|
+
type IPlugin = Pick<LayerPlugin, 'up' | 'down' | 'toFront' | 'toBack'>;
|
|
5
|
+
|
|
6
|
+
declare module '@hprint/core' {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
8
|
+
interface IEditor extends IPlugin {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class LayerPlugin implements IPluginTempl {
|
|
12
|
+
static pluginName = 'LayerPlugin';
|
|
13
|
+
static apis = ['up', 'down', 'toFront', 'toBack'];
|
|
14
|
+
constructor(
|
|
15
|
+
public canvas: fabric.Canvas,
|
|
16
|
+
public editor: IEditor
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
_getWorkspace() {
|
|
20
|
+
return this.canvas.getObjects().find((item) => item.id === 'workspace');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_workspaceSendToBack() {
|
|
24
|
+
const workspace = this._getWorkspace();
|
|
25
|
+
workspace && workspace.sendToBack();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
up() {
|
|
29
|
+
const actives = this.canvas.getActiveObjects();
|
|
30
|
+
if (actives && actives.length === 1) {
|
|
31
|
+
const activeObject = this.canvas.getActiveObjects()[0];
|
|
32
|
+
activeObject && activeObject.bringForward();
|
|
33
|
+
this.canvas.renderAll();
|
|
34
|
+
this._workspaceSendToBack();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
down() {
|
|
39
|
+
const actives = this.canvas.getActiveObjects();
|
|
40
|
+
if (actives && actives.length === 1) {
|
|
41
|
+
const activeObject = this.canvas.getActiveObjects()[0];
|
|
42
|
+
activeObject && activeObject.sendBackwards();
|
|
43
|
+
this.canvas.renderAll();
|
|
44
|
+
this._workspaceSendToBack();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
toFront() {
|
|
49
|
+
const actives = this.canvas.getActiveObjects();
|
|
50
|
+
if (actives && actives.length === 1) {
|
|
51
|
+
const activeObject = this.canvas.getActiveObjects()[0];
|
|
52
|
+
activeObject && activeObject.bringToFront();
|
|
53
|
+
this.canvas.renderAll();
|
|
54
|
+
this._workspaceSendToBack();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
toBack() {
|
|
59
|
+
const actives = this.canvas.getActiveObjects();
|
|
60
|
+
if (actives && actives.length === 1) {
|
|
61
|
+
const activeObject = this.canvas.getActiveObjects()[0];
|
|
62
|
+
activeObject && activeObject.sendToBack();
|
|
63
|
+
this.canvas.renderAll();
|
|
64
|
+
this._workspaceSendToBack();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
contextMenu() {
|
|
69
|
+
const activeObject = this.canvas.getActiveObject();
|
|
70
|
+
if (activeObject) {
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
text: '图层管理',
|
|
74
|
+
hotkey: '❯',
|
|
75
|
+
subitems: [
|
|
76
|
+
{
|
|
77
|
+
text: '上一个',
|
|
78
|
+
hotkey: '',
|
|
79
|
+
onclick: () => this.up(),
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
text: '下一个',
|
|
83
|
+
hotkey: '',
|
|
84
|
+
onclick: () => this.down(),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
text: '置顶',
|
|
88
|
+
hotkey: '',
|
|
89
|
+
onclick: () => this.toFront(),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
text: '置底',
|
|
93
|
+
hotkey: '',
|
|
94
|
+
onclick: () => this.toBack(),
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
// return [{ text: '复制', hotkey: 'Ctrl+V', disabled: false, onclick: () => this.clone() }];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
destroy() {
|
|
104
|
+
console.log('pluginDestroy');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default LayerPlugin;
|