@kerebron/legacy-compat 0.8.3 → 0.8.5
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/dist/{__vite-browser-external-BXJKwL9l.js → __vite-browser-external-Bk07RSXL.js} +2 -2
- package/dist/__vite-browser-external-Bk07RSXL.js.map +1 -0
- package/dist/__vite-browser-external-Dghh9khe.cjs +2 -0
- package/dist/__vite-browser-external-Dghh9khe.cjs.map +1 -0
- package/dist/kerebron.cjs +21 -15
- package/dist/kerebron.cjs.map +1 -1
- package/dist/kerebron.js +825 -191
- package/dist/kerebron.js.map +1 -1
- package/dist/{rolldown-runtime-3b4jIN3o.js → rolldown-runtime-Dqa2HsxW.js} +10 -3
- package/dist/rolldown-runtime-mLOUI7ql.cjs +1 -0
- package/package.json +1 -1
- package/dist/__vite-browser-external-BXJKwL9l.js.map +0 -1
- package/dist/__vite-browser-external-p6FPCswx.cjs +0 -2
- package/dist/__vite-browser-external-p6FPCswx.cjs.map +0 -1
- package/dist/rolldown-runtime-C6qsp3rV.cjs +0 -1
package/dist/kerebron.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as __toESM, t as __commonJSMin } from "./rolldown-runtime-
|
|
1
|
+
import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-Dqa2HsxW.js";
|
|
2
2
|
//#region ../../node_modules/.deno/orderedmap@2.1.1/node_modules/orderedmap/dist/index.js
|
|
3
3
|
function OrderedMap(e) {
|
|
4
4
|
this.content = e;
|
|
@@ -6958,6 +6958,483 @@ var TrackSelecionPlugin = class extends Plugin {
|
|
|
6958
6958
|
}
|
|
6959
6959
|
});
|
|
6960
6960
|
}
|
|
6961
|
+
}, yaml_exports = /* @__PURE__ */ __exportAll({
|
|
6962
|
+
fromJSON: () => fromJSON,
|
|
6963
|
+
parse: () => parse$1,
|
|
6964
|
+
setPathValue: () => setPathValue,
|
|
6965
|
+
stringify: () => stringify,
|
|
6966
|
+
toJSON: () => toJSON
|
|
6967
|
+
}), findUnquotedColon = (e) => {
|
|
6968
|
+
let t = !1, n = !1;
|
|
6969
|
+
for (let r = 0; r < e.length; r++) {
|
|
6970
|
+
let a = e[r];
|
|
6971
|
+
if (a === "\"" && !t) n = !n;
|
|
6972
|
+
else if (a === "'" && !n) t = !t;
|
|
6973
|
+
else if (a === ":" && !t && !n) return r;
|
|
6974
|
+
}
|
|
6975
|
+
return -1;
|
|
6976
|
+
};
|
|
6977
|
+
function parse$1(e) {
|
|
6978
|
+
let t = e.replace(/\r\n/g, "\n").split("\n").filter((e) => e.trim().length > 0 && !e.trim().startsWith("#")), n = (e) => (e = e.trim(), e === "" || e === "null" ? null : e === "true" ? !0 : e === "false" ? !1 : isNaN(Number(e)) ? e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'") ? e.slice(1, -1) : e : Number(e)), r = 0, a = (e) => {
|
|
6979
|
+
let o = null, s = null;
|
|
6980
|
+
for (; r < t.length;) {
|
|
6981
|
+
let c = t[r], l = c.match(/^ */)?.[0].length ?? 0;
|
|
6982
|
+
if (l < e) break;
|
|
6983
|
+
let u = c.trim();
|
|
6984
|
+
if (u.startsWith("-")) {
|
|
6985
|
+
if (o === null && (o = [], s = !0), s === !1) throw Error("Mixed array/object structure");
|
|
6986
|
+
s = !0;
|
|
6987
|
+
let e = u.slice(1).trim();
|
|
6988
|
+
if (e === "") r++, o.push(a(l + 2));
|
|
6989
|
+
else {
|
|
6990
|
+
let s = findUnquotedColon(e);
|
|
6991
|
+
if (s === -1) o.push(n(e)), r++;
|
|
6992
|
+
else {
|
|
6993
|
+
let c = /* @__PURE__ */ new Map(), u = e.slice(0, s).trim(), d = e.slice(s + 1).trim();
|
|
6994
|
+
for (r++, c.set(u, d === "" ? a(l + 2) : n(d)); r < t.length;) {
|
|
6995
|
+
let e = t[r], o = e.match(/^ */)?.[0].length ?? 0;
|
|
6996
|
+
if (o <= l) break;
|
|
6997
|
+
let s = e.trim(), u = findUnquotedColon(s);
|
|
6998
|
+
if (u === -1) break;
|
|
6999
|
+
let d = s.slice(0, u).trim(), f = s.slice(u + 1).trim();
|
|
7000
|
+
r++, c.set(d, f === "" ? a(o + 2) : n(f));
|
|
7001
|
+
}
|
|
7002
|
+
o.push(c);
|
|
7003
|
+
}
|
|
7004
|
+
}
|
|
7005
|
+
continue;
|
|
7006
|
+
}
|
|
7007
|
+
let d = u.indexOf(":");
|
|
7008
|
+
if (d === -1) throw Error(`Invalid line: ${c}`);
|
|
7009
|
+
if (o === null && (o = /* @__PURE__ */ new Map(), s = !1), s === !0) throw Error("Mixed array/object structure");
|
|
7010
|
+
let f = u.slice(0, d).trim(), p = u.slice(d + 1).trim();
|
|
7011
|
+
r++, o.set(f, p === "" ? a(l + 2) : n(p));
|
|
7012
|
+
}
|
|
7013
|
+
return o ?? /* @__PURE__ */ new Map();
|
|
7014
|
+
};
|
|
7015
|
+
return a(0);
|
|
7016
|
+
}
|
|
7017
|
+
function stringify(e, t = 2) {
|
|
7018
|
+
e = fromJSON(e);
|
|
7019
|
+
let n = (e) => " ".repeat(e * t), r = (e) => typeof e == "object" && !!e && !Array.isArray(e), a = [];
|
|
7020
|
+
function o(e, t, c) {
|
|
7021
|
+
let l = c === void 0 ? n(t) : n(t) + c + ": ";
|
|
7022
|
+
if (e === null) {
|
|
7023
|
+
a.push(l + "null");
|
|
7024
|
+
return;
|
|
7025
|
+
}
|
|
7026
|
+
if (typeof e == "number" || typeof e == "boolean") {
|
|
7027
|
+
a.push(l + String(e));
|
|
7028
|
+
return;
|
|
7029
|
+
}
|
|
7030
|
+
if (typeof e == "string") {
|
|
7031
|
+
let t = /[:\s]/.test(e) ? `"${e}"` : e;
|
|
7032
|
+
a.push(l + t);
|
|
7033
|
+
return;
|
|
7034
|
+
}
|
|
7035
|
+
if (Array.isArray(e)) {
|
|
7036
|
+
c !== void 0 && (a.push(n(t) + c + ":"), t++);
|
|
7037
|
+
for (let c of e) Array.isArray(c) || r(c) ? (a.push(n(t) + "-"), o(c, t + 1)) : a.push(n(t) + "- " + s(c));
|
|
7038
|
+
return;
|
|
7039
|
+
}
|
|
7040
|
+
if (r(e)) {
|
|
7041
|
+
c !== void 0 && (a.push(n(t) + c + ":"), t++);
|
|
7042
|
+
for (let [n, r] of e) o(r, t, n);
|
|
7043
|
+
return;
|
|
7044
|
+
}
|
|
7045
|
+
a.push(l + String(e));
|
|
7046
|
+
}
|
|
7047
|
+
function s(e) {
|
|
7048
|
+
return e === null ? "null" : typeof e == "string" ? /[:\s]/.test(e) ? `"${e}"` : e : String(e);
|
|
7049
|
+
}
|
|
7050
|
+
return o(e, 0), a.join("\n");
|
|
7051
|
+
}
|
|
7052
|
+
function fromJSON(e) {
|
|
7053
|
+
if (e === null) return null;
|
|
7054
|
+
if (Array.isArray(e)) return e.map(fromJSON);
|
|
7055
|
+
if (typeof e == "object") {
|
|
7056
|
+
if (e instanceof Map) return e;
|
|
7057
|
+
let t = /* @__PURE__ */ new Map();
|
|
7058
|
+
for (let [n, r] of Object.entries(e)) t.set(n, fromJSON(r));
|
|
7059
|
+
return t;
|
|
7060
|
+
}
|
|
7061
|
+
if (typeof e == "string" || typeof e == "number" || typeof e == "boolean") return e;
|
|
7062
|
+
throw Error(`Unsupported JSON value: ${typeof e}`);
|
|
7063
|
+
}
|
|
7064
|
+
function toJSON(e) {
|
|
7065
|
+
if (e instanceof Map) {
|
|
7066
|
+
let t = {};
|
|
7067
|
+
for (let [n, r] of e) t[n] = toJSON(r);
|
|
7068
|
+
return t;
|
|
7069
|
+
}
|
|
7070
|
+
return Array.isArray(e) ? e.map(toJSON) : e;
|
|
7071
|
+
}
|
|
7072
|
+
function setPathValue(e, t, n) {
|
|
7073
|
+
let r = t.match(/[^.\[\]]+|\[\d+\]/g)?.map((e) => e.startsWith("[") ? Number(e.slice(1, -1)) : e) ?? [];
|
|
7074
|
+
if (r.length === 0) throw Error("empty path");
|
|
7075
|
+
if (!(e instanceof Map) && !Array.isArray(e)) throw Error("root must be Map or array");
|
|
7076
|
+
let a = e;
|
|
7077
|
+
for (let e = 0; e < r.length - 1; e++) {
|
|
7078
|
+
let n = r[e], o = typeof n == "number" ? Array.isArray(a) ? a[n] : void 0 : a instanceof Map ? a.get(n) : void 0;
|
|
7079
|
+
if (!(o instanceof Map) && !Array.isArray(o)) {
|
|
7080
|
+
if (o != null) throw console.log("next", o), Error(`"${n}" #${e} of "${t}" not container`);
|
|
7081
|
+
o = typeof r[e + 1] == "number" ? [] : /* @__PURE__ */ new Map(), typeof n == "number" ? a[n] = o : a.set(n, o);
|
|
7082
|
+
}
|
|
7083
|
+
a = o;
|
|
7084
|
+
}
|
|
7085
|
+
let o = r[r.length - 1];
|
|
7086
|
+
if (typeof o == "number") {
|
|
7087
|
+
if (!Array.isArray(a)) throw Error("target not array");
|
|
7088
|
+
for (; a.length <= o;) a.push(null);
|
|
7089
|
+
a[o] = n;
|
|
7090
|
+
} else {
|
|
7091
|
+
if (!(a instanceof Map)) throw Error("target not map");
|
|
7092
|
+
a.set(o, n);
|
|
7093
|
+
}
|
|
7094
|
+
}
|
|
7095
|
+
//#endregion
|
|
7096
|
+
//#region ../editor/src/search/query.ts
|
|
7097
|
+
var SearchQuery = class {
|
|
7098
|
+
search;
|
|
7099
|
+
caseSensitive;
|
|
7100
|
+
literal;
|
|
7101
|
+
regexp;
|
|
7102
|
+
replace;
|
|
7103
|
+
valid;
|
|
7104
|
+
wholeWord;
|
|
7105
|
+
filter;
|
|
7106
|
+
impl;
|
|
7107
|
+
constructor(e) {
|
|
7108
|
+
this.search = e.search, this.caseSensitive = !!e.caseSensitive, this.literal = !!e.literal, this.regexp = !!e.regexp, this.replace = e.replace || "", this.valid = !!this.search && !(this.regexp && !validRegExp(this.search)), this.wholeWord = !!e.wholeWord, this.filter = e.filter || null, this.impl = this.valid ? this.regexp ? new RegExpQuery(this) : new StringQuery(this) : nullQuery;
|
|
7109
|
+
}
|
|
7110
|
+
eq(e) {
|
|
7111
|
+
return this.search == e.search && this.replace == e.replace && this.caseSensitive == e.caseSensitive && this.regexp == e.regexp && this.wholeWord == e.wholeWord;
|
|
7112
|
+
}
|
|
7113
|
+
findNext(e, t = 0, n = e.doc.content.size) {
|
|
7114
|
+
for (;;) {
|
|
7115
|
+
if (t >= n) return null;
|
|
7116
|
+
let r = this.impl.findNext(e, t, n);
|
|
7117
|
+
if (!r || this.checkResult(e, r)) return r;
|
|
7118
|
+
t = r.from + 1;
|
|
7119
|
+
}
|
|
7120
|
+
}
|
|
7121
|
+
findPrev(e, t = e.doc.content.size, n = 0) {
|
|
7122
|
+
for (;;) {
|
|
7123
|
+
if (t <= n) return null;
|
|
7124
|
+
let r = this.impl.findPrev(e, t, n);
|
|
7125
|
+
if (!r || this.checkResult(e, r)) return r;
|
|
7126
|
+
t = r.to - 1;
|
|
7127
|
+
}
|
|
7128
|
+
}
|
|
7129
|
+
checkResult(e, t) {
|
|
7130
|
+
return (!this.wholeWord || checkWordBoundary(e, t.from) && checkWordBoundary(e, t.to)) && (!this.filter || this.filter(e, t));
|
|
7131
|
+
}
|
|
7132
|
+
unquote(e) {
|
|
7133
|
+
return this.literal ? e : e.replace(/\\([nrt\\])/g, (e, t) => t == "n" ? "\n" : t == "r" ? "\r" : t == "t" ? " " : "\\");
|
|
7134
|
+
}
|
|
7135
|
+
getReplacements(e, t) {
|
|
7136
|
+
let n = e.doc.resolve(t.from).marksAcross(e.doc.resolve(t.to)), r = [], a = Fragment.empty, o = t.from, { match: s } = t, c = s ? getGroupIndices(s) : [[0, t.to - t.from]], l = parseReplacement(this.unquote(this.replace)), u;
|
|
7137
|
+
for (let s of l) if (typeof s == "string") a = a.addToEnd(e.schema.text(s, n));
|
|
7138
|
+
else if (u = c[s.group], u) {
|
|
7139
|
+
let n = t.matchStart + u[0], c = t.matchStart + u[1];
|
|
7140
|
+
s.copy ? a = a.append(e.doc.slice(n, c).content) : ((a != Fragment.empty || n > o) && (r.push({
|
|
7141
|
+
from: o,
|
|
7142
|
+
to: n,
|
|
7143
|
+
insert: new Slice(a, 0, 0)
|
|
7144
|
+
}), a = Fragment.empty), o = c);
|
|
7145
|
+
}
|
|
7146
|
+
return (a != Fragment.empty || o < t.to) && r.push({
|
|
7147
|
+
from: o,
|
|
7148
|
+
to: t.to,
|
|
7149
|
+
insert: new Slice(a, 0, 0)
|
|
7150
|
+
}), r;
|
|
7151
|
+
}
|
|
7152
|
+
}, nullQuery = new class {
|
|
7153
|
+
findNext() {
|
|
7154
|
+
return null;
|
|
7155
|
+
}
|
|
7156
|
+
findPrev() {
|
|
7157
|
+
return null;
|
|
7158
|
+
}
|
|
7159
|
+
}(), StringQuery = class {
|
|
7160
|
+
query;
|
|
7161
|
+
string;
|
|
7162
|
+
constructor(e) {
|
|
7163
|
+
this.query = e;
|
|
7164
|
+
let t = e.unquote(e.search);
|
|
7165
|
+
e.caseSensitive || (t = t.toLowerCase()), this.string = t;
|
|
7166
|
+
}
|
|
7167
|
+
findNext(e, t, n) {
|
|
7168
|
+
return scanTextblocks(e.doc, t, n, (e, r) => {
|
|
7169
|
+
let a = Math.max(t, r), o = textContent(e).slice(a - r, Math.min(e.content.size, n - r)), s = (this.query.caseSensitive ? o : o.toLowerCase()).indexOf(this.string);
|
|
7170
|
+
return s < 0 ? null : {
|
|
7171
|
+
from: a + s,
|
|
7172
|
+
to: a + s + this.string.length,
|
|
7173
|
+
match: null,
|
|
7174
|
+
matchStart: r
|
|
7175
|
+
};
|
|
7176
|
+
});
|
|
7177
|
+
}
|
|
7178
|
+
findPrev(e, t, n) {
|
|
7179
|
+
return scanTextblocks(e.doc, t, n, (e, r) => {
|
|
7180
|
+
let a = Math.max(r, n), o = textContent(e).slice(a - r, Math.min(e.content.size, t - r));
|
|
7181
|
+
this.query.caseSensitive || (o = o.toLowerCase());
|
|
7182
|
+
let s = o.lastIndexOf(this.string);
|
|
7183
|
+
return s < 0 ? null : {
|
|
7184
|
+
from: a + s,
|
|
7185
|
+
to: a + s + this.string.length,
|
|
7186
|
+
match: null,
|
|
7187
|
+
matchStart: r
|
|
7188
|
+
};
|
|
7189
|
+
});
|
|
7190
|
+
}
|
|
7191
|
+
}, baseFlags = "g" + (/x/.unicode == null ? "" : "u") + (/x/.hasIndices == null ? "" : "d"), RegExpQuery = class {
|
|
7192
|
+
query;
|
|
7193
|
+
regexp;
|
|
7194
|
+
constructor(e) {
|
|
7195
|
+
this.query = e, this.regexp = new RegExp(e.search, baseFlags + (e.caseSensitive ? "" : "i"));
|
|
7196
|
+
}
|
|
7197
|
+
findNext(e, t, n) {
|
|
7198
|
+
return scanTextblocks(e.doc, t, n, (e, r) => {
|
|
7199
|
+
let a = textContent(e).slice(0, Math.min(e.content.size, n - r));
|
|
7200
|
+
this.regexp.lastIndex = t - r;
|
|
7201
|
+
let o = this.regexp.exec(a);
|
|
7202
|
+
return o ? {
|
|
7203
|
+
from: r + o.index,
|
|
7204
|
+
to: r + o.index + o[0].length,
|
|
7205
|
+
match: o,
|
|
7206
|
+
matchStart: r
|
|
7207
|
+
} : null;
|
|
7208
|
+
});
|
|
7209
|
+
}
|
|
7210
|
+
findPrev(e, t, n) {
|
|
7211
|
+
return scanTextblocks(e.doc, t, n, (e, n) => {
|
|
7212
|
+
let r = textContent(e).slice(0, Math.min(e.content.size, t - n)), a;
|
|
7213
|
+
for (let e = 0;;) {
|
|
7214
|
+
this.regexp.lastIndex = e;
|
|
7215
|
+
let t = this.regexp.exec(r);
|
|
7216
|
+
if (!t) break;
|
|
7217
|
+
a = t, e = t.index + 1;
|
|
7218
|
+
}
|
|
7219
|
+
return a ? {
|
|
7220
|
+
from: n + a.index,
|
|
7221
|
+
to: n + a.index + a[0].length,
|
|
7222
|
+
match: a,
|
|
7223
|
+
matchStart: n
|
|
7224
|
+
} : null;
|
|
7225
|
+
});
|
|
7226
|
+
}
|
|
7227
|
+
};
|
|
7228
|
+
function getGroupIndices(e) {
|
|
7229
|
+
if (e.indices) return e.indices;
|
|
7230
|
+
let t = [[0, e[0].length]];
|
|
7231
|
+
for (let n = 1, r = 0; n < e.length; n++) {
|
|
7232
|
+
let a = e[n] ? e[0].indexOf(e[n], r) : -1;
|
|
7233
|
+
t.push(a < 0 ? void 0 : [a, r = a + e[n].length]);
|
|
7234
|
+
}
|
|
7235
|
+
return t;
|
|
7236
|
+
}
|
|
7237
|
+
function parseReplacement(e) {
|
|
7238
|
+
let t = [], n = -1;
|
|
7239
|
+
function r(e) {
|
|
7240
|
+
let n = t.length - 1;
|
|
7241
|
+
n > -1 && typeof t[n] == "string" ? t[n] += e : t.push(e);
|
|
7242
|
+
}
|
|
7243
|
+
for (; e.length;) {
|
|
7244
|
+
let a = /\$([$&\d+])/.exec(e);
|
|
7245
|
+
if (!a) return r(e), t;
|
|
7246
|
+
if (a.index > 0 && r(e.slice(0, a.index + +(a[1] == "$"))), a[1] != "$") {
|
|
7247
|
+
let e = a[1] == "&" ? 0 : +a[1];
|
|
7248
|
+
n >= e ? t.push({
|
|
7249
|
+
group: e,
|
|
7250
|
+
copy: !0
|
|
7251
|
+
}) : (n = e || 1e3, t.push({
|
|
7252
|
+
group: e,
|
|
7253
|
+
copy: !1
|
|
7254
|
+
}));
|
|
7255
|
+
}
|
|
7256
|
+
e = e.slice(a.index + a[0].length);
|
|
7257
|
+
}
|
|
7258
|
+
return t;
|
|
7259
|
+
}
|
|
7260
|
+
function validRegExp(e) {
|
|
7261
|
+
try {
|
|
7262
|
+
return new RegExp(e, baseFlags), !0;
|
|
7263
|
+
} catch {
|
|
7264
|
+
return !1;
|
|
7265
|
+
}
|
|
7266
|
+
}
|
|
7267
|
+
var TextContentCache = /* @__PURE__ */ new WeakMap();
|
|
7268
|
+
function textContent(e) {
|
|
7269
|
+
let t = TextContentCache.get(e);
|
|
7270
|
+
if (t) return t;
|
|
7271
|
+
let n = "";
|
|
7272
|
+
for (let t = 0; t < e.childCount; t++) {
|
|
7273
|
+
let r = e.child(t);
|
|
7274
|
+
r.isText ? n += r.text : r.isLeaf ? n += "" : n += " " + textContent(r) + " ";
|
|
7275
|
+
}
|
|
7276
|
+
return TextContentCache.set(e, n), n;
|
|
7277
|
+
}
|
|
7278
|
+
function scanTextblocks(e, t, n, r, a = 0) {
|
|
7279
|
+
if (e.inlineContent) return r(e, a);
|
|
7280
|
+
if (!e.isLeaf) if (t > n) for (let o = e.childCount - 1, s = a + e.content.size; o >= 0 && s > n; o--) {
|
|
7281
|
+
let a = e.child(o);
|
|
7282
|
+
if (s -= a.nodeSize, s < t) {
|
|
7283
|
+
let e = scanTextblocks(a, t, n, r, s + 1);
|
|
7284
|
+
if (e != null) return e;
|
|
7285
|
+
}
|
|
7286
|
+
}
|
|
7287
|
+
else for (let o = 0, s = a; o < e.childCount && s < n; o++) {
|
|
7288
|
+
let a = e.child(o), c = s;
|
|
7289
|
+
if (s += a.nodeSize, s > t) {
|
|
7290
|
+
let e = scanTextblocks(a, t, n, r, c + 1);
|
|
7291
|
+
if (e != null) return e;
|
|
7292
|
+
}
|
|
7293
|
+
}
|
|
7294
|
+
return null;
|
|
7295
|
+
}
|
|
7296
|
+
function checkWordBoundary(e, t) {
|
|
7297
|
+
let n = e.doc.resolve(t), r = n.nodeBefore, a = n.nodeAfter;
|
|
7298
|
+
return !r || !a || !r.isText || !a.isText ? !0 : !/\p{L}$/u.test(r.text) || !/^\p{L}/u.test(a.text);
|
|
7299
|
+
}
|
|
7300
|
+
//#endregion
|
|
7301
|
+
//#region ../editor/src/search/search.ts
|
|
7302
|
+
var SearchState = class {
|
|
7303
|
+
query;
|
|
7304
|
+
range;
|
|
7305
|
+
deco;
|
|
7306
|
+
constructor(e, t, n) {
|
|
7307
|
+
this.query = e, this.range = t, this.deco = n;
|
|
7308
|
+
}
|
|
7309
|
+
};
|
|
7310
|
+
function buildMatchDeco(e, t, n) {
|
|
7311
|
+
if (!t.valid) return DecorationSet.empty;
|
|
7312
|
+
let r = [], a = e.selection;
|
|
7313
|
+
for (let o = n ? n.from : 0, s = n ? n.to : e.doc.content.size;;) {
|
|
7314
|
+
let n = t.findNext(e, o, s);
|
|
7315
|
+
if (!n) break;
|
|
7316
|
+
let c = n.from == a.from && n.to == a.to ? "kb-active-search-match" : "kb-search-match";
|
|
7317
|
+
r.push(Decoration.inline(n.from, n.to, { class: c })), o = n.to;
|
|
7318
|
+
}
|
|
7319
|
+
return DecorationSet.create(e.doc, r);
|
|
7320
|
+
}
|
|
7321
|
+
var searchKey = new PluginKey("search");
|
|
7322
|
+
function createSearchPlugin(e = {}) {
|
|
7323
|
+
return new Plugin({
|
|
7324
|
+
key: searchKey,
|
|
7325
|
+
state: {
|
|
7326
|
+
init(t, n) {
|
|
7327
|
+
let r = e.initialQuery || new SearchQuery({ search: "" }), a = e.initialRange || null;
|
|
7328
|
+
return new SearchState(r, a, buildMatchDeco(n, r, a));
|
|
7329
|
+
},
|
|
7330
|
+
apply(e, t, n, r) {
|
|
7331
|
+
let a = e.getMeta(searchKey);
|
|
7332
|
+
if (a) return new SearchState(a.query, a.range, buildMatchDeco(r, a.query, a.range));
|
|
7333
|
+
if (e.docChanged || e.selectionSet) {
|
|
7334
|
+
let n = t.range;
|
|
7335
|
+
if (n) {
|
|
7336
|
+
let t = e.mapping.map(n.from, 1), r = e.mapping.map(n.to, -1);
|
|
7337
|
+
n = t < r ? {
|
|
7338
|
+
from: t,
|
|
7339
|
+
to: r
|
|
7340
|
+
} : null;
|
|
7341
|
+
}
|
|
7342
|
+
t = new SearchState(t.query, n, buildMatchDeco(r, t.query, n));
|
|
7343
|
+
}
|
|
7344
|
+
return t;
|
|
7345
|
+
}
|
|
7346
|
+
},
|
|
7347
|
+
props: { decorations: (e) => searchKey.getState(e).deco }
|
|
7348
|
+
});
|
|
7349
|
+
}
|
|
7350
|
+
function setSearchState(e, t, n = null) {
|
|
7351
|
+
return e.setMeta(searchKey, {
|
|
7352
|
+
query: t,
|
|
7353
|
+
range: n
|
|
7354
|
+
});
|
|
7355
|
+
}
|
|
7356
|
+
function nextMatch(e, t, n, r, a) {
|
|
7357
|
+
let o = e.range || {
|
|
7358
|
+
from: 0,
|
|
7359
|
+
to: t.doc.content.size
|
|
7360
|
+
}, s = e.query.findNext(t, Math.max(a, o.from), o.to);
|
|
7361
|
+
return !s && n && (s = e.query.findNext(t, o.from, Math.min(r, o.to))), s;
|
|
7362
|
+
}
|
|
7363
|
+
function prevMatch(e, t, n, r, a) {
|
|
7364
|
+
let o = e.range || {
|
|
7365
|
+
from: 0,
|
|
7366
|
+
to: t.doc.content.size
|
|
7367
|
+
}, s = e.query.findPrev(t, Math.min(r, o.to), o.from);
|
|
7368
|
+
return !s && n && (s = e.query.findPrev(t, o.to, Math.max(a, o.from))), s;
|
|
7369
|
+
}
|
|
7370
|
+
function findCommand(e, t) {
|
|
7371
|
+
return (n, r) => {
|
|
7372
|
+
let a = searchKey.getState(n);
|
|
7373
|
+
if (!a || !a.query.valid) return !1;
|
|
7374
|
+
let { from: o, to: s } = n.selection, c = t > 0 ? nextMatch(a, n, e, o, s) : prevMatch(a, n, e, o, s);
|
|
7375
|
+
if (!c) return !1;
|
|
7376
|
+
let l = TextSelection.create(n.doc, c.from, c.to);
|
|
7377
|
+
return r && r(n.tr.setSelection(l).scrollIntoView()), !0;
|
|
7378
|
+
};
|
|
7379
|
+
}
|
|
7380
|
+
var findNext = findCommand(!0, 1), findNextNoWrap = findCommand(!1, 1), findPrev = findCommand(!0, -1), findPrevNoWrap = findCommand(!1, -1);
|
|
7381
|
+
function replaceCommand(e, t) {
|
|
7382
|
+
return (n, r) => {
|
|
7383
|
+
let a = searchKey.getState(n);
|
|
7384
|
+
if (!a || !a.query.valid) return !1;
|
|
7385
|
+
let { from: o } = n.selection, s = nextMatch(a, n, e, o, o);
|
|
7386
|
+
if (!s) return !1;
|
|
7387
|
+
if (!r) return !0;
|
|
7388
|
+
if (n.selection.from == s.from && n.selection.to == s.to) {
|
|
7389
|
+
let o = n.tr, c = a.query.getReplacements(n, s);
|
|
7390
|
+
for (let e = c.length - 1; e >= 0; e--) {
|
|
7391
|
+
let { from: t, to: n, insert: r } = c[e];
|
|
7392
|
+
o.replace(t, n, r);
|
|
7393
|
+
}
|
|
7394
|
+
let l = t && nextMatch(a, n, e, s.from, s.to);
|
|
7395
|
+
l ? o.setSelection(TextSelection.create(o.doc, o.mapping.map(l.from, 1), o.mapping.map(l.to, -1))) : o.setSelection(TextSelection.create(o.doc, s.from, o.mapping.map(s.to, 1))), r(o.scrollIntoView());
|
|
7396
|
+
} else if (t) r(n.tr.setSelection(TextSelection.create(n.doc, s.from, s.to)).scrollIntoView());
|
|
7397
|
+
else return !1;
|
|
7398
|
+
return !0;
|
|
7399
|
+
};
|
|
7400
|
+
}
|
|
7401
|
+
var replaceNext = replaceCommand(!0, !0), replaceNextNoWrap = replaceCommand(!1, !0), replaceCurrent = replaceCommand(!1, !1), replaceAll = (e, t) => {
|
|
7402
|
+
let n = searchKey.getState(e);
|
|
7403
|
+
if (!n) return !1;
|
|
7404
|
+
let r = [], a = n.range || {
|
|
7405
|
+
from: 0,
|
|
7406
|
+
to: e.doc.content.size
|
|
7407
|
+
};
|
|
7408
|
+
for (let t = a.from;;) {
|
|
7409
|
+
let o = n.query.findNext(e, t, a.to);
|
|
7410
|
+
if (!o) break;
|
|
7411
|
+
r.push(o), t = o.to;
|
|
7412
|
+
}
|
|
7413
|
+
if (t) {
|
|
7414
|
+
let a = e.tr;
|
|
7415
|
+
for (let t = r.length - 1; t >= 0; t--) {
|
|
7416
|
+
let o = r[t], s = n.query.getReplacements(e, o);
|
|
7417
|
+
for (let e = s.length - 1; e >= 0; e--) {
|
|
7418
|
+
let { from: t, to: n, insert: r } = s[e];
|
|
7419
|
+
a.replace(t, n, r);
|
|
7420
|
+
}
|
|
7421
|
+
}
|
|
7422
|
+
t(a);
|
|
7423
|
+
}
|
|
7424
|
+
return !0;
|
|
7425
|
+
}, searchFactory = (e, t = null) => (n, r) => {
|
|
7426
|
+
let a = n.tr;
|
|
7427
|
+
return setSearchState(a, e, t), r && r(a), !0;
|
|
7428
|
+
}, searchCommandFactories = {
|
|
7429
|
+
search: searchFactory,
|
|
7430
|
+
findNext: () => findNext,
|
|
7431
|
+
findNextNoWrap: () => findNextNoWrap,
|
|
7432
|
+
findPrev: () => findPrev,
|
|
7433
|
+
findPrevNoWrap: () => findPrevNoWrap,
|
|
7434
|
+
replaceNext: () => replaceNext,
|
|
7435
|
+
replaceNextNoWrap: () => replaceNextNoWrap,
|
|
7436
|
+
replaceCurrent: () => replaceCurrent,
|
|
7437
|
+
replaceAll: () => replaceAll
|
|
6961
7438
|
};
|
|
6962
7439
|
//#endregion
|
|
6963
7440
|
//#region ../editor/src/ExtensionManager.ts
|
|
@@ -7016,7 +7493,7 @@ var ExtensionManager = class {
|
|
|
7016
7493
|
let t = r.get(e);
|
|
7017
7494
|
t && r.set(e, firstCommand$1((t, n, r) => (console.debug(`Key: ${e}`), !0), t));
|
|
7018
7495
|
}
|
|
7019
|
-
this.converters = o, this.plugins.push(new InputRulesPlugin(n)), this.plugins.push(new KeymapPlugin(Object.fromEntries(r))), this.plugins.push(new TrackSelecionPlugin(e));
|
|
7496
|
+
this.converters = o, this.plugins.push(new InputRulesPlugin(n)), this.plugins.push(new KeymapPlugin(Object.fromEntries(r))), this.plugins.push(createSearchPlugin()), this.plugins.push(new TrackSelecionPlugin(e));
|
|
7020
7497
|
}
|
|
7021
7498
|
setupExtensions(e) {
|
|
7022
7499
|
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
@@ -7077,7 +7554,7 @@ var ExtensionManager = class {
|
|
|
7077
7554
|
for (let t of e.conflicts) if (a.find((e) => e.name === t)) throw Error(`Extension conflict: ${e.name} vs ${t}`);
|
|
7078
7555
|
}
|
|
7079
7556
|
for (let t of a) e.ci.register(t.name, t);
|
|
7080
|
-
this.initPlugins(e, t);
|
|
7557
|
+
e.ci.register("yaml", yaml_exports), this.initPlugins(e, t);
|
|
7081
7558
|
for (let e of this.extensions) e.created();
|
|
7082
7559
|
}
|
|
7083
7560
|
};
|
|
@@ -7579,7 +8056,7 @@ var insertBlockBefore = (e, t) => (n, r) => {
|
|
|
7579
8056
|
run = {};
|
|
7580
8057
|
debug = !0;
|
|
7581
8058
|
constructor(e) {
|
|
7582
|
-
this.editor = e, this.mergeCommandFactories(baseCommandFactories, "baseCommand"), this.mergeCommandFactories(keyCommandFactories, "key"), this.mergeCommandFactories(replaceCommandFactories, "replace");
|
|
8059
|
+
this.editor = e, this.mergeCommandFactories(baseCommandFactories, "baseCommand"), this.mergeCommandFactories(keyCommandFactories, "key"), this.mergeCommandFactories(replaceCommandFactories, "replace"), this.mergeCommandFactories(searchCommandFactories, "search");
|
|
7583
8060
|
}
|
|
7584
8061
|
mergeCommandFactories(e, t) {
|
|
7585
8062
|
for (let n in e) {
|
|
@@ -8102,6 +8579,9 @@ var CoreEditor = class e extends EventTarget {
|
|
|
8102
8579
|
let n = await this.getConverter(e).toDoc(t), r = this.state.tr;
|
|
8103
8580
|
r.replaceWith(0, this.state.doc.content.size, n.content), this.dispatchTransaction(r);
|
|
8104
8581
|
}
|
|
8582
|
+
getMediaTypes() {
|
|
8583
|
+
return Object.keys(this.extensionManager.converters);
|
|
8584
|
+
}
|
|
8105
8585
|
patchDocumentText(e, t) {
|
|
8106
8586
|
return this.patchDocument(e, new TextEncoder().encode(t));
|
|
8107
8587
|
}
|
|
@@ -8693,168 +9173,6 @@ var ExtensionGapcursor = class extends Extension {
|
|
|
8693
9173
|
getProseMirrorPlugins() {
|
|
8694
9174
|
return [gapCursor()];
|
|
8695
9175
|
}
|
|
8696
|
-
};
|
|
8697
|
-
//#endregion
|
|
8698
|
-
//#region ../extension-basic-editor/src/ExtensionHtml.ts
|
|
8699
|
-
function getHTMLFromFragment(e, t) {
|
|
8700
|
-
let n = globalThis.document, r = DOMSerializer.fromSchema(t).serializeFragment(e, { document: n }), a = n.implementation.createHTMLDocument().createElement("div");
|
|
8701
|
-
return a.appendChild(r), a.innerHTML;
|
|
8702
|
-
}
|
|
8703
|
-
var removeWhitespaces$1 = (e) => {
|
|
8704
|
-
let t = e.childNodes;
|
|
8705
|
-
for (let n = t.length - 1; n >= 0; --n) {
|
|
8706
|
-
let r = t[n];
|
|
8707
|
-
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && removeWhitespaces$1(r);
|
|
8708
|
-
}
|
|
8709
|
-
return e;
|
|
8710
|
-
};
|
|
8711
|
-
function elementFromString$1(e) {
|
|
8712
|
-
let t = `<html lang="en"><body>${e}</body></html>`, n = new globalThis.DOMParser().parseFromString(t, "text/html").body;
|
|
8713
|
-
return removeWhitespaces$1(n);
|
|
8714
|
-
}
|
|
8715
|
-
function prepareContentCheckSchema(e) {
|
|
8716
|
-
return new Schema({
|
|
8717
|
-
topNode: e.spec.topNode,
|
|
8718
|
-
marks: e.spec.marks,
|
|
8719
|
-
nodes: e.spec.nodes.append({ __unknown__catch__all__node: {
|
|
8720
|
-
content: "inline*",
|
|
8721
|
-
group: "block",
|
|
8722
|
-
parseDOM: [{
|
|
8723
|
-
tag: "*",
|
|
8724
|
-
getAttrs: (e) => {
|
|
8725
|
-
let t = typeof e == "string" ? e : e.outerHTML;
|
|
8726
|
-
throw Error("Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${t}`) });
|
|
8727
|
-
}
|
|
8728
|
-
}]
|
|
8729
|
-
} })
|
|
8730
|
-
});
|
|
8731
|
-
}
|
|
8732
|
-
function createNodeFromHTML(e, t, n) {
|
|
8733
|
-
if (n = {
|
|
8734
|
-
parseOptions: {},
|
|
8735
|
-
...n
|
|
8736
|
-
}, n.errorOnInvalidContent) {
|
|
8737
|
-
let r = prepareContentCheckSchema(t);
|
|
8738
|
-
DOMParser$1.fromSchema(r).parse(elementFromString$1(e), n.parseOptions);
|
|
8739
|
-
}
|
|
8740
|
-
return DOMParser$1.fromSchema(t).parse(elementFromString$1(e), n.parseOptions);
|
|
8741
|
-
}
|
|
8742
|
-
var ExtensionHtml = class extends Extension {
|
|
8743
|
-
name = "html";
|
|
8744
|
-
getConverters(e, t) {
|
|
8745
|
-
return { "text/html": {
|
|
8746
|
-
fromDoc: async (t) => {
|
|
8747
|
-
let n = getHTMLFromFragment(t.content, e.schema);
|
|
8748
|
-
return new TextEncoder().encode(n);
|
|
8749
|
-
},
|
|
8750
|
-
toDoc: async (t) => createNodeFromHTML(new TextDecoder().decode(t), e.schema)
|
|
8751
|
-
} };
|
|
8752
|
-
}
|
|
8753
|
-
}, mediaUploadKey = new PluginKey("mediaUpload");
|
|
8754
|
-
function fileToDataURL(e) {
|
|
8755
|
-
return new Promise((t, n) => {
|
|
8756
|
-
let r = new FileReader();
|
|
8757
|
-
r.onload = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
|
|
8758
|
-
});
|
|
8759
|
-
}
|
|
8760
|
-
function fileToObjectURL(e) {
|
|
8761
|
-
return URL.createObjectURL(e);
|
|
8762
|
-
}
|
|
8763
|
-
function isImage(e, t) {
|
|
8764
|
-
return t.some((t) => e.type.match(t));
|
|
8765
|
-
}
|
|
8766
|
-
function isVideo(e, t) {
|
|
8767
|
-
return t.some((t) => e.type.match(t));
|
|
8768
|
-
}
|
|
8769
|
-
function insertImage(e, t, n, r, a) {
|
|
8770
|
-
let { schema: o } = e.state, s = o.nodes.image;
|
|
8771
|
-
if (!s) {
|
|
8772
|
-
console.warn("Image node type not found in schema");
|
|
8773
|
-
return;
|
|
8774
|
-
}
|
|
8775
|
-
let c = s.create({
|
|
8776
|
-
src: n,
|
|
8777
|
-
alt: r,
|
|
8778
|
-
title: a
|
|
8779
|
-
}), l = e.state.tr.insert(t, c);
|
|
8780
|
-
e.dispatch(l);
|
|
8781
|
-
}
|
|
8782
|
-
function insertVideo(e, t, n, r, a, o) {
|
|
8783
|
-
let { schema: s } = e.state, c = s.nodes.video;
|
|
8784
|
-
if (!c) {
|
|
8785
|
-
console.warn("Video node type not found in schema");
|
|
8786
|
-
return;
|
|
8787
|
-
}
|
|
8788
|
-
let l = c.create({
|
|
8789
|
-
src: n,
|
|
8790
|
-
title: r,
|
|
8791
|
-
width: a,
|
|
8792
|
-
height: o,
|
|
8793
|
-
controls: !0
|
|
8794
|
-
}), u = e.state.tr.insert(t, l);
|
|
8795
|
-
e.dispatch(u);
|
|
8796
|
-
}
|
|
8797
|
-
async function handleMediaFiles(e, t, n, r) {
|
|
8798
|
-
let { maxFileSize: a = 10 * 1024 * 1024, maxVideoFileSize: o = 50 * 1024 * 1024, allowedImageTypes: s = ["^image/"], allowedVideoTypes: c = ["^video/"], uploadHandler: l } = r;
|
|
8799
|
-
for (let u of t) {
|
|
8800
|
-
let t = isImage(u, s), d = isVideo(u, c);
|
|
8801
|
-
if (!t && !d) continue;
|
|
8802
|
-
let f = d ? o : a;
|
|
8803
|
-
if (u.size > f) {
|
|
8804
|
-
console.warn(`${d ? "Video" : "Image"} file "${u.name}" is too large (${(u.size / 1024 / 1024).toFixed(2)}MB). Maximum size is ${(f / 1024 / 1024).toFixed(2)}MB.`);
|
|
8805
|
-
continue;
|
|
8806
|
-
}
|
|
8807
|
-
try {
|
|
8808
|
-
console.log(`Processing ${d ? "video" : "image"}: ${u.name} (${(u.size / 1024 / 1024).toFixed(2)}MB, ${u.type})`);
|
|
8809
|
-
let t;
|
|
8810
|
-
l ? t = await l(u) : d && r.useObjectURLForVideos !== !1 ? (t = fileToObjectURL(u), console.log("Using object URL for video:", t)) : (t = await fileToDataURL(u), console.log(`${d ? "Video" : "Image"} converted to data URL, length: ${t.length} characters`)), d ? (insertVideo(e, n, t, u.name), console.log("Video inserted into editor")) : (insertImage(e, n, t, u.name), console.log("Image inserted into editor")), n += 1;
|
|
8811
|
-
} catch (e) {
|
|
8812
|
-
console.error(`Failed to process ${d ? "video" : "image"} "${u.name}":`, e);
|
|
8813
|
-
}
|
|
8814
|
-
}
|
|
8815
|
-
}
|
|
8816
|
-
function createMediaUploadPlugin(e = {}) {
|
|
8817
|
-
return new Plugin({
|
|
8818
|
-
key: mediaUploadKey,
|
|
8819
|
-
props: {
|
|
8820
|
-
handleDrop(t, n, r, a) {
|
|
8821
|
-
if (a) return !1;
|
|
8822
|
-
let o = Array.from(n.dataTransfer?.files || []);
|
|
8823
|
-
if (o.length === 0) return !1;
|
|
8824
|
-
let { allowedImageTypes: s = ["^image/"], allowedVideoTypes: c = ["^video/"] } = e;
|
|
8825
|
-
if (!o.some((e) => isImage(e, s) || isVideo(e, c))) return !1;
|
|
8826
|
-
n.preventDefault();
|
|
8827
|
-
let l = {
|
|
8828
|
-
left: n.clientX,
|
|
8829
|
-
top: n.clientY
|
|
8830
|
-
}, u = t.posAtCoords(l);
|
|
8831
|
-
return u ? (handleMediaFiles(t, o, u.pos, e), !0) : !1;
|
|
8832
|
-
},
|
|
8833
|
-
handlePaste(t, n, r) {
|
|
8834
|
-
let a = Array.from(n.clipboardData?.items || []).filter((e) => e.type.startsWith("image/"));
|
|
8835
|
-
if (a.length === 0) return !1;
|
|
8836
|
-
n.preventDefault();
|
|
8837
|
-
let o = [];
|
|
8838
|
-
for (let e of a) {
|
|
8839
|
-
let t = e.getAsFile();
|
|
8840
|
-
t && o.push(t);
|
|
8841
|
-
}
|
|
8842
|
-
if (o.length === 0) return !1;
|
|
8843
|
-
let { from: s } = t.state.selection;
|
|
8844
|
-
return handleMediaFiles(t, o, s, e), !0;
|
|
8845
|
-
}
|
|
8846
|
-
}
|
|
8847
|
-
});
|
|
8848
|
-
}
|
|
8849
|
-
var ExtensionMediaUpload = class extends Extension {
|
|
8850
|
-
config;
|
|
8851
|
-
name = "mediaUpload";
|
|
8852
|
-
constructor(e = {}) {
|
|
8853
|
-
super(e), this.config = e;
|
|
8854
|
-
}
|
|
8855
|
-
getProseMirrorPlugins() {
|
|
8856
|
-
return [createMediaUploadPlugin(this.config)];
|
|
8857
|
-
}
|
|
8858
9176
|
}, ExtensionTextAlign = class extends Extension {
|
|
8859
9177
|
name = "textAlign";
|
|
8860
9178
|
getCommandFactories(e) {
|
|
@@ -9086,6 +9404,290 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
|
|
|
9086
9404
|
getProseMirrorPlugins() {
|
|
9087
9405
|
return [createPairingPlugin(["shortcode_inline"])];
|
|
9088
9406
|
}
|
|
9407
|
+
};
|
|
9408
|
+
//#endregion
|
|
9409
|
+
//#region ../extension-basic-editor/src/media/ExtensionHtml.ts
|
|
9410
|
+
function getHTMLFromFragment(e, t) {
|
|
9411
|
+
let n = globalThis.document, r = DOMSerializer.fromSchema(t).serializeFragment(e, { document: n }), a = n.implementation.createHTMLDocument().createElement("div");
|
|
9412
|
+
return a.appendChild(r), a.innerHTML;
|
|
9413
|
+
}
|
|
9414
|
+
var removeWhitespaces$1 = (e) => {
|
|
9415
|
+
let t = e.childNodes;
|
|
9416
|
+
for (let n = t.length - 1; n >= 0; --n) {
|
|
9417
|
+
let r = t[n];
|
|
9418
|
+
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && removeWhitespaces$1(r);
|
|
9419
|
+
}
|
|
9420
|
+
return e;
|
|
9421
|
+
};
|
|
9422
|
+
function elementFromString$1(e) {
|
|
9423
|
+
let t = `<html lang="en"><body>${e}</body></html>`, n = new globalThis.DOMParser().parseFromString(t, "text/html").body;
|
|
9424
|
+
return removeWhitespaces$1(n);
|
|
9425
|
+
}
|
|
9426
|
+
var ExtensionHtml = class extends Extension {
|
|
9427
|
+
name = "html";
|
|
9428
|
+
getConverters(e, t) {
|
|
9429
|
+
return { "text/html": {
|
|
9430
|
+
fromDoc: async (t) => {
|
|
9431
|
+
let n = getHTMLFromFragment(t.content, e.schema);
|
|
9432
|
+
return new TextEncoder().encode(n);
|
|
9433
|
+
},
|
|
9434
|
+
toDoc: async (e) => {
|
|
9435
|
+
let n = elementFromString$1(new TextDecoder().decode(e));
|
|
9436
|
+
return DOMParser$1.fromSchema(t).parse(n);
|
|
9437
|
+
}
|
|
9438
|
+
} };
|
|
9439
|
+
}
|
|
9440
|
+
}, mediaUploadKey = new PluginKey("mediaUpload");
|
|
9441
|
+
function fileToDataURL(e) {
|
|
9442
|
+
return new Promise((t, n) => {
|
|
9443
|
+
let r = new FileReader();
|
|
9444
|
+
r.onload = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
|
|
9445
|
+
});
|
|
9446
|
+
}
|
|
9447
|
+
function fileToObjectURL(e) {
|
|
9448
|
+
return URL.createObjectURL(e);
|
|
9449
|
+
}
|
|
9450
|
+
function isImage(e, t) {
|
|
9451
|
+
return t.some((t) => e.type.match(t));
|
|
9452
|
+
}
|
|
9453
|
+
function isVideo(e, t) {
|
|
9454
|
+
return t.some((t) => e.type.match(t));
|
|
9455
|
+
}
|
|
9456
|
+
function insertImage(e, t, n, r, a) {
|
|
9457
|
+
let { schema: o } = e.state, s = o.nodes.image;
|
|
9458
|
+
if (!s) {
|
|
9459
|
+
console.warn("Image node type not found in schema");
|
|
9460
|
+
return;
|
|
9461
|
+
}
|
|
9462
|
+
let c = s.create({
|
|
9463
|
+
src: n,
|
|
9464
|
+
alt: r,
|
|
9465
|
+
title: a
|
|
9466
|
+
}), l = e.state.tr.insert(t, c);
|
|
9467
|
+
e.dispatch(l);
|
|
9468
|
+
}
|
|
9469
|
+
function insertVideo(e, t, n, r, a, o) {
|
|
9470
|
+
let { schema: s } = e.state, c = s.nodes.video;
|
|
9471
|
+
if (!c) {
|
|
9472
|
+
console.warn("Video node type not found in schema");
|
|
9473
|
+
return;
|
|
9474
|
+
}
|
|
9475
|
+
let l = c.create({
|
|
9476
|
+
src: n,
|
|
9477
|
+
title: r,
|
|
9478
|
+
width: a,
|
|
9479
|
+
height: o,
|
|
9480
|
+
controls: !0
|
|
9481
|
+
}), u = e.state.tr.insert(t, l);
|
|
9482
|
+
e.dispatch(u);
|
|
9483
|
+
}
|
|
9484
|
+
async function handleMediaFiles(e, t, n, r) {
|
|
9485
|
+
let { maxFileSize: a = 10 * 1024 * 1024, maxVideoFileSize: o = 50 * 1024 * 1024, allowedImageTypes: s = ["^image/"], allowedVideoTypes: c = ["^video/"], uploadHandler: l } = r;
|
|
9486
|
+
for (let u of t) {
|
|
9487
|
+
let t = isImage(u, s), d = isVideo(u, c);
|
|
9488
|
+
if (!t && !d) continue;
|
|
9489
|
+
let f = d ? o : a;
|
|
9490
|
+
if (u.size > f) {
|
|
9491
|
+
console.warn(`${d ? "Video" : "Image"} file "${u.name}" is too large (${(u.size / 1024 / 1024).toFixed(2)}MB). Maximum size is ${(f / 1024 / 1024).toFixed(2)}MB.`);
|
|
9492
|
+
continue;
|
|
9493
|
+
}
|
|
9494
|
+
try {
|
|
9495
|
+
console.log(`Processing ${d ? "video" : "image"}: ${u.name} (${(u.size / 1024 / 1024).toFixed(2)}MB, ${u.type})`);
|
|
9496
|
+
let t;
|
|
9497
|
+
l ? t = await l(u) : d && r.useObjectURLForVideos !== !1 ? (t = fileToObjectURL(u), console.log("Using object URL for video:", t)) : (t = await fileToDataURL(u), console.log(`${d ? "Video" : "Image"} converted to data URL, length: ${t.length} characters`)), d ? (insertVideo(e, n, t, u.name), console.log("Video inserted into editor")) : (insertImage(e, n, t, u.name), console.log("Image inserted into editor")), n += 1;
|
|
9498
|
+
} catch (e) {
|
|
9499
|
+
console.error(`Failed to process ${d ? "video" : "image"} "${u.name}":`, e);
|
|
9500
|
+
}
|
|
9501
|
+
}
|
|
9502
|
+
}
|
|
9503
|
+
function createMediaUploadPlugin(e = {}) {
|
|
9504
|
+
return new Plugin({
|
|
9505
|
+
key: mediaUploadKey,
|
|
9506
|
+
props: {
|
|
9507
|
+
handleDrop(t, n, r, a) {
|
|
9508
|
+
if (a) return !1;
|
|
9509
|
+
let o = Array.from(n.dataTransfer?.files || []);
|
|
9510
|
+
if (o.length === 0) return !1;
|
|
9511
|
+
let { allowedImageTypes: s = ["^image/"], allowedVideoTypes: c = ["^video/"] } = e;
|
|
9512
|
+
if (o.some((e) => isImage(e, s) || isVideo(e, c))) {
|
|
9513
|
+
n.preventDefault();
|
|
9514
|
+
let r = {
|
|
9515
|
+
left: n.clientX,
|
|
9516
|
+
top: n.clientY
|
|
9517
|
+
}, a = t.posAtCoords(r);
|
|
9518
|
+
return a ? (handleMediaFiles(t, o, a.pos, e), !0) : !1;
|
|
9519
|
+
}
|
|
9520
|
+
},
|
|
9521
|
+
handlePaste(t, n, r) {
|
|
9522
|
+
let a = Array.from(n.clipboardData?.items || []).filter((e) => e.type.startsWith("image/"));
|
|
9523
|
+
if (a.length > 0) {
|
|
9524
|
+
n.preventDefault();
|
|
9525
|
+
let r = [];
|
|
9526
|
+
for (let e of a) {
|
|
9527
|
+
let t = e.getAsFile();
|
|
9528
|
+
t && r.push(t);
|
|
9529
|
+
}
|
|
9530
|
+
if (r.length === 0) return !1;
|
|
9531
|
+
let { from: o } = t.state.selection;
|
|
9532
|
+
return handleMediaFiles(t, r, o, e), !0;
|
|
9533
|
+
}
|
|
9534
|
+
}
|
|
9535
|
+
}
|
|
9536
|
+
});
|
|
9537
|
+
}
|
|
9538
|
+
var ExtensionMediaUpload = class extends Extension {
|
|
9539
|
+
config;
|
|
9540
|
+
name = "mediaUpload";
|
|
9541
|
+
constructor(e = {}) {
|
|
9542
|
+
super(e), this.config = e;
|
|
9543
|
+
}
|
|
9544
|
+
getProseMirrorPlugins() {
|
|
9545
|
+
return [createMediaUploadPlugin(this.config)];
|
|
9546
|
+
}
|
|
9547
|
+
};
|
|
9548
|
+
//#endregion
|
|
9549
|
+
//#region ../extension-basic-editor/src/media/ExtensionPaste.ts
|
|
9550
|
+
function getStringByXPath(e, t) {
|
|
9551
|
+
return t.ownerDocument.evaluate(e, t, null, XPathResult.STRING_TYPE, null).stringValue;
|
|
9552
|
+
}
|
|
9553
|
+
function getElementsByXPath(e, t) {
|
|
9554
|
+
let n = t.ownerDocument.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), r = [];
|
|
9555
|
+
for (let e = 0; e < n.snapshotLength; e++) {
|
|
9556
|
+
let t = n.snapshotItem(e);
|
|
9557
|
+
t && r.push(t);
|
|
9558
|
+
}
|
|
9559
|
+
return r;
|
|
9560
|
+
}
|
|
9561
|
+
var PasteState = class {
|
|
9562
|
+
editor;
|
|
9563
|
+
pasteRules = [];
|
|
9564
|
+
constructor(e) {
|
|
9565
|
+
this.editor = e;
|
|
9566
|
+
}
|
|
9567
|
+
handleCommands(e, t) {
|
|
9568
|
+
if (!e) return !1;
|
|
9569
|
+
if (e.getPasteRules) return e.getPasteRules(this.pasteRules), !0;
|
|
9570
|
+
if (e.setPasteRules) return console.log("setPasteRules", e.setPasteRules), this.pasteRules = e.setPasteRules, !0;
|
|
9571
|
+
if (e.pasteHtml) {
|
|
9572
|
+
let { from: t, html: n } = e.pasteHtml, r = elementFromString$1(n), a = this.editor, o = !1, s = [], c = a.ci.resolve("yaml");
|
|
9573
|
+
for (let e of this.pasteRules) {
|
|
9574
|
+
if (typeof e.match == "string") {
|
|
9575
|
+
if (getElementsByXPath(e.match, r).length === 0) continue;
|
|
9576
|
+
} else if (!e.match(r)) continue;
|
|
9577
|
+
for (let t of e.steps) {
|
|
9578
|
+
let e;
|
|
9579
|
+
if (typeof t.match == "string") switch (t.result || "") {
|
|
9580
|
+
case "string":
|
|
9581
|
+
e = getStringByXPath(t.match, r);
|
|
9582
|
+
break;
|
|
9583
|
+
default:
|
|
9584
|
+
e = getElementsByXPath(t.match, r);
|
|
9585
|
+
break;
|
|
9586
|
+
}
|
|
9587
|
+
else e = t.match(r);
|
|
9588
|
+
switch (console.log("step", e, t), t.op) {
|
|
9589
|
+
case "remove":
|
|
9590
|
+
for (let t of e) t.parentNode?.removeChild(t);
|
|
9591
|
+
break;
|
|
9592
|
+
case "replaceTag":
|
|
9593
|
+
for (let n of e) {
|
|
9594
|
+
let e = n.ownerDocument.createElement(t.tag);
|
|
9595
|
+
e.innerHTML = n.innerHTML, n.parentNode?.replaceChild(e, n);
|
|
9596
|
+
}
|
|
9597
|
+
break;
|
|
9598
|
+
case "replaceBody":
|
|
9599
|
+
for (let t of e) r.innerHTML = "", r.appendChild(t);
|
|
9600
|
+
break;
|
|
9601
|
+
case "console.debug":
|
|
9602
|
+
console.debug(e);
|
|
9603
|
+
break;
|
|
9604
|
+
case "meta.set":
|
|
9605
|
+
s.push({
|
|
9606
|
+
path: t.path,
|
|
9607
|
+
value: e
|
|
9608
|
+
});
|
|
9609
|
+
break;
|
|
9610
|
+
}
|
|
9611
|
+
}
|
|
9612
|
+
o = !!e.replaceDocument;
|
|
9613
|
+
break;
|
|
9614
|
+
}
|
|
9615
|
+
let l = DOMParser$1.fromSchema(this.editor.schema).parse(r);
|
|
9616
|
+
return setTimeout(async () => {
|
|
9617
|
+
let e = this.editor.state.tr;
|
|
9618
|
+
o ? e.replaceWith(0, this.editor.state.doc.content.size, l) : e.insert(t, l);
|
|
9619
|
+
{
|
|
9620
|
+
let t = await new Promise((e) => this.editor.chain().getMeta(e).run()) || /* @__PURE__ */ new Map();
|
|
9621
|
+
for (let e of s) c.setPathValue(t, e.path, e.value);
|
|
9622
|
+
e.setDocAttribute("meta", t);
|
|
9623
|
+
}
|
|
9624
|
+
this.editor.dispatchTransaction(e);
|
|
9625
|
+
}, 0), !0;
|
|
9626
|
+
}
|
|
9627
|
+
return !1;
|
|
9628
|
+
}
|
|
9629
|
+
}, PastePluginKey = new PluginKey("paste"), ExtensionPaste = class extends Extension {
|
|
9630
|
+
name = "paste";
|
|
9631
|
+
getProseMirrorPlugins() {
|
|
9632
|
+
let e = this.editor;
|
|
9633
|
+
return [new Plugin({
|
|
9634
|
+
key: PastePluginKey,
|
|
9635
|
+
state: {
|
|
9636
|
+
init() {
|
|
9637
|
+
return PastePluginKey.getState(e.state) || new PasteState(e);
|
|
9638
|
+
},
|
|
9639
|
+
apply(e, t, n, r) {
|
|
9640
|
+
if (e.isGeneric) return t;
|
|
9641
|
+
let a = e.getMeta(PastePluginKey);
|
|
9642
|
+
return t.handleCommands(a, e), t;
|
|
9643
|
+
}
|
|
9644
|
+
},
|
|
9645
|
+
props: {
|
|
9646
|
+
handlePaste(t, n, r) {
|
|
9647
|
+
let { clipboardData: a } = n;
|
|
9648
|
+
if (!a) return !1;
|
|
9649
|
+
if (a.types.includes("text/html")) {
|
|
9650
|
+
let { from: e } = t.state.selection, r = a.getData("text/html");
|
|
9651
|
+
n.preventDefault();
|
|
9652
|
+
let o = t.state.tr.setMeta(PastePluginKey, { pasteHtml: {
|
|
9653
|
+
from: e,
|
|
9654
|
+
html: r
|
|
9655
|
+
} });
|
|
9656
|
+
return t.dispatch(o), !0;
|
|
9657
|
+
}
|
|
9658
|
+
[...a.items].map((e) => e.getAsFile()).filter((e) => !!e);
|
|
9659
|
+
let o = Array.from(n.clipboardData?.files || []);
|
|
9660
|
+
if (o.length === 1) {
|
|
9661
|
+
let t = o[0];
|
|
9662
|
+
if (e.getMediaTypes().includes(t.type)) return t.bytes().then((n) => {
|
|
9663
|
+
e.loadDocument(t.type, n);
|
|
9664
|
+
}), !0;
|
|
9665
|
+
}
|
|
9666
|
+
},
|
|
9667
|
+
handleDrop(t, n, r, a) {
|
|
9668
|
+
let o = Array.from(n.dataTransfer?.files || []);
|
|
9669
|
+
if (o.length === 1) {
|
|
9670
|
+
let t = o[0];
|
|
9671
|
+
if (e.getMediaTypes().includes(t.type)) return t.bytes().then((n) => {
|
|
9672
|
+
e.loadDocument(t.type, n);
|
|
9673
|
+
}), !0;
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9676
|
+
}
|
|
9677
|
+
})];
|
|
9678
|
+
}
|
|
9679
|
+
getCommandFactories(e) {
|
|
9680
|
+
return {
|
|
9681
|
+
getPasteRules: (e) => (t, n) => {
|
|
9682
|
+
let r = t.tr;
|
|
9683
|
+
return r.setMeta(PastePluginKey, { getPasteRules: e }), n && n(r), !0;
|
|
9684
|
+
},
|
|
9685
|
+
setPasteRules: (e) => (t, n) => {
|
|
9686
|
+
let r = t.tr;
|
|
9687
|
+
return r.setMeta(PastePluginKey, { setPasteRules: e }), n && n(r), !0;
|
|
9688
|
+
}
|
|
9689
|
+
};
|
|
9690
|
+
}
|
|
9089
9691
|
}, MarkLink = class extends Mark {
|
|
9090
9692
|
name = "link";
|
|
9091
9693
|
requires = ["doc"];
|
|
@@ -9363,6 +9965,7 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
|
|
|
9363
9965
|
getNodeSpec() {
|
|
9364
9966
|
return {
|
|
9365
9967
|
content: "block+",
|
|
9968
|
+
attrs: { meta: { default: null } },
|
|
9366
9969
|
marks: "code em strong link bookmark",
|
|
9367
9970
|
EMPTY_DOC: {
|
|
9368
9971
|
type: this.name,
|
|
@@ -9373,6 +9976,19 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
|
|
|
9373
9976
|
}
|
|
9374
9977
|
};
|
|
9375
9978
|
}
|
|
9979
|
+
getCommandFactories(e, t) {
|
|
9980
|
+
return {
|
|
9981
|
+
getMeta: (e) => (t, n) => (e(structuredClone(t.doc.attrs.meta)), !0),
|
|
9982
|
+
setMeta: (e) => (t, n) => {
|
|
9983
|
+
let r = t.tr;
|
|
9984
|
+
return r.setDocAttribute("meta", e), n && n(r), r.docChanged;
|
|
9985
|
+
},
|
|
9986
|
+
updateMeta: (e) => (t, n) => {
|
|
9987
|
+
let r = t.tr;
|
|
9988
|
+
return r.setDocAttribute("meta", e(t.doc.attrs.meta)), n && n(r), r.docChanged;
|
|
9989
|
+
}
|
|
9990
|
+
};
|
|
9991
|
+
}
|
|
9376
9992
|
}, NodeText = class extends Node$2 {
|
|
9377
9993
|
name = "text";
|
|
9378
9994
|
getNodeSpec() {
|
|
@@ -9863,20 +10479,6 @@ var NodeCodeBlock$1 = class extends Node$2 {
|
|
|
9863
10479
|
}
|
|
9864
10480
|
};
|
|
9865
10481
|
}
|
|
9866
|
-
}, NodeFrontmatter = class extends Node$2 {
|
|
9867
|
-
name = "frontmatter";
|
|
9868
|
-
requires = ["doc"];
|
|
9869
|
-
getNodeSpec() {
|
|
9870
|
-
return {
|
|
9871
|
-
content: "inline*",
|
|
9872
|
-
group: "block",
|
|
9873
|
-
defining: !0,
|
|
9874
|
-
parseDOM: [{ tag: "pre" }],
|
|
9875
|
-
toDOM() {
|
|
9876
|
-
return ["pre", 0];
|
|
9877
|
-
}
|
|
9878
|
-
};
|
|
9879
|
-
}
|
|
9880
10482
|
};
|
|
9881
10483
|
//#endregion
|
|
9882
10484
|
//#region ../extension-basic-editor/src/NodeInlineShortCode.ts
|
|
@@ -10443,6 +11045,7 @@ var joinListBackwards = (e, t) => {
|
|
|
10443
11045
|
new ExtensionTextAlign(),
|
|
10444
11046
|
new ExtensionPairing(),
|
|
10445
11047
|
new ExtensionUser(),
|
|
11048
|
+
new ExtensionPaste(),
|
|
10446
11049
|
new NodeDocument(),
|
|
10447
11050
|
new NodeText(),
|
|
10448
11051
|
new NodeParagraph(),
|
|
@@ -10461,7 +11064,6 @@ var joinListBackwards = (e, t) => {
|
|
|
10461
11064
|
new NodeDefinitionDesc(),
|
|
10462
11065
|
new NodeTaskList(),
|
|
10463
11066
|
new NodeTaskItem(),
|
|
10464
|
-
new NodeFrontmatter(),
|
|
10465
11067
|
new NodeImage(),
|
|
10466
11068
|
new NodeVideo(),
|
|
10467
11069
|
new NodeBlockquote(),
|
|
@@ -11750,7 +12352,7 @@ var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/, Language = class e {
|
|
|
11750
12352
|
static async load(t) {
|
|
11751
12353
|
let n;
|
|
11752
12354
|
if (t instanceof Uint8Array) n = t;
|
|
11753
|
-
else if (globalThis.process?.versions.node) n = await (await import("./__vite-browser-external-
|
|
12355
|
+
else if (globalThis.process?.versions.node) n = await (await import("./__vite-browser-external-Bk07RSXL.js").then((e) => /* @__PURE__ */ __toESM(e.default, 1))).readFile(t);
|
|
11754
12356
|
else {
|
|
11755
12357
|
let e = await fetch(t);
|
|
11756
12358
|
if (!e.ok) {
|
|
@@ -11775,7 +12377,7 @@ ${JSON.stringify(a, null, 2)}`), Error("Language.load failed: no language functi
|
|
|
11775
12377
|
async function Module2(moduleArg = {}) {
|
|
11776
12378
|
var moduleRtn, Module = moduleArg, ENVIRONMENT_IS_WEB = typeof window == "object", ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope < "u", ENVIRONMENT_IS_NODE = typeof process == "object" && process.versions?.node && process.type != "renderer";
|
|
11777
12379
|
if (ENVIRONMENT_IS_NODE) {
|
|
11778
|
-
let { createRequire: e } = await import("./__vite-browser-external-
|
|
12380
|
+
let { createRequire: e } = await import("./__vite-browser-external-Bk07RSXL.js").then((e) => /* @__PURE__ */ __toESM(e.default, 1));
|
|
11779
12381
|
var require = e(import.meta.url);
|
|
11780
12382
|
}
|
|
11781
12383
|
Module.currentQueryProgressCallback = null, Module.currentProgressCallback = null, Module.currentLogCallback = null, Module.currentParseCallback = null;
|
|
@@ -21343,7 +21945,7 @@ function getHeaderTokensHandlers() {
|
|
|
21343
21945
|
function getBasicTokensHandlers() {
|
|
21344
21946
|
return {
|
|
21345
21947
|
frontmatter: [(e, t) => {
|
|
21346
|
-
t.current.log(
|
|
21948
|
+
t.current.log(e.content, e);
|
|
21347
21949
|
}],
|
|
21348
21950
|
heading_open: [(e, t) => {
|
|
21349
21951
|
t.stash("getBasicTokensHandlers.heading_open"), t.current.handlers = getHeaderTokensHandlers(), e.markup !== "---" && t.current.log("#".repeat(+e.tag.substring(1)) + " ", e);
|
|
@@ -22073,6 +22675,7 @@ var nullNode = {
|
|
|
22073
22675
|
async markString(e, t, n) {
|
|
22074
22676
|
let r = this.getMark(e.type.name), a = t ? r.open : r.close;
|
|
22075
22677
|
if (!a) {
|
|
22678
|
+
if (["highlight", "textColor"].includes(e.type.name)) return;
|
|
22076
22679
|
console.warn("Unsupported mark type for markdown: " + e.type.name + ", available types: " + Object.keys(this.marks).join(", ") + ". Mark will be ignored.");
|
|
22077
22680
|
return;
|
|
22078
22681
|
}
|
|
@@ -22182,6 +22785,12 @@ async function pmToMdConverter(e, t, n, r) {
|
|
|
22182
22785
|
}
|
|
22183
22786
|
async function extPmToMdConverter(e, t, n, r) {
|
|
22184
22787
|
let a = new MdStashContext(), o, s = new DocumentMarkdownTokenizer({
|
|
22788
|
+
doc(e) {
|
|
22789
|
+
return { open: async (e, n, r) => {
|
|
22790
|
+
let a = new Token("frontmatter", "frontmatter", 0);
|
|
22791
|
+
return e.attrs.meta && (console.log("node.attrs", e.attrs), t.yaml ? a.content = `---\n${t.yaml.stringify(e.attrs.meta)}\n---\n` : a.content = "---\n# No yaml service\n---\n"), a;
|
|
22792
|
+
} };
|
|
22793
|
+
},
|
|
22185
22794
|
paragraph(e) {
|
|
22186
22795
|
return {
|
|
22187
22796
|
open: async (e, t, n) => {
|
|
@@ -22446,7 +23055,7 @@ async function extPmToMdConverter(e, t, n, r) {
|
|
|
22446
23055
|
};
|
|
22447
23056
|
}
|
|
22448
23057
|
//#endregion
|
|
22449
|
-
//#region \0deno::TypeScript::@kerebron/extension-basic-editor/ExtensionHtml::/home/runner/work/kerebron/kerebron/packages/extension-basic-editor/src/ExtensionHtml.ts
|
|
23058
|
+
//#region \0deno::TypeScript::@kerebron/extension-basic-editor/ExtensionHtml::/home/runner/work/kerebron/kerebron/packages/extension-basic-editor/src/media/ExtensionHtml.ts
|
|
22450
23059
|
var removeWhitespaces = (e) => {
|
|
22451
23060
|
let t = e.childNodes;
|
|
22452
23061
|
for (let n = t.length - 1; n >= 0; --n) {
|
|
@@ -22742,6 +23351,12 @@ function treeToTokens(e, t, n) {
|
|
|
22742
23351
|
t.map = e, t.meta = "noEscText", t.content = o(u) ?? "", s(t, "hard_line_break");
|
|
22743
23352
|
}
|
|
22744
23353
|
break;
|
|
23354
|
+
case "backslash_escape":
|
|
23355
|
+
{
|
|
23356
|
+
let t = new Token("text", "", 0);
|
|
23357
|
+
t.map = e, t.meta = "noEscText", t.content = o(u) ?? "", s(t, "backslash_escape");
|
|
23358
|
+
}
|
|
23359
|
+
break;
|
|
22745
23360
|
default: throw console.debug("inline_node", u), Error(`Unhandled inline node type: ${u.type}`);
|
|
22746
23361
|
}
|
|
22747
23362
|
}
|
|
@@ -23012,7 +23627,19 @@ async function mdToPmConverter(e, t, n) {
|
|
|
23012
23627
|
async function mdToPmConverterText(e, t, n) {
|
|
23013
23628
|
if (!t.assetLoad) throw Error("No config.assetLoad");
|
|
23014
23629
|
let r = new MarkdownParser(n, await sitterTokenizer(t.assetLoad), {
|
|
23015
|
-
frontmatter: {
|
|
23630
|
+
frontmatter: { custom: (e, n) => {
|
|
23631
|
+
let r = e.stack[0];
|
|
23632
|
+
if (r?.type.name === "doc") {
|
|
23633
|
+
let e = n.content, a = e.indexOf("\n---\n", 4);
|
|
23634
|
+
if (e.startsWith("---\n") && a > -1) {
|
|
23635
|
+
let n = t.yaml?.parse(e.substring(4, a)) || void 0;
|
|
23636
|
+
r.attrs = {
|
|
23637
|
+
...r.attrs,
|
|
23638
|
+
meta: n
|
|
23639
|
+
};
|
|
23640
|
+
}
|
|
23641
|
+
}
|
|
23642
|
+
} },
|
|
23016
23643
|
blockquote: { block: "blockquote" },
|
|
23017
23644
|
paragraph: { block: "paragraph" },
|
|
23018
23645
|
task_item: { block: "task_item" },
|
|
@@ -23046,7 +23673,9 @@ async function mdToPmConverterText(e, t, n) {
|
|
|
23046
23673
|
getAttrs: (e) => ({ lang: e.attrGet("lang") || void 0 }),
|
|
23047
23674
|
noCloseToken: !0
|
|
23048
23675
|
},
|
|
23049
|
-
hr: {
|
|
23676
|
+
hr: { custom: (e, t, r, a) => {
|
|
23677
|
+
e.openNode(n.nodes.paragraph, {}), e.addNode(n.nodes.hr, {}), e.closeNode();
|
|
23678
|
+
} },
|
|
23050
23679
|
image: {
|
|
23051
23680
|
node: "image",
|
|
23052
23681
|
getAttrs: (e) => {
|
|
@@ -23429,19 +24058,24 @@ var ExtensionMarkdown = class extends Extension {
|
|
|
23429
24058
|
assetLoad: this.editor.config.assetLoad,
|
|
23430
24059
|
...this.config,
|
|
23431
24060
|
urlRewriter: this.urlToRewriter,
|
|
23432
|
-
hooks: this.hooks["pm2md.pre"]
|
|
24061
|
+
hooks: this.hooks["pm2md.pre"],
|
|
24062
|
+
yaml: e.ci.resolve("yaml")
|
|
23433
24063
|
}, t, e),
|
|
23434
|
-
toDoc: (
|
|
24064
|
+
toDoc: (n) => mdToPmConverter(n, {
|
|
23435
24065
|
assetLoad: this.editor.config.assetLoad,
|
|
23436
24066
|
...this.config,
|
|
23437
24067
|
urlRewriter: this.urlFromRewriter,
|
|
23438
|
-
hooks: this.hooks["md2pm.post"]
|
|
24068
|
+
hooks: this.hooks["md2pm.post"],
|
|
24069
|
+
yaml: e.ci.resolve("yaml")
|
|
23439
24070
|
}, t)
|
|
23440
24071
|
} };
|
|
23441
24072
|
return n["text/markdown"] = n["text/x-markdown"], n;
|
|
23442
24073
|
}
|
|
23443
24074
|
toMarkdown(e) {
|
|
23444
|
-
return extPmToMdConverter(e, {
|
|
24075
|
+
return extPmToMdConverter(e, {
|
|
24076
|
+
sourceMap: !0,
|
|
24077
|
+
yaml: this.editor.ci.resolve("yaml")
|
|
24078
|
+
}, this.editor.schema, this.editor);
|
|
23445
24079
|
}
|
|
23446
24080
|
async fromMarkdown(e) {
|
|
23447
24081
|
let t = (await mdToPmConverterText(e, {
|