@hprint/core 0.0.1-alpha.2 → 0.0.1-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hprint/core",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  "hotkeys-js": "~3.8.9",
34
34
  "tapable": "~2.3.0",
35
35
  "uuid": "~8.3.2",
36
- "@hprint/shared": "0.0.1-alpha.2"
36
+ "@hprint/shared": "0.0.1-alpha.4"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "vite build",
package/src/Editor.ts CHANGED
@@ -39,10 +39,13 @@ class Editor extends EventEmitter {
39
39
  [propName: string]: AsyncSeriesHook<any, any>;
40
40
  } = {};
41
41
 
42
- init(canvas: fabric.Canvas) {
42
+ init(canvas: fabric.Canvas, options?: { contextMenu?: boolean }) {
43
43
  this.canvas = canvas;
44
- this._initContextMenu();
45
- this._bindContextMenu();
44
+ // 初始化上下文菜单
45
+ if (options?.contextMenu !== false) {
46
+ this._initContextMenu();
47
+ this._bindContextMenu();
48
+ }
46
49
  this._initActionHooks();
47
50
  this._initServersPlugin();
48
51
 
@@ -199,9 +199,19 @@ class ServersPlugin implements IPluginTempl {
199
199
  });
200
200
  }
201
201
 
202
- getJson() {
202
+ getJson(options?: {
203
+ clearSrc?: boolean
204
+ }) {
203
205
  const keys = this.getExtensionKey();
204
- return this.canvas.toJSON(keys);
206
+ const jsonObject = this.canvas.toJSON(keys);
207
+ if (options?.clearSrc) {
208
+ jsonObject.objects.forEach((item: any) => {
209
+ if (['qrcode', 'barcode'].includes(item.extensionType)) {
210
+ item.src = '';
211
+ }
212
+ });
213
+ }
214
+ return jsonObject;
205
215
  }
206
216
 
207
217
  getExtensionKey() {
@@ -217,6 +227,8 @@ class ServersPlugin implements IPluginTempl {
217
227
  'verticalAlign',
218
228
  'roundValue',
219
229
  'getBase64',
230
+ 'lockScalingX',
231
+ 'lockScalingY',
220
232
  '_originSize',
221
233
  ];
222
234
  }