@hprint/plugins 0.0.1-alpha.1 → 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.
Files changed (64) hide show
  1. package/dist/index.js +122 -117
  2. package/dist/index.mjs +41257 -21115
  3. package/dist/src/plugins/AlignGuidLinePlugin.d.ts +7 -2
  4. package/dist/src/plugins/AlignGuidLinePlugin.d.ts.map +1 -1
  5. package/dist/src/plugins/BarCodePlugin.d.ts +4 -0
  6. package/dist/src/plugins/BarCodePlugin.d.ts.map +1 -1
  7. package/dist/src/plugins/CreateElementPlugin.d.ts +3 -9
  8. package/dist/src/plugins/CreateElementPlugin.d.ts.map +1 -1
  9. package/dist/src/plugins/GroupAlignPlugin.d.ts.map +1 -1
  10. package/dist/src/plugins/LockPlugin.d.ts.map +1 -1
  11. package/dist/src/plugins/QrCodePlugin.d.ts +19 -97
  12. package/dist/src/plugins/QrCodePlugin.d.ts.map +1 -1
  13. package/dist/src/plugins/ResizePlugin.d.ts.map +1 -1
  14. package/dist/src/plugins/UnitPlugin.d.ts.map +1 -1
  15. package/dist/src/plugins/WorkspacePlugin.d.ts.map +1 -1
  16. package/dist/src/utils/units.d.ts.map +1 -1
  17. package/package.json +5 -4
  18. package/src/assets/style/resizePlugin.css +27 -27
  19. package/src/objects/Arrow.js +47 -47
  20. package/src/objects/ThinTailArrow.js +50 -50
  21. package/src/plugins/AlignGuidLinePlugin.ts +1152 -1141
  22. package/src/plugins/BarCodePlugin.ts +33 -27
  23. package/src/plugins/ControlsPlugin.ts +251 -251
  24. package/src/plugins/ControlsRotatePlugin.ts +111 -111
  25. package/src/plugins/CopyPlugin.ts +255 -255
  26. package/src/plugins/CreateElementPlugin.ts +14 -10
  27. package/src/plugins/DeleteHotKeyPlugin.ts +57 -57
  28. package/src/plugins/DrawLinePlugin.ts +162 -162
  29. package/src/plugins/DrawPolygonPlugin.ts +205 -205
  30. package/src/plugins/DringPlugin.ts +125 -125
  31. package/src/plugins/FlipPlugin.ts +59 -59
  32. package/src/plugins/FontPlugin.ts +165 -165
  33. package/src/plugins/FreeDrawPlugin.ts +49 -49
  34. package/src/plugins/GroupAlignPlugin.ts +365 -365
  35. package/src/plugins/GroupPlugin.ts +82 -82
  36. package/src/plugins/GroupTextEditorPlugin.ts +198 -198
  37. package/src/plugins/HistoryPlugin.ts +181 -181
  38. package/src/plugins/ImageStroke.ts +121 -121
  39. package/src/plugins/LayerPlugin.ts +108 -108
  40. package/src/plugins/LockPlugin.ts +242 -240
  41. package/src/plugins/MaskPlugin.ts +155 -155
  42. package/src/plugins/MaterialPlugin.ts +224 -224
  43. package/src/plugins/MiddleMousePlugin.ts +45 -45
  44. package/src/plugins/MoveHotKeyPlugin.ts +46 -46
  45. package/src/plugins/PathTextPlugin.ts +89 -89
  46. package/src/plugins/PolygonModifyPlugin.ts +224 -224
  47. package/src/plugins/PrintPlugin.ts +81 -81
  48. package/src/plugins/PsdPlugin.ts +52 -52
  49. package/src/plugins/QrCodePlugin.ts +322 -393
  50. package/src/plugins/ResizePlugin.ts +278 -274
  51. package/src/plugins/RulerPlugin.ts +78 -78
  52. package/src/plugins/SimpleClipImagePlugin.ts +244 -244
  53. package/src/plugins/UnitPlugin.ts +326 -327
  54. package/src/plugins/WaterMarkPlugin.ts +257 -257
  55. package/src/plugins/WorkspacePlugin.ts +10 -6
  56. package/src/types/eventType.ts +11 -11
  57. package/src/utils/psd.js +432 -432
  58. package/src/utils/ruler/guideline.ts +145 -145
  59. package/src/utils/ruler/index.ts +91 -91
  60. package/src/utils/ruler/ruler.ts +924 -924
  61. package/src/utils/ruler/utils.ts +162 -162
  62. package/src/utils/units.ts +4 -2
  63. package/tsconfig.json +10 -10
  64. 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;