@kerebron/legacy-compat 0.8.3 → 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;
@@ -6958,7 +6958,140 @@ 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;
6961
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
+ }
6962
7095
  //#endregion
6963
7096
  //#region ../editor/src/ExtensionManager.ts
6964
7097
  function splitExtensions(e) {
@@ -7077,7 +7210,7 @@ var ExtensionManager = class {
7077
7210
  for (let t of e.conflicts) if (a.find((e) => e.name === t)) throw Error(`Extension conflict: ${e.name} vs ${t}`);
7078
7211
  }
7079
7212
  for (let t of a) e.ci.register(t.name, t);
7080
- this.initPlugins(e, t);
7213
+ e.ci.register("yaml", yaml_exports), this.initPlugins(e, t);
7081
7214
  for (let e of this.extensions) e.created();
7082
7215
  }
7083
7216
  };
@@ -8102,6 +8235,9 @@ var CoreEditor = class e extends EventTarget {
8102
8235
  let n = await this.getConverter(e).toDoc(t), r = this.state.tr;
8103
8236
  r.replaceWith(0, this.state.doc.content.size, n.content), this.dispatchTransaction(r);
8104
8237
  }
8238
+ getMediaTypes() {
8239
+ return Object.keys(this.extensionManager.converters);
8240
+ }
8105
8241
  patchDocumentText(e, t) {
8106
8242
  return this.patchDocument(e, new TextEncoder().encode(t));
8107
8243
  }
@@ -8693,168 +8829,6 @@ var ExtensionGapcursor = class extends Extension {
8693
8829
  getProseMirrorPlugins() {
8694
8830
  return [gapCursor()];
8695
8831
  }
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
8832
  }, ExtensionTextAlign = class extends Extension {
8859
8833
  name = "textAlign";
8860
8834
  getCommandFactories(e) {
@@ -9086,6 +9060,290 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
9086
9060
  getProseMirrorPlugins() {
9087
9061
  return [createPairingPlugin(["shortcode_inline"])];
9088
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
+ }
9089
9347
  }, MarkLink = class extends Mark {
9090
9348
  name = "link";
9091
9349
  requires = ["doc"];
@@ -9363,6 +9621,7 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
9363
9621
  getNodeSpec() {
9364
9622
  return {
9365
9623
  content: "block+",
9624
+ attrs: { meta: { default: null } },
9366
9625
  marks: "code em strong link bookmark",
9367
9626
  EMPTY_DOC: {
9368
9627
  type: this.name,
@@ -9373,6 +9632,19 @@ var createPairingPlugin = (e) => new Plugin({ appendTransaction(t, n, r) {
9373
9632
  }
9374
9633
  };
9375
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
+ }
9376
9648
  }, NodeText = class extends Node$2 {
9377
9649
  name = "text";
9378
9650
  getNodeSpec() {
@@ -9863,20 +10135,6 @@ var NodeCodeBlock$1 = class extends Node$2 {
9863
10135
  }
9864
10136
  };
9865
10137
  }
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
10138
  };
9881
10139
  //#endregion
9882
10140
  //#region ../extension-basic-editor/src/NodeInlineShortCode.ts
@@ -10443,6 +10701,7 @@ var joinListBackwards = (e, t) => {
10443
10701
  new ExtensionTextAlign(),
10444
10702
  new ExtensionPairing(),
10445
10703
  new ExtensionUser(),
10704
+ new ExtensionPaste(),
10446
10705
  new NodeDocument(),
10447
10706
  new NodeText(),
10448
10707
  new NodeParagraph(),
@@ -10461,7 +10720,6 @@ var joinListBackwards = (e, t) => {
10461
10720
  new NodeDefinitionDesc(),
10462
10721
  new NodeTaskList(),
10463
10722
  new NodeTaskItem(),
10464
- new NodeFrontmatter(),
10465
10723
  new NodeImage(),
10466
10724
  new NodeVideo(),
10467
10725
  new NodeBlockquote(),
@@ -11750,7 +12008,7 @@ var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/, Language = class e {
11750
12008
  static async load(t) {
11751
12009
  let n;
11752
12010
  if (t instanceof Uint8Array) n = t;
11753
- 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);
11754
12012
  else {
11755
12013
  let e = await fetch(t);
11756
12014
  if (!e.ok) {
@@ -11775,7 +12033,7 @@ ${JSON.stringify(a, null, 2)}`), Error("Language.load failed: no language functi
11775
12033
  async function Module2(moduleArg = {}) {
11776
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";
11777
12035
  if (ENVIRONMENT_IS_NODE) {
11778
- 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));
11779
12037
  var require = e(import.meta.url);
11780
12038
  }
11781
12039
  Module.currentQueryProgressCallback = null, Module.currentProgressCallback = null, Module.currentLogCallback = null, Module.currentParseCallback = null;
@@ -21343,7 +21601,7 @@ function getHeaderTokensHandlers() {
21343
21601
  function getBasicTokensHandlers() {
21344
21602
  return {
21345
21603
  frontmatter: [(e, t) => {
21346
- t.current.log("---\n" + e.content + "\n---\n\n", e);
21604
+ t.current.log(e.content, e);
21347
21605
  }],
21348
21606
  heading_open: [(e, t) => {
21349
21607
  t.stash("getBasicTokensHandlers.heading_open"), t.current.handlers = getHeaderTokensHandlers(), e.markup !== "---" && t.current.log("#".repeat(+e.tag.substring(1)) + " ", e);
@@ -22073,6 +22331,7 @@ var nullNode = {
22073
22331
  async markString(e, t, n) {
22074
22332
  let r = this.getMark(e.type.name), a = t ? r.open : r.close;
22075
22333
  if (!a) {
22334
+ if (["highlight", "textColor"].includes(e.type.name)) return;
22076
22335
  console.warn("Unsupported mark type for markdown: " + e.type.name + ", available types: " + Object.keys(this.marks).join(", ") + ". Mark will be ignored.");
22077
22336
  return;
22078
22337
  }
@@ -22182,6 +22441,12 @@ async function pmToMdConverter(e, t, n, r) {
22182
22441
  }
22183
22442
  async function extPmToMdConverter(e, t, n, r) {
22184
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
+ },
22185
22450
  paragraph(e) {
22186
22451
  return {
22187
22452
  open: async (e, t, n) => {
@@ -22446,7 +22711,7 @@ async function extPmToMdConverter(e, t, n, r) {
22446
22711
  };
22447
22712
  }
22448
22713
  //#endregion
22449
- //#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
22450
22715
  var removeWhitespaces = (e) => {
22451
22716
  let t = e.childNodes;
22452
22717
  for (let n = t.length - 1; n >= 0; --n) {
@@ -22742,6 +23007,12 @@ function treeToTokens(e, t, n) {
22742
23007
  t.map = e, t.meta = "noEscText", t.content = o(u) ?? "", s(t, "hard_line_break");
22743
23008
  }
22744
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;
22745
23016
  default: throw console.debug("inline_node", u), Error(`Unhandled inline node type: ${u.type}`);
22746
23017
  }
22747
23018
  }
@@ -23012,7 +23283,19 @@ async function mdToPmConverter(e, t, n) {
23012
23283
  async function mdToPmConverterText(e, t, n) {
23013
23284
  if (!t.assetLoad) throw Error("No config.assetLoad");
23014
23285
  let r = new MarkdownParser(n, await sitterTokenizer(t.assetLoad), {
23015
- 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
+ } },
23016
23299
  blockquote: { block: "blockquote" },
23017
23300
  paragraph: { block: "paragraph" },
23018
23301
  task_item: { block: "task_item" },
@@ -23429,19 +23712,24 @@ var ExtensionMarkdown = class extends Extension {
23429
23712
  assetLoad: this.editor.config.assetLoad,
23430
23713
  ...this.config,
23431
23714
  urlRewriter: this.urlToRewriter,
23432
- hooks: this.hooks["pm2md.pre"]
23715
+ hooks: this.hooks["pm2md.pre"],
23716
+ yaml: e.ci.resolve("yaml")
23433
23717
  }, t, e),
23434
- toDoc: (e) => mdToPmConverter(e, {
23718
+ toDoc: (n) => mdToPmConverter(n, {
23435
23719
  assetLoad: this.editor.config.assetLoad,
23436
23720
  ...this.config,
23437
23721
  urlRewriter: this.urlFromRewriter,
23438
- hooks: this.hooks["md2pm.post"]
23722
+ hooks: this.hooks["md2pm.post"],
23723
+ yaml: e.ci.resolve("yaml")
23439
23724
  }, t)
23440
23725
  } };
23441
23726
  return n["text/markdown"] = n["text/x-markdown"], n;
23442
23727
  }
23443
23728
  toMarkdown(e) {
23444
- 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);
23445
23733
  }
23446
23734
  async fromMarkdown(e) {
23447
23735
  let t = (await mdToPmConverterText(e, {