editate 0.6.4 → 0.6.5

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/lib/index.js CHANGED
@@ -29,10 +29,10 @@ const t = ([t, e]) => t > e ? [ e, t ] : [ t, e ], e = ([t, e]) => t === e, n =
29
29
  let r = 0;
30
30
  for (const n of e) r += x(t, 0, n), 0 !== n && r++, t = t.children[n];
31
31
  return r + n;
32
- }, w = (t, e) => {
32
+ }, v = (t, e) => {
33
33
  const n = A(t, e);
34
34
  return [ n.t, n.o ];
35
- }, v = (t, [e, n]) => [ m(t, e), m(t, n) ], M = (t, [e, n]) => [ w(t, e), w(t, n) ], S = (t, e = 0, n = t.length - 1) => {
35
+ }, w = (t, [e, n]) => [ m(t, e), m(t, n) ], M = (t, [e, n]) => [ v(t, e), v(t, n) ], S = (t, e = 0, n = t.length - 1) => {
36
36
  let r = e + 1;
37
37
  for (;r <= n; ) {
38
38
  const e = t[r - 1], o = t[r];
@@ -214,12 +214,10 @@ function W(e, n) {
214
214
 
215
215
  function q(t, e) {
216
216
  t.apply({
217
- type: "delete",
218
- range: [ 0, b(t.doc) ]
219
- }).apply({
220
- type: "insert_node",
221
- at: 0,
222
- fragment: e
217
+ type: "set_node_attr",
218
+ path: [],
219
+ key: "children",
220
+ value: e
223
221
  });
224
222
  }
225
223
 
@@ -345,7 +343,7 @@ const $ = t => 1 === t.nodeType, tt = t => 8 === t.nodeType, et = () => z, nt =
345
343
  if (n <= t) return [ et(), n ];
346
344
  n -= t;
347
345
  }
348
- }, t), wt = (t, e, r, o) => {
346
+ }, t), vt = (t, e, r, o) => {
349
347
  let c = !0;
350
348
  if (t === e && !e.hasChildNodes()) return [ [ 0 ], 0 ];
351
349
  if ($(e) && e.hasChildNodes()) {
@@ -373,9 +371,9 @@ const $ = t => 1 === t.nodeType, tt = t => 8 === t.nodeType, et = () => z, nt =
373
371
  }
374
372
  return [ n, s + r ];
375
373
  }, t, e);
376
- }, vt = (t, e, {startOffset: n, startContainer: r, endOffset: o, endContainer: c}) => {
377
- const s = wt(t, r, n, e);
378
- return [ s, r === c && n === o ? s : wt(t, c, o, e) ];
374
+ }, wt = (t, e, {startOffset: n, startContainer: r, endOffset: o, endContainer: c}) => {
375
+ const s = vt(t, r, n, e);
376
+ return [ s, r === c && n === o ? s : vt(t, c, o, e) ];
379
377
  }, Mt = "undefined" != typeof navigator && /Mac|iP(hone|od|ad)/.test(navigator.platform), St = (t, e) => {
380
378
  const n = t.endsWith("+"), r = (n ? t.slice(0, -2) : t).split("+"), o = n ? "+" : r.pop(), c = "Space" === o ? " " : o.toLowerCase();
381
379
  let s = !1, i = !1, a = !1, l = !1;
@@ -476,7 +474,7 @@ const It = [], Ct = () => {}, Rt = t => {
476
474
  return !1;
477
475
  };
478
476
  a && !b(n) && k("Invalid document");
479
- const w = new Map, S = new WeakMap, E = t => w.get(t) || It, O = new Map, D = [], I = t => {
477
+ const v = new Map, S = new WeakMap, E = t => v.get(t) || It, O = new Map, D = [], I = t => {
480
478
  const e = O.get(t);
481
479
  e && (D.length || i(() => {
482
480
  D.forEach(t => {
@@ -600,8 +598,8 @@ const It = [], Ct = () => {}, Rt = t => {
600
598
  };
601
599
  },
602
600
  hook: (t, e) => {
603
- let n = w.get(t);
604
- return n || w.set(t, n = []), n.push(e), () => {
601
+ let n = v.get(t);
602
+ return n || v.set(t, n = []), n.push(e), () => {
605
603
  const t = n.indexOf(e);
606
604
  -1 !== t && n.splice(t, 1);
607
605
  };
@@ -618,7 +616,7 @@ const It = [], Ct = () => {}, Rt = t => {
618
616
  const {contentEditable: i, role: a, ariaMultiLine: l, ariaReadOnly: f} = o, u = o.style.whiteSpace;
619
617
  o.role = "textbox", o.style.whiteSpace = "pre-wrap", o.ariaMultiLine = "true";
620
618
  let d = !1, p = null, h = !1, y = !1, k = !1;
621
- const b = gt(o), w = (t => {
619
+ const b = gt(o), v = (t => {
622
620
  const e = (n, r, o) => {
623
621
  const c = K, s = Q, i = j, a = z, l = X;
624
622
  try {
@@ -645,7 +643,7 @@ const It = [], Ct = () => {}, Rt = t => {
645
643
  });
646
644
  }), D = U.on("readonly", S), P = t => {
647
645
  for (const e of E("paste")) {
648
- const n = e(t, w);
646
+ const n = e(t, v);
649
647
  if (n) return n;
650
648
  }
651
649
  _("failed to serialize pasted data");
@@ -682,17 +680,17 @@ const It = [], Ct = () => {}, Rt = t => {
682
680
  }
683
681
  };
684
682
  })(o, () => {
685
- bt(b, o, M(n, x), x[0] - x[1], w);
683
+ bt(b, o, M(n, x), x[0] - x[1], v);
686
684
  }), I = () => {
687
- F(v(n, ((t, e) => {
685
+ F(w(n, ((t, e) => {
688
686
  const n = _t(t), r = kt(n, t);
689
687
  if (!r) return [ [ [ 0 ], 0 ], [ [ 0 ], 0 ] ];
690
- const o = vt(t, e, r), c = yt(n.anchorNode, n.focusNode);
688
+ const o = wt(t, e, r), c = yt(n.anchorNode, n.focusNode);
691
689
  return (0 === c ? n.anchorOffset > n.focusOffset : 2 & c) ? [ o[1], o[0] ] : o;
692
- })(o, w)));
690
+ })(o, v)));
693
691
  }, C = () => {
694
692
  const t = A.m();
695
- A.k(!1), t.length && (A._(t), b.removeEventListener("selectionchange", G), bt(b, o, M(n, x), x[0] - x[1], w, !0),
693
+ A.k(!1), t.length && (A._(t), b.removeEventListener("selectionchange", G), bt(b, o, M(n, x), x[0] - x[1], v, !0),
696
694
  b.addEventListener("selectionchange", G)), p && (F(p[1]), B(p[0]), p = null), h = !1;
697
695
  }, R = t => {
698
696
  if (!h) for (const e of E("keyboard")) if (e(t)) return t.preventDefault(), void A.k(!1);
@@ -706,7 +704,7 @@ const It = [], Ct = () => {}, Rt = t => {
706
704
  h ? A.k(!0) : I();
707
705
  const c = t.getTargetRanges()[0];
708
706
  if (c) {
709
- const s = v(n, vt(o, w, c));
707
+ const s = w(n, wt(o, v, c));
710
708
  let i, a = "insertParagraph" === r || "insertLineBreak" === r ? "\n" : t.data;
711
709
  if (null == a) {
712
710
  const e = t.dataTransfer;
@@ -764,12 +762,12 @@ const It = [], Ct = () => {}, Rt = t => {
764
762
  const r = e.dataTransfer, s = ((t, e, {clientX: n, clientY: r}, o) => {
765
763
  if (t.caretPositionFromPoint) {
766
764
  const c = t.caretPositionFromPoint(n, r);
767
- if (c) return wt(e, c.offsetNode, c.offset, o);
765
+ if (c) return vt(e, c.offsetNode, c.offset, o);
768
766
  } else if (t.caretRangeFromPoint) {
769
767
  const c = t.caretRangeFromPoint(n, r);
770
- if (c) return wt(e, c.startContainer, c.startOffset, o);
768
+ if (c) return vt(e, c.startContainer, c.startOffset, o);
771
769
  }
772
- })(b, o, e, w);
770
+ })(b, o, e, v);
773
771
  if (r && s) {
774
772
  let e;
775
773
  const o = [];
@@ -940,9 +938,9 @@ const qt = ({text: t, singleline: e, onChange: n, ...r}) => {
940
938
  children: l(t)
941
939
  }
942
940
  }).exec(Ht);
943
- return o.on("change", () => {
941
+ return e && o.exec(Wt), o.on("change", () => {
944
942
  n(a(o.doc));
945
- }), e && o.exec(Wt), o;
943
+ }), o;
946
944
  };
947
945
 
948
946
  export { V as Delete, G as Format, U as InsertNode, F as InsertText, Dt as Redo, At as Redoable, q as ReplaceDoc, W as ReplaceText, Y as SetBlockAttr, Z as ToggleBlockAttr, J as ToggleFormat, Ot as Undo, Pt as Undoable, Tt as createEditor, qt as createPlainEditor, Ft as debugPlugin, Lt as fileTransferPlugin, Bt as htmlTransferPlugin, Vt as internalTranferPlugin, Ut as keymapPlugin, Ht as plainTransferPlugin, Wt as singlelinePlugin };