@kerebron/legacy-compat 0.8.2 → 0.8.4

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/kerebron.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as __toESM, t as __commonJSMin } from "./rolldown-runtime-3b4jIN3o.js";
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;
@@ -65,7 +65,7 @@ OrderedMap.prototype = {
65
65
  return new OrderedMap(t);
66
66
  };
67
67
  //#endregion
68
- //#region ../../node_modules/.deno/prosemirror-model@1.25.3/node_modules/prosemirror-model/dist/index.js
68
+ //#region ../../node_modules/.deno/prosemirror-model@1.25.9/node_modules/prosemirror-model/dist/index.js
69
69
  function findDiffStart(e, t, n) {
70
70
  for (let r = 0;; r++) {
71
71
  if (r == e.childCount || r == t.childCount) return e.childCount == t.childCount ? null : n;
@@ -76,8 +76,9 @@ function findDiffStart(e, t, n) {
76
76
  }
77
77
  if (!a.sameMarkup(o)) return n;
78
78
  if (a.isText && a.text != o.text) {
79
- for (let e = 0; a.text[e] == o.text[e]; e++) n++;
80
- return n;
79
+ let e = a.text, t = o.text, r = 0;
80
+ for (; e[r] == t[r]; r++) n++;
81
+ return r && r < e.length && r < t.length && surrogateHigh(e.charCodeAt(r - 1)) && surrogateLow(e.charCodeAt(r)) && n--, n;
81
82
  }
82
83
  if (a.content.size || o.content.size) {
83
84
  let e = findDiffStart(a.content, o.content, n + 1);
@@ -102,9 +103,9 @@ function findDiffEnd(e, t, n, r) {
102
103
  b: r
103
104
  };
104
105
  if (s.isText && s.text != c.text) {
105
- let e = 0, t = Math.min(s.text.length, c.text.length);
106
- for (; e < t && s.text[s.text.length - e - 1] == c.text[c.text.length - e - 1];) e++, n--, r--;
107
- return {
106
+ let e = s.text, t = c.text, a = e.length, o = t.length;
107
+ for (; a > 0 && o > 0 && e[a - 1] == t[o - 1];) a--, o--, n--, r--;
108
+ return a && o && a < e.length && surrogateHigh(e.charCodeAt(a - 1)) && surrogateLow(e.charCodeAt(a)) && (n++, r++), {
108
109
  a: n,
109
110
  b: r
110
111
  };
@@ -116,6 +117,12 @@ function findDiffEnd(e, t, n, r) {
116
117
  n -= l, r -= l;
117
118
  }
118
119
  }
120
+ function surrogateLow(e) {
121
+ return e >= 56320 && e < 57344;
122
+ }
123
+ function surrogateHigh(e) {
124
+ return e >= 55296 && e < 56320;
125
+ }
119
126
  var Fragment = class e {
120
127
  constructor(e, t) {
121
128
  if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize;
@@ -227,7 +234,7 @@ var Fragment = class e {
227
234
  static fromJSON(t, n) {
228
235
  if (!n) return e.empty;
229
236
  if (!Array.isArray(n)) throw RangeError("Invalid input for Fragment.fromJSON");
230
- return new e(n.map(t.nodeFromJSON));
237
+ return e.fromArray(n.map(t.nodeFromJSON));
231
238
  }
232
239
  static fromArray(t) {
233
240
  if (!t.length) return e.empty;
@@ -331,7 +338,7 @@ var ReplaceError = class extends Error {}, Slice = class e {
331
338
  return this.content.size - this.openStart - this.openEnd;
332
339
  }
333
340
  insertAt(t, n) {
334
- let r = insertInto(this.content, t + this.openStart, n);
341
+ let r = insertInto(this.content, t + this.openStart, n, this.openStart + 1, this.openEnd + 1);
335
342
  return r && new e(r, this.openStart, this.openEnd);
336
343
  }
337
344
  removeBetween(t, n) {
@@ -371,11 +378,11 @@ function removeRange(e, t, n) {
371
378
  if (r != s) throw RangeError("Removing non-flat range");
372
379
  return e.replaceChild(r, o.copy(removeRange(o.content, t - a - 1, n - a - 1)));
373
380
  }
374
- function insertInto(e, t, n, r) {
375
- let { index: a, offset: o } = e.findIndex(t), s = e.maybeChild(a);
376
- if (o == t || s.isText) return r && !r.canReplace(a, a, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
377
- let c = insertInto(s.content, t - o - 1, n, s);
378
- return c && e.replaceChild(a, s.copy(c));
381
+ function insertInto(e, t, n, r, a, o) {
382
+ let { index: s, offset: c } = e.findIndex(t), l = e.maybeChild(s);
383
+ if (c == t || l.isText) return o && r <= 0 && a <= 0 && !o.canReplace(s, s, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
384
+ let u = insertInto(l.content, t - c - 1, n, s == 0 ? r - 1 : 0, s == e.childCount - 1 ? a - 1 : 0, l);
385
+ return u && e.replaceChild(s, l.copy(u));
379
386
  }
380
387
  function replace(e, t, n) {
381
388
  if (n.openStart > e.depth) throw new ReplaceError("Inserted content deeper than insertion position");
@@ -414,7 +421,8 @@ function addRange(e, t, n, r) {
414
421
  t && t.depth == n && t.textOffset && addNode(t.nodeBefore, r);
415
422
  }
416
423
  function close(e, t) {
417
- return e.type.checkContent(t), e.copy(t);
424
+ if (!e.type.validContent(t)) throw new ReplaceError("Invalid content for node " + e.type.name);
425
+ return e.copy(t);
418
426
  }
419
427
  function replaceThreeWay(e, t, n, r, a) {
420
428
  let o = e.depth > a && joinable$1(e, t, a + 1), s = r.depth > a && joinable$1(n, r, a + 1), c = [];
@@ -1116,11 +1124,8 @@ function computeAttrs(e, t) {
1116
1124
  return n;
1117
1125
  }
1118
1126
  function checkAttrs(e, t, n, r) {
1119
- for (let r in t) if (!(r in e)) throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);
1120
- for (let n in e) {
1121
- let r = e[n];
1122
- r.validate && r.validate(t[n]);
1123
- }
1127
+ for (let a in t) if (!(a in e)) throw RangeError(`Unsupported attribute ${a} for ${n} of type ${r}`);
1128
+ for (let n in e) e[n].validate && e[n].validate(t[n]);
1124
1129
  }
1125
1130
  function initAttrs(e, t) {
1126
1131
  let n = Object.create(null);
@@ -1479,14 +1484,20 @@ var NodeContext = class {
1479
1484
  e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t);
1480
1485
  }
1481
1486
  addTextNode(e, t) {
1482
- let n = e.nodeValue, r = this.top, a = r.options & OPT_PRESERVE_WS_FULL ? "full" : this.localPreserveWS || (r.options & OPT_PRESERVE_WS) > 0;
1487
+ let n = e.nodeValue, r = this.top, a = r.options & OPT_PRESERVE_WS_FULL ? "full" : this.localPreserveWS || (r.options & OPT_PRESERVE_WS) > 0, { schema: o } = this.parser;
1483
1488
  if (a === "full" || r.inlineContext(e) || /[^ \t\r\n\u000c]/.test(n)) {
1484
- if (a) n = a === "full" ? n.replace(/\r\n?/g, "\n") : n.replace(/\r?\n|\r/g, " ");
1485
- else if (n = n.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) {
1486
- let t = r.content[r.content.length - 1], a = e.previousSibling;
1487
- (!t || a && a.nodeName == "BR" || t.isText && /[ \t\r\n\u000c]$/.test(t.text)) && (n = n.slice(1));
1488
- }
1489
- n && this.insertNode(this.parser.schema.text(n), t, !/\S/.test(n)), this.findInText(e);
1489
+ if (!a) {
1490
+ if (n = n.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) {
1491
+ let t = r.content[r.content.length - 1], a = e.previousSibling;
1492
+ (!t || a && a.nodeName == "BR" || t.isText && /[ \t\r\n\u000c]$/.test(t.text)) && (n = n.slice(1));
1493
+ }
1494
+ } else if (a === "full") n = n.replace(/\r\n?/g, "\n");
1495
+ else if (o.linebreakReplacement && /[\r\n]/.test(n) && this.top.findWrapping(o.linebreakReplacement.create())) {
1496
+ let e = n.split(/\r?\n|\r/);
1497
+ for (let n = 0; n < e.length; n++) n && this.insertNode(o.linebreakReplacement.create(), t, !0), e[n] && this.insertNode(o.text(e[n]), t, !/\S/.test(e[n]));
1498
+ n = "";
1499
+ } else n = n.replace(/\r?\n|\r/g, " ");
1500
+ n && this.insertNode(o.text(n), t, !/\S/.test(n)), this.findInText(e);
1490
1501
  } else this.findInside(e);
1491
1502
  }
1492
1503
  addElement(e, t, n) {
@@ -1728,6 +1739,7 @@ var DOMSerializer = class e {
1728
1739
  }), n;
1729
1740
  }
1730
1741
  serializeNodeInner(e, t) {
1742
+ if (e.isText) return doc$1(t).createTextNode(e.text);
1731
1743
  let { dom: n, contentDOM: r } = renderSpec(doc$1(t), this.nodes[e.type.name](e), null, e.attrs);
1732
1744
  if (r) {
1733
1745
  if (e.isLeaf) throw RangeError("Content hole not allowed in a leaf node spec");
@@ -1748,7 +1760,7 @@ var DOMSerializer = class e {
1748
1760
  return r && renderSpec(doc$1(n), r(e, t), null, e.attrs);
1749
1761
  }
1750
1762
  static renderSpec(e, t, n = null, r) {
1751
- return renderSpec(e, t, n, r);
1763
+ return typeof t == "string" ? { dom: e.createTextNode(t) } : renderSpec(e, t, n, r);
1752
1764
  }
1753
1765
  static fromSchema(t) {
1754
1766
  return t.cached.domSerializer || (t.cached.domSerializer = new e(this.nodesFromSchema(t), this.marksFromSchema(t)));
@@ -1787,9 +1799,8 @@ function suspiciousAttributesInner(e) {
1787
1799
  return n(e), t;
1788
1800
  }
1789
1801
  function renderSpec(e, t, n, r) {
1790
- if (typeof t == "string") return { dom: e.createTextNode(t) };
1791
- if (t.nodeType != null) return { dom: t };
1792
- if (t.dom && t.dom.nodeType != null) return t;
1802
+ if (t.nodeType == 1) return { dom: t };
1803
+ if (t.dom && t.dom.nodeType == 1) return t;
1793
1804
  let a = t[0], o;
1794
1805
  if (typeof a != "string") throw RangeError("Invalid array passed to renderSpec");
1795
1806
  if (r && (o = suspiciousAttributes(r)) && o.indexOf(t) > -1) throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
@@ -1811,7 +1822,8 @@ function renderSpec(e, t, n, r) {
1811
1822
  dom: l,
1812
1823
  contentDOM: l
1813
1824
  };
1814
- } else {
1825
+ } else if (typeof o == "string") l.appendChild(e.createTextNode(o));
1826
+ else {
1815
1827
  let { dom: t, contentDOM: a } = renderSpec(e, o, n, r);
1816
1828
  if (l.appendChild(t), a) {
1817
1829
  if (c) throw RangeError("Multiple content holes");
@@ -6946,7 +6958,140 @@ var TrackSelecionPlugin = class extends Plugin {
6946
6958
  }
6947
6959
  });
6948
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;
6949
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
+ }
6950
7095
  //#endregion
6951
7096
  //#region ../editor/src/ExtensionManager.ts
6952
7097
  function splitExtensions(e) {
@@ -7065,7 +7210,7 @@ var ExtensionManager = class {
7065
7210
  for (let t of e.conflicts) if (a.find((e) => e.name === t)) throw Error(`Extension conflict: ${e.name} vs ${t}`);
7066
7211
  }
7067
7212
  for (let t of a) e.ci.register(t.name, t);
7068
- this.initPlugins(e, t);
7213
+ e.ci.register("yaml", yaml_exports), this.initPlugins(e, t);
7069
7214
  for (let e of this.extensions) e.created();
7070
7215
  }
7071
7216
  };
@@ -8090,6 +8235,9 @@ var CoreEditor = class e extends EventTarget {
8090
8235
  let n = await this.getConverter(e).toDoc(t), r = this.state.tr;
8091
8236
  r.replaceWith(0, this.state.doc.content.size, n.content), this.dispatchTransaction(r);
8092
8237
  }
8238
+ getMediaTypes() {
8239
+ return Object.keys(this.extensionManager.converters);
8240
+ }
8093
8241
  patchDocumentText(e, t) {
8094
8242
  return this.patchDocument(e, new TextEncoder().encode(t));
8095
8243
  }
@@ -8681,168 +8829,6 @@ var ExtensionGapcursor = class extends Extension {
8681
8829
  getProseMirrorPlugins() {
8682
8830
  return [gapCursor()];
8683
8831
  }
8684
- };
8685
- //#endregion
8686
- //#region ../extension-basic-editor/src/ExtensionHtml.ts
8687
- function getHTMLFromFragment(e, t) {
8688
- let n = globalThis.document, r = DOMSerializer.fromSchema(t).serializeFragment(e, { document: n }), a = n.implementation.createHTMLDocument().createElement("div");
8689
- return a.appendChild(r), a.innerHTML;
8690
- }
8691
- var removeWhitespaces$1 = (e) => {
8692
- let t = e.childNodes;
8693
- for (let n = t.length - 1; n >= 0; --n) {
8694
- let r = t[n];
8695
- r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && removeWhitespaces$1(r);
8696
- }
8697
- return e;
8698
- };
8699
- function elementFromString$1(e) {
8700
- let t = `<html lang="en"><body>${e}</body></html>`, n = new globalThis.DOMParser().parseFromString(t, "text/html").body;
8701
- return removeWhitespaces$1(n);
8702
- }
8703
- function prepareContentCheckSchema(e) {
8704
- return new Schema({
8705
- topNode: e.spec.topNode,
8706
- marks: e.spec.marks,
8707
- nodes: e.spec.nodes.append({ __unknown__catch__all__node: {
8708
- content: "inline*",
8709
- group: "block",
8710
- parseDOM: [{
8711
- tag: "*",
8712
- getAttrs: (e) => {
8713
- let t = typeof e == "string" ? e : e.outerHTML;
8714
- throw Error("Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${t}`) });
8715
- }
8716
- }]
8717
- } })
8718
- });
8719
- }
8720
- function createNodeFromHTML(e, t, n) {
8721
- if (n = {
8722
- parseOptions: {},
8723
- ...n
8724
- }, n.errorOnInvalidContent) {
8725
- let r = prepareContentCheckSchema(t);
8726
- DOMParser$1.fromSchema(r).parse(elementFromString$1(e), n.parseOptions);
8727
- }
8728
- return DOMParser$1.fromSchema(t).parse(elementFromString$1(e), n.parseOptions);
8729
- }
8730
- var ExtensionHtml = class extends Extension {
8731
- name = "html";
8732
- getConverters(e, t) {
8733
- return { "text/html": {
8734
- fromDoc: async (t) => {
8735
- let n = getHTMLFromFragment(t.content, e.schema);
8736
- return new TextEncoder().encode(n);
8737
- },
8738
- toDoc: async (t) => createNodeFromHTML(new TextDecoder().decode(t), e.schema)
8739
- } };
8740
- }
8741
- }, mediaUploadKey = new PluginKey("mediaUpload");
8742
- function fileToDataURL(e) {
8743
- return new Promise((t, n) => {
8744
- let r = new FileReader();
8745
- r.onload = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
8746
- });
8747
- }
8748
- function fileToObjectURL(e) {
8749
- return URL.createObjectURL(e);
8750
- }
8751
- function isImage(e, t) {
8752
- return t.some((t) => e.type.match(t));
8753
- }
8754
- function isVideo(e, t) {
8755
- return t.some((t) => e.type.match(t));
8756
- }
8757
- function insertImage(e, t, n, r, a) {
8758
- let { schema: o } = e.state, s = o.nodes.image;
8759
- if (!s) {
8760
- console.warn("Image node type not found in schema");
8761
- return;
8762
- }
8763
- let c = s.create({
8764
- src: n,
8765
- alt: r,
8766
- title: a
8767
- }), l = e.state.tr.insert(t, c);
8768
- e.dispatch(l);
8769
- }
8770
- function insertVideo(e, t, n, r, a, o) {
8771
- let { schema: s } = e.state, c = s.nodes.video;
8772
- if (!c) {
8773
- console.warn("Video node type not found in schema");
8774
- return;
8775
- }
8776
- let l = c.create({
8777
- src: n,
8778
- title: r,
8779
- width: a,
8780
- height: o,
8781
- controls: !0
8782
- }), u = e.state.tr.insert(t, l);
8783
- e.dispatch(u);
8784
- }
8785
- async function handleMediaFiles(e, t, n, r) {
8786
- let { maxFileSize: a = 10 * 1024 * 1024, maxVideoFileSize: o = 50 * 1024 * 1024, allowedImageTypes: s = ["^image/"], allowedVideoTypes: c = ["^video/"], uploadHandler: l } = r;
8787
- for (let u of t) {
8788
- let t = isImage(u, s), d = isVideo(u, c);
8789
- if (!t && !d) continue;
8790
- let f = d ? o : a;
8791
- if (u.size > f) {
8792
- 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.`);
8793
- continue;
8794
- }
8795
- try {
8796
- console.log(`Processing ${d ? "video" : "image"}: ${u.name} (${(u.size / 1024 / 1024).toFixed(2)}MB, ${u.type})`);
8797
- let t;
8798
- 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;
8799
- } catch (e) {
8800
- console.error(`Failed to process ${d ? "video" : "image"} "${u.name}":`, e);
8801
- }
8802
- }
8803
- }
8804
- function createMediaUploadPlugin(e = {}) {
8805
- return new Plugin({
8806
- key: mediaUploadKey,
8807
- props: {
8808
- handleDrop(t, n, r, a) {
8809
- if (a) return !1;
8810
- let o = Array.from(n.dataTransfer?.files || []);
8811
- if (o.length === 0) return !1;
8812
- let { allowedImageTypes: s = ["^image/"], allowedVideoTypes: c = ["^video/"] } = e;
8813
- if (!o.some((e) => isImage(e, s) || isVideo(e, c))) return !1;
8814
- n.preventDefault();
8815
- let l = {
8816
- left: n.clientX,
8817
- top: n.clientY
8818
- }, u = t.posAtCoords(l);
8819
- return u ? (handleMediaFiles(t, o, u.pos, e), !0) : !1;
8820
- },
8821
- handlePaste(t, n, r) {
8822
- let a = Array.from(n.clipboardData?.items || []).filter((e) => e.type.startsWith("image/"));
8823
- if (a.length === 0) return !1;
8824
- n.preventDefault();
8825
- let o = [];
8826
- for (let e of a) {
8827
- let t = e.getAsFile();
8828
- t && o.push(t);
8829
- }
8830
- if (o.length === 0) return !1;
8831
- let { from: s } = t.state.selection;
8832
- return handleMediaFiles(t, o, s, e), !0;
8833
- }
8834
- }
8835
- });
8836
- }
8837
- var ExtensionMediaUpload = class extends Extension {
8838
- config;
8839
- name = "mediaUpload";
8840
- constructor(e = {}) {
8841
- super(e), this.config = e;
8842
- }
8843
- getProseMirrorPlugins() {
8844
- return [createMediaUploadPlugin(this.config)];
8845
- }
8846
8832
  }, ExtensionTextAlign = class extends Extension {
8847
8833
  name = "textAlign";
8848
8834
  getCommandFactories(e) {
@@ -9074,6 +9060,290 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
9074
9060
  getProseMirrorPlugins() {
9075
9061
  return [createPairingPlugin(["shortcode_inline"])];
9076
9062
  }
9063
+ };
9064
+ //#endregion
9065
+ //#region ../extension-basic-editor/src/media/ExtensionHtml.ts
9066
+ function getHTMLFromFragment(e, t) {
9067
+ let n = globalThis.document, r = DOMSerializer.fromSchema(t).serializeFragment(e, { document: n }), a = n.implementation.createHTMLDocument().createElement("div");
9068
+ return a.appendChild(r), a.innerHTML;
9069
+ }
9070
+ var removeWhitespaces$1 = (e) => {
9071
+ let t = e.childNodes;
9072
+ for (let n = t.length - 1; n >= 0; --n) {
9073
+ let r = t[n];
9074
+ r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && removeWhitespaces$1(r);
9075
+ }
9076
+ return e;
9077
+ };
9078
+ function elementFromString$1(e) {
9079
+ let t = `<html lang="en"><body>${e}</body></html>`, n = new globalThis.DOMParser().parseFromString(t, "text/html").body;
9080
+ return removeWhitespaces$1(n);
9081
+ }
9082
+ var ExtensionHtml = class extends Extension {
9083
+ name = "html";
9084
+ getConverters(e, t) {
9085
+ return { "text/html": {
9086
+ fromDoc: async (t) => {
9087
+ let n = getHTMLFromFragment(t.content, e.schema);
9088
+ return new TextEncoder().encode(n);
9089
+ },
9090
+ toDoc: async (e) => {
9091
+ let n = elementFromString$1(new TextDecoder().decode(e));
9092
+ return DOMParser$1.fromSchema(t).parse(n);
9093
+ }
9094
+ } };
9095
+ }
9096
+ }, mediaUploadKey = new PluginKey("mediaUpload");
9097
+ function fileToDataURL(e) {
9098
+ return new Promise((t, n) => {
9099
+ let r = new FileReader();
9100
+ r.onload = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
9101
+ });
9102
+ }
9103
+ function fileToObjectURL(e) {
9104
+ return URL.createObjectURL(e);
9105
+ }
9106
+ function isImage(e, t) {
9107
+ return t.some((t) => e.type.match(t));
9108
+ }
9109
+ function isVideo(e, t) {
9110
+ return t.some((t) => e.type.match(t));
9111
+ }
9112
+ function insertImage(e, t, n, r, a) {
9113
+ let { schema: o } = e.state, s = o.nodes.image;
9114
+ if (!s) {
9115
+ console.warn("Image node type not found in schema");
9116
+ return;
9117
+ }
9118
+ let c = s.create({
9119
+ src: n,
9120
+ alt: r,
9121
+ title: a
9122
+ }), l = e.state.tr.insert(t, c);
9123
+ e.dispatch(l);
9124
+ }
9125
+ function insertVideo(e, t, n, r, a, o) {
9126
+ let { schema: s } = e.state, c = s.nodes.video;
9127
+ if (!c) {
9128
+ console.warn("Video node type not found in schema");
9129
+ return;
9130
+ }
9131
+ let l = c.create({
9132
+ src: n,
9133
+ title: r,
9134
+ width: a,
9135
+ height: o,
9136
+ controls: !0
9137
+ }), u = e.state.tr.insert(t, l);
9138
+ e.dispatch(u);
9139
+ }
9140
+ async function handleMediaFiles(e, t, n, r) {
9141
+ let { maxFileSize: a = 10 * 1024 * 1024, maxVideoFileSize: o = 50 * 1024 * 1024, allowedImageTypes: s = ["^image/"], allowedVideoTypes: c = ["^video/"], uploadHandler: l } = r;
9142
+ for (let u of t) {
9143
+ let t = isImage(u, s), d = isVideo(u, c);
9144
+ if (!t && !d) continue;
9145
+ let f = d ? o : a;
9146
+ if (u.size > f) {
9147
+ 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.`);
9148
+ continue;
9149
+ }
9150
+ try {
9151
+ console.log(`Processing ${d ? "video" : "image"}: ${u.name} (${(u.size / 1024 / 1024).toFixed(2)}MB, ${u.type})`);
9152
+ let t;
9153
+ 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;
9154
+ } catch (e) {
9155
+ console.error(`Failed to process ${d ? "video" : "image"} "${u.name}":`, e);
9156
+ }
9157
+ }
9158
+ }
9159
+ function createMediaUploadPlugin(e = {}) {
9160
+ return new Plugin({
9161
+ key: mediaUploadKey,
9162
+ props: {
9163
+ handleDrop(t, n, r, a) {
9164
+ if (a) return !1;
9165
+ let o = Array.from(n.dataTransfer?.files || []);
9166
+ if (o.length === 0) return !1;
9167
+ let { allowedImageTypes: s = ["^image/"], allowedVideoTypes: c = ["^video/"] } = e;
9168
+ if (o.some((e) => isImage(e, s) || isVideo(e, c))) {
9169
+ n.preventDefault();
9170
+ let r = {
9171
+ left: n.clientX,
9172
+ top: n.clientY
9173
+ }, a = t.posAtCoords(r);
9174
+ return a ? (handleMediaFiles(t, o, a.pos, e), !0) : !1;
9175
+ }
9176
+ },
9177
+ handlePaste(t, n, r) {
9178
+ let a = Array.from(n.clipboardData?.items || []).filter((e) => e.type.startsWith("image/"));
9179
+ if (a.length > 0) {
9180
+ n.preventDefault();
9181
+ let r = [];
9182
+ for (let e of a) {
9183
+ let t = e.getAsFile();
9184
+ t && r.push(t);
9185
+ }
9186
+ if (r.length === 0) return !1;
9187
+ let { from: o } = t.state.selection;
9188
+ return handleMediaFiles(t, r, o, e), !0;
9189
+ }
9190
+ }
9191
+ }
9192
+ });
9193
+ }
9194
+ var ExtensionMediaUpload = class extends Extension {
9195
+ config;
9196
+ name = "mediaUpload";
9197
+ constructor(e = {}) {
9198
+ super(e), this.config = e;
9199
+ }
9200
+ getProseMirrorPlugins() {
9201
+ return [createMediaUploadPlugin(this.config)];
9202
+ }
9203
+ };
9204
+ //#endregion
9205
+ //#region ../extension-basic-editor/src/media/ExtensionPaste.ts
9206
+ function getStringByXPath(e, t) {
9207
+ return t.ownerDocument.evaluate(e, t, null, XPathResult.STRING_TYPE, null).stringValue;
9208
+ }
9209
+ function getElementsByXPath(e, t) {
9210
+ let n = t.ownerDocument.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), r = [];
9211
+ for (let e = 0; e < n.snapshotLength; e++) {
9212
+ let t = n.snapshotItem(e);
9213
+ t && r.push(t);
9214
+ }
9215
+ return r;
9216
+ }
9217
+ var PasteState = class {
9218
+ editor;
9219
+ pasteRules = [];
9220
+ constructor(e) {
9221
+ this.editor = e;
9222
+ }
9223
+ handleCommands(e, t) {
9224
+ if (!e) return !1;
9225
+ if (e.getPasteRules) return e.getPasteRules(this.pasteRules), !0;
9226
+ if (e.setPasteRules) return console.log("setPasteRules", e.setPasteRules), this.pasteRules = e.setPasteRules, !0;
9227
+ if (e.pasteHtml) {
9228
+ let { from: t, html: n } = e.pasteHtml, r = elementFromString$1(n), a = this.editor, o = !1, s = [], c = a.ci.resolve("yaml");
9229
+ for (let e of this.pasteRules) {
9230
+ if (typeof e.match == "string") {
9231
+ if (getElementsByXPath(e.match, r).length === 0) continue;
9232
+ } else if (!e.match(r)) continue;
9233
+ for (let t of e.steps) {
9234
+ let e;
9235
+ if (typeof t.match == "string") switch (t.result || "") {
9236
+ case "string":
9237
+ e = getStringByXPath(t.match, r);
9238
+ break;
9239
+ default:
9240
+ e = getElementsByXPath(t.match, r);
9241
+ break;
9242
+ }
9243
+ else e = t.match(r);
9244
+ switch (console.log("step", e, t), t.op) {
9245
+ case "remove":
9246
+ for (let t of e) t.parentNode?.removeChild(t);
9247
+ break;
9248
+ case "replaceTag":
9249
+ for (let n of e) {
9250
+ let e = n.ownerDocument.createElement(t.tag);
9251
+ e.innerHTML = n.innerHTML, n.parentNode?.replaceChild(e, n);
9252
+ }
9253
+ break;
9254
+ case "replaceBody":
9255
+ for (let t of e) r.innerHTML = "", r.appendChild(t);
9256
+ break;
9257
+ case "console.debug":
9258
+ console.debug(e);
9259
+ break;
9260
+ case "meta.set":
9261
+ s.push({
9262
+ path: t.path,
9263
+ value: e
9264
+ });
9265
+ break;
9266
+ }
9267
+ }
9268
+ o = !!e.replaceDocument;
9269
+ break;
9270
+ }
9271
+ let l = DOMParser$1.fromSchema(this.editor.schema).parse(r);
9272
+ return setTimeout(async () => {
9273
+ let e = this.editor.state.tr;
9274
+ o ? e.replaceWith(0, this.editor.state.doc.content.size, l) : e.insert(t, l);
9275
+ {
9276
+ let t = await new Promise((e) => this.editor.chain().getMeta(e).run()) || /* @__PURE__ */ new Map();
9277
+ for (let e of s) c.setPathValue(t, e.path, e.value);
9278
+ e.setDocAttribute("meta", t);
9279
+ }
9280
+ this.editor.dispatchTransaction(e);
9281
+ }, 0), !0;
9282
+ }
9283
+ return !1;
9284
+ }
9285
+ }, PastePluginKey = new PluginKey("paste"), ExtensionPaste = class extends Extension {
9286
+ name = "paste";
9287
+ getProseMirrorPlugins() {
9288
+ let e = this.editor;
9289
+ return [new Plugin({
9290
+ key: PastePluginKey,
9291
+ state: {
9292
+ init() {
9293
+ return PastePluginKey.getState(e.state) || new PasteState(e);
9294
+ },
9295
+ apply(e, t, n, r) {
9296
+ if (e.isGeneric) return t;
9297
+ let a = e.getMeta(PastePluginKey);
9298
+ return t.handleCommands(a, e), t;
9299
+ }
9300
+ },
9301
+ props: {
9302
+ handlePaste(t, n, r) {
9303
+ let { clipboardData: a } = n;
9304
+ if (!a) return !1;
9305
+ if (a.types.includes("text/html")) {
9306
+ let { from: e } = t.state.selection, r = a.getData("text/html");
9307
+ n.preventDefault();
9308
+ let o = t.state.tr.setMeta(PastePluginKey, { pasteHtml: {
9309
+ from: e,
9310
+ html: r
9311
+ } });
9312
+ return t.dispatch(o), !0;
9313
+ }
9314
+ [...a.items].map((e) => e.getAsFile()).filter((e) => !!e);
9315
+ let o = Array.from(n.clipboardData?.files || []);
9316
+ if (o.length === 1) {
9317
+ let t = o[0];
9318
+ if (e.getMediaTypes().includes(t.type)) return t.bytes().then((n) => {
9319
+ e.loadDocument(t.type, n);
9320
+ }), !0;
9321
+ }
9322
+ },
9323
+ handleDrop(t, n, r, a) {
9324
+ let o = Array.from(n.dataTransfer?.files || []);
9325
+ if (o.length === 1) {
9326
+ let t = o[0];
9327
+ if (e.getMediaTypes().includes(t.type)) return t.bytes().then((n) => {
9328
+ e.loadDocument(t.type, n);
9329
+ }), !0;
9330
+ }
9331
+ }
9332
+ }
9333
+ })];
9334
+ }
9335
+ getCommandFactories(e) {
9336
+ return {
9337
+ getPasteRules: (e) => (t, n) => {
9338
+ let r = t.tr;
9339
+ return r.setMeta(PastePluginKey, { getPasteRules: e }), n && n(r), !0;
9340
+ },
9341
+ setPasteRules: (e) => (t, n) => {
9342
+ let r = t.tr;
9343
+ return r.setMeta(PastePluginKey, { setPasteRules: e }), n && n(r), !0;
9344
+ }
9345
+ };
9346
+ }
9077
9347
  }, MarkLink = class extends Mark {
9078
9348
  name = "link";
9079
9349
  requires = ["doc"];
@@ -9351,6 +9621,7 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
9351
9621
  getNodeSpec() {
9352
9622
  return {
9353
9623
  content: "block+",
9624
+ attrs: { meta: { default: null } },
9354
9625
  marks: "code em strong link bookmark",
9355
9626
  EMPTY_DOC: {
9356
9627
  type: this.name,
@@ -9361,6 +9632,19 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
9361
9632
  }
9362
9633
  };
9363
9634
  }
9635
+ getCommandFactories(e, t) {
9636
+ return {
9637
+ getMeta: (e) => (t, n) => (e(structuredClone(t.doc.attrs.meta)), !0),
9638
+ setMeta: (e) => (t, n) => {
9639
+ let r = t.tr;
9640
+ return r.setDocAttribute("meta", e), n && n(r), r.docChanged;
9641
+ },
9642
+ updateMeta: (e) => (t, n) => {
9643
+ let r = t.tr;
9644
+ return r.setDocAttribute("meta", e(t.doc.attrs.meta)), n && n(r), r.docChanged;
9645
+ }
9646
+ };
9647
+ }
9364
9648
  }, NodeText = class extends Node$2 {
9365
9649
  name = "text";
9366
9650
  getNodeSpec() {
@@ -9851,20 +10135,6 @@ var NodeCodeBlock$1 = class extends Node$2 {
9851
10135
  }
9852
10136
  };
9853
10137
  }
9854
- }, NodeFrontmatter = class extends Node$2 {
9855
- name = "frontmatter";
9856
- requires = ["doc"];
9857
- getNodeSpec() {
9858
- return {
9859
- content: "inline*",
9860
- group: "block",
9861
- defining: !0,
9862
- parseDOM: [{ tag: "pre" }],
9863
- toDOM() {
9864
- return ["pre", 0];
9865
- }
9866
- };
9867
- }
9868
10138
  };
9869
10139
  //#endregion
9870
10140
  //#region ../extension-basic-editor/src/NodeInlineShortCode.ts
@@ -10431,6 +10701,7 @@ var joinListBackwards = (e, t) => {
10431
10701
  new ExtensionTextAlign(),
10432
10702
  new ExtensionPairing(),
10433
10703
  new ExtensionUser(),
10704
+ new ExtensionPaste(),
10434
10705
  new NodeDocument(),
10435
10706
  new NodeText(),
10436
10707
  new NodeParagraph(),
@@ -10449,7 +10720,6 @@ var joinListBackwards = (e, t) => {
10449
10720
  new NodeDefinitionDesc(),
10450
10721
  new NodeTaskList(),
10451
10722
  new NodeTaskItem(),
10452
- new NodeFrontmatter(),
10453
10723
  new NodeImage(),
10454
10724
  new NodeVideo(),
10455
10725
  new NodeBlockquote(),
@@ -11738,7 +12008,7 @@ var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/, Language = class e {
11738
12008
  static async load(t) {
11739
12009
  let n;
11740
12010
  if (t instanceof Uint8Array) n = t;
11741
- else if (globalThis.process?.versions.node) n = await (await import("./__vite-browser-external-BXJKwL9l.js").then((e) => /* @__PURE__ */ __toESM(e.default, 1))).readFile(t);
12011
+ else if (globalThis.process?.versions.node) n = await (await import("./__vite-browser-external-Bk07RSXL.js").then((e) => /* @__PURE__ */ __toESM(e.default, 1))).readFile(t);
11742
12012
  else {
11743
12013
  let e = await fetch(t);
11744
12014
  if (!e.ok) {
@@ -11763,7 +12033,7 @@ ${JSON.stringify(a, null, 2)}`), Error("Language.load failed: no language functi
11763
12033
  async function Module2(moduleArg = {}) {
11764
12034
  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";
11765
12035
  if (ENVIRONMENT_IS_NODE) {
11766
- let { createRequire: e } = await import("./__vite-browser-external-BXJKwL9l.js").then((e) => /* @__PURE__ */ __toESM(e.default, 1));
12036
+ let { createRequire: e } = await import("./__vite-browser-external-Bk07RSXL.js").then((e) => /* @__PURE__ */ __toESM(e.default, 1));
11767
12037
  var require = e(import.meta.url);
11768
12038
  }
11769
12039
  Module.currentQueryProgressCallback = null, Module.currentProgressCallback = null, Module.currentLogCallback = null, Module.currentParseCallback = null;
@@ -21331,7 +21601,7 @@ function getHeaderTokensHandlers() {
21331
21601
  function getBasicTokensHandlers() {
21332
21602
  return {
21333
21603
  frontmatter: [(e, t) => {
21334
- t.current.log("---\n" + e.content + "\n---\n\n", e);
21604
+ t.current.log(e.content, e);
21335
21605
  }],
21336
21606
  heading_open: [(e, t) => {
21337
21607
  t.stash("getBasicTokensHandlers.heading_open"), t.current.handlers = getHeaderTokensHandlers(), e.markup !== "---" && t.current.log("#".repeat(+e.tag.substring(1)) + " ", e);
@@ -22061,6 +22331,7 @@ var nullNode = {
22061
22331
  async markString(e, t, n) {
22062
22332
  let r = this.getMark(e.type.name), a = t ? r.open : r.close;
22063
22333
  if (!a) {
22334
+ if (["highlight", "textColor"].includes(e.type.name)) return;
22064
22335
  console.warn("Unsupported mark type for markdown: " + e.type.name + ", available types: " + Object.keys(this.marks).join(", ") + ". Mark will be ignored.");
22065
22336
  return;
22066
22337
  }
@@ -22170,6 +22441,12 @@ async function pmToMdConverter(e, t, n, r) {
22170
22441
  }
22171
22442
  async function extPmToMdConverter(e, t, n, r) {
22172
22443
  let a = new MdStashContext(), o, s = new DocumentMarkdownTokenizer({
22444
+ doc(e) {
22445
+ return { open: async (e, n, r) => {
22446
+ let a = new Token("frontmatter", "frontmatter", 0);
22447
+ 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;
22448
+ } };
22449
+ },
22173
22450
  paragraph(e) {
22174
22451
  return {
22175
22452
  open: async (e, t, n) => {
@@ -22434,7 +22711,7 @@ async function extPmToMdConverter(e, t, n, r) {
22434
22711
  };
22435
22712
  }
22436
22713
  //#endregion
22437
- //#region \0deno::TypeScript::@kerebron/extension-basic-editor/ExtensionHtml::/home/runner/work/kerebron/kerebron/packages/extension-basic-editor/src/ExtensionHtml.ts
22714
+ //#region \0deno::TypeScript::@kerebron/extension-basic-editor/ExtensionHtml::/home/runner/work/kerebron/kerebron/packages/extension-basic-editor/src/media/ExtensionHtml.ts
22438
22715
  var removeWhitespaces = (e) => {
22439
22716
  let t = e.childNodes;
22440
22717
  for (let n = t.length - 1; n >= 0; --n) {
@@ -22730,6 +23007,12 @@ function treeToTokens(e, t, n) {
22730
23007
  t.map = e, t.meta = "noEscText", t.content = o(u) ?? "", s(t, "hard_line_break");
22731
23008
  }
22732
23009
  break;
23010
+ case "backslash_escape":
23011
+ {
23012
+ let t = new Token("text", "", 0);
23013
+ t.map = e, t.meta = "noEscText", t.content = o(u) ?? "", s(t, "backslash_escape");
23014
+ }
23015
+ break;
22733
23016
  default: throw console.debug("inline_node", u), Error(`Unhandled inline node type: ${u.type}`);
22734
23017
  }
22735
23018
  }
@@ -23000,7 +23283,19 @@ async function mdToPmConverter(e, t, n) {
23000
23283
  async function mdToPmConverterText(e, t, n) {
23001
23284
  if (!t.assetLoad) throw Error("No config.assetLoad");
23002
23285
  let r = new MarkdownParser(n, await sitterTokenizer(t.assetLoad), {
23003
- frontmatter: { node: "frontmatter" },
23286
+ frontmatter: { custom: (e, n) => {
23287
+ let r = e.stack[0];
23288
+ if (r?.type.name === "doc") {
23289
+ let e = n.content, a = e.indexOf("\n---\n", 4);
23290
+ if (e.startsWith("---\n") && a > -1) {
23291
+ let n = t.yaml?.parse(e.substring(4, a)) || void 0;
23292
+ r.attrs = {
23293
+ ...r.attrs,
23294
+ meta: n
23295
+ };
23296
+ }
23297
+ }
23298
+ } },
23004
23299
  blockquote: { block: "blockquote" },
23005
23300
  paragraph: { block: "paragraph" },
23006
23301
  task_item: { block: "task_item" },
@@ -23417,19 +23712,24 @@ var ExtensionMarkdown = class extends Extension {
23417
23712
  assetLoad: this.editor.config.assetLoad,
23418
23713
  ...this.config,
23419
23714
  urlRewriter: this.urlToRewriter,
23420
- hooks: this.hooks["pm2md.pre"]
23715
+ hooks: this.hooks["pm2md.pre"],
23716
+ yaml: e.ci.resolve("yaml")
23421
23717
  }, t, e),
23422
- toDoc: (e) => mdToPmConverter(e, {
23718
+ toDoc: (n) => mdToPmConverter(n, {
23423
23719
  assetLoad: this.editor.config.assetLoad,
23424
23720
  ...this.config,
23425
23721
  urlRewriter: this.urlFromRewriter,
23426
- hooks: this.hooks["md2pm.post"]
23722
+ hooks: this.hooks["md2pm.post"],
23723
+ yaml: e.ci.resolve("yaml")
23427
23724
  }, t)
23428
23725
  } };
23429
23726
  return n["text/markdown"] = n["text/x-markdown"], n;
23430
23727
  }
23431
23728
  toMarkdown(e) {
23432
- return extPmToMdConverter(e, { sourceMap: !0 }, this.editor.schema, this.editor);
23729
+ return extPmToMdConverter(e, {
23730
+ sourceMap: !0,
23731
+ yaml: this.editor.ci.resolve("yaml")
23732
+ }, this.editor.schema, this.editor);
23433
23733
  }
23434
23734
  async fromMarkdown(e) {
23435
23735
  let t = (await mdToPmConverterText(e, {