@anu3ev/fabric-image-editor 0.1.62 → 0.1.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.
Files changed (2) hide show
  1. package/dist/main.js +35 -23
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -89,7 +89,10 @@ class R {
89
89
  */
90
90
  _filterLockedSelection({ selected: e, e: t }) {
91
91
  if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1) return;
92
- const s = e.filter((a) => a.locked), n = e.filter((a) => !a.locked);
92
+ const { lockedObjects: s, unlockedObjects: n } = e.reduce(
93
+ (a, o) => o.locked ? (a.lockedObjects.push(o), a) : (a.unlockedObjects.push(o), a),
94
+ { lockedObjects: [], unlockedObjects: [] }
95
+ );
93
96
  if (s.length === 0) return;
94
97
  if (n.length > 0) {
95
98
  if (n.length === 1)
@@ -685,7 +688,9 @@ class Je {
685
688
  d.innerHTML = i[n] ? `<img src="${i[n]}" title="${s}" />` : s, Object.assign(d.style, a), d.onclick = () => {
686
689
  var c;
687
690
  return (c = o[n]) == null ? void 0 : c.call(o, this.editor);
688
- }, this.el.appendChild(d);
691
+ }, d.onmousedown = (c) => {
692
+ c.stopPropagation(), c.preventDefault();
693
+ }, d.ondragstart = (c) => c.preventDefault(), this.el.appendChild(d);
689
694
  }
690
695
  }
691
696
  /**
@@ -2357,7 +2362,7 @@ class dt {
2357
2362
  copy() {
2358
2363
  return v(this, null, function* () {
2359
2364
  const { canvas: e, errorManager: t } = this.editor, s = e.getActiveObject();
2360
- if (!s) return;
2365
+ if (!s || s.locked) return;
2361
2366
  try {
2362
2367
  const g = yield s.clone(["format"]);
2363
2368
  this.clipboard = g, e.fire("editor:object-copied", { object: g });
@@ -2414,28 +2419,35 @@ class dt {
2414
2419
  * @param event.clipboardData — данные из буфера обмена
2415
2420
  * @param event.clipboardData.items — элементы буфера обмена
2416
2421
  */
2417
- handlePasteEvent({ clipboardData: e }) {
2418
- var a;
2419
- if (!((a = e == null ? void 0 : e.items) != null && a.length)) return;
2420
- const { imageManager: t } = this.editor, { items: s } = e, n = s[s.length - 1];
2421
- if (n.type !== "text/html") {
2422
- const o = n.getAsFile();
2423
- if (!o) return;
2424
- const d = new FileReader();
2425
- d.onload = (c) => {
2426
- c.target && this.editor.imageManager.importImage({ source: c.target.result });
2427
- }, d.readAsDataURL(o);
2428
- return;
2429
- }
2430
- const i = e.getData("text/html");
2431
- if (i) {
2432
- const c = new DOMParser().parseFromString(i, "text/html").querySelector("img");
2433
- if (c != null && c.src) {
2434
- t.importImage({ source: c.src });
2422
+ handlePasteEvent(t) {
2423
+ return v(this, arguments, function* ({ clipboardData: e }) {
2424
+ var d;
2425
+ if (!((d = e == null ? void 0 : e.items) != null && d.length)) return;
2426
+ const s = e.getData("text/plain");
2427
+ if (s && s.startsWith("application/image-editor:")) {
2428
+ this.paste();
2435
2429
  return;
2436
2430
  }
2437
- }
2438
- this.paste();
2431
+ const { imageManager: n } = this.editor, { items: i } = e, a = i[i.length - 1];
2432
+ if (a.type !== "text/html") {
2433
+ const c = a.getAsFile();
2434
+ if (!c) return;
2435
+ const l = new FileReader();
2436
+ l.onload = (h) => {
2437
+ h.target && this.editor.imageManager.importImage({ source: h.target.result });
2438
+ }, l.readAsDataURL(c);
2439
+ return;
2440
+ }
2441
+ const o = e.getData("text/html");
2442
+ if (o) {
2443
+ const h = new DOMParser().parseFromString(o, "text/html").querySelector("img");
2444
+ if (h != null && h.src) {
2445
+ n.importImage({ source: h.src });
2446
+ return;
2447
+ }
2448
+ }
2449
+ this.paste();
2450
+ });
2439
2451
  }
2440
2452
  /**
2441
2453
  * Вставка объекта
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "description": "JavaScript image editor built on FabricJS, allowing you to create instances with an integrated montage area and providing an API to modify and manage state.",
5
5
  "module": "dist/main.js",
6
6
  "files": [