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/README.md +1 -0
- package/lib/index.cjs +20 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +25 -26
- 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
|
@@ -833,9 +833,7 @@ function ft(t, e) {
|
|
|
833
833
|
}), t.hook("paste", t => t.getData("text/plain"));
|
|
834
834
|
}
|
|
835
835
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
function dt(t, e) {
|
|
836
|
+
function pt(t, e) {
|
|
839
837
|
const n = e.isLocked, r = e => n(h(t.doc, e)[0]), o = (e, r) => {
|
|
840
838
|
const [o, c] = e;
|
|
841
839
|
for (const [s, i] of v(t.doc, e)) {
|
|
@@ -883,18 +881,18 @@ function dt(t, e) {
|
|
|
883
881
|
}
|
|
884
882
|
}
|
|
885
883
|
i(e);
|
|
886
|
-
}), t.set(
|
|
884
|
+
}), t.set(pt, {
|
|
887
885
|
locked: t => F(t) ? r(t[0]) : o(t, !0)
|
|
888
886
|
});
|
|
889
887
|
}
|
|
890
888
|
|
|
891
|
-
var
|
|
889
|
+
var dt = (t, e) => {
|
|
892
890
|
const n = parseFloat(t);
|
|
893
891
|
return n ? t.endsWith("%") ? n / 100 * e : n : 0;
|
|
894
|
-
},
|
|
892
|
+
}, 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
893
|
const o = r ? -n : 0;
|
|
896
894
|
return Math.max(o - e, Math.min(t, o + n - e));
|
|
897
|
-
},
|
|
895
|
+
}, mt = (t, [e, n], r) => {
|
|
898
896
|
(n || e) && t.scrollBy({
|
|
899
897
|
top: n,
|
|
900
898
|
left: e,
|
|
@@ -902,7 +900,7 @@ var ht = (t, e) => {
|
|
|
902
900
|
});
|
|
903
901
|
};
|
|
904
902
|
|
|
905
|
-
function
|
|
903
|
+
function gt(t) {
|
|
906
904
|
t.hook("mount", t => {
|
|
907
905
|
t.ariaMultiLine = null;
|
|
908
906
|
}), t.hook("apply", (t, e) => {
|
|
@@ -949,7 +947,7 @@ exports.ClearHistory = function(t) {
|
|
|
949
947
|
text: e
|
|
950
948
|
});
|
|
951
949
|
}, exports.LeavesInRange = V, exports.LockedInRange = function(t, e = W(t.selection)) {
|
|
952
|
-
return t.get(
|
|
950
|
+
return t.get(pt).locked(e);
|
|
953
951
|
}, exports.Redo = function(t) {
|
|
954
952
|
t.get(st).redo();
|
|
955
953
|
}, exports.Redoable = function(t) {
|
|
@@ -1003,14 +1001,14 @@ exports.ClearHistory = function(t) {
|
|
|
1003
1001
|
t.get(st).undo();
|
|
1004
1002
|
}, exports.Undoable = function(t) {
|
|
1005
1003
|
return t.get(st).undoable();
|
|
1006
|
-
}, exports.blockLockPlugin =
|
|
1004
|
+
}, exports.blockLockPlugin = pt, exports.createEditor = ut, exports.createPlainEditor = ({text: t, singleline: e, onChange: n, ...r}) => {
|
|
1007
1005
|
const o = ut({
|
|
1008
1006
|
...r,
|
|
1009
1007
|
doc: {
|
|
1010
1008
|
children: M(t)
|
|
1011
1009
|
}
|
|
1012
1010
|
}).exec(ft);
|
|
1013
|
-
return e && o.exec(
|
|
1011
|
+
return e && o.exec(gt), o.on("change", () => {
|
|
1014
1012
|
n(E(o.doc));
|
|
1015
1013
|
}), o;
|
|
1016
1014
|
}, exports.debugPlugin = function(t) {
|
|
@@ -1077,12 +1075,13 @@ exports.getNodeSize = p, exports.htmlTransferPlugin = function(t, e) {
|
|
|
1077
1075
|
o(), c();
|
|
1078
1076
|
};
|
|
1079
1077
|
});
|
|
1080
|
-
}, exports.internalTransferPlugin = function(t) {
|
|
1078
|
+
}, exports.internalTransferPlugin = function(t, e) {
|
|
1079
|
+
const n = e && e.mime || "application/x-editate-editor";
|
|
1081
1080
|
t.hook("copy", e => {
|
|
1082
|
-
e.setData(
|
|
1081
|
+
e.setData(n, JSON.stringify(w(t.doc, ...W(t.selection))));
|
|
1083
1082
|
}), t.hook("paste", t => {
|
|
1084
1083
|
try {
|
|
1085
|
-
return JSON.parse(t.getData(
|
|
1084
|
+
return JSON.parse(t.getData(n));
|
|
1086
1085
|
} catch (e) {
|
|
1087
1086
|
return null;
|
|
1088
1087
|
}
|
|
@@ -1100,7 +1099,7 @@ exports.getNodeSize = p, exports.htmlTransferPlugin = function(t, e) {
|
|
|
1100
1099
|
let c = t;
|
|
1101
1100
|
for (;c && c !== r && c !== o; ) {
|
|
1102
1101
|
const {overflowX: t, overflowY: e} = n.getComputedStyle(c);
|
|
1103
|
-
if (
|
|
1102
|
+
if (yt(t) || yt(e)) return c;
|
|
1104
1103
|
c = c.parentElement;
|
|
1105
1104
|
}
|
|
1106
1105
|
return null;
|
|
@@ -1132,13 +1131,13 @@ exports.getNodeSize = p, exports.htmlTransferPlugin = function(t, e) {
|
|
|
1132
1131
|
default:
|
|
1133
1132
|
return [ e, !1 ];
|
|
1134
1133
|
}
|
|
1135
|
-
})(e), h =
|
|
1136
|
-
return [
|
|
1134
|
+
})(e), h = kt(xt(n.top, n.bottom, ht(f.top + l, u, e.scrollPaddingTop, e.scrollPaddingBottom)), o, s - u, d);
|
|
1135
|
+
return [ kt(xt(n.left, n.right, ht(f.left + i, a, e.scrollPaddingLeft, e.scrollPaddingRight)), r, c - a, p), h ];
|
|
1137
1136
|
})(i, l, f) : [ 0, 0 ], d = ((t, e, n, [r, o]) => {
|
|
1138
|
-
const {clientWidth: c, clientHeight: s} = t, i =
|
|
1139
|
-
return [
|
|
1137
|
+
const {clientWidth: c, clientHeight: s} = t, i = xt(n.top - o, n.bottom - o, ht(0, s, e.scrollPaddingTop, e.scrollPaddingBottom));
|
|
1138
|
+
return [ xt(n.left - r, n.right - r, ht(0, c, e.scrollPaddingLeft, e.scrollPaddingRight)), i ];
|
|
1140
1139
|
})(s, a, f, p);
|
|
1141
|
-
i &&
|
|
1140
|
+
i && mt(i, p, e), mt(c, d, e);
|
|
1142
1141
|
}, 50));
|
|
1143
1142
|
});
|
|
1144
1143
|
return () => {
|
|
@@ -1160,5 +1159,5 @@ exports.getNodeSize = p, exports.htmlTransferPlugin = function(t, e) {
|
|
|
1160
1159
|
o = !1, s();
|
|
1161
1160
|
};
|
|
1162
1161
|
});
|
|
1163
|
-
}, exports.singlelinePlugin =
|
|
1162
|
+
}, exports.singlelinePlugin = gt, exports.sliceText = E;
|
|
1164
1163
|
//# sourceMappingURL=index.cjs.map
|