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/README.md
CHANGED
|
@@ -217,6 +217,7 @@ export const App = () => {
|
|
|
217
217
|
- Preact ([Demo](https://inokawa.github.io/editate/preact), [Source](./examples/preact))
|
|
218
218
|
- Alpine ([Demo](https://inokawa.github.io/editate/alpine), [Source](./examples/alpine))
|
|
219
219
|
- Marko ([Demo](https://inokawa.github.io/editate/marko), [Source](./examples/marko))
|
|
220
|
+
- Octane ([Demo](https://inokawa.github.io/editate/octane), [Source](./examples/octane))
|
|
220
221
|
- Vanilla ([Demo](https://inokawa.github.io/editate/vanilla), [Source](./examples/vanilla))
|
|
221
222
|
|
|
222
223
|
...and more! Contribution welcome!
|
package/lib/index.cjs
CHANGED
|
@@ -580,14 +580,20 @@ var it = [], lt = () => {}, at = t => {
|
|
|
580
580
|
return r = n.nextNode();
|
|
581
581
|
}, i = () => {
|
|
582
582
|
const t = r.parentNode;
|
|
583
|
-
return
|
|
583
|
+
return f(() => {
|
|
584
584
|
for (o = 0; s(); ) {
|
|
585
585
|
if (c()) return !0;
|
|
586
586
|
if (!t.contains(r)) break;
|
|
587
587
|
}
|
|
588
588
|
return !1;
|
|
589
589
|
});
|
|
590
|
-
}, l = {
|
|
590
|
+
}, l = () => {
|
|
591
|
+
const t = c();
|
|
592
|
+
return 0 === t || 6 === t;
|
|
593
|
+
}, a = (t, e) => {
|
|
594
|
+
for (;(o = null) || (r = t ? n.previousSibling() : n.nextSibling()); ) if (e ? 4 === c() : !l()) return !0;
|
|
595
|
+
return !1;
|
|
596
|
+
}, u = {
|
|
591
597
|
t: () => {
|
|
592
598
|
for (;s(); ) {
|
|
593
599
|
const t = c();
|
|
@@ -601,26 +607,27 @@ var it = [], lt = () => {}, at = t => {
|
|
|
601
607
|
return 1 === t ? r.data.length : 2 === t ? 1 : 0;
|
|
602
608
|
},
|
|
603
609
|
u: t => {
|
|
604
|
-
o = null, n.currentNode = r = t
|
|
610
|
+
o = null, n.currentNode = r = t, l() && !a(!0) && (o = null, n.currentNode = r = t,
|
|
611
|
+
a(!1) || (o = null, n.currentNode = r = t));
|
|
605
612
|
},
|
|
606
613
|
h: () => {
|
|
607
|
-
|
|
614
|
+
a(!0, !0);
|
|
608
615
|
},
|
|
609
616
|
o: () => {
|
|
610
|
-
|
|
617
|
+
a(!1, !0);
|
|
611
618
|
},
|
|
612
619
|
p: () => {
|
|
613
620
|
for (;(o = null) || (r = n.parentNode()); ) if (4 === c()) return;
|
|
614
621
|
}
|
|
615
|
-
},
|
|
616
|
-
const s = n, i = r,
|
|
622
|
+
}, f = (e, c) => {
|
|
623
|
+
const s = n, i = r, l = o;
|
|
617
624
|
try {
|
|
618
|
-
return n || (n = t.createTreeWalker(r = c, 5)), e(
|
|
625
|
+
return n || (n = t.createTreeWalker(r = c, 5)), e(u);
|
|
619
626
|
} finally {
|
|
620
|
-
n = s, r = i, o =
|
|
627
|
+
n = s, r = i, o = l, n && i && (n.currentNode = i);
|
|
621
628
|
}
|
|
622
629
|
};
|
|
623
|
-
return
|
|
630
|
+
return f;
|
|
624
631
|
})(E, r), M = () => {
|
|
625
632
|
n.contentEditable = e ? "false" : "true", n.ariaReadOnly = e ? "true" : null;
|
|
626
633
|
};
|
|
@@ -833,9 +840,7 @@ function ft(t, e) {
|
|
|
833
840
|
}), t.hook("paste", t => t.getData("text/plain"));
|
|
834
841
|
}
|
|
835
842
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
function dt(t, e) {
|
|
843
|
+
function pt(t, e) {
|
|
839
844
|
const n = e.isLocked, r = e => n(h(t.doc, e)[0]), o = (e, r) => {
|
|
840
845
|
const [o, c] = e;
|
|
841
846
|
for (const [s, i] of v(t.doc, e)) {
|
|
@@ -883,18 +888,18 @@ function dt(t, e) {
|
|
|
883
888
|
}
|
|
884
889
|
}
|
|
885
890
|
i(e);
|
|
886
|
-
}), t.set(
|
|
891
|
+
}), t.set(pt, {
|
|
887
892
|
locked: t => F(t) ? r(t[0]) : o(t, !0)
|
|
888
893
|
});
|
|
889
894
|
}
|
|
890
895
|
|
|
891
|
-
var
|
|
896
|
+
var dt = (t, e) => {
|
|
892
897
|
const n = parseFloat(t);
|
|
893
898
|
return n ? t.endsWith("%") ? n / 100 * e : n : 0;
|
|
894
|
-
},
|
|
899
|
+
}, ht = (t, e, n, r) => [ t + dt(n, e), t + e - dt(r, e) ], yt = t => "auto" === t || "scroll" === t || "overlay" === t, xt = (t, e, [n, r]) => t < n ? t - n : e > r ? e - r : 0, kt = (t, e, n, r) => {
|
|
895
900
|
const o = r ? -n : 0;
|
|
896
901
|
return Math.max(o - e, Math.min(t, o + n - e));
|
|
897
|
-
},
|
|
902
|
+
}, mt = (t, [e, n], r) => {
|
|
898
903
|
(n || e) && t.scrollBy({
|
|
899
904
|
top: n,
|
|
900
905
|
left: e,
|
|
@@ -902,7 +907,7 @@ var ht = (t, e) => {
|
|
|
902
907
|
});
|
|
903
908
|
};
|
|
904
909
|
|
|
905
|
-
function
|
|
910
|
+
function gt(t) {
|
|
906
911
|
t.hook("mount", t => {
|
|
907
912
|
t.ariaMultiLine = null;
|
|
908
913
|
}), t.hook("apply", (t, e) => {
|
|
@@ -949,7 +954,7 @@ exports.ClearHistory = function(t) {
|
|
|
949
954
|
text: e
|
|
950
955
|
});
|
|
951
956
|
}, exports.LeavesInRange = V, exports.LockedInRange = function(t, e = W(t.selection)) {
|
|
952
|
-
return t.get(
|
|
957
|
+
return t.get(pt).locked(e);
|
|
953
958
|
}, exports.Redo = function(t) {
|
|
954
959
|
t.get(st).redo();
|
|
955
960
|
}, exports.Redoable = function(t) {
|
|
@@ -1003,14 +1008,14 @@ exports.ClearHistory = function(t) {
|
|
|
1003
1008
|
t.get(st).undo();
|
|
1004
1009
|
}, exports.Undoable = function(t) {
|
|
1005
1010
|
return t.get(st).undoable();
|
|
1006
|
-
}, exports.blockLockPlugin =
|
|
1011
|
+
}, exports.blockLockPlugin = pt, exports.createEditor = ut, exports.createPlainEditor = ({text: t, singleline: e, onChange: n, ...r}) => {
|
|
1007
1012
|
const o = ut({
|
|
1008
1013
|
...r,
|
|
1009
1014
|
doc: {
|
|
1010
1015
|
children: M(t)
|
|
1011
1016
|
}
|
|
1012
1017
|
}).exec(ft);
|
|
1013
|
-
return e && o.exec(
|
|
1018
|
+
return e && o.exec(gt), o.on("change", () => {
|
|
1014
1019
|
n(E(o.doc));
|
|
1015
1020
|
}), o;
|
|
1016
1021
|
}, exports.debugPlugin = function(t) {
|
|
@@ -1077,12 +1082,13 @@ exports.getNodeSize = p, exports.htmlTransferPlugin = function(t, e) {
|
|
|
1077
1082
|
o(), c();
|
|
1078
1083
|
};
|
|
1079
1084
|
});
|
|
1080
|
-
}, exports.internalTransferPlugin = function(t) {
|
|
1085
|
+
}, exports.internalTransferPlugin = function(t, e) {
|
|
1086
|
+
const n = e && e.mime || "application/x-editate-editor";
|
|
1081
1087
|
t.hook("copy", e => {
|
|
1082
|
-
e.setData(
|
|
1088
|
+
e.setData(n, JSON.stringify(w(t.doc, ...W(t.selection))));
|
|
1083
1089
|
}), t.hook("paste", t => {
|
|
1084
1090
|
try {
|
|
1085
|
-
return JSON.parse(t.getData(
|
|
1091
|
+
return JSON.parse(t.getData(n));
|
|
1086
1092
|
} catch (e) {
|
|
1087
1093
|
return null;
|
|
1088
1094
|
}
|
|
@@ -1100,7 +1106,7 @@ exports.getNodeSize = p, exports.htmlTransferPlugin = function(t, e) {
|
|
|
1100
1106
|
let c = t;
|
|
1101
1107
|
for (;c && c !== r && c !== o; ) {
|
|
1102
1108
|
const {overflowX: t, overflowY: e} = n.getComputedStyle(c);
|
|
1103
|
-
if (
|
|
1109
|
+
if (yt(t) || yt(e)) return c;
|
|
1104
1110
|
c = c.parentElement;
|
|
1105
1111
|
}
|
|
1106
1112
|
return null;
|
|
@@ -1132,13 +1138,13 @@ exports.getNodeSize = p, exports.htmlTransferPlugin = function(t, e) {
|
|
|
1132
1138
|
default:
|
|
1133
1139
|
return [ e, !1 ];
|
|
1134
1140
|
}
|
|
1135
|
-
})(e), h =
|
|
1136
|
-
return [
|
|
1141
|
+
})(e), h = kt(xt(n.top, n.bottom, ht(f.top + l, u, e.scrollPaddingTop, e.scrollPaddingBottom)), o, s - u, d);
|
|
1142
|
+
return [ kt(xt(n.left, n.right, ht(f.left + i, a, e.scrollPaddingLeft, e.scrollPaddingRight)), r, c - a, p), h ];
|
|
1137
1143
|
})(i, l, f) : [ 0, 0 ], d = ((t, e, n, [r, o]) => {
|
|
1138
|
-
const {clientWidth: c, clientHeight: s} = t, i =
|
|
1139
|
-
return [
|
|
1144
|
+
const {clientWidth: c, clientHeight: s} = t, i = xt(n.top - o, n.bottom - o, ht(0, s, e.scrollPaddingTop, e.scrollPaddingBottom));
|
|
1145
|
+
return [ xt(n.left - r, n.right - r, ht(0, c, e.scrollPaddingLeft, e.scrollPaddingRight)), i ];
|
|
1140
1146
|
})(s, a, f, p);
|
|
1141
|
-
i &&
|
|
1147
|
+
i && mt(i, p, e), mt(c, d, e);
|
|
1142
1148
|
}, 50));
|
|
1143
1149
|
});
|
|
1144
1150
|
return () => {
|
|
@@ -1160,5 +1166,5 @@ exports.getNodeSize = p, exports.htmlTransferPlugin = function(t, e) {
|
|
|
1160
1166
|
o = !1, s();
|
|
1161
1167
|
};
|
|
1162
1168
|
});
|
|
1163
|
-
}, exports.singlelinePlugin =
|
|
1169
|
+
}, exports.singlelinePlugin = gt, exports.sliceText = E;
|
|
1164
1170
|
//# sourceMappingURL=index.cjs.map
|