@meta2d/core 1.0.63 → 1.0.64

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": "@meta2d/core",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -129,7 +129,7 @@ export declare class Canvas {
129
129
  listen(): void;
130
130
  onCopy: (event: ClipboardEvent) => void;
131
131
  onCut: (event: ClipboardEvent) => void;
132
- onPaste: (event: ClipboardEvent) => void;
132
+ onPaste: (event: ClipboardEvent) => Promise<void>;
133
133
  onMessage: (e: MessageEvent) => void;
134
134
  onwheel: (e: WheelEvent) => void;
135
135
  onkeydown: (e: KeyboardEvent) => void;
@@ -285,7 +285,7 @@ export class Canvas {
285
285
  }
286
286
  this.cut();
287
287
  };
288
- onPaste = (event) => {
288
+ onPaste = async (event) => {
289
289
  if (this.store.data.locked || this.store.options.disableClipboard) {
290
290
  return;
291
291
  }
@@ -316,29 +316,39 @@ export class Canvas {
316
316
  const blob = items[i].getAsFile();
317
317
  let name = items[i].type.slice(6) === 'gif' ? 'gif' : 'image';
318
318
  if (blob !== null) {
319
- let base64_str;
320
- const reader = new FileReader();
321
- reader.onload = (e) => {
322
- base64_str = e.target.result;
323
- const image = new Image();
324
- image.src = base64_str;
325
- image.onload = () => {
326
- const { width, height } = image;
327
- const pen = {
328
- name,
329
- x: x - 50 / 2,
330
- y: y - (height / width) * 50,
331
- externElement: name === 'gif',
332
- width: 100,
333
- height: (height / width) * 100,
334
- image: base64_str,
335
- };
336
- this.addPens([pen]);
337
- this.active([pen]);
338
- this.copy([pen]);
339
- };
340
- };
341
- reader.readAsDataURL(blob);
319
+ const isGif = name === 'gif';
320
+ const pen = await this.fileToPen(blob, isGif);
321
+ pen.height = (pen.height / pen.width) * 100,
322
+ pen.width = 100;
323
+ pen.x = x - 50 / 2,
324
+ pen.y = y - (pen.height / pen.width) * 50,
325
+ pen.externElement = isGif,
326
+ this.addPens([pen]);
327
+ this.active([pen]);
328
+ this.copy([pen]);
329
+ // let base64_str: any;
330
+ // const reader = new FileReader();
331
+ // reader.onload = (e) => {
332
+ // base64_str = e.target.result;
333
+ // const image = new Image();
334
+ // image.src = base64_str;
335
+ // image.onload = () => {
336
+ // const { width, height } = image;
337
+ // const pen = {
338
+ // name,
339
+ // x: x - 50 / 2,
340
+ // y: y - (height / width) * 50,
341
+ // externElement: name === 'gif',
342
+ // width: 100,
343
+ // height: (height / width) * 100,
344
+ // image: base64_str as any,
345
+ // };
346
+ // this.addPens([pen]);
347
+ // this.active([pen]);
348
+ // this.copy([pen]);
349
+ // };
350
+ // };
351
+ // reader.readAsDataURL(blob);
342
352
  }
343
353
  }
344
354
  }
@@ -6171,6 +6181,7 @@ export class Canvas {
6171
6181
  this.dropdown.style.background = pen.dropdownBackground || '#fff';
6172
6182
  this.dropdown.style.color = pen.dropdownColor || '#bdc7db';
6173
6183
  this.setDropdownList();
6184
+ this.externalElements.style.zIndex = '9999';
6174
6185
  }
6175
6186
  else {
6176
6187
  // this.inputRight.style.display = 'none';
@@ -6353,6 +6364,7 @@ export class Canvas {
6353
6364
  });
6354
6365
  }
6355
6366
  hideInput = () => {
6367
+ this.externalElements.style.zIndex = '5';
6356
6368
  if (this.inputParent.style.display === 'flex') {
6357
6369
  this.inputParent.style.display = 'none';
6358
6370
  const pen = this.store.pens[this.inputDiv.dataset.penId];