editate 0.6.24 → 0.6.26

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
@@ -685,14 +685,20 @@ var bt = [], vt = () => {}, Tt = t => {
685
685
  return r = n.nextNode();
686
686
  }, i = () => {
687
687
  const t = r.parentNode;
688
- return a(() => {
688
+ return f(() => {
689
689
  for (o = 0; s(); ) {
690
690
  if (c()) return !0;
691
691
  if (!t.contains(r)) break;
692
692
  }
693
693
  return !1;
694
694
  });
695
- }, l = {
695
+ }, l = () => {
696
+ const t = c();
697
+ return 0 === t || 6 === t;
698
+ }, a = (t, e) => {
699
+ for (;(o = null) || (r = t ? n.previousSibling() : n.nextSibling()); ) if (e ? 4 === c() : !l()) return !0;
700
+ return !1;
701
+ }, u = {
696
702
  t: () => {
697
703
  for (;s(); ) {
698
704
  const t = c();
@@ -706,26 +712,27 @@ var bt = [], vt = () => {}, Tt = t => {
706
712
  return 1 === t ? r.data.length : 2 === t ? 1 : 0;
707
713
  },
708
714
  u: t => {
709
- o = null, n.currentNode = r = t;
715
+ o = null, n.currentNode = r = t, l() && !a(!0) && (o = null, n.currentNode = r = t,
716
+ a(!1) || (o = null, n.currentNode = r = t));
710
717
  },
711
718
  h: () => {
712
- for (;(o = null) || (r = n.previousSibling()); ) if (4 === c()) return;
719
+ a(!0, !0);
713
720
  },
714
721
  o: () => {
715
- for (;(o = null) || (r = n.nextSibling()); ) if (4 === c()) return;
722
+ a(!1, !0);
716
723
  },
717
724
  p: () => {
718
725
  for (;(o = null) || (r = n.parentNode()); ) if (4 === c()) return;
719
726
  }
720
- }, a = (e, c) => {
721
- const s = n, i = r, a = o;
727
+ }, f = (e, c) => {
728
+ const s = n, i = r, l = o;
722
729
  try {
723
- return n || (n = t.createTreeWalker(r = c, 5)), e(l);
730
+ return n || (n = t.createTreeWalker(r = c, 5)), e(u);
724
731
  } finally {
725
- n = s, r = i, o = a, n && i && (n.currentNode = i);
732
+ n = s, r = i, o = l, n && i && (n.currentNode = i);
726
733
  }
727
734
  };
728
- return a;
735
+ return f;
729
736
  })(E, r), M = () => {
730
737
  n.contentEditable = e ? "false" : "true", n.ariaReadOnly = e ? "true" : null;
731
738
  };
@@ -995,21 +1002,20 @@ function St(t, e) {
995
1002
  });
996
1003
  }
997
1004
 
998
- var At = "application/x-editate-editor";
999
-
1000
- function Ot(t) {
1005
+ function At(t, e) {
1006
+ const n = e && e.mime || "application/x-editate-editor";
1001
1007
  t.hook("copy", e => {
1002
- e.setData(At, JSON.stringify(w(t.doc, ...W(t.selection))));
1008
+ e.setData(n, JSON.stringify(w(t.doc, ...W(t.selection))));
1003
1009
  }), t.hook("paste", t => {
1004
1010
  try {
1005
- return JSON.parse(t.getData(At));
1011
+ return JSON.parse(t.getData(n));
1006
1012
  } catch (e) {
1007
1013
  return null;
1008
1014
  }
1009
1015
  });
1010
1016
  }
1011
1017
 
1012
- function Rt(t, e) {
1018
+ function Ot(t, e) {
1013
1019
  const n = e.isLocked, r = e => n(h(t.doc, e)[0]), o = (e, r) => {
1014
1020
  const [o, c] = e;
1015
1021
  for (const [s, i] of v(t.doc, e)) {
@@ -1057,16 +1063,16 @@ function Rt(t, e) {
1057
1063
  }
1058
1064
  }
1059
1065
  i(e);
1060
- }), t.set(Rt, {
1066
+ }), t.set(Ot, {
1061
1067
  locked: t => F(t) ? r(t[0]) : o(t, !0)
1062
1068
  });
1063
1069
  }
1064
1070
 
1065
- function Dt(t, e = W(t.selection)) {
1066
- return t.get(Rt).locked(e);
1071
+ function Rt(t, e = W(t.selection)) {
1072
+ return t.get(Ot).locked(e);
1067
1073
  }
1068
1074
 
1069
- function Bt(t) {
1075
+ function Dt(t) {
1070
1076
  t.hook("apply", t => {
1071
1077
  console.log("apply", t);
1072
1078
  }), t.on("change", () => {
@@ -1076,26 +1082,26 @@ function Bt(t) {
1076
1082
  });
1077
1083
  }
1078
1084
 
1079
- function It(t, e) {
1085
+ function Bt(t, e) {
1080
1086
  n(e).forEach(n => {
1081
1087
  const r = e[n];
1082
1088
  t.hook("keyboard", ht(n, r));
1083
1089
  });
1084
1090
  }
1085
1091
 
1086
- var Lt = (t, e) => {
1092
+ var It = (t, e) => {
1087
1093
  const n = parseFloat(t);
1088
1094
  return n ? t.endsWith("%") ? n / 100 * e : n : 0;
1089
- }, Pt = (t, e, n, r) => [ t + Lt(n, e), t + e - Lt(r, e) ], Ht = t => "auto" === t || "scroll" === t || "overlay" === t, Nt = (t, e, [n, r]) => t < n ? t - n : e > r ? e - r : 0, Ct = (t, e, n, r) => {
1095
+ }, Lt = (t, e, n, r) => [ t + It(n, e), t + e - It(r, e) ], Pt = t => "auto" === t || "scroll" === t || "overlay" === t, Ht = (t, e, [n, r]) => t < n ? t - n : e > r ? e - r : 0, Nt = (t, e, n, r) => {
1090
1096
  const o = r ? -n : 0;
1091
1097
  return Math.max(o - e, Math.min(t, o + n - e));
1092
- }, Wt = (t, [e, n], r) => {
1098
+ }, Ct = (t, [e, n], r) => {
1093
1099
  (n || e) && t.scrollBy({
1094
1100
  top: n,
1095
1101
  left: e,
1096
1102
  behavior: r
1097
1103
  });
1098
- }, Ft = t => {
1104
+ }, Wt = t => {
1099
1105
  const e = "auto";
1100
1106
  t.hook("mount", (n, r) => {
1101
1107
  const o = ct(n), c = o.defaultView, {documentElement: s} = o, i = ((t, e, n) => {
@@ -1103,7 +1109,7 @@ var Lt = (t, e) => {
1103
1109
  let c = t;
1104
1110
  for (;c && c !== r && c !== o; ) {
1105
1111
  const {overflowX: t, overflowY: e} = n.getComputedStyle(c);
1106
- if (Ht(t) || Ht(e)) return c;
1112
+ if (Pt(t) || Pt(e)) return c;
1107
1113
  c = c.parentElement;
1108
1114
  }
1109
1115
  return null;
@@ -1135,13 +1141,13 @@ var Lt = (t, e) => {
1135
1141
  default:
1136
1142
  return [ e, !1 ];
1137
1143
  }
1138
- })(e), h = Ct(Nt(n.top, n.bottom, Pt(f.top + l, u, e.scrollPaddingTop, e.scrollPaddingBottom)), o, s - u, p);
1139
- return [ Ct(Nt(n.left, n.right, Pt(f.left + i, a, e.scrollPaddingLeft, e.scrollPaddingRight)), r, c - a, d), h ];
1144
+ })(e), h = Nt(Ht(n.top, n.bottom, Lt(f.top + l, u, e.scrollPaddingTop, e.scrollPaddingBottom)), o, s - u, p);
1145
+ return [ Nt(Ht(n.left, n.right, Lt(f.left + i, a, e.scrollPaddingLeft, e.scrollPaddingRight)), r, c - a, d), h ];
1140
1146
  })(i, l, f) : [ 0, 0 ], p = ((t, e, n, [r, o]) => {
1141
- const {clientWidth: c, clientHeight: s} = t, i = Nt(n.top - o, n.bottom - o, Pt(0, s, e.scrollPaddingTop, e.scrollPaddingBottom));
1142
- return [ Nt(n.left - r, n.right - r, Pt(0, c, e.scrollPaddingLeft, e.scrollPaddingRight)), i ];
1147
+ const {clientWidth: c, clientHeight: s} = t, i = Ht(n.top - o, n.bottom - o, Lt(0, s, e.scrollPaddingTop, e.scrollPaddingBottom));
1148
+ return [ Ht(n.left - r, n.right - r, Lt(0, c, e.scrollPaddingLeft, e.scrollPaddingRight)), i ];
1143
1149
  })(s, a, f, d);
1144
- i && Wt(i, d, e), Wt(c, p, e);
1150
+ i && Ct(i, d, e), Ct(c, p, e);
1145
1151
  }, 50));
1146
1152
  });
1147
1153
  return () => {
@@ -1150,7 +1156,7 @@ var Lt = (t, e) => {
1150
1156
  });
1151
1157
  };
1152
1158
 
1153
- function Ut(t, e) {
1159
+ function Ft(t, e) {
1154
1160
  t.hook("mount", (n, r) => {
1155
1161
  let o = !0, c = !1;
1156
1162
  const s = t.on("selectionchange", () => {
@@ -1167,7 +1173,7 @@ function Ut(t, e) {
1167
1173
  });
1168
1174
  }
1169
1175
 
1170
- function Vt(t) {
1176
+ function Ut(t) {
1171
1177
  t.hook("mount", t => {
1172
1178
  t.ariaMultiLine = null;
1173
1179
  }), t.hook("apply", (t, e) => {
@@ -1185,17 +1191,17 @@ function Vt(t) {
1185
1191
  });
1186
1192
  }
1187
1193
 
1188
- var qt = ({text: t, singleline: e, onChange: n, ...r}) => {
1194
+ var Vt = ({text: t, singleline: e, onChange: n, ...r}) => {
1189
1195
  const o = Et({
1190
1196
  ...r,
1191
1197
  doc: {
1192
1198
  children: M(t)
1193
1199
  }
1194
1200
  }).exec(Mt);
1195
- return e && o.exec(Vt), o.on("change", () => {
1201
+ return e && o.exec(Ut), o.on("change", () => {
1196
1202
  n(E(o.doc));
1197
1203
  }), o;
1198
1204
  };
1199
1205
 
1200
- export { xt as ClearHistory, q as Delete, Y as Format, G as InsertNode, z as InsertText, V as LeavesInRange, Dt as LockedInRange, mt as Redo, _t as Redoable, X as ReplaceDoc, J as ReplaceText, j as SetBlockAttr, Q as SetVoidAttr, K as ToggleBlockAttr, Z as ToggleFormat, kt as Undo, gt as Undoable, Rt as blockLockPlugin, Et as createEditor, qt as createPlainEditor, Bt as debugPlugin, wt as fileTransferPlugin, p as getChildAt, y as getLeafAt, h as getLeafBlockAt, k as getNodeOffset, d as getNodeSize, St as htmlTransferPlugin, Ot as internalTransferPlugin, v as iterLeafBlocks, T as iterLeaves, It as keymapPlugin, N as mapPosition, Mt as plainTransferPlugin, Ft as scrollToSelectionPlugin, Ut as selectionRectPlugin, Vt as singlelinePlugin, E as sliceText };
1206
+ export { xt as ClearHistory, q as Delete, Y as Format, G as InsertNode, z as InsertText, V as LeavesInRange, Rt as LockedInRange, mt as Redo, _t as Redoable, X as ReplaceDoc, J as ReplaceText, j as SetBlockAttr, Q as SetVoidAttr, K as ToggleBlockAttr, Z as ToggleFormat, kt as Undo, gt as Undoable, Ot as blockLockPlugin, Et as createEditor, Vt as createPlainEditor, Dt as debugPlugin, wt as fileTransferPlugin, p as getChildAt, y as getLeafAt, h as getLeafBlockAt, k as getNodeOffset, d as getNodeSize, St as htmlTransferPlugin, At as internalTransferPlugin, v as iterLeafBlocks, T as iterLeaves, Bt as keymapPlugin, N as mapPosition, Mt as plainTransferPlugin, Wt as scrollToSelectionPlugin, Ft as selectionRectPlugin, Ut as singlelinePlugin, E as sliceText };
1201
1207
  //# sourceMappingURL=index.js.map