editate 0.6.24 → 0.6.25

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
@@ -995,21 +995,20 @@ function St(t, e) {
995
995
  });
996
996
  }
997
997
 
998
- var At = "application/x-editate-editor";
999
-
1000
- function Ot(t) {
998
+ function At(t, e) {
999
+ const n = e && e.mime || "application/x-editate-editor";
1001
1000
  t.hook("copy", e => {
1002
- e.setData(At, JSON.stringify(w(t.doc, ...W(t.selection))));
1001
+ e.setData(n, JSON.stringify(w(t.doc, ...W(t.selection))));
1003
1002
  }), t.hook("paste", t => {
1004
1003
  try {
1005
- return JSON.parse(t.getData(At));
1004
+ return JSON.parse(t.getData(n));
1006
1005
  } catch (e) {
1007
1006
  return null;
1008
1007
  }
1009
1008
  });
1010
1009
  }
1011
1010
 
1012
- function Rt(t, e) {
1011
+ function Ot(t, e) {
1013
1012
  const n = e.isLocked, r = e => n(h(t.doc, e)[0]), o = (e, r) => {
1014
1013
  const [o, c] = e;
1015
1014
  for (const [s, i] of v(t.doc, e)) {
@@ -1057,16 +1056,16 @@ function Rt(t, e) {
1057
1056
  }
1058
1057
  }
1059
1058
  i(e);
1060
- }), t.set(Rt, {
1059
+ }), t.set(Ot, {
1061
1060
  locked: t => F(t) ? r(t[0]) : o(t, !0)
1062
1061
  });
1063
1062
  }
1064
1063
 
1065
- function Dt(t, e = W(t.selection)) {
1066
- return t.get(Rt).locked(e);
1064
+ function Rt(t, e = W(t.selection)) {
1065
+ return t.get(Ot).locked(e);
1067
1066
  }
1068
1067
 
1069
- function Bt(t) {
1068
+ function Dt(t) {
1070
1069
  t.hook("apply", t => {
1071
1070
  console.log("apply", t);
1072
1071
  }), t.on("change", () => {
@@ -1076,26 +1075,26 @@ function Bt(t) {
1076
1075
  });
1077
1076
  }
1078
1077
 
1079
- function It(t, e) {
1078
+ function Bt(t, e) {
1080
1079
  n(e).forEach(n => {
1081
1080
  const r = e[n];
1082
1081
  t.hook("keyboard", ht(n, r));
1083
1082
  });
1084
1083
  }
1085
1084
 
1086
- var Lt = (t, e) => {
1085
+ var It = (t, e) => {
1087
1086
  const n = parseFloat(t);
1088
1087
  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) => {
1088
+ }, 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
1089
  const o = r ? -n : 0;
1091
1090
  return Math.max(o - e, Math.min(t, o + n - e));
1092
- }, Wt = (t, [e, n], r) => {
1091
+ }, Ct = (t, [e, n], r) => {
1093
1092
  (n || e) && t.scrollBy({
1094
1093
  top: n,
1095
1094
  left: e,
1096
1095
  behavior: r
1097
1096
  });
1098
- }, Ft = t => {
1097
+ }, Wt = t => {
1099
1098
  const e = "auto";
1100
1099
  t.hook("mount", (n, r) => {
1101
1100
  const o = ct(n), c = o.defaultView, {documentElement: s} = o, i = ((t, e, n) => {
@@ -1103,7 +1102,7 @@ var Lt = (t, e) => {
1103
1102
  let c = t;
1104
1103
  for (;c && c !== r && c !== o; ) {
1105
1104
  const {overflowX: t, overflowY: e} = n.getComputedStyle(c);
1106
- if (Ht(t) || Ht(e)) return c;
1105
+ if (Pt(t) || Pt(e)) return c;
1107
1106
  c = c.parentElement;
1108
1107
  }
1109
1108
  return null;
@@ -1135,13 +1134,13 @@ var Lt = (t, e) => {
1135
1134
  default:
1136
1135
  return [ e, !1 ];
1137
1136
  }
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 ];
1137
+ })(e), h = Nt(Ht(n.top, n.bottom, Lt(f.top + l, u, e.scrollPaddingTop, e.scrollPaddingBottom)), o, s - u, p);
1138
+ return [ Nt(Ht(n.left, n.right, Lt(f.left + i, a, e.scrollPaddingLeft, e.scrollPaddingRight)), r, c - a, d), h ];
1140
1139
  })(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 ];
1140
+ const {clientWidth: c, clientHeight: s} = t, i = Ht(n.top - o, n.bottom - o, Lt(0, s, e.scrollPaddingTop, e.scrollPaddingBottom));
1141
+ return [ Ht(n.left - r, n.right - r, Lt(0, c, e.scrollPaddingLeft, e.scrollPaddingRight)), i ];
1143
1142
  })(s, a, f, d);
1144
- i && Wt(i, d, e), Wt(c, p, e);
1143
+ i && Ct(i, d, e), Ct(c, p, e);
1145
1144
  }, 50));
1146
1145
  });
1147
1146
  return () => {
@@ -1150,7 +1149,7 @@ var Lt = (t, e) => {
1150
1149
  });
1151
1150
  };
1152
1151
 
1153
- function Ut(t, e) {
1152
+ function Ft(t, e) {
1154
1153
  t.hook("mount", (n, r) => {
1155
1154
  let o = !0, c = !1;
1156
1155
  const s = t.on("selectionchange", () => {
@@ -1167,7 +1166,7 @@ function Ut(t, e) {
1167
1166
  });
1168
1167
  }
1169
1168
 
1170
- function Vt(t) {
1169
+ function Ut(t) {
1171
1170
  t.hook("mount", t => {
1172
1171
  t.ariaMultiLine = null;
1173
1172
  }), t.hook("apply", (t, e) => {
@@ -1185,17 +1184,17 @@ function Vt(t) {
1185
1184
  });
1186
1185
  }
1187
1186
 
1188
- var qt = ({text: t, singleline: e, onChange: n, ...r}) => {
1187
+ var Vt = ({text: t, singleline: e, onChange: n, ...r}) => {
1189
1188
  const o = Et({
1190
1189
  ...r,
1191
1190
  doc: {
1192
1191
  children: M(t)
1193
1192
  }
1194
1193
  }).exec(Mt);
1195
- return e && o.exec(Vt), o.on("change", () => {
1194
+ return e && o.exec(Ut), o.on("change", () => {
1196
1195
  n(E(o.doc));
1197
1196
  }), o;
1198
1197
  };
1199
1198
 
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 };
1199
+ 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
1200
  //# sourceMappingURL=index.js.map