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/README.md +1 -0
- package/lib/index.cjs +37 -31
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +42 -36
- package/lib/index.js.map +1 -1
- package/lib/plugins/transfer/internalTransfer.d.ts +6 -1
- package/package.json +3 -2
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
|
|
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
|
-
|
|
719
|
+
a(!0, !0);
|
|
713
720
|
},
|
|
714
721
|
o: () => {
|
|
715
|
-
|
|
722
|
+
a(!1, !0);
|
|
716
723
|
},
|
|
717
724
|
p: () => {
|
|
718
725
|
for (;(o = null) || (r = n.parentNode()); ) if (4 === c()) return;
|
|
719
726
|
}
|
|
720
|
-
},
|
|
721
|
-
const s = n, i = r,
|
|
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(
|
|
730
|
+
return n || (n = t.createTreeWalker(r = c, 5)), e(u);
|
|
724
731
|
} finally {
|
|
725
|
-
n = s, r = i, o =
|
|
732
|
+
n = s, r = i, o = l, n && i && (n.currentNode = i);
|
|
726
733
|
}
|
|
727
734
|
};
|
|
728
|
-
return
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
|
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(
|
|
1066
|
+
}), t.set(Ot, {
|
|
1061
1067
|
locked: t => F(t) ? r(t[0]) : o(t, !0)
|
|
1062
1068
|
});
|
|
1063
1069
|
}
|
|
1064
1070
|
|
|
1065
|
-
function
|
|
1066
|
-
return t.get(
|
|
1071
|
+
function Rt(t, e = W(t.selection)) {
|
|
1072
|
+
return t.get(Ot).locked(e);
|
|
1067
1073
|
}
|
|
1068
1074
|
|
|
1069
|
-
function
|
|
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
|
|
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
|
|
1092
|
+
var It = (t, e) => {
|
|
1087
1093
|
const n = parseFloat(t);
|
|
1088
1094
|
return n ? t.endsWith("%") ? n / 100 * e : n : 0;
|
|
1089
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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 (
|
|
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 =
|
|
1139
|
-
return [
|
|
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 =
|
|
1142
|
-
return [
|
|
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 &&
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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,
|
|
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
|