@pie-element/drag-in-the-blank 10.1.2-next.8 → 10.1.2-next.9

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.
@@ -1,5 +1,5 @@
1
1
  import { i as e, r as t, t as n } from "../rolldown-runtime-CWhphoD1.js";
2
- import { $ as r, A as i, At as a, B as o, Bt as s, C as c, Ct as l, D as u, Dt as d, E as f, Et as p, F as m, Ft as h, G as g, H as _, I as v, It as y, J as b, K as x, L as S, Lt as C, Mt as w, N as ee, Nt as T, O as te, Ot as E, P as ne, Pt as re, Q as ie, R as D, Rt as O, S as ae, St as oe, Tt as k, U as se, V as A, Vt as ce, W as le, X as ue, Y as j, Z as de, _t as fe, at as pe, b as me, bt as he, c as ge, ct as _e, d as ve, dt as ye, et as be, f as xe, ft as Se, gt as Ce, ht as M, it as we, j as Te, jt as Ee, k as De, kt as Oe, l as ke, lt as Ae, mt as je, n as Me, nt as Ne, o as Pe, ot as Fe, q as Ie, rt as Le, s as Re, st as ze, t as Be, tt as Ve, u as He, ut as Ue, v as We, vt as Ge, w as Ke, wt as qe, x as Je, xt as Ye, y as Xe, yt as Ze, z as Qe, zt as $e } from "../drag-provider-BbQMM4wo.js";
2
+ import { $ as r, A as i, At as a, B as o, Bt as s, C as c, Ct as l, D as u, Dt as d, E as f, Et as p, F as m, Ft as h, G as g, H as _, I as v, It as y, J as b, K as x, L as S, Lt as C, Mt as w, N as ee, Nt as T, O as te, Ot as E, P as ne, Pt as re, Q as ie, R as D, Rt as O, S as ae, St as oe, Tt as k, U as se, V as A, Vt as ce, W as le, X as ue, Y as j, Z as de, _t as fe, at as pe, b as me, bt as he, c as ge, ct as _e, d as ve, dt as ye, et as be, f as xe, ft as Se, gt as Ce, ht as M, it as we, j as Te, jt as Ee, k as De, kt as Oe, l as ke, lt as Ae, mt as je, n as Me, nt as Ne, o as Pe, ot as Fe, q as Ie, rt as Le, s as Re, st as ze, t as Be, tt as Ve, u as He, ut as Ue, v as We, vt as Ge, w as Ke, wt as qe, x as Je, xt as Ye, y as Xe, yt as Ze, z as Qe, zt as $e } from "../drag-provider-C--v2fW9.js";
3
3
  import { a as et, c as tt, d as nt, f as rt, g as it, h as at, i as ot, n as st, o as ct, p as lt, s as ut, t as dt, u as ft } from "../dist-CqufoV2m.js";
4
4
  import * as N from "react";
5
5
  import pt, { Component as mt, createContext as ht, createElement as gt, createRef as _t, forwardRef as vt, memo as yt, useCallback as bt, useContext as xt, useDebugValue as St, useEffect as Ct, useLayoutEffect as wt, useMemo as Tt, useRef as Et, useState as Dt, version as Ot } from "react";
@@ -38787,34 +38787,55 @@ var jK = Vm.create({
38787
38787
  },
38788
38788
  addNodeView() {
38789
38789
  if (!this.options.resize || !this.options.resize.enabled || typeof document > "u") return null;
38790
- let { directions: e, minWidth: t, minHeight: n, alwaysPreserveAspectRatio: r } = this.options.resize;
38791
- return ({ node: i, getPos: a, HTMLAttributes: o, editor: s }) => {
38792
- let c = document.createElement("img");
38793
- Object.entries(o).forEach(([e, t]) => {
38790
+ let { directions: e, minWidth: t, minHeight: n, alwaysPreserveAspectRatio: r } = this.options.resize, i = /* @__PURE__ */ new Set([
38791
+ "src",
38792
+ "width",
38793
+ "height"
38794
+ ]);
38795
+ return ({ node: a, getPos: o, HTMLAttributes: s, editor: c }) => {
38796
+ let l = document.createElement("img");
38797
+ l.draggable = !1;
38798
+ let u = kp(this.options.HTMLAttributes, s);
38799
+ Object.entries(u).forEach(([e, t]) => {
38794
38800
  if (t != null) switch (e) {
38801
+ case "src":
38795
38802
  case "width":
38796
38803
  case "height": break;
38797
- default:
38798
- c.setAttribute(e, t);
38799
- break;
38804
+ default: l.setAttribute(e, t);
38800
38805
  }
38801
- }), c.src = o.src;
38802
- let l = new mh({
38803
- element: c,
38804
- editor: s,
38805
- node: i,
38806
- getPos: a,
38806
+ }), u.src !== null && (l.src = u.src);
38807
+ let d = { ...s }, f = (e) => {
38808
+ if (typeof e == "string" && e !== "") {
38809
+ l.getAttribute("src") !== e && (l.src = e);
38810
+ return;
38811
+ }
38812
+ l.hasAttribute("src") && l.removeAttribute("src"), l.src !== "" && (l.src = "");
38813
+ };
38814
+ f(s.src);
38815
+ let p = new mh({
38816
+ element: l,
38817
+ editor: c,
38818
+ node: a,
38819
+ getPos: o,
38807
38820
  onResize: (e, t) => {
38808
- c.style.width = `${e}px`, c.style.height = `${t}px`;
38821
+ l.style.width = `${e}px`, l.style.height = `${t}px`;
38809
38822
  },
38810
38823
  onCommit: (e, t) => {
38811
- let n = a();
38824
+ let n = o();
38812
38825
  n !== void 0 && this.editor.chain().setNodeSelection(n).updateAttributes(this.name, {
38813
38826
  width: e,
38814
38827
  height: t
38815
38828
  }).run();
38816
38829
  },
38817
- onUpdate: (e, t, n) => e.type === i.type,
38830
+ onUpdate: (e) => {
38831
+ if (e.type !== a.type) return !1;
38832
+ let t = Ap(e, c.extensionManager.attributes.filter((t) => t.type === e.type.name));
38833
+ return Object.keys(d).forEach((e) => {
38834
+ !i.has(e) && !(e in t) && l.removeAttribute(e);
38835
+ }), Object.entries(t).forEach(([e, t]) => {
38836
+ i.has(e) || (t == null ? l.removeAttribute(e) : l.setAttribute(e, t));
38837
+ }), f(t.src), d = t, !0;
38838
+ },
38818
38839
  options: {
38819
38840
  directions: e,
38820
38841
  min: {
@@ -38823,10 +38844,10 @@ var jK = Vm.create({
38823
38844
  },
38824
38845
  preserveAspectRatio: r === !0
38825
38846
  }
38826
- }), u = l.dom;
38827
- return u.style.visibility = "hidden", u.style.pointerEvents = "none", c.onload = () => {
38828
- u.style.visibility = "", u.style.pointerEvents = "";
38829
- }, l;
38847
+ }), m = p.dom, h = () => {
38848
+ m.style.visibility = "", m.style.pointerEvents = "";
38849
+ };
38850
+ return m.style.visibility = "hidden", m.style.pointerEvents = "none", l.complete && l.naturalWidth > 0 ? h() : (l.onload = h, l.onerror = h), p;
38830
38851
  };
38831
38852
  },
38832
38853
  addCommands() {