@cocoar/vue-markdown-editor 2.11.0 → 2.13.0

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/index.js CHANGED
@@ -1,31 +1,31 @@
1
- import { Fragment as e, Teleport as t, computed as n, createApp as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, h as d, inject as f, markRaw as p, normalizeClass as m, normalizeStyle as h, onBeforeUnmount as ee, onMounted as g, openBlock as _, ref as v, renderList as y, shallowRef as b, toDisplayString as x, unref as S, useId as C, useTemplateRef as w, vModelText as T, vShow as E, watch as D, withCtx as O, withDirectives as k, withKeys as A, withModifiers as j } from "vue";
2
- import { Editor as te, commandsCtx as M, defaultValueCtx as N, editorViewCtx as P, editorViewOptionsCtx as F, rootCtx as I } from "@milkdown/core";
3
- import { Milkdown as ne, MilkdownProvider as re, useEditor as ie, useInstance as ae } from "@milkdown/vue";
4
- import { CoarButton as L, CoarCodeBlock as R, CoarContextMenu as oe, CoarFormField as z, CoarIcon as B, CoarMenuDivider as se, CoarMenuItem as ce, CoarSelect as V, CoarSidebar as le, CoarSidebarDivider as H, CoarSidebarGroup as ue, CoarSidebarItem as U, CoarTextInput as W, FORM_FIELD_INJECTION_KEY as G, menuPreset as K, useContextMenu as de, useDialog as fe, useOverlay as pe } from "@cocoar/vue-ui";
5
- import { codeBlockSchema as me, commonmark as q, createCodeBlockCommand as he, insertHrCommand as ge, insertImageCommand as _e, liftListItemCommand as ve, sinkListItemCommand as ye, toggleEmphasisCommand as be, toggleInlineCodeCommand as xe, toggleStrongCommand as Se, turnIntoTextCommand as Ce, wrapInBlockquoteCommand as we, wrapInBulletListCommand as Te, wrapInHeadingCommand as J, wrapInOrderedListCommand as Ee } from "@milkdown/preset-commonmark";
6
- import { Plugin as De, PluginKey as Oe, TextSelection as ke } from "@milkdown/prose/state";
7
- import { $markSchema as Ae, $nodeSchema as je, $prose as Me, $remark as Ne, $view as Pe, replaceAll as Fe } from "@milkdown/utils";
8
- import { isColorSpanClose as Ie, parse as Le, parseColorSpanOpen as Re, parseFrontmatter as ze, sanitizeColor as Y, serializeColorSpanClose as Be, serializeColorSpanOpen as Ve } from "@cocoar/vue-markdown-core";
9
- import { CoarMarkdown as He } from "@cocoar/vue-markdown";
10
- import { addColAfterCommand as Ue, addColBeforeCommand as We, addRowAfterCommand as Ge, addRowBeforeCommand as Ke, deleteSelectedCellsCommand as qe, gfm as Je, insertTableCommand as Ye, moveColCommand as Xe, moveRowCommand as Ze, selectColCommand as Qe, selectRowCommand as $e, selectTableCommand as et, toggleStrikethroughCommand as tt } from "@milkdown/preset-gfm";
11
- import { Decoration as nt, DecorationSet as rt } from "@milkdown/prose/view";
12
- import { history as it, redoCommand as at, undoCommand as ot } from "@milkdown/plugin-history";
13
- import { clipboard as st } from "@milkdown/plugin-clipboard";
14
- import { listener as ct, listenerCtx as lt } from "@milkdown/plugin-listener";
1
+ import { Fragment as e, Teleport as t, computed as n, createApp as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, getCurrentInstance as d, h as f, inject as p, markRaw as m, normalizeClass as h, normalizeStyle as g, onBeforeUnmount as ee, onMounted as _, openBlock as v, ref as y, render as b, renderList as x, shallowRef as te, toDisplayString as S, unref as C, useId as w, useTemplateRef as T, vModelText as E, vShow as D, watch as O, withCtx as k, withDirectives as A, withKeys as j, withModifiers as M } from "vue";
2
+ import { Editor as N, commandsCtx as P, defaultValueCtx as F, editorViewCtx as I, editorViewOptionsCtx as L, rootCtx as ne } from "@milkdown/core";
3
+ import { Milkdown as re, MilkdownProvider as R, useEditor as z, useInstance as ie } from "@milkdown/vue";
4
+ import { CoarButton as B, CoarCodeBlock as ae, CoarContextMenu as oe, CoarFormField as V, CoarIcon as H, CoarMenuDivider as se, CoarMenuItem as U, CoarSelect as W, CoarSidebar as ce, CoarSidebarDivider as le, CoarSidebarGroup as ue, CoarSidebarItem as G, CoarTextInput as K, FORM_FIELD_INJECTION_KEY as de, menuPreset as fe, useContextMenu as pe, useDialog as me, useOverlay as he } from "@cocoar/vue-ui";
5
+ import { codeBlockSchema as q, commonmark as ge, createCodeBlockCommand as _e, insertHrCommand as ve, insertImageCommand as ye, liftListItemCommand as be, sinkListItemCommand as xe, toggleEmphasisCommand as Se, toggleInlineCodeCommand as Ce, toggleStrongCommand as we, turnIntoTextCommand as Te, wrapInBlockquoteCommand as Ee, wrapInBulletListCommand as De, wrapInHeadingCommand as J, wrapInOrderedListCommand as Oe } from "@milkdown/preset-commonmark";
6
+ import { Plugin as ke, PluginKey as Ae, TextSelection as je } from "@milkdown/prose/state";
7
+ import { $markSchema as Me, $nodeSchema as Ne, $prose as Pe, $remark as Fe, $view as Ie, replaceAll as Le } from "@milkdown/utils";
8
+ import { isColorSpanClose as Re, parse as ze, parseColorSpanOpen as Be, parseEmbedDirective as Ve, parseFrontmatter as He, sanitizeColor as Y, serializeColorSpanClose as Ue, serializeColorSpanOpen as We, serializeEmbedDirective as Ge, toEmbedProps as Ke } from "@cocoar/vue-markdown-core";
9
+ import { CoarMarkdown as qe, EmbedRenderer as Je, EmbedRenderer as Ye, MARKDOWN_EMBEDS_KEY as Xe, resolveEmbed as Ze, resolveEmbed as Qe } from "@cocoar/vue-markdown";
10
+ import { addColAfterCommand as $e, addColBeforeCommand as et, addRowAfterCommand as tt, addRowBeforeCommand as nt, deleteSelectedCellsCommand as rt, gfm as it, insertTableCommand as at, moveColCommand as ot, moveRowCommand as st, selectColCommand as ct, selectRowCommand as lt, selectTableCommand as ut, toggleStrikethroughCommand as dt } from "@milkdown/preset-gfm";
11
+ import { Decoration as ft, DecorationSet as pt } from "@milkdown/prose/view";
12
+ import { history as mt, redoCommand as ht, undoCommand as gt } from "@milkdown/plugin-history";
13
+ import { clipboard as _t } from "@milkdown/plugin-clipboard";
14
+ import { listener as vt, listenerCtx as yt } from "@milkdown/plugin-listener";
15
15
  //#region \0rolldown/runtime.js
16
- var ut = Object.create, dt = Object.defineProperty, ft = Object.getOwnPropertyDescriptor, pt = Object.getOwnPropertyNames, mt = Object.getPrototypeOf, ht = Object.prototype.hasOwnProperty, gt = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), _t = (e, t, n, r) => {
17
- if (t && typeof t == "object" || typeof t == "function") for (var i = pt(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !ht.call(e, s) && s !== n && dt(e, s, {
16
+ var bt = Object.create, xt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, Ct = Object.getOwnPropertyNames, wt = Object.getPrototypeOf, Tt = Object.prototype.hasOwnProperty, Et = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), Dt = (e, t, n, r) => {
17
+ if (t && typeof t == "object" || typeof t == "function") for (var i = Ct(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !Tt.call(e, s) && s !== n && xt(e, s, {
18
18
  get: ((e) => t[e]).bind(null, s),
19
- enumerable: !(r = ft(t, s)) || r.enumerable
19
+ enumerable: !(r = St(t, s)) || r.enumerable
20
20
  });
21
21
  return e;
22
- }, vt = (e, t, n) => (n = e == null ? {} : ut(mt(e)), _t(t || !e || !e.__esModule ? dt(n, "default", {
22
+ }, Ot = (e, t, n) => (n = e == null ? {} : bt(wt(e)), Dt(t || !e || !e.__esModule ? xt(n, "default", {
23
23
  value: e,
24
24
  enumerable: !0
25
25
  }) : n, e));
26
26
  //#endregion
27
27
  //#region src/toolbar-helpers.ts
28
- function yt(e, t) {
28
+ function kt(e, t) {
29
29
  switch (e) {
30
30
  case "table":
31
31
  case "tableOps":
@@ -35,38 +35,42 @@ function yt(e, t) {
35
35
  default: return !0;
36
36
  }
37
37
  }
38
- function bt(e, t) {
38
+ function At(e, t) {
39
39
  return t === void 0 ? !0 : "has" in t ? t.has(e) : t.includes(e);
40
40
  }
41
- function xt(e) {
41
+ function jt(e) {
42
42
  let { target: t, inBulletList: n, inOrderedList: r } = e;
43
43
  return (t === "bullet_list" ? n : r) ? "lift" : (t === "bullet_list" ? r : n) ? "switch" : "wrap";
44
44
  }
45
45
  //#endregion
46
46
  //#region src/flavor.ts
47
- var St = {
47
+ var Mt = {
48
48
  commonmark: {
49
49
  gfm: !1,
50
- textColor: !1
50
+ textColor: !1,
51
+ embeds: !1
51
52
  },
52
53
  gfm: {
53
54
  gfm: !0,
54
- textColor: !1
55
+ textColor: !1,
56
+ embeds: !1
55
57
  },
56
58
  cocoar: {
57
59
  gfm: !0,
58
- textColor: !0
60
+ textColor: !0,
61
+ embeds: !0
59
62
  }
60
63
  };
61
- function Ct(e) {
62
- return e === void 0 ? { ...St.cocoar } : typeof e == "string" ? { ...St[e] ?? St.cocoar } : {
64
+ function Nt(e) {
65
+ return e === void 0 ? { ...Mt.cocoar } : typeof e == "string" ? { ...Mt[e] ?? Mt.cocoar } : {
63
66
  gfm: e.gfm ?? !1,
64
- textColor: e.textColor ?? !1
67
+ textColor: e.textColor ?? !1,
68
+ embeds: e.embeds ?? !1
65
69
  };
66
70
  }
67
71
  //#endregion
68
72
  //#region src/code-block-view/CodeBlockShell.vue?vue&type=script&setup=true&lang.ts
69
- var wt = { class: "coar-md-code-render" }, Tt = { class: "coar-md-code-edit" }, Et = { class: "coar-md-code-lang-row" }, Dt = /* @__PURE__ */ u({
73
+ var Pt = { class: "coar-md-code-render" }, Ft = { class: "coar-md-code-edit" }, It = { class: "coar-md-code-lang-row" }, Lt = /* @__PURE__ */ u({
70
74
  __name: "CodeBlockShell",
71
75
  props: {
72
76
  text: {},
@@ -109,13 +113,13 @@ var wt = { class: "coar-md-code-render" }, Tt = { class: "coar-md-code-edit" },
109
113
  value: "bash",
110
114
  label: "Bash"
111
115
  }
112
- ], a = w("contentMount");
113
- return D([a, () => n.contentDOM], ([e, t]) => {
116
+ ], a = T("contentMount");
117
+ return O([a, () => n.contentDOM], ([e, t]) => {
114
118
  e && t && t.parentElement !== e && e.appendChild(t);
115
119
  }, {
116
120
  immediate: !0,
117
121
  flush: "post"
118
- }), (t, n) => (_(), o("div", { class: m(["coar-md-code-host", { "coar-md-code-host--editing": e.editing }]) }, [k(s("div", wt, [l(S(R), {
122
+ }), (t, n) => (v(), o("div", { class: h(["coar-md-code-host", { "coar-md-code-host--editing": e.editing }]) }, [A(s("div", Pt, [l(C(ae), {
119
123
  code: e.text,
120
124
  language: e.language || "text",
121
125
  collapsible: !1,
@@ -124,11 +128,11 @@ var wt = { class: "coar-md-code-render" }, Tt = { class: "coar-md-code-edit" },
124
128
  class: "coar-md-code-edit-btn",
125
129
  type: "button",
126
130
  title: "Edit code block",
127
- onMousedown: n[0] ||= j((e) => r("enterEdit"), ["prevent"])
128
- }, [l(S(B), {
131
+ onMousedown: n[0] ||= M((e) => r("enterEdit"), ["prevent"])
132
+ }, [l(C(H), {
129
133
  name: "pencil",
130
134
  size: "xs"
131
- }), n[2] ||= s("span", null, "Edit", -1)], 32)], 512), [[E, !e.editing]]), k(s("div", Tt, [s("div", Et, [l(S(V), {
135
+ }), n[2] ||= s("span", null, "Edit", -1)], 32)], 512), [[D, !e.editing]]), A(s("div", Ft, [s("div", It, [l(C(W), {
132
136
  class: "coar-md-code-lang-select",
133
137
  "model-value": e.language,
134
138
  options: i,
@@ -138,21 +142,21 @@ var wt = { class: "coar-md-code-render" }, Tt = { class: "coar-md-code-edit" },
138
142
  ref_key: "contentMount",
139
143
  ref: a,
140
144
  class: "coar-md-code-content"
141
- }, null, 512)], 512), [[E, e.editing]])], 2));
145
+ }, null, 512)], 512), [[D, e.editing]])], 2));
142
146
  }
143
- }), Ot = /* @__PURE__ */ new Set(), kt = class {
147
+ }), Rt = /* @__PURE__ */ new Set(), zt = class {
144
148
  dom;
145
149
  contentDOM;
146
150
  app;
147
- text = v("");
148
- language = v("");
149
- editing = v(!1);
151
+ text = y("");
152
+ language = y("");
153
+ editing = y(!1);
150
154
  constructor(e, t, n) {
151
- this.node = e, this.view = t, this.getPos = n, Ot.add(this), this.dom = document.createElement("div"), this.dom.className = "coar-md-code-host-mount";
155
+ this.node = e, this.view = t, this.getPos = n, Rt.add(this), this.dom = document.createElement("div"), this.dom.className = "coar-md-code-host-mount";
152
156
  let i = document.createElement("pre"), a = document.createElement("code");
153
157
  i.appendChild(a), this.contentDOM = a, this.text.value = e.textContent, this.language.value = e.attrs.language ?? "", this.app = r({
154
158
  name: "CodeBlockShellRoot",
155
- setup: () => () => d(Dt, {
159
+ setup: () => () => f(Lt, {
156
160
  text: this.text.value,
157
161
  language: this.language.value,
158
162
  editing: this.editing.value,
@@ -174,7 +178,7 @@ var wt = { class: "coar-md-code-render" }, Tt = { class: "coar-md-code-edit" },
174
178
  this.editing.value = !1;
175
179
  }
176
180
  destroy() {
177
- Ot.delete(this), this.app.unmount();
181
+ Rt.delete(this), this.app.unmount();
178
182
  }
179
183
  notifySelectionChanged() {
180
184
  let e = this.getPos();
@@ -192,17 +196,17 @@ var wt = { class: "coar-md-code-render" }, Tt = { class: "coar-md-code-edit" },
192
196
  let e = this.getPos();
193
197
  if (e == null) return;
194
198
  let { tr: t } = this.view.state;
195
- t.setSelection(ke.create(this.view.state.doc, e + 1)), this.view.dispatch(t), this.view.focus();
199
+ t.setSelection(je.create(this.view.state.doc, e + 1)), this.view.dispatch(t), this.view.focus();
196
200
  };
197
201
  handleLanguageChange = (e) => {
198
202
  let t = this.getPos();
199
203
  t != null && this.view.dispatch(this.view.state.tr.setNodeAttribute(t, "language", e));
200
204
  };
201
- }, At = [Pe(me.node, () => (e, t, n) => new kt(e, t, n)), Me(() => new De({ view: () => ({ update(e, t) {
202
- e.state.selection.eq(t.selection) || Ot.forEach((t) => {
205
+ }, Bt = [Ie(q.node, () => (e, t, n) => new zt(e, t, n)), Pe(() => new ke({ view: () => ({ update(e, t) {
206
+ e.state.selection.eq(t.selection) || Rt.forEach((t) => {
203
207
  t.view === e && t.notifySelectionChanged();
204
208
  });
205
- } }) }))].flat(), jt = function() {
209
+ } }) }))].flat(), Vt = function() {
206
210
  let e = this.data();
207
211
  return (e.toMarkdownExtensions ??= []).push({ handlers: { colorTextSpan(e, t, n) {
208
212
  let r = Y(e.color ?? "") ?? "";
@@ -214,45 +218,45 @@ var wt = { class: "coar-md-code-render" }, Tt = { class: "coar-md-code-edit" },
214
218
  before: ">",
215
219
  after: "<"
216
220
  });
217
- return `${Ve(r)}${i}${Be()}`;
221
+ return `${We(r)}${i}${Ue()}`;
218
222
  } } }), (e) => {
219
223
  t(e);
220
224
  };
221
225
  function t(e) {
222
226
  if (Array.isArray(e.children)) {
223
- let n = Pt(e.children);
227
+ let n = Wt(e.children);
224
228
  e.children = n;
225
229
  for (let e of n) t(e);
226
230
  }
227
231
  }
228
232
  };
229
- function Mt(e) {
233
+ function Ht(e) {
230
234
  return !!e && e.type === "html" && typeof e.value == "string";
231
235
  }
232
- function Nt(e, t) {
236
+ function Ut(e, t) {
233
237
  let n = 1;
234
238
  for (let r = t + 1; r < e.length; r++) {
235
239
  let t = e[r];
236
- if (Mt(t)) {
237
- if (Re(t.value)) {
240
+ if (Ht(t)) {
241
+ if (Be(t.value)) {
238
242
  n++;
239
243
  continue;
240
244
  }
241
- if (Ie(t.value) && (n--, n === 0)) return r;
245
+ if (Re(t.value) && (n--, n === 0)) return r;
242
246
  }
243
247
  }
244
248
  return null;
245
249
  }
246
- function Pt(e) {
250
+ function Wt(e) {
247
251
  let t = [], n = 0;
248
252
  for (; n < e.length;) {
249
253
  let r = e[n];
250
- if (Mt(r)) {
251
- let i = Re(r.value);
254
+ if (Ht(r)) {
255
+ let i = Be(r.value);
252
256
  if (i) {
253
- let r = Nt(e, n);
257
+ let r = Ut(e, n);
254
258
  if (r !== null) {
255
- let a = Pt(e.slice(n + 1, r)), o = {
259
+ let a = Wt(e.slice(n + 1, r)), o = {
256
260
  type: "colorTextSpan",
257
261
  color: i.color,
258
262
  children: a,
@@ -267,7 +271,7 @@ function Pt(e) {
267
271
  }
268
272
  return t;
269
273
  }
270
- var Ft = [Ne("textColor", () => jt), Ae("text_color", () => ({
274
+ var Gt = [Fe("textColor", () => Vt), Me("text_color", () => ({
271
275
  attrs: { color: { default: "" } },
272
276
  inclusive: !0,
273
277
  parseDOM: [{
@@ -314,7 +318,7 @@ var Ft = [Ne("textColor", () => jt), Ae("text_color", () => ({
314
318
  n.length !== 0 && e.withMark(t, "colorTextSpan", void 0, { color: n });
315
319
  }
316
320
  }
317
- }))].flat(), It = [
321
+ }))].flat(), Kt = [
318
322
  {
319
323
  name: "Default",
320
324
  value: ""
@@ -351,26 +355,26 @@ var Ft = [Ne("textColor", () => jt), Ae("text_color", () => ({
351
355
  name: "Gray",
352
356
  value: "#6b7280"
353
357
  }
354
- ], Lt = {
358
+ ], qt = {
355
359
  class: "coar-md-placeholder",
356
360
  "aria-hidden": "true"
357
- }, Rt = /* @__PURE__ */ u({
361
+ }, Jt = /* @__PURE__ */ u({
358
362
  __name: "PlaceholderOverlay",
359
363
  props: { source: {} },
360
364
  setup(e) {
361
- let t = e, r = n(() => Le(t.source));
362
- return (e, t) => (_(), o("div", Lt, [l(S(He), { doc: r.value }, null, 8, ["doc"])]));
365
+ let t = e, r = n(() => ze(t.source));
366
+ return (e, t) => (v(), o("div", qt, [l(C(qe), { doc: r.value }, null, 8, ["doc"])]));
363
367
  }
364
368
  });
365
- function zt(e) {
369
+ function Yt(e) {
366
370
  return e !== null && e < -2;
367
371
  }
368
- function Bt(e) {
372
+ function Xt(e) {
369
373
  return e === -2 || e === -1 || e === 32;
370
374
  }
371
375
  //#endregion
372
376
  //#region ../../node_modules/.pnpm/fault@2.0.1/node_modules/fault/index.js
373
- var Vt = /* @__PURE__ */ vt((/* @__PURE__ */ gt(((e, t) => {
377
+ var Zt = /* @__PURE__ */ Ot((/* @__PURE__ */ Et(((e, t) => {
374
378
  (function() {
375
379
  var e = t === void 0 ? function() {
376
380
  return this || (0, eval)("this");
@@ -424,7 +428,7 @@ var Vt = /* @__PURE__ */ vt((/* @__PURE__ */ gt(((e, t) => {
424
428
  return a;
425
429
  }
426
430
  })();
427
- })))(), 1), Ht = Object.assign(X(Error), {
431
+ })))(), 1), Qt = Object.assign(X(Error), {
428
432
  eval: X(EvalError),
429
433
  range: X(RangeError),
430
434
  reference: X(ReferenceError),
@@ -435,44 +439,44 @@ var Vt = /* @__PURE__ */ vt((/* @__PURE__ */ gt(((e, t) => {
435
439
  function X(e) {
436
440
  return t.displayName = e.displayName || e.name, t;
437
441
  function t(t, ...n) {
438
- return new e(t && (0, Vt.default)(t, ...n));
442
+ return new e(t && (0, Zt.default)(t, ...n));
439
443
  }
440
444
  }
441
445
  //#endregion
442
446
  //#region ../../node_modules/.pnpm/micromark-extension-frontmatter@2.0.0/node_modules/micromark-extension-frontmatter/lib/to-matters.js
443
- var Ut = {}.hasOwnProperty, Wt = {
447
+ var $t = {}.hasOwnProperty, en = {
444
448
  yaml: "-",
445
449
  toml: "+"
446
450
  };
447
- function Gt(e) {
451
+ function tn(e) {
448
452
  let t = [], n = -1, r = Array.isArray(e) ? e : e ? [e] : ["yaml"];
449
- for (; ++n < r.length;) t[n] = Kt(r[n]);
453
+ for (; ++n < r.length;) t[n] = nn(r[n]);
450
454
  return t;
451
455
  }
452
- function Kt(e) {
456
+ function nn(e) {
453
457
  let t = e;
454
458
  if (typeof t == "string") {
455
- if (!Ut.call(Wt, t)) throw Ht("Missing matter definition for `%s`", t);
459
+ if (!$t.call(en, t)) throw Qt("Missing matter definition for `%s`", t);
456
460
  t = {
457
461
  type: t,
458
- marker: Wt[t]
462
+ marker: en[t]
459
463
  };
460
- } else if (typeof t != "object") throw Ht("Expected matter to be an object, not `%j`", t);
461
- if (!Ut.call(t, "type")) throw Ht("Missing `type` in matter `%j`", t);
462
- if (!Ut.call(t, "fence") && !Ut.call(t, "marker")) throw Ht("Missing `marker` or `fence` in matter `%j`", t);
464
+ } else if (typeof t != "object") throw Qt("Expected matter to be an object, not `%j`", t);
465
+ if (!$t.call(t, "type")) throw Qt("Missing `type` in matter `%j`", t);
466
+ if (!$t.call(t, "fence") && !$t.call(t, "marker")) throw Qt("Missing `marker` or `fence` in matter `%j`", t);
463
467
  return t;
464
468
  }
465
469
  //#endregion
466
470
  //#region ../../node_modules/.pnpm/micromark-extension-frontmatter@2.0.0/node_modules/micromark-extension-frontmatter/lib/syntax.js
467
- function qt(e) {
468
- let t = Gt(e), n = {}, r = -1;
471
+ function rn(e) {
472
+ let t = tn(e), n = {}, r = -1;
469
473
  for (; ++r < t.length;) {
470
- let e = t[r], i = Yt(e, "open").charCodeAt(0), a = Jt(e), o = n[i];
474
+ let e = t[r], i = on(e, "open").charCodeAt(0), a = an(e), o = n[i];
471
475
  Array.isArray(o) ? o.push(a) : n[i] = [a];
472
476
  }
473
477
  return { flow: n };
474
478
  }
475
- function Jt(e) {
479
+ function an(e) {
476
480
  let t = e.anywhere, n = e.type, r = n + "Fence", i = r + "Sequence", a = n + "Value", o = {
477
481
  tokenize: u,
478
482
  partial: !0
@@ -486,25 +490,25 @@ function Jt(e) {
486
490
  return p;
487
491
  function p(a) {
488
492
  let o = f.now();
489
- return o.column === 1 && (o.line === 1 || t) && (s = Yt(e, "open"), c = 0, a === s.charCodeAt(c)) ? (l.enter(n), l.enter(r), l.enter(i), m(a)) : d(a);
493
+ return o.column === 1 && (o.line === 1 || t) && (s = on(e, "open"), c = 0, a === s.charCodeAt(c)) ? (l.enter(n), l.enter(r), l.enter(i), m(a)) : d(a);
490
494
  }
491
495
  function m(e) {
492
- return c === s.length ? (l.exit(i), Bt(e) ? (l.enter("whitespace"), h(e)) : ee(e)) : e === s.charCodeAt(c++) ? (l.consume(e), m) : d(e);
496
+ return c === s.length ? (l.exit(i), Xt(e) ? (l.enter("whitespace"), h(e)) : g(e)) : e === s.charCodeAt(c++) ? (l.consume(e), m) : d(e);
493
497
  }
494
498
  function h(e) {
495
- return Bt(e) ? (l.consume(e), h) : (l.exit("whitespace"), ee(e));
499
+ return Xt(e) ? (l.consume(e), h) : (l.exit("whitespace"), g(e));
496
500
  }
497
- function ee(t) {
498
- return zt(t) ? (l.exit(r), l.enter("lineEnding"), l.consume(t), l.exit("lineEnding"), s = Yt(e, "close"), c = 0, l.attempt(o, y, g)) : d(t);
501
+ function g(t) {
502
+ return Yt(t) ? (l.exit(r), l.enter("lineEnding"), l.consume(t), l.exit("lineEnding"), s = on(e, "close"), c = 0, l.attempt(o, y, ee)) : d(t);
499
503
  }
500
- function g(e) {
501
- return e === null || zt(e) ? v(e) : (l.enter(a), _(e));
504
+ function ee(e) {
505
+ return e === null || Yt(e) ? v(e) : (l.enter(a), _(e));
502
506
  }
503
507
  function _(e) {
504
- return e === null || zt(e) ? (l.exit(a), v(e)) : (l.consume(e), _);
508
+ return e === null || Yt(e) ? (l.exit(a), v(e)) : (l.consume(e), _);
505
509
  }
506
510
  function v(e) {
507
- return e === null ? d(e) : (l.enter("lineEnding"), l.consume(e), l.exit("lineEnding"), l.attempt(o, y, g));
511
+ return e === null ? d(e) : (l.enter("lineEnding"), l.consume(e), l.exit("lineEnding"), l.attempt(o, y, ee));
508
512
  }
509
513
  function y(e) {
510
514
  return l.exit(n), u(e);
@@ -517,42 +521,42 @@ function Jt(e) {
517
521
  return t === s.charCodeAt(a) ? (e.enter(r), e.enter(i), c(t)) : n(t);
518
522
  }
519
523
  function c(t) {
520
- return a === s.length ? (e.exit(i), Bt(t) ? (e.enter("whitespace"), l(t)) : u(t)) : t === s.charCodeAt(a++) ? (e.consume(t), c) : n(t);
524
+ return a === s.length ? (e.exit(i), Xt(t) ? (e.enter("whitespace"), l(t)) : u(t)) : t === s.charCodeAt(a++) ? (e.consume(t), c) : n(t);
521
525
  }
522
526
  function l(t) {
523
- return Bt(t) ? (e.consume(t), l) : (e.exit("whitespace"), u(t));
527
+ return Xt(t) ? (e.consume(t), l) : (e.exit("whitespace"), u(t));
524
528
  }
525
529
  function u(i) {
526
- return i === null || zt(i) ? (e.exit(r), t(i)) : n(i);
530
+ return i === null || Yt(i) ? (e.exit(r), t(i)) : n(i);
527
531
  }
528
532
  }
529
533
  }
530
- function Yt(e, t) {
531
- return e.marker ? Xt(e.marker, t).repeat(3) : Xt(e.fence, t);
534
+ function on(e, t) {
535
+ return e.marker ? sn(e.marker, t).repeat(3) : sn(e.fence, t);
532
536
  }
533
- function Xt(e, t) {
537
+ function sn(e, t) {
534
538
  return typeof e == "string" ? e : e[t];
535
539
  }
536
540
  //#endregion
537
541
  //#region ../../node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
538
- function Zt(e) {
542
+ function cn(e) {
539
543
  if (typeof e != "string") throw TypeError("Expected a string");
540
544
  return e.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
541
545
  }
542
546
  //#endregion
543
547
  //#region ../../node_modules/.pnpm/mdast-util-frontmatter@2.0.1/node_modules/mdast-util-frontmatter/lib/index.js
544
- function Qt(e) {
545
- let t = Gt(e), n = {}, r = {}, i = -1;
548
+ function ln(e) {
549
+ let t = tn(e), n = {}, r = {}, i = -1;
546
550
  for (; ++i < t.length;) {
547
551
  let e = t[i];
548
- n[e.type] = $t(e), r[e.type] = en, r[e.type + "Value"] = tn;
552
+ n[e.type] = un(e), r[e.type] = dn, r[e.type + "Value"] = fn;
549
553
  }
550
554
  return {
551
555
  enter: n,
552
556
  exit: r
553
557
  };
554
558
  }
555
- function $t(e) {
559
+ function un(e) {
556
560
  return t;
557
561
  function t(t) {
558
562
  this.enter({
@@ -561,23 +565,23 @@ function $t(e) {
561
565
  }, t), this.buffer();
562
566
  }
563
567
  }
564
- function en(e) {
568
+ function dn(e) {
565
569
  let t = this.resume(), n = this.stack[this.stack.length - 1];
566
570
  "value" in n, this.exit(e), n.value = t.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
567
571
  }
568
- function tn(e) {
572
+ function fn(e) {
569
573
  this.config.enter.data.call(this, e), this.config.exit.data.call(this, e);
570
574
  }
571
- function nn(e) {
572
- let t = [], n = {}, r = Gt(e), i = -1;
575
+ function pn(e) {
576
+ let t = [], n = {}, r = tn(e), i = -1;
573
577
  for (; ++i < r.length;) {
574
578
  let e = r[i];
575
- n[e.type] = rn(e);
576
- let a = an(e, "open");
579
+ n[e.type] = mn(e);
580
+ let a = hn(e, "open");
577
581
  t.push({
578
582
  atBreak: !0,
579
583
  character: a.charAt(0),
580
- after: Zt(a.charAt(1))
584
+ after: cn(a.charAt(1))
581
585
  });
582
586
  }
583
587
  return {
@@ -585,29 +589,29 @@ function nn(e) {
585
589
  handlers: n
586
590
  };
587
591
  }
588
- function rn(e) {
589
- let t = an(e, "open"), n = an(e, "close");
592
+ function mn(e) {
593
+ let t = hn(e, "open"), n = hn(e, "close");
590
594
  return r;
591
595
  function r(e) {
592
596
  return t + (e.value ? "\n" + e.value : "") + "\n" + n;
593
597
  }
594
598
  }
595
- function an(e, t) {
596
- return e.marker ? on(e.marker, t).repeat(3) : on(e.fence, t);
599
+ function hn(e, t) {
600
+ return e.marker ? gn(e.marker, t).repeat(3) : gn(e.fence, t);
597
601
  }
598
- function on(e, t) {
602
+ function gn(e, t) {
599
603
  return typeof e == "string" ? e : e[t];
600
604
  }
601
605
  //#endregion
602
606
  //#region ../../node_modules/.pnpm/remark-frontmatter@5.0.0/node_modules/remark-frontmatter/lib/index.js
603
- var sn = "yaml";
604
- function cn(e) {
605
- let t = this, n = e || sn, r = t.data(), i = r.micromarkExtensions ||= [], a = r.fromMarkdownExtensions ||= [], o = r.toMarkdownExtensions ||= [];
606
- i.push(qt(n)), a.push(Qt(n)), o.push(nn(n));
607
+ var _n = "yaml";
608
+ function vn(e) {
609
+ let t = this, n = e || _n, r = t.data(), i = r.micromarkExtensions ||= [], a = r.fromMarkdownExtensions ||= [], o = r.toMarkdownExtensions ||= [];
610
+ i.push(rn(n)), a.push(ln(n)), o.push(pn(n));
607
611
  }
608
612
  //#endregion
609
613
  //#region src/frontmatter/index.ts
610
- var ln = Ne("coarRemarkFrontmatter", () => cn, ["yaml"]), un = je("frontmatter", () => ({
614
+ var yn = Fe("coarRemarkFrontmatter", () => vn, ["yaml"]), bn = Ne("frontmatter", () => ({
611
615
  group: "block",
612
616
  atom: !0,
613
617
  marks: "",
@@ -635,8 +639,8 @@ var ln = Ne("coarRemarkFrontmatter", () => cn, ["yaml"]), un = je("frontmatter",
635
639
  }
636
640
  }
637
641
  }));
638
- function dn(e, t) {
639
- let { entries: n } = ze(t);
642
+ function xn(e, t) {
643
+ let { entries: n } = He(t);
640
644
  if (e.replaceChildren(), n.length === 0) {
641
645
  let n = document.createElement("pre");
642
646
  n.className = "coar-markdown-frontmatter__raw", n.textContent = t, e.appendChild(n);
@@ -651,14 +655,14 @@ function dn(e, t) {
651
655
  i.className = "coar-markdown-frontmatter__value", i.textContent = t.value, n.append(r, document.createTextNode(": "), i), e.appendChild(n);
652
656
  }
653
657
  }
654
- var fn = class {
658
+ var Sn = class {
655
659
  dom;
656
660
  node;
657
661
  constructor(e) {
658
662
  this.node = e, this.dom = document.createElement("div"), this.dom.className = "coar-markdown-frontmatter", this.dom.setAttribute("data-type", "frontmatter"), this.dom.setAttribute("aria-label", "Document metadata"), this.dom.contentEditable = "false", this.dom.draggable = !1, this.renderCard();
659
663
  }
660
664
  renderCard() {
661
- dn(this.dom, this.node.attrs.value ?? "");
665
+ xn(this.dom, this.node.attrs.value ?? "");
662
666
  }
663
667
  update(e) {
664
668
  if (e.type !== this.node.type) return !1;
@@ -671,66 +675,213 @@ var fn = class {
671
675
  stopEvent() {
672
676
  return !1;
673
677
  }
674
- }, pn = [
675
- ln,
676
- un,
677
- Pe(un.node, () => (e) => new fn(e))
678
- ].flat(), mn = { class: "coar-md-color-grid" }, hn = [
678
+ }, Cn = [
679
+ yn,
680
+ bn,
681
+ Ie(bn.node, () => (e) => new Sn(e))
682
+ ].flat();
683
+ //#endregion
684
+ //#region src/embed/index.ts
685
+ function wn(e, t) {
686
+ let n = e.position?.start?.offset, r = e.position?.end?.offset;
687
+ if (t && typeof n == "number" && typeof r == "number") return t.slice(n, r).trim();
688
+ let i = e.children;
689
+ return Array.isArray(i) && i.length === 1 && i[0]?.type === "text" && typeof i[0].value == "string" ? i[0].value.trim() : null;
690
+ }
691
+ function Tn(e, t) {
692
+ Array.isArray(e.children) && (e.children = e.children.map((e) => {
693
+ if (e.type === "paragraph") {
694
+ let n = wn(e, t);
695
+ if (n) {
696
+ let t = Ve(n);
697
+ if (t) return {
698
+ type: "embed",
699
+ embedKey: t.key,
700
+ props: t.props,
701
+ position: e.position
702
+ };
703
+ }
704
+ }
705
+ return Tn(e, t), e;
706
+ }));
707
+ }
708
+ var En = function() {
709
+ let e = this.data();
710
+ return (e.toMarkdownExtensions ??= []).push({ handlers: { embed(e) {
711
+ let t = typeof e.embedKey == "string" ? e.embedKey : "";
712
+ return t.length === 0 ? "" : Ge({
713
+ key: t,
714
+ props: Ke(e.props)
715
+ });
716
+ } } }), (e, t) => {
717
+ Tn(e, typeof t?.value == "string" ? t.value : "");
718
+ };
719
+ }, Dn = Fe("coarEmbed", () => En), On = Ne("embed", () => ({
720
+ group: "block",
721
+ atom: !0,
722
+ marks: "",
723
+ selectable: !0,
724
+ draggable: !1,
725
+ isolating: !0,
726
+ attrs: {
727
+ embedKey: { default: "" },
728
+ props: { default: {} }
729
+ },
730
+ parseDOM: [{
731
+ tag: "div[data-type=\"embed\"]",
732
+ getAttrs: (e) => {
733
+ let t = e, n;
734
+ try {
735
+ n = JSON.parse(t.getAttribute("data-embed-props") ?? "{}");
736
+ } catch {
737
+ n = {};
738
+ }
739
+ return {
740
+ embedKey: t.getAttribute("data-embed-key") ?? "",
741
+ props: n
742
+ };
743
+ }
744
+ }],
745
+ toDOM: (e) => ["div", {
746
+ "data-type": "embed",
747
+ "data-embed-key": e.attrs.embedKey ?? "",
748
+ "data-embed-props": JSON.stringify(e.attrs.props ?? {})
749
+ }],
750
+ parseMarkdown: {
751
+ match: (e) => e.type === "embed",
752
+ runner: (e, t, n) => {
753
+ e.addNode(n, {
754
+ embedKey: typeof t.embedKey == "string" ? t.embedKey : "",
755
+ props: t.props && typeof t.props == "object" ? t.props : {}
756
+ });
757
+ }
758
+ },
759
+ toMarkdown: {
760
+ match: (e) => e.type.name === "embed",
761
+ runner: (e, t) => {
762
+ e.addNode("embed", void 0, void 0, {
763
+ embedKey: t.attrs.embedKey ?? "",
764
+ props: t.attrs.props ?? {}
765
+ });
766
+ }
767
+ }
768
+ })), kn = class {
769
+ dom;
770
+ node;
771
+ view;
772
+ getPos;
773
+ options;
774
+ constructor(e, t, n, r) {
775
+ this.node = e, this.view = t, this.getPos = n, this.options = r, this.dom = document.createElement("div"), this.dom.className = "coar-markdown-embed-host", this.dom.setAttribute("data-type", "embed"), this.dom.contentEditable = "false", this.dom.draggable = !1, this.renderPreview();
776
+ }
777
+ updateProps(e) {
778
+ let t = this.getPos();
779
+ if (t == null) return;
780
+ let n = this.view.state.tr.setNodeMarkup(t, void 0, {
781
+ embedKey: this.node.attrs.embedKey ?? "",
782
+ props: e
783
+ });
784
+ this.view.dispatch(n);
785
+ }
786
+ renderPreview() {
787
+ let e = this.node.attrs.embedKey ?? "", t = this.node.attrs.props ?? {}, n = this.options.resolveRegistry(), r = Qe(n, e), i = r?.editor ? f(r.editor, { controller: {
788
+ props: t,
789
+ update: (e) => this.updateProps(e),
790
+ patch: (e) => this.updateProps({
791
+ ...t,
792
+ ...e
793
+ })
794
+ } }) : f(Ye, {
795
+ embedKey: e,
796
+ embedProps: t,
797
+ registry: n
798
+ });
799
+ this.options.appContext && (i.appContext = this.options.appContext), b(i, this.dom);
800
+ }
801
+ update(e) {
802
+ return e.type === this.node.type ? (this.node = e, this.renderPreview(), !0) : !1;
803
+ }
804
+ selectNode() {
805
+ this.dom.classList.add("coar-markdown-embed-host--selected");
806
+ }
807
+ deselectNode() {
808
+ this.dom.classList.remove("coar-markdown-embed-host--selected");
809
+ }
810
+ stopEvent() {
811
+ return !0;
812
+ }
813
+ ignoreMutation() {
814
+ return !0;
815
+ }
816
+ destroy() {
817
+ b(null, this.dom);
818
+ }
819
+ }, An = (e) => Ie(On.node, () => (t, n, r) => new kn(t, n, r, e));
820
+ function jn(e) {
821
+ return [
822
+ Dn,
823
+ On,
824
+ An(e)
825
+ ].flat();
826
+ }
827
+ //#endregion
828
+ //#region src/text-color/ColorPickerPanel.vue?vue&type=script&setup=true&lang.ts
829
+ var Mn = { class: "coar-md-color-grid" }, Nn = [
679
830
  "title",
680
831
  "aria-label",
681
832
  "onMousedown"
682
- ], gn = { class: "coar-md-color-custom" }, _n = /* @__PURE__ */ u({
833
+ ], Pn = { class: "coar-md-color-custom" }, Fn = /* @__PURE__ */ u({
683
834
  __name: "ColorPickerPanel",
684
835
  props: {
685
836
  currentColor: {},
686
837
  pick: { type: Function }
687
838
  },
688
839
  setup(t) {
689
- let n = v(t.currentColor ?? "#000000");
690
- return (r, c) => (_(), o("div", {
840
+ let n = y(t.currentColor ?? "#000000");
841
+ return (r, c) => (v(), o("div", {
691
842
  class: "coar-md-color-picker",
692
843
  role: "menu",
693
- onMousedown: c[2] ||= j(() => {}, ["stop"])
694
- }, [s("div", mn, [(_(!0), o(e, null, y(S(It), (e) => (_(), o("button", {
844
+ onMousedown: c[2] ||= M(() => {}, ["stop"])
845
+ }, [s("div", Mn, [(v(!0), o(e, null, x(C(Kt), (e) => (v(), o("button", {
695
846
  key: e.value || "default",
696
847
  type: "button",
697
- class: m([
848
+ class: h([
698
849
  "coar-md-color-swatch",
699
850
  e.value === "" ? "coar-md-color-swatch--clear" : "",
700
851
  e.value !== "" && t.currentColor === e.value ? "coar-md-color-swatch--active" : ""
701
852
  ]),
702
- style: h(e.value ? { "--coar-md-swatch": e.value } : void 0),
853
+ style: g(e.value ? { "--coar-md-swatch": e.value } : void 0),
703
854
  title: e.name,
704
855
  "aria-label": e.name,
705
- onMousedown: j((n) => t.pick(e.value === "" ? null : e.value), ["prevent"])
706
- }, [e.value === "" ? (_(), i(S(B), {
856
+ onMousedown: M((n) => t.pick(e.value === "" ? null : e.value), ["prevent"])
857
+ }, [e.value === "" ? (v(), i(C(H), {
707
858
  key: 0,
708
859
  name: "ban",
709
860
  size: "s"
710
- })) : a("", !0)], 46, hn))), 128))]), s("div", gn, [c[3] ||= s("label", {
861
+ })) : a("", !0)], 46, Nn))), 128))]), s("div", Pn, [c[3] ||= s("label", {
711
862
  class: "coar-md-color-custom-label",
712
863
  for: "coar-md-color-custom-input"
713
- }, " Custom ", -1), k(s("input", {
864
+ }, " Custom ", -1), A(s("input", {
714
865
  id: "coar-md-color-custom-input",
715
866
  "onUpdate:modelValue": c[0] ||= (e) => n.value = e,
716
867
  type: "color",
717
868
  class: "coar-md-color-custom-input",
718
869
  onChange: c[1] ||= (e) => t.pick(n.value)
719
- }, null, 544), [[T, n.value]])])], 32));
870
+ }, null, 544), [[E, n.value]])])], 32));
720
871
  }
721
- }), vn = [
872
+ }), In = [
722
873
  "aria-label",
723
874
  "onMouseover",
724
875
  "onFocus",
725
876
  "onClick"
726
- ], yn = { class: "coar-md-table-picker__label" }, bn = /* @__PURE__ */ u({
877
+ ], Ln = { class: "coar-md-table-picker__label" }, Rn = /* @__PURE__ */ u({
727
878
  __name: "TableSizePicker",
728
879
  props: {
729
880
  pick: { type: Function },
730
881
  max: {}
731
882
  },
732
883
  setup(t) {
733
- let r = t.max ?? 8, i = Array.from({ length: r }, (e, t) => t + 1), a = v(0), l = v(0), u = n(() => a.value > 0 ? `${l.value} × ${a.value}` : "Pick size");
884
+ let r = t.max ?? 8, i = Array.from({ length: r }, (e, t) => t + 1), a = y(0), l = y(0), u = n(() => a.value > 0 ? `${l.value} × ${a.value}` : "Pick size");
734
885
  function d(e, t) {
735
886
  a.value = e, l.value = t;
736
887
  }
@@ -740,23 +891,23 @@ var fn = class {
740
891
  function p(e, t) {
741
892
  return e <= a.value && t <= l.value;
742
893
  }
743
- return (n, a) => (_(), o("div", {
894
+ return (n, a) => (v(), o("div", {
744
895
  class: "coar-md-table-picker",
745
896
  onMouseleave: f
746
897
  }, [
747
898
  s("div", {
748
899
  class: "coar-md-table-picker__grid",
749
- style: h({ gridTemplateColumns: `repeat(${S(r)}, 1fr)` })
750
- }, [(_(!0), o(e, null, y(S(i), (n) => (_(), o(e, { key: n }, [(_(!0), o(e, null, y(S(i), (e) => (_(), o("button", {
900
+ style: g({ gridTemplateColumns: `repeat(${C(r)}, 1fr)` })
901
+ }, [(v(!0), o(e, null, x(C(i), (n) => (v(), o(e, { key: n }, [(v(!0), o(e, null, x(C(i), (e) => (v(), o("button", {
751
902
  key: `${n}-${e}`,
752
903
  type: "button",
753
- class: m(["coar-md-table-picker__cell", { "coar-md-table-picker__cell--on": p(n, e) }]),
904
+ class: h(["coar-md-table-picker__cell", { "coar-md-table-picker__cell--on": p(n, e) }]),
754
905
  "aria-label": `${e} by ${n}`,
755
906
  onMouseover: (t) => d(n, e),
756
907
  onFocus: (t) => d(n, e),
757
908
  onClick: (r) => t.pick(n, e)
758
- }, null, 42, vn))), 128))], 64))), 128))], 4),
759
- s("div", yn, x(u.value), 1),
909
+ }, null, 42, In))), 128))], 64))), 128))], 4),
910
+ s("div", Ln, S(u.value), 1),
760
911
  a[0] ||= s("div", { class: "coar-md-table-picker__hint" }, [
761
912
  c(" or type "),
762
913
  s("code", null, "|3x4|"),
@@ -764,31 +915,31 @@ var fn = class {
764
915
  ], -1)
765
916
  ], 32));
766
917
  }
767
- }), xn = (e, t) => {
918
+ }), zn = (e, t) => {
768
919
  let n = e.__vccOpts || e;
769
920
  for (let [e, r] of t) n[e] = r;
770
921
  return n;
771
- }, Sn = /* @__PURE__ */ xn(bn, [["__scopeId", "data-v-68fa1760"]]), Cn = {
922
+ }, Bn = /* @__PURE__ */ zn(Rn, [["__scopeId", "data-v-68fa1760"]]), Vn = {
772
923
  key: 0,
773
924
  class: "coar-md-th"
774
- }, wn = [
925
+ }, Hn = [
775
926
  "aria-label",
776
927
  "onMouseenter",
777
928
  "onMousedown"
778
- ], Tn = [
929
+ ], Un = [
779
930
  "aria-label",
780
931
  "onMouseenter",
781
932
  "onMousedown"
782
- ], Z = 14, En = 4, Dn = /* @__PURE__ */ xn(/* @__PURE__ */ u({
933
+ ], Z = 14, Wn = 4, Gn = /* @__PURE__ */ zn(/* @__PURE__ */ u({
783
934
  __name: "TableHandles",
784
935
  props: { area: {} },
785
936
  emits: ["menuToggle"],
786
937
  setup(r, { emit: s }) {
787
- let c = r, u = s, [, d] = ae(), f = b(null), p = v(null), x = v(null), C = v(null), w = de();
788
- D(w.isOpen, (e) => {
789
- !e && x.value && (x.value = null, p.value = null, u("menuToggle", !1));
938
+ let c = r, u = s, [, d] = ie(), f = te(null), p = y(null), m = y(null), b = y(null), S = pe();
939
+ O(S.isOpen, (e) => {
940
+ !e && m.value && (m.value = null, p.value = null, u("menuToggle", !1));
790
941
  });
791
- function T(e) {
942
+ function w(e) {
792
943
  return {
793
944
  left: e.left,
794
945
  top: e.top,
@@ -796,22 +947,22 @@ var fn = class {
796
947
  height: e.height
797
948
  };
798
949
  }
799
- function E(e) {
950
+ function T(e) {
800
951
  let t = Array.from(e.querySelectorAll("tr")), n = t[0];
801
952
  if (!n) return null;
802
953
  let r = Array.from(n.children);
803
954
  return r.length === 0 ? null : {
804
955
  table: e,
805
- rect: T(e.getBoundingClientRect()),
806
- cols: r.map((e) => T(e.getBoundingClientRect())),
807
- rows: t.map((e) => T(e.getBoundingClientRect()))
956
+ rect: w(e.getBoundingClientRect()),
957
+ cols: r.map((e) => w(e.getBoundingClientRect())),
958
+ rows: t.map((e) => w(e.getBoundingClientRect()))
808
959
  };
809
960
  }
810
- function k(e, t, n) {
961
+ function E(e, t, n) {
811
962
  return t >= e.rect.left - Z - 4 && t <= e.rect.left + e.rect.width + Z + 4 && n >= e.rect.top - Z - 4 && n <= e.rect.top + e.rect.height + Z + 4;
812
963
  }
813
- let A = !1;
814
- function j(e, t) {
964
+ let D = !1;
965
+ function A(e, t) {
815
966
  let n = c.area?.querySelectorAll("table");
816
967
  if (!n) return null;
817
968
  for (let r of Array.from(n)) {
@@ -820,71 +971,71 @@ var fn = class {
820
971
  }
821
972
  return null;
822
973
  }
823
- function te(e) {
824
- x.value || R || C.value || A || (A = !0, requestAnimationFrame(() => {
825
- A = !1;
974
+ function j(e) {
975
+ m.value || z || b.value || D || (D = !0, requestAnimationFrame(() => {
976
+ D = !1;
826
977
  let t = e.clientX, n = e.clientY;
827
- if (f.value && k(f.value, t, n)) return;
828
- let r = j(t, n);
829
- r ? f.value = E(r) : (f.value = null, p.value = null);
978
+ if (f.value && E(f.value, t, n)) return;
979
+ let r = A(t, n);
980
+ r ? f.value = T(r) : (f.value = null, p.value = null);
830
981
  }));
831
982
  }
832
- function N() {
983
+ function M() {
833
984
  if (f.value) {
834
- let e = E(f.value.table);
835
- f.value = e, e || (p.value = null, w.close());
985
+ let e = T(f.value.table);
986
+ f.value = e, e || (p.value = null, S.close());
836
987
  }
837
988
  }
838
- g(() => {
839
- document.addEventListener("mousemove", te, !0), window.addEventListener("scroll", N, !0), window.addEventListener("resize", N);
989
+ _(() => {
990
+ document.addEventListener("mousemove", j, !0), window.addEventListener("scroll", M, !0), window.addEventListener("resize", M);
840
991
  }), ee(() => {
841
- document.removeEventListener("mousemove", te, !0), document.removeEventListener("mousemove", le, !0), document.removeEventListener("mouseup", H, !0), window.removeEventListener("scroll", N, !0), window.removeEventListener("resize", N);
992
+ document.removeEventListener("mousemove", j, !0), document.removeEventListener("mousemove", H, !0), document.removeEventListener("mouseup", W, !0), window.removeEventListener("scroll", M, !0), window.removeEventListener("resize", M);
842
993
  });
843
- function F(e, t) {
994
+ function N(e, t) {
844
995
  let n = f.value, r = d();
845
996
  if (!n || !r) return null;
846
997
  let i = null;
847
998
  return r.action((r) => {
848
- let a = r.get(P), o = e === "col" ? n.table.querySelector("tr")?.children[t] : n.table.querySelectorAll("tr")[t]?.children[0];
999
+ let a = r.get(I), o = e === "col" ? n.table.querySelector("tr")?.children[t] : n.table.querySelectorAll("tr")[t]?.children[0];
849
1000
  o && (i = a.posAtDOM(o, 0));
850
1001
  }), i;
851
1002
  }
852
- function I(e, t, ...n) {
853
- let r = d(), i = F(e, t);
1003
+ function F(e, t, ...n) {
1004
+ let r = d(), i = N(e, t);
854
1005
  if (!r || i == null) return;
855
- let a = e === "col" ? Qe : $e;
1006
+ let a = e === "col" ? ct : lt;
856
1007
  r.action((e) => {
857
- let r = e.get(M);
1008
+ let r = e.get(P);
858
1009
  r.call(a.key, {
859
1010
  index: t,
860
1011
  pos: i
861
1012
  });
862
1013
  for (let e of n) r.call(e.key);
863
- }), w.close(), f.value = null;
1014
+ }), S.close(), f.value = null;
1015
+ }
1016
+ function L() {
1017
+ m.value && F(m.value.kind, m.value.index, rt);
864
1018
  }
865
1019
  function ne() {
866
- x.value && I(x.value.kind, x.value.index, qe);
1020
+ if (!m.value) return;
1021
+ let { kind: e, index: t } = m.value;
1022
+ F(e, t, e === "col" ? et : nt);
867
1023
  }
868
1024
  function re() {
869
- if (!x.value) return;
870
- let { kind: e, index: t } = x.value;
871
- I(e, t, e === "col" ? We : Ke);
872
- }
873
- function ie() {
874
- if (!x.value) return;
875
- let { kind: e, index: t } = x.value;
876
- I(e, t, e === "col" ? Ue : Ge);
1025
+ if (!m.value) return;
1026
+ let { kind: e, index: t } = m.value;
1027
+ F(e, t, e === "col" ? $e : tt);
877
1028
  }
878
- function L(e, t) {
879
- return p.value?.kind === e && p.value.index === t || x.value?.kind === e && x.value.index === t || C.value?.kind === e && C.value.from === t;
1029
+ function R(e, t) {
1030
+ return p.value?.kind === e && p.value.index === t || m.value?.kind === e && m.value.index === t || b.value?.kind === e && b.value.from === t;
880
1031
  }
881
- let R = null;
882
- function z(e, t, n) {
883
- let r = d(), i = F(e, t);
1032
+ let z = null;
1033
+ function B(e, t, n) {
1034
+ let r = d(), i = N(e, t);
884
1035
  if (!r || i == null || t === n) return;
885
- let a = e === "col" ? Qe : $e, o = e === "col" ? Xe : Ze;
1036
+ let a = e === "col" ? ct : lt, o = e === "col" ? ot : st;
886
1037
  r.action((e) => {
887
- let r = e.get(M);
1038
+ let r = e.get(P);
888
1039
  r.call(a.key, {
889
1040
  index: t,
890
1041
  pos: i
@@ -893,11 +1044,11 @@ var fn = class {
893
1044
  to: n,
894
1045
  pos: i
895
1046
  });
896
- let s = e.get(P), { state: c } = s;
897
- c.selection.empty || s.dispatch(c.tr.setSelection(ke.create(c.doc, c.selection.from)));
1047
+ let s = e.get(I), { state: c } = s;
1048
+ c.selection.empty || s.dispatch(c.tr.setSelection(je.create(c.doc, c.selection.from)));
898
1049
  }), f.value = null, p.value = null;
899
1050
  }
900
- function B(e, t, n) {
1051
+ function ae(e, t, n) {
901
1052
  let r = f.value;
902
1053
  if (!r) return 0;
903
1054
  if (e === "col") {
@@ -908,44 +1059,44 @@ var fn = class {
908
1059
  return i === -1 ? r.rows.length - 1 : i;
909
1060
  }
910
1061
  function V(e, t, n) {
911
- n.preventDefault(), n.stopPropagation(), R = {
1062
+ n.preventDefault(), n.stopPropagation(), z = {
912
1063
  kind: e,
913
1064
  from: t,
914
1065
  x: n.clientX,
915
1066
  y: n.clientY,
916
1067
  ev: n
917
- }, document.addEventListener("mousemove", le, !0), document.addEventListener("mouseup", H, !0);
918
- }
919
- function le(e) {
920
- if (R) {
921
- if (!C.value) {
922
- if (Math.hypot(e.clientX - R.x, e.clientY - R.y) < En) return;
923
- C.value = {
924
- kind: R.kind,
925
- from: R.from,
926
- target: R.from
1068
+ }, document.addEventListener("mousemove", H, !0), document.addEventListener("mouseup", W, !0);
1069
+ }
1070
+ function H(e) {
1071
+ if (z) {
1072
+ if (!b.value) {
1073
+ if (Math.hypot(e.clientX - z.x, e.clientY - z.y) < Wn) return;
1074
+ b.value = {
1075
+ kind: z.kind,
1076
+ from: z.from,
1077
+ target: z.from
927
1078
  };
928
1079
  }
929
- C.value = {
930
- ...C.value,
931
- target: B(C.value.kind, e.clientX, e.clientY)
1080
+ b.value = {
1081
+ ...b.value,
1082
+ target: ae(b.value.kind, e.clientX, e.clientY)
932
1083
  };
933
1084
  }
934
1085
  }
935
- function H() {
936
- if (document.removeEventListener("mousemove", le, !0), document.removeEventListener("mouseup", H, !0), C.value) {
937
- let { kind: e, from: t, target: n } = C.value;
938
- C.value = null, z(e, t, n);
939
- } else R && ue(R.kind, R.from, R.ev);
940
- R = null;
1086
+ function W() {
1087
+ if (document.removeEventListener("mousemove", H, !0), document.removeEventListener("mouseup", W, !0), b.value) {
1088
+ let { kind: e, from: t, target: n } = b.value;
1089
+ b.value = null, B(e, t, n);
1090
+ } else z && ce(z.kind, z.from, z.ev);
1091
+ z = null;
941
1092
  }
942
- function ue(e, t, n) {
943
- n.preventDefault(), n.stopPropagation(), x.value = {
1093
+ function ce(e, t, n) {
1094
+ n.preventDefault(), n.stopPropagation(), m.value = {
944
1095
  kind: e,
945
1096
  index: t
946
- }, u("menuToggle", !0), w.open(n), requestAnimationFrame(N);
1097
+ }, u("menuToggle", !0), S.open(n), requestAnimationFrame(M);
947
1098
  }
948
- let U = n(() => {
1099
+ let le = n(() => {
949
1100
  let e = f.value;
950
1101
  return e ? [{
951
1102
  key: "top",
@@ -960,7 +1111,7 @@ var fn = class {
960
1111
  width: e.rect.width,
961
1112
  height: Z
962
1113
  }] : [];
963
- }), W = n(() => {
1114
+ }), ue = n(() => {
964
1115
  let e = f.value;
965
1116
  return e ? [{
966
1117
  key: "left",
@@ -976,9 +1127,9 @@ var fn = class {
976
1127
  height: e.rect.height
977
1128
  }] : [];
978
1129
  }), G = n(() => {
979
- let e = f.value, t = p.value ?? x.value ?? (C.value ? {
980
- kind: C.value.kind,
981
- index: C.value.from
1130
+ let e = f.value, t = p.value ?? m.value ?? (b.value ? {
1131
+ kind: b.value.kind,
1132
+ index: b.value.from
982
1133
  } : null);
983
1134
  if (!e || !t) return null;
984
1135
  if (t.kind === "col") {
@@ -998,7 +1149,7 @@ var fn = class {
998
1149
  height: `${n.height}px`
999
1150
  };
1000
1151
  }), K = n(() => {
1001
- let e = f.value, t = C.value;
1152
+ let e = f.value, t = b.value;
1002
1153
  if (!e || !t) return null;
1003
1154
  if (t.kind === "col") {
1004
1155
  let n = e.cols[t.target], r = t.target >= t.from ? n.left + n.width : n.left;
@@ -1017,31 +1168,31 @@ var fn = class {
1017
1168
  height: "2px"
1018
1169
  };
1019
1170
  });
1020
- return (n, r) => (_(), i(t, { to: "body" }, [f.value ? (_(), o("div", Cn, [
1021
- G.value ? (_(), o("div", {
1171
+ return (n, r) => (v(), i(t, { to: "body" }, [f.value ? (v(), o("div", Vn, [
1172
+ G.value ? (v(), o("div", {
1022
1173
  key: 0,
1023
1174
  class: "coar-md-th__hl",
1024
- style: h(G.value)
1175
+ style: g(G.value)
1025
1176
  }, null, 4)) : a("", !0),
1026
- K.value ? (_(), o("div", {
1177
+ K.value ? (v(), o("div", {
1027
1178
  key: 1,
1028
1179
  class: "coar-md-th__drop",
1029
- style: h(K.value)
1180
+ style: g(K.value)
1030
1181
  }, null, 4)) : a("", !0),
1031
- (_(!0), o(e, null, y(U.value, (t) => (_(), o("div", {
1182
+ (v(!0), o(e, null, x(le.value, (t) => (v(), o("div", {
1032
1183
  key: t.key,
1033
1184
  class: "coar-md-th__bar coar-md-th__bar--col",
1034
- style: h({
1185
+ style: g({
1035
1186
  left: `${t.left}px`,
1036
1187
  top: `${t.top}px`,
1037
1188
  width: `${t.width}px`,
1038
1189
  height: `${t.height}px`
1039
1190
  })
1040
- }, [(_(!0), o(e, null, y(f.value.cols, (e, t) => (_(), o("button", {
1191
+ }, [(v(!0), o(e, null, x(f.value.cols, (e, t) => (v(), o("button", {
1041
1192
  key: `c${t}`,
1042
1193
  type: "button",
1043
- class: m(["coar-md-th__grip", { "coar-md-th__grip--active": L("col", t) }]),
1044
- style: h({
1194
+ class: h(["coar-md-th__grip", { "coar-md-th__grip--active": R("col", t) }]),
1195
+ style: g({
1045
1196
  left: `${e.left - f.value.rect.left}px`,
1046
1197
  width: `${e.width}px`
1047
1198
  }),
@@ -1052,21 +1203,21 @@ var fn = class {
1052
1203
  },
1053
1204
  onMouseleave: r[0] ||= (e) => p.value = null,
1054
1205
  onMousedown: (e) => V("col", t, e)
1055
- }, null, 46, wn))), 128))], 4))), 128)),
1056
- (_(!0), o(e, null, y(W.value, (t) => (_(), o("div", {
1206
+ }, null, 46, Hn))), 128))], 4))), 128)),
1207
+ (v(!0), o(e, null, x(ue.value, (t) => (v(), o("div", {
1057
1208
  key: t.key,
1058
1209
  class: "coar-md-th__bar coar-md-th__bar--row",
1059
- style: h({
1210
+ style: g({
1060
1211
  left: `${t.left}px`,
1061
1212
  top: `${t.top}px`,
1062
1213
  width: `${t.width}px`,
1063
1214
  height: `${t.height}px`
1064
1215
  })
1065
- }, [(_(!0), o(e, null, y(f.value.rows, (e, t) => (_(), o("button", {
1216
+ }, [(v(!0), o(e, null, x(f.value.rows, (e, t) => (v(), o("button", {
1066
1217
  key: `r${t}`,
1067
1218
  type: "button",
1068
- class: m(["coar-md-th__grip", { "coar-md-th__grip--active": L("row", t) }]),
1069
- style: h({
1219
+ class: h(["coar-md-th__grip", { "coar-md-th__grip--active": R("row", t) }]),
1220
+ style: g({
1070
1221
  top: `${e.top - f.value.rect.top}px`,
1071
1222
  height: `${e.height}px`
1072
1223
  }),
@@ -1077,30 +1228,30 @@ var fn = class {
1077
1228
  },
1078
1229
  onMouseleave: r[1] ||= (e) => p.value = null,
1079
1230
  onMousedown: (e) => V("row", t, e)
1080
- }, null, 46, Tn))), 128))], 4))), 128))
1081
- ])) : a("", !0), l(S(oe), { menu: S(w) }, {
1082
- default: O(() => [
1083
- l(S(ce), {
1084
- label: x.value?.kind === "col" ? "Insert column left" : "Insert row above",
1085
- icon: x.value?.kind === "col" ? "table-column-plus-left" : "table-row-plus-above",
1086
- onClicked: re
1231
+ }, null, 46, Un))), 128))], 4))), 128))
1232
+ ])) : a("", !0), l(C(oe), { menu: C(S) }, {
1233
+ default: k(() => [
1234
+ l(C(U), {
1235
+ label: m.value?.kind === "col" ? "Insert column left" : "Insert row above",
1236
+ icon: m.value?.kind === "col" ? "table-column-plus-left" : "table-row-plus-above",
1237
+ onClicked: ne
1087
1238
  }, null, 8, ["label", "icon"]),
1088
- l(S(ce), {
1089
- label: x.value?.kind === "col" ? "Insert column right" : "Insert row below",
1090
- icon: x.value?.kind === "col" ? "table-column-plus-right" : "table-row-plus-below",
1091
- onClicked: ie
1239
+ l(C(U), {
1240
+ label: m.value?.kind === "col" ? "Insert column right" : "Insert row below",
1241
+ icon: m.value?.kind === "col" ? "table-column-plus-right" : "table-row-plus-below",
1242
+ onClicked: re
1092
1243
  }, null, 8, ["label", "icon"]),
1093
- l(S(se)),
1094
- l(S(ce), {
1095
- label: x.value?.kind === "col" ? "Delete column" : "Delete row",
1244
+ l(C(se)),
1245
+ l(C(U), {
1246
+ label: m.value?.kind === "col" ? "Delete column" : "Delete row",
1096
1247
  icon: "trash-2",
1097
- onClicked: ne
1248
+ onClicked: L
1098
1249
  }, null, 8, ["label"])
1099
1250
  ]),
1100
1251
  _: 1
1101
1252
  }, 8, ["menu"])]));
1102
1253
  }
1103
- }), [["__scopeId", "data-v-24e26df4"]]), On = ["onKeydown"], kn = { ref: "urlField" }, An = { class: "coar-md-image-dialog__actions" }, jn = /* @__PURE__ */ xn(/* @__PURE__ */ u({
1254
+ }), [["__scopeId", "data-v-24e26df4"]]), Kn = ["onKeydown"], qn = { ref: "urlField" }, Jn = { class: "coar-md-image-dialog__actions" }, Yn = /* @__PURE__ */ zn(/* @__PURE__ */ u({
1104
1255
  __name: "ImageInsertDialog",
1105
1256
  props: {
1106
1257
  close: { type: Function },
@@ -1109,7 +1260,7 @@ var fn = class {
1109
1260
  initialTitle: {}
1110
1261
  },
1111
1262
  setup(e) {
1112
- let t = e, r = v(t.initialUrl ?? ""), i = v(t.initialAlt ?? ""), a = v(t.initialTitle ?? ""), u = w("urlField"), d = n(() => r.value.trim().length > 0);
1263
+ let t = e, r = y(t.initialUrl ?? ""), i = y(t.initialAlt ?? ""), a = y(t.initialTitle ?? ""), u = T("urlField"), d = n(() => r.value.trim().length > 0);
1113
1264
  function f() {
1114
1265
  d.value && t.close({
1115
1266
  url: r.value.trim(),
@@ -1120,17 +1271,17 @@ var fn = class {
1120
1271
  function p() {
1121
1272
  t.close();
1122
1273
  }
1123
- return g(() => {
1274
+ return _(() => {
1124
1275
  u.value?.querySelector("input")?.focus();
1125
- }), (e, t) => (_(), o("div", {
1276
+ }), (e, t) => (v(), o("div", {
1126
1277
  class: "coar-md-image-dialog",
1127
- onKeydown: A(j(f, ["prevent"]), ["enter"])
1278
+ onKeydown: j(M(f, ["prevent"]), ["enter"])
1128
1279
  }, [
1129
- s("div", kn, [l(S(z), {
1280
+ s("div", qn, [l(C(V), {
1130
1281
  label: "Image URL",
1131
1282
  required: ""
1132
1283
  }, {
1133
- default: O(() => [l(S(W), {
1284
+ default: k(() => [l(C(K), {
1134
1285
  modelValue: r.value,
1135
1286
  "onUpdate:modelValue": t[0] ||= (e) => r.value = e,
1136
1287
  placeholder: "https://example.com/image.png",
@@ -1138,8 +1289,8 @@ var fn = class {
1138
1289
  }, null, 8, ["modelValue"])]),
1139
1290
  _: 1
1140
1291
  })], 512),
1141
- l(S(z), { label: "Alt text" }, {
1142
- default: O(() => [l(S(W), {
1292
+ l(C(V), { label: "Alt text" }, {
1293
+ default: k(() => [l(C(K), {
1143
1294
  modelValue: i.value,
1144
1295
  "onUpdate:modelValue": t[1] ||= (e) => i.value = e,
1145
1296
  placeholder: "Describe the image",
@@ -1147,8 +1298,8 @@ var fn = class {
1147
1298
  }, null, 8, ["modelValue"])]),
1148
1299
  _: 1
1149
1300
  }),
1150
- l(S(z), { label: "Title (optional)" }, {
1151
- default: O(() => [l(S(W), {
1301
+ l(C(V), { label: "Title (optional)" }, {
1302
+ default: k(() => [l(C(K), {
1152
1303
  modelValue: a.value,
1153
1304
  "onUpdate:modelValue": t[2] ||= (e) => a.value = e,
1154
1305
  placeholder: "Shown on hover",
@@ -1156,39 +1307,39 @@ var fn = class {
1156
1307
  }, null, 8, ["modelValue"])]),
1157
1308
  _: 1
1158
1309
  }),
1159
- s("div", An, [l(S(L), {
1310
+ s("div", Jn, [l(C(B), {
1160
1311
  variant: "tertiary",
1161
1312
  type: "button",
1162
1313
  onClick: p
1163
1314
  }, {
1164
- default: O(() => [...t[3] ||= [c("Cancel", -1)]]),
1315
+ default: k(() => [...t[3] ||= [c("Cancel", -1)]]),
1165
1316
  _: 1
1166
- }), l(S(L), {
1317
+ }), l(C(B), {
1167
1318
  variant: "primary",
1168
1319
  type: "button",
1169
1320
  disabled: !d.value,
1170
1321
  onClick: f
1171
1322
  }, {
1172
- default: O(() => [...t[4] ||= [c("Insert", -1)]]),
1323
+ default: k(() => [...t[4] ||= [c("Insert", -1)]]),
1173
1324
  _: 1
1174
1325
  }, 8, ["disabled"])])
1175
- ], 40, On));
1326
+ ], 40, Kn));
1176
1327
  }
1177
- }), [["__scopeId", "data-v-a0456b93"]]), Q = new Oe("coar-image-upload-placeholder");
1178
- function Mn() {
1328
+ }), [["__scopeId", "data-v-a0456b93"]]), Q = new Ae("coar-image-upload-placeholder");
1329
+ function Xn() {
1179
1330
  let e = document.createElement("span");
1180
1331
  return e.className = "coar-md-image-uploading", e.setAttribute("aria-label", "Uploading image…"), e.setAttribute("role", "img"), e;
1181
1332
  }
1182
- function Nn(e, t) {
1333
+ function Zn(e, t) {
1183
1334
  let n = Q.getState(e.state);
1184
1335
  if (!n) return null;
1185
1336
  let r = n.find(void 0, void 0, (e) => e.id === t);
1186
1337
  return r.length ? r[0].from : null;
1187
1338
  }
1188
- function Pn(e) {
1339
+ function Qn(e) {
1189
1340
  return e ? Array.from(e.files).filter((e) => e.type.startsWith("image/")) : [];
1190
1341
  }
1191
- function Fn(e, t, n, r) {
1342
+ function $n(e, t, n, r) {
1192
1343
  let i = r.getUploader();
1193
1344
  if (!i) return;
1194
1345
  let a = { token: Symbol("coar-image-upload") };
@@ -1197,7 +1348,7 @@ function Fn(e, t, n, r) {
1197
1348
  id: a,
1198
1349
  pos: n
1199
1350
  })), i(t).then(({ url: n, alt: r }) => {
1200
- let i = Nn(e, a);
1351
+ let i = Zn(e, a);
1201
1352
  if (i === null) return;
1202
1353
  let o = e.state.schema.nodes.image;
1203
1354
  if (!o) return;
@@ -1210,21 +1361,21 @@ function Fn(e, t, n, r) {
1210
1361
  });
1211
1362
  e.dispatch(c);
1212
1363
  }).catch((n) => {
1213
- Nn(e, a) !== null && e.dispatch(e.state.tr.setMeta(Q, {
1364
+ Zn(e, a) !== null && e.dispatch(e.state.tr.setMeta(Q, {
1214
1365
  type: "remove",
1215
1366
  id: a
1216
1367
  })), (r.onError ?? ((e) => console.error("[CoarMarkdownEditor] image upload failed", e)))(n, t);
1217
1368
  });
1218
1369
  }
1219
- function In(e) {
1220
- return Me(() => new De({
1370
+ function er(e) {
1371
+ return Pe(() => new ke({
1221
1372
  key: Q,
1222
1373
  state: {
1223
- init: () => rt.empty,
1374
+ init: () => pt.empty,
1224
1375
  apply(e, t) {
1225
1376
  let n = t.map(e.mapping, e.doc), r = e.getMeta(Q);
1226
1377
  if (r?.type === "add") {
1227
- let t = nt.widget(r.pos, Mn(), { id: r.id });
1378
+ let t = ft.widget(r.pos, Xn(), { id: r.id });
1228
1379
  n = n.add(e.doc, [t]);
1229
1380
  } else r?.type === "remove" && (n = n.remove(n.find(void 0, void 0, (e) => e.id === r.id)));
1230
1381
  return n;
@@ -1236,29 +1387,29 @@ function In(e) {
1236
1387
  },
1237
1388
  handlePaste(t, n) {
1238
1389
  if (!e.getUploader()) return !1;
1239
- let r = Pn(n.clipboardData);
1390
+ let r = Qn(n.clipboardData);
1240
1391
  if (r.length === 0) return !1;
1241
1392
  n.preventDefault();
1242
1393
  let i = t.state.selection.from;
1243
- return r.forEach((n) => Fn(t, n, i, e)), !0;
1394
+ return r.forEach((n) => $n(t, n, i, e)), !0;
1244
1395
  },
1245
1396
  handleDrop(t, n, r, i) {
1246
1397
  if (i || !e.getUploader()) return !1;
1247
- let a = Pn(n.dataTransfer);
1398
+ let a = Qn(n.dataTransfer);
1248
1399
  if (a.length === 0) return !1;
1249
1400
  n.preventDefault();
1250
1401
  let o = t.posAtCoords({
1251
1402
  left: n.clientX,
1252
1403
  top: n.clientY
1253
1404
  })?.pos ?? t.state.selection.from;
1254
- return a.forEach((n) => Fn(t, n, o, e)), !0;
1405
+ return a.forEach((n) => $n(t, n, o, e)), !0;
1255
1406
  }
1256
1407
  }
1257
1408
  }));
1258
1409
  }
1259
1410
  //#endregion
1260
1411
  //#region src/CoarMarkdownEditor.vue?vue&type=script&lang.ts
1261
- var Ln = [
1412
+ var tr = [
1262
1413
  "bold",
1263
1414
  "italic",
1264
1415
  "strikethrough",
@@ -1280,26 +1431,26 @@ var Ln = [
1280
1431
  "undo",
1281
1432
  "redo"
1282
1433
  ], $ = {
1283
- bold: { command: Se },
1284
- italic: { command: be },
1285
- strike: { command: tt },
1286
- code: { command: xe },
1287
- bulletList: { command: Te },
1288
- orderedList: { command: Ee },
1289
- blockquote: { command: we },
1290
- hr: { command: ge },
1291
- codeBlock: { command: he },
1292
- table: { command: Ye },
1293
- undo: { command: ot },
1294
- redo: { command: at },
1295
- paragraph: { command: Ce },
1296
- addRowBefore: { command: Ke },
1297
- addRowAfter: { command: Ge },
1298
- addColBefore: { command: We },
1299
- addColAfter: { command: Ue },
1300
- deleteCell: { command: qe },
1301
- indent: { command: ye },
1302
- outdent: { command: ve },
1434
+ bold: { command: we },
1435
+ italic: { command: Se },
1436
+ strike: { command: dt },
1437
+ code: { command: Ce },
1438
+ bulletList: { command: De },
1439
+ orderedList: { command: Oe },
1440
+ blockquote: { command: Ee },
1441
+ hr: { command: ve },
1442
+ codeBlock: { command: _e },
1443
+ table: { command: at },
1444
+ undo: { command: gt },
1445
+ redo: { command: ht },
1446
+ paragraph: { command: Te },
1447
+ addRowBefore: { command: nt },
1448
+ addRowAfter: { command: tt },
1449
+ addColBefore: { command: et },
1450
+ addColAfter: { command: $e },
1451
+ deleteCell: { command: rt },
1452
+ indent: { command: xe },
1453
+ outdent: { command: be },
1303
1454
  h1: {
1304
1455
  command: J,
1305
1456
  payload: 1
@@ -1324,7 +1475,7 @@ var Ln = [
1324
1475
  command: J,
1325
1476
  payload: 6
1326
1477
  }
1327
- }, Rn = u({
1478
+ }, nr = u({
1328
1479
  props: {
1329
1480
  initialValue: {
1330
1481
  type: String,
@@ -1394,56 +1545,63 @@ var Ln = [
1394
1545
  type: Function,
1395
1546
  default: void 0
1396
1547
  },
1548
+ embeds: {
1549
+ type: Object,
1550
+ default: void 0
1551
+ },
1397
1552
  onMarkdownChange: {
1398
1553
  type: Function,
1399
1554
  required: !0
1400
1555
  }
1401
1556
  },
1402
1557
  setup(e) {
1403
- let t = v(e.initialValue), n = v("rendered"), r = Ct(e.flavor);
1404
- ie((n) => {
1405
- let i = te.make().config((r) => {
1406
- r.set(I, n), r.set(N, e.initialValue), r.update(F, (t) => ({
1558
+ let t = d()?.appContext ?? null, n = y(e.initialValue), r = y("rendered"), i = Nt(e.flavor);
1559
+ z((r) => {
1560
+ let a = N.make().config((t) => {
1561
+ t.set(ne, r), t.set(F, e.initialValue), t.update(L, (t) => ({
1407
1562
  ...t,
1408
1563
  editable: () => !e.readonly
1409
- })), r.get(lt).markdownUpdated((n, r) => {
1410
- r !== t.value && (t.value = r, e.onMarkdownChange(r));
1564
+ })), t.get(yt).markdownUpdated((t, r) => {
1565
+ r !== n.value && (n.value = r, e.onMarkdownChange(r));
1411
1566
  });
1412
- }).use(q);
1413
- return r.gfm && i.use(Je), i.use(pn).use(it).use(st).use(ct), r.textColor && i.use(Ft), i.use(At).use(In({ getUploader: () => e.uploadImage })), i;
1567
+ }).use(ge);
1568
+ return i.gfm && a.use(it), a.use(Cn).use(mt).use(_t).use(vt), i.textColor && a.use(Gt), i.embeds && a.use(jn({
1569
+ resolveRegistry: () => e.embeds,
1570
+ appContext: t
1571
+ })), a.use(Bt).use(er({ getUploader: () => e.uploadImage })), a;
1414
1572
  });
1415
- let [i, a] = ae(), o = v(null);
1416
- return D(() => e.externalValue.value, (e) => {
1417
- if (e === t.value) return;
1418
- if (n.value === "source") {
1419
- t.value = e;
1573
+ let [a, o] = ie(), s = y(null);
1574
+ return O(() => e.externalValue.value, (e) => {
1575
+ if (e === n.value) return;
1576
+ if (r.value === "source") {
1577
+ n.value = e;
1420
1578
  return;
1421
1579
  }
1422
- let r = a();
1423
- if (!r) {
1424
- o.value = e;
1580
+ let t = o();
1581
+ if (!t) {
1582
+ s.value = e;
1425
1583
  return;
1426
1584
  }
1427
- o.value = null, t.value = e, r.action(Fe(e));
1428
- }), D(n, (e) => {
1585
+ s.value = null, n.value = e, t.action(Le(e));
1586
+ }), O(r, (e) => {
1429
1587
  if (e !== "rendered") return;
1430
- let n = a();
1431
- n && n.action(Fe(t.value));
1432
- }), D(i, (e) => {
1433
- if (e || o.value === null) return;
1434
- let n = a();
1435
- if (!n) return;
1436
- let r = o.value;
1437
- o.value = null, r !== t.value && (t.value = r, n.action(Fe(r)));
1438
- }, { immediate: !0 }), D(() => e.readonly, () => {
1439
- let t = a();
1588
+ let t = o();
1589
+ t && t.action(Le(n.value));
1590
+ }), O(a, (e) => {
1591
+ if (e || s.value === null) return;
1592
+ let t = o();
1593
+ if (!t) return;
1594
+ let r = s.value;
1595
+ s.value = null, r !== n.value && (n.value = r, t.action(Le(r)));
1596
+ }, { immediate: !0 }), O(() => e.readonly, () => {
1597
+ let t = o();
1440
1598
  t && t.action((t) => {
1441
- t.update(F, (t) => ({
1599
+ t.update(L, (t) => ({
1442
1600
  ...t,
1443
1601
  editable: () => !e.readonly
1444
- })), t.get(P).update(t.get(P).props);
1602
+ })), t.get(I).update(t.get(I).props);
1445
1603
  });
1446
- }), () => d(zn, {
1604
+ }), () => f(rr, {
1447
1605
  readonly: e.readonly,
1448
1606
  disabled: e.disabled,
1449
1607
  toolbarMode: e.toolbarMode,
@@ -1456,20 +1614,21 @@ var Ln = [
1456
1614
  required: e.required,
1457
1615
  placeholder: e.placeholder,
1458
1616
  pickImage: e.pickImage,
1617
+ embeds: e.embeds,
1459
1618
  flavor: e.flavor,
1460
- isEmpty: t.value.trim() === "",
1619
+ isEmpty: n.value.trim() === "",
1461
1620
  sourceToggle: e.sourceToggle,
1462
- viewMode: n.value,
1463
- sourceValue: t.value,
1621
+ viewMode: r.value,
1622
+ sourceValue: n.value,
1464
1623
  onToggleView: (e) => {
1465
- n.value = e;
1624
+ r.value = e;
1466
1625
  },
1467
- onSourceInput: (n) => {
1468
- n !== t.value && (t.value = n, e.onMarkdownChange(n));
1626
+ onSourceInput: (t) => {
1627
+ t !== n.value && (n.value = t, e.onMarkdownChange(t));
1469
1628
  }
1470
1629
  });
1471
1630
  }
1472
- }), zn = u({
1631
+ }), rr = u({
1473
1632
  props: {
1474
1633
  readonly: {
1475
1634
  type: Boolean,
@@ -1523,6 +1682,10 @@ var Ln = [
1523
1682
  type: Function,
1524
1683
  default: void 0
1525
1684
  },
1685
+ embeds: {
1686
+ type: Object,
1687
+ default: void 0
1688
+ },
1526
1689
  isEmpty: {
1527
1690
  type: Boolean,
1528
1691
  default: !1
@@ -1549,10 +1712,10 @@ var Ln = [
1549
1712
  }
1550
1713
  },
1551
1714
  setup(e) {
1552
- let [, r] = ae(), i = v(null), a = v(null), o = v(!1), s = v(!1), c = v({
1715
+ let [, r] = ie(), i = y(null), a = y(null), o = y(!1), s = y(!1), c = y({
1553
1716
  left: "0px",
1554
1717
  top: "0px"
1555
- }), l = v("text"), u = v(!1), f = {
1718
+ }), l = y("text"), u = y(!1), d = {
1556
1719
  strong: !1,
1557
1720
  emphasis: !1,
1558
1721
  strike_through: !1,
@@ -1567,19 +1730,38 @@ var Ln = [
1567
1730
  cell_alignment: null,
1568
1731
  code_block: !1,
1569
1732
  list_item_depth: 0
1570
- }, m = pe(), h = fe(), _ = null, y = null, b = v({ ...f });
1733
+ }, p = he(), h = me(), g = null, v = null, b = y({ ...d });
1571
1734
  function x(t) {
1572
1735
  if (e.readonly) return;
1573
1736
  let n = r();
1574
1737
  n && (n.action((e) => {
1575
- e.get(M).call(t.command.key, t.payload);
1576
- }), R());
1738
+ e.get(P).call(t.command.key, t.payload);
1739
+ }), B());
1740
+ }
1741
+ async function te(t) {
1742
+ if (e.readonly) return;
1743
+ let n = e.embeds?.[t], i = {};
1744
+ if (n?.insert?.pick) {
1745
+ let e = await n.insert.pick();
1746
+ if (e == null) return;
1747
+ i = e;
1748
+ }
1749
+ let a = r();
1750
+ a && (a.action((e) => {
1751
+ let n = e.get(I), r = n.state.schema.nodes.embed;
1752
+ if (!r) return;
1753
+ let a = r.create({
1754
+ embedKey: t,
1755
+ props: i
1756
+ });
1757
+ n.dispatch(n.state.tr.replaceSelectionWith(a).scrollIntoView()), n.focus();
1758
+ }), B());
1577
1759
  }
1578
1760
  function S(t) {
1579
1761
  if (e.readonly) return;
1580
1762
  let n = r();
1581
1763
  n && (n.action((e) => {
1582
- let n = e.get(P), { state: r } = n, { $from: i } = r.selection, a = -1, o = null, s = -1;
1764
+ let n = e.get(I), { state: r } = n, { $from: i } = r.selection, a = -1, o = null, s = -1;
1583
1765
  for (let e = i.depth; e > 0; e--) {
1584
1766
  let t = i.node(e);
1585
1767
  t.type.name === "table" && (o = t, a = i.before(e)), (t.type.name === "table_cell" || t.type.name === "table_header") && s < 0 && (s = e);
@@ -1596,32 +1778,39 @@ var Ln = [
1596
1778
  });
1597
1779
  });
1598
1780
  }), l.docChanged && n.dispatch(l);
1599
- }), R());
1781
+ }), B());
1600
1782
  }
1601
1783
  function C() {
1602
1784
  if (e.readonly) return;
1603
1785
  let t = r();
1604
1786
  t && (t.action((e) => {
1605
- let t = e.get(M);
1606
- t.call(et.key), t.call(qe.key);
1607
- }), R());
1787
+ let t = e.get(P);
1788
+ t.call(ut.key), t.call(rt.key);
1789
+ }), B());
1608
1790
  }
1609
1791
  function w(t) {
1610
1792
  if (e.readonly) return;
1611
- let n = t === "bullet_list" ? $.bulletList : $.orderedList, r = xt({
1793
+ let n = t === "bullet_list" ? $.bulletList : $.orderedList, r = jt({
1612
1794
  target: t,
1613
1795
  inBulletList: b.value.bullet_list,
1614
1796
  inOrderedList: b.value.ordered_list
1615
1797
  });
1616
1798
  if (r === "lift") {
1617
- x({ command: ve });
1799
+ x({ command: be });
1618
1800
  return;
1619
1801
  }
1620
- r === "switch" && x({ command: ve }), x(n);
1802
+ r === "switch" && x({ command: be }), x(n);
1621
1803
  }
1622
- let T = n(() => e.tools ? new Set(e.tools) : void 0), E = n(() => Ct(e.flavor));
1804
+ let T = n(() => {
1805
+ if (!e.tools) return;
1806
+ let t = /* @__PURE__ */ new Set(), n = (e) => {
1807
+ typeof e == "string" && e !== "divider" && !e.startsWith("embed:") && t.add(e);
1808
+ };
1809
+ for (let t of e.tools) typeof t == "string" ? n(t) : t && typeof t == "object" && Array.isArray(t.flyout) && t.flyout.forEach(n);
1810
+ return t;
1811
+ }), E = n(() => Nt(e.flavor));
1623
1812
  function D(e) {
1624
- return yt(e, E.value) ? bt(e, T.value) : !1;
1813
+ return kt(e, E.value) ? At(e, T.value) : !1;
1625
1814
  }
1626
1815
  function O(t) {
1627
1816
  if (e.readonly) return;
@@ -1629,7 +1818,7 @@ var Ln = [
1629
1818
  if (!n) return;
1630
1819
  let i = t === null ? null : Y(t);
1631
1820
  n.action((e) => {
1632
- let t = e.get(P), { state: n } = t, r = n.schema.marks.text_color;
1821
+ let t = e.get(I), { state: n } = t, r = n.schema.marks.text_color;
1633
1822
  if (!r) return;
1634
1823
  let { from: a, to: o, empty: s } = n.selection;
1635
1824
  if (s) {
@@ -1639,17 +1828,17 @@ var Ln = [
1639
1828
  let e = n.tr.removeMark(a, o, r);
1640
1829
  i && (e = e.addMark(a, o, r.create({ color: i }))), t.dispatch(e);
1641
1830
  }
1642
- }), A(), R();
1831
+ }), A(), B();
1643
1832
  }
1644
1833
  function k(e) {
1645
1834
  if (e) {
1646
- if (_ && !_.isClosed) {
1835
+ if (g && !g.isClosed) {
1647
1836
  A();
1648
1837
  return;
1649
1838
  }
1650
- _ = m.open({
1839
+ g = p.open({
1651
1840
  spec: {
1652
- ...K,
1841
+ ...fe,
1653
1842
  anchor: {
1654
1843
  kind: "element",
1655
1844
  element: e
@@ -1657,39 +1846,39 @@ var Ln = [
1657
1846
  },
1658
1847
  content: {
1659
1848
  kind: "component",
1660
- component: p(_n)
1849
+ component: m(Fn)
1661
1850
  },
1662
1851
  inputs: {
1663
1852
  currentColor: b.value.text_color,
1664
1853
  pick: (e) => O(e)
1665
1854
  }
1666
- }), _.afterClosed.then(() => {
1667
- _?.isClosed && (_ = null);
1855
+ }), g.afterClosed.then(() => {
1856
+ g?.isClosed && (g = null);
1668
1857
  });
1669
1858
  }
1670
1859
  }
1671
1860
  function A() {
1672
- _ && !_.isClosed && _.close(), _ = null;
1861
+ g && !g.isClosed && g.close(), g = null;
1673
1862
  }
1674
1863
  function j(t, n) {
1675
1864
  if (N(), e.readonly) return;
1676
1865
  let i = r();
1677
1866
  i && (i.action((e) => {
1678
- e.get(M).call(Ye.key, {
1867
+ e.get(P).call(at.key, {
1679
1868
  row: t,
1680
1869
  col: n
1681
1870
  });
1682
- }), R());
1871
+ }), B());
1683
1872
  }
1684
- function te(t) {
1873
+ function M(t) {
1685
1874
  if (!(!t || e.readonly)) {
1686
- if (y && !y.isClosed) {
1875
+ if (v && !v.isClosed) {
1687
1876
  N();
1688
1877
  return;
1689
1878
  }
1690
- y = m.open({
1879
+ v = p.open({
1691
1880
  spec: {
1692
- ...K,
1881
+ ...fe,
1693
1882
  anchor: {
1694
1883
  kind: "element",
1695
1884
  element: t
@@ -1697,48 +1886,48 @@ var Ln = [
1697
1886
  },
1698
1887
  content: {
1699
1888
  kind: "component",
1700
- component: p(Sn)
1889
+ component: m(Bn)
1701
1890
  },
1702
1891
  inputs: { pick: (e, t) => j(e, t) }
1703
- }), y.afterClosed.then(() => {
1704
- y?.isClosed && (y = null);
1892
+ }), v.afterClosed.then(() => {
1893
+ v?.isClosed && (v = null);
1705
1894
  });
1706
1895
  }
1707
1896
  }
1708
1897
  function N() {
1709
- y && !y.isClosed && y.close(), y = null;
1898
+ v && !v.isClosed && v.close(), v = null;
1710
1899
  }
1711
1900
  function F(t) {
1712
1901
  if (e.readonly || !t.url) return;
1713
1902
  let n = r();
1714
1903
  n && n.action((e) => {
1715
- e.get(M).call(_e.key, {
1904
+ e.get(P).call(ye.key, {
1716
1905
  src: t.url,
1717
1906
  alt: t.alt || void 0,
1718
1907
  title: t.title || void 0
1719
1908
  });
1720
1909
  });
1721
1910
  }
1722
- function I() {
1911
+ function L() {
1723
1912
  let e = r();
1724
1913
  if (!e) return "";
1725
1914
  let t = "";
1726
1915
  return e.action((e) => {
1727
- let { state: n } = e.get(P), { from: r, to: i } = n.selection;
1916
+ let { state: n } = e.get(I), { from: r, to: i } = n.selection;
1728
1917
  t = n.doc.textBetween(r, i, " ");
1729
1918
  }), t;
1730
1919
  }
1731
- function re() {
1920
+ function ne() {
1732
1921
  if (e.readonly) return;
1733
1922
  let t = e.pickImage;
1734
1923
  if (t) {
1735
1924
  t({
1736
1925
  insertImage: F,
1737
- selectedText: I()
1926
+ selectedText: L()
1738
1927
  });
1739
1928
  return;
1740
1929
  }
1741
- h.open(jn, {
1930
+ h.open(Yn, {
1742
1931
  title: "Insert image",
1743
1932
  size: "s"
1744
1933
  }).result.then((e) => {
@@ -1746,21 +1935,21 @@ var Ln = [
1746
1935
  t?.url && F(t);
1747
1936
  });
1748
1937
  }
1749
- function ie() {
1938
+ function R() {
1750
1939
  if (e.readonly) return;
1751
1940
  let t = r();
1752
1941
  t && t.action((e) => {
1753
- let t = e.get(P), { state: n } = t, r = n.tr, { from: i, to: a, empty: o } = n.selection;
1942
+ let t = e.get(I), { state: n } = t, r = n.tr, { from: i, to: a, empty: o } = n.selection;
1754
1943
  o ? r = r.setStoredMarks([]) : Object.values(n.schema.marks).forEach((e) => {
1755
1944
  r = r.removeMark(i, a, e);
1756
- }), t.dispatch(r), e.get(M).call(Ce.key);
1945
+ }), t.dispatch(r), e.get(P).call(Te.key);
1757
1946
  });
1758
1947
  }
1759
- function L() {
1948
+ function z() {
1760
1949
  if (e.readonly) return;
1761
1950
  let t = r();
1762
1951
  t && t.action((e) => {
1763
- let n = e.get(P), { $from: r } = n.state.selection;
1952
+ let n = e.get(I), { $from: r } = n.state.selection;
1764
1953
  for (let e = r.depth; e > 0; e--) {
1765
1954
  let t = r.node(e);
1766
1955
  if (t.type.name === "list_item") {
@@ -1769,9 +1958,9 @@ var Ln = [
1769
1958
  return;
1770
1959
  }
1771
1960
  }
1772
- e.get(M).call(Te.key), queueMicrotask(() => {
1961
+ e.get(P).call(De.key), queueMicrotask(() => {
1773
1962
  t.action((e) => {
1774
- let t = e.get(P), { $from: n } = t.state.selection;
1963
+ let t = e.get(I), { $from: n } = t.state.selection;
1775
1964
  for (let e = n.depth; e > 0; e--) if (n.node(e).type.name === "list_item") {
1776
1965
  t.dispatch(t.state.tr.setNodeAttribute(n.before(e), "checked", !1));
1777
1966
  return;
@@ -1780,11 +1969,11 @@ var Ln = [
1780
1969
  });
1781
1970
  });
1782
1971
  }
1783
- function R() {
1972
+ function B() {
1784
1973
  let e = r();
1785
1974
  if (e) try {
1786
1975
  e.action((e) => {
1787
- let t = e.get(P).state, { from: n, to: r, empty: i, $from: a } = t.selection, o = t.storedMarks, s = { ...f }, c = (e) => {
1976
+ let t = e.get(I).state, { from: n, to: r, empty: i, $from: a } = t.selection, o = t.storedMarks, s = { ...d }, c = (e) => {
1788
1977
  let s = t.schema.marks[e];
1789
1978
  if (!s) return !1;
1790
1979
  if (i) {
@@ -1826,32 +2015,32 @@ var Ln = [
1826
2015
  b.value = s;
1827
2016
  });
1828
2017
  } catch {
1829
- b.value = { ...f };
2018
+ b.value = { ...d };
1830
2019
  }
1831
2020
  }
1832
- function oe(t) {
2021
+ function ae(t) {
1833
2022
  if (e.readonly) return;
1834
2023
  let n = t.target, i = n.closest("li[data-item-type=\"task\"]");
1835
2024
  if (i) {
1836
2025
  let e = i.getBoundingClientRect();
1837
2026
  if (t.clientX - e.left < 18) {
1838
- t.preventDefault(), z(i);
2027
+ t.preventDefault(), oe(i);
1839
2028
  return;
1840
2029
  }
1841
2030
  }
1842
2031
  if (n.closest(".ProseMirror")) return;
1843
2032
  let a = r();
1844
2033
  a && (t.preventDefault(), a.action((e) => {
1845
- let t = e.get(P);
2034
+ let t = e.get(I);
1846
2035
  t.focus();
1847
- let n = t.state.tr.setSelection(ke.atEnd(t.state.doc));
2036
+ let n = t.state.tr.setSelection(je.atEnd(t.state.doc));
1848
2037
  t.dispatch(n);
1849
2038
  }));
1850
2039
  }
1851
- function z(e) {
2040
+ function oe(e) {
1852
2041
  let t = r();
1853
2042
  t && t.action((t) => {
1854
- let n = t.get(P), r = n.posAtDOM(e, 0);
2043
+ let n = t.get(I), r = n.posAtDOM(e, 0);
1855
2044
  if (r < 0) return;
1856
2045
  let i = n.state.doc.resolve(r);
1857
2046
  for (let e = i.depth; e >= 0; e--) {
@@ -1864,13 +2053,13 @@ var Ln = [
1864
2053
  }
1865
2054
  });
1866
2055
  }
1867
- function se() {
2056
+ function V() {
1868
2057
  let e = r();
1869
2058
  if (!e) return "text";
1870
2059
  try {
1871
2060
  let t = "text";
1872
2061
  return e.action((e) => {
1873
- let { $from: n } = e.get(P).state.selection;
2062
+ let { $from: n } = e.get(I).state.selection;
1874
2063
  for (let e = n.depth; e > 0; e--) if (n.node(e).type.name === "table") {
1875
2064
  t = "table";
1876
2065
  break;
@@ -1880,14 +2069,14 @@ var Ln = [
1880
2069
  return "text";
1881
2070
  }
1882
2071
  }
1883
- function ce(e) {
2072
+ function se(e) {
1884
2073
  let t = e.left + e.width / 2, n = e.top - 8;
1885
2074
  t = Math.max(108, Math.min(t, window.innerWidth - 108)), n < 50 && (n = e.bottom + 8), c.value = {
1886
2075
  left: `${t}px`,
1887
2076
  top: `${n}px`
1888
2077
  };
1889
2078
  }
1890
- function V() {
2079
+ function U() {
1891
2080
  if (e.readonly || e.toolbarMode === "fixed") {
1892
2081
  o.value = !1;
1893
2082
  return;
@@ -1902,13 +2091,13 @@ var Ln = [
1902
2091
  o.value = !1, u.value = !1;
1903
2092
  return;
1904
2093
  }
1905
- ce(n.getBoundingClientRect()), l.value = se(), o.value = !0, u.value = !1;
2094
+ se(n.getBoundingClientRect()), l.value = V(), o.value = !0, u.value = !1;
1906
2095
  }
1907
2096
  function W(e) {
1908
2097
  let t = e.target;
1909
2098
  t.closest(".coar-md-floating-toolbar") || t.closest(".coar-md-float-submenu") || t.closest(".coar-md-color-picker") || t.closest(".coar-overlay-outlet") || (!i.value || !i.value.contains(t)) && (o.value = !1, u.value = !1);
1910
2099
  }
1911
- let G = null;
2100
+ let K = null;
1912
2101
  function de(e = 20) {
1913
2102
  let t = r();
1914
2103
  if (!t) {
@@ -1917,33 +2106,33 @@ var Ln = [
1917
2106
  }
1918
2107
  try {
1919
2108
  t.action((e) => {
1920
- let t = e.get(lt);
1921
- G = () => queueMicrotask(R), t.selectionUpdated(G);
2109
+ let t = e.get(yt);
2110
+ K = () => queueMicrotask(B), t.selectionUpdated(K);
1922
2111
  });
1923
2112
  } catch {
1924
2113
  e > 0 && setTimeout(() => de(e - 1), 50);
1925
2114
  }
1926
2115
  }
1927
- function me() {
1928
- if (!G) return;
2116
+ function pe() {
2117
+ if (!K) return;
1929
2118
  let e = r();
1930
2119
  if (e) {
1931
2120
  try {
1932
2121
  e.action((e) => {
1933
- let t = e.get(lt).listeners.selectionUpdated, n = t.indexOf(G);
2122
+ let t = e.get(yt).listeners.selectionUpdated, n = t.indexOf(K);
1934
2123
  n >= 0 && t.splice(n, 1);
1935
2124
  });
1936
2125
  } catch {}
1937
- G = null;
2126
+ K = null;
1938
2127
  }
1939
2128
  }
1940
- g(() => {
1941
- document.addEventListener("selectionchange", V), document.addEventListener("mousedown", W, !0), de();
2129
+ _(() => {
2130
+ document.addEventListener("selectionchange", U), document.addEventListener("mousedown", W, !0), de();
1942
2131
  }), ee(() => {
1943
- document.removeEventListener("selectionchange", V), document.removeEventListener("mousedown", W, !0), me(), A();
2132
+ document.removeEventListener("selectionchange", U), document.removeEventListener("mousedown", W, !0), pe(), A();
1944
2133
  });
1945
2134
  function q(e, t, n, r = {}) {
1946
- return d(U, {
2135
+ return f(G, {
1947
2136
  icon: e,
1948
2137
  label: t,
1949
2138
  active: r.active ?? !1,
@@ -1951,113 +2140,205 @@ var Ln = [
1951
2140
  onClick: r.disabled ? () => {} : r.onClick ?? (() => x(n))
1952
2141
  });
1953
2142
  }
1954
- function he() {
1955
- let t = b.value, n = t.heading != null;
1956
- function r(e, t, n) {
1957
- D(t) && e.push(n);
1958
- }
2143
+ let ge = [
2144
+ "bold",
2145
+ "italic",
2146
+ "strikethrough",
2147
+ "inlineCode",
2148
+ "textColor",
2149
+ "headings",
2150
+ "divider",
2151
+ "bulletList",
2152
+ "orderedList",
2153
+ "taskList",
2154
+ "outdent",
2155
+ "indent",
2156
+ "blockquote",
2157
+ "horizontalRule",
2158
+ "divider",
2159
+ "codeBlock",
2160
+ "table",
2161
+ "image",
2162
+ "divider",
2163
+ "tableOps",
2164
+ "divider",
2165
+ "clearFormatting",
2166
+ "divider",
2167
+ "undo",
2168
+ "redo"
2169
+ ];
2170
+ function _e() {
2171
+ let t = b.value, n = t.heading != null, r = E.value;
1959
2172
  function i(e) {
1960
- e.length !== 0 && e[e.length - 1]?.type !== H && e.push(d(H));
2173
+ e.length !== 0 && e[e.length - 1]?.type !== le && e.push(f(le));
1961
2174
  }
1962
- let a = [];
2175
+ function a(e) {
2176
+ if (!kt(e, r)) return [];
2177
+ switch (e) {
2178
+ case "bold": return [q("bold", "Bold", $.bold, { active: t.strong })];
2179
+ case "italic": return [q("italic", "Italic", $.italic, { active: t.emphasis })];
2180
+ case "strikethrough": return [q("strikethrough", "Strikethrough", $.strike, { active: t.strike_through })];
2181
+ case "inlineCode": return [q("code", "Inline Code", $.code, { active: t.inlineCode })];
2182
+ case "textColor": return [f(G, {
2183
+ icon: "palette",
2184
+ label: "Text Color",
2185
+ active: t.text_color !== null,
2186
+ onClick: (e) => {
2187
+ k(e.currentTarget ?? e.target);
2188
+ }
2189
+ })];
2190
+ case "headings": return [f(ue, {
2191
+ icon: "hash",
2192
+ label: n ? `Heading ${t.heading}` : "Headings",
2193
+ mode: "flyout",
2194
+ openOnHover: !0
2195
+ }, { default: () => [
2196
+ f(G, {
2197
+ icon: "pilcrow",
2198
+ label: "Paragraph",
2199
+ active: !n,
2200
+ onClick: () => x($.paragraph)
2201
+ }),
2202
+ f(G, {
2203
+ icon: "heading",
2204
+ label: "Heading 1",
2205
+ active: t.heading === 1,
2206
+ onClick: () => x($.h1)
2207
+ }),
2208
+ f(G, {
2209
+ icon: "heading",
2210
+ label: "Heading 2",
2211
+ active: t.heading === 2,
2212
+ onClick: () => x($.h2)
2213
+ }),
2214
+ f(G, {
2215
+ icon: "heading",
2216
+ label: "Heading 3",
2217
+ active: t.heading === 3,
2218
+ onClick: () => x($.h3)
2219
+ }),
2220
+ f(G, {
2221
+ icon: "heading",
2222
+ label: "Heading 4",
2223
+ active: t.heading === 4,
2224
+ onClick: () => x($.h4)
2225
+ }),
2226
+ f(G, {
2227
+ icon: "heading",
2228
+ label: "Heading 5",
2229
+ active: t.heading === 5,
2230
+ onClick: () => x($.h5)
2231
+ }),
2232
+ f(G, {
2233
+ icon: "heading",
2234
+ label: "Heading 6",
2235
+ active: t.heading === 6,
2236
+ onClick: () => x($.h6)
2237
+ })
2238
+ ] })];
2239
+ case "bulletList": return [q("list", "Bullet List", $.bulletList, {
2240
+ active: t.bullet_list,
2241
+ onClick: () => w("bullet_list")
2242
+ })];
2243
+ case "orderedList": return [q("list-ordered", "Ordered List", $.orderedList, {
2244
+ active: t.ordered_list,
2245
+ onClick: () => w("ordered_list")
2246
+ })];
2247
+ case "taskList": return [q("clipboard-check", "Task List", $.bulletList, {
2248
+ active: t.task_list,
2249
+ onClick: z
2250
+ })];
2251
+ case "outdent": return [q("indent-decrease", "Outdent", $.outdent, { disabled: t.list_item_depth < 2 })];
2252
+ case "indent": return [q("indent-increase", "Indent", $.indent, { disabled: t.list_item_depth < 1 })];
2253
+ case "blockquote": return [q("text-quote", "Blockquote", $.blockquote, { active: t.blockquote })];
2254
+ case "horizontalRule": return [q("minus", "Horizontal Rule", $.hr)];
2255
+ case "codeBlock": return [q("square-code", "Code Block", $.codeBlock, { active: t.code_block })];
2256
+ case "table": return [f(G, {
2257
+ icon: "table",
2258
+ label: "Insert Table",
2259
+ active: t.table,
2260
+ onClick: (e) => {
2261
+ M(e.currentTarget ?? e.target);
2262
+ }
2263
+ })];
2264
+ case "image": return [q("image", "Insert Image", $.bold, { onClick: ne })];
2265
+ case "tableOps": return t.table ? [
2266
+ q("table-row-plus-above", "Insert Row Above", $.addRowBefore),
2267
+ q("table-row-plus-below", "Insert Row Below", $.addRowAfter),
2268
+ q("table-column-plus-left", "Insert Column Left", $.addColBefore),
2269
+ q("table-column-plus-right", "Insert Column Right", $.addColAfter),
2270
+ q("align-left", "Align Left", $.deleteCell, {
2271
+ active: t.cell_alignment === "left",
2272
+ onClick: () => S("left")
2273
+ }),
2274
+ q("align-center", "Align Center", $.deleteCell, {
2275
+ active: t.cell_alignment === "center",
2276
+ onClick: () => S("center")
2277
+ }),
2278
+ q("align-right", "Align Right", $.deleteCell, {
2279
+ active: t.cell_alignment === "right",
2280
+ onClick: () => S("right")
2281
+ }),
2282
+ q("trash-2", "Delete Cell", $.deleteCell),
2283
+ q("table", "Delete Table", $.deleteCell, { onClick: C })
2284
+ ] : [];
2285
+ case "clearFormatting": return [q("eraser", "Clear Formatting", $.bold, { onClick: R })];
2286
+ case "undo": return [q("undo-2", "Undo", $.undo)];
2287
+ case "redo": return [q("redo-2", "Redo", $.redo)];
2288
+ default: return [];
2289
+ }
2290
+ }
2291
+ function o(t) {
2292
+ if (!r.embeds) return [];
2293
+ let n = e.embeds?.[t];
2294
+ return n?.insert ? [f(G, {
2295
+ icon: n.insert.icon ?? "layout-grid",
2296
+ label: n.insert.label ?? t,
2297
+ onClick: () => {
2298
+ te(t);
2299
+ }
2300
+ })] : [];
2301
+ }
2302
+ function s(e) {
2303
+ if (typeof e == "string") return e === "divider" ? [] : e.startsWith("embed:") ? o(e.slice(6)) : a(e);
2304
+ if (e && typeof e == "object" && Array.isArray(e.flyout)) {
2305
+ let t = e.flyout.flatMap((e) => s(e));
2306
+ return t.length === 0 ? [] : [f(ue, {
2307
+ icon: e.icon ?? "plus",
2308
+ label: e.label ?? "",
2309
+ mode: "flyout",
2310
+ openOnHover: !0
2311
+ }, { default: () => t })];
2312
+ }
2313
+ return [];
2314
+ }
2315
+ let c = [];
1963
2316
  if (e.sourceToggle) {
1964
2317
  let t = e.viewMode === "source";
1965
- if (a.push(d(U, {
2318
+ if (c.push(f(G, {
1966
2319
  icon: t ? "eye" : "code",
1967
2320
  label: t ? "Rendered" : "Source",
1968
2321
  active: t,
1969
2322
  onClick: () => e.onToggleView?.(t ? "rendered" : "source")
1970
- })), t) return ge(a);
1971
- i(a);
2323
+ })), t) return ve(c);
2324
+ i(c);
1972
2325
  }
1973
- return r(a, "bold", q("bold", "Bold", $.bold, { active: t.strong })), r(a, "italic", q("italic", "Italic", $.italic, { active: t.emphasis })), r(a, "strikethrough", q("strikethrough", "Strikethrough", $.strike, { active: t.strike_through })), r(a, "inlineCode", q("code", "Inline Code", $.code, { active: t.inlineCode })), r(a, "textColor", d(U, {
1974
- icon: "palette",
1975
- label: "Text Color",
1976
- active: t.text_color !== null,
1977
- onClick: (e) => {
1978
- k(e.currentTarget ?? e.target);
1979
- }
1980
- })), r(a, "headings", d(ue, {
1981
- icon: "hash",
1982
- label: n ? `Heading ${t.heading}` : "Headings",
1983
- mode: "flyout",
1984
- openOnHover: !0
1985
- }, { default: () => [
1986
- d(U, {
1987
- icon: "pilcrow",
1988
- label: "Paragraph",
1989
- active: !n,
1990
- onClick: () => x($.paragraph)
1991
- }),
1992
- d(U, {
1993
- icon: "heading",
1994
- label: "Heading 1",
1995
- active: t.heading === 1,
1996
- onClick: () => x($.h1)
1997
- }),
1998
- d(U, {
1999
- icon: "heading",
2000
- label: "Heading 2",
2001
- active: t.heading === 2,
2002
- onClick: () => x($.h2)
2003
- }),
2004
- d(U, {
2005
- icon: "heading",
2006
- label: "Heading 3",
2007
- active: t.heading === 3,
2008
- onClick: () => x($.h3)
2009
- }),
2010
- d(U, {
2011
- icon: "heading",
2012
- label: "Heading 4",
2013
- active: t.heading === 4,
2014
- onClick: () => x($.h4)
2015
- }),
2016
- d(U, {
2017
- icon: "heading",
2018
- label: "Heading 5",
2019
- active: t.heading === 5,
2020
- onClick: () => x($.h5)
2021
- }),
2022
- d(U, {
2023
- icon: "heading",
2024
- label: "Heading 6",
2025
- active: t.heading === 6,
2026
- onClick: () => x($.h6)
2027
- })
2028
- ] })), i(a), r(a, "bulletList", q("list", "Bullet List", $.bulletList, {
2029
- active: t.bullet_list,
2030
- onClick: () => w("bullet_list")
2031
- })), r(a, "orderedList", q("list-ordered", "Ordered List", $.orderedList, {
2032
- active: t.ordered_list,
2033
- onClick: () => w("ordered_list")
2034
- })), r(a, "taskList", q("clipboard-check", "Task List", $.bulletList, {
2035
- active: t.task_list,
2036
- onClick: L
2037
- })), r(a, "outdent", q("indent-decrease", "Outdent", $.outdent, { disabled: t.list_item_depth < 2 })), r(a, "indent", q("indent-increase", "Indent", $.indent, { disabled: t.list_item_depth < 1 })), r(a, "blockquote", q("text-quote", "Blockquote", $.blockquote, { active: t.blockquote })), r(a, "horizontalRule", q("minus", "Horizontal Rule", $.hr)), i(a), r(a, "codeBlock", q("square-code", "Code Block", $.codeBlock, { active: t.code_block })), r(a, "table", d(U, {
2038
- icon: "table",
2039
- label: "Insert Table",
2040
- active: t.table,
2041
- onClick: (e) => {
2042
- te(e.currentTarget ?? e.target);
2326
+ let l = e.tools ?? ge;
2327
+ for (let e of l) {
2328
+ if (e === "divider") {
2329
+ i(c);
2330
+ continue;
2043
2331
  }
2044
- })), r(a, "image", q("image", "Insert Image", $.bold, { onClick: re })), t.table && D("tableOps") && (i(a), a.push(q("table-row-plus-above", "Insert Row Above", $.addRowBefore)), a.push(q("table-row-plus-below", "Insert Row Below", $.addRowAfter)), a.push(q("table-column-plus-left", "Insert Column Left", $.addColBefore)), a.push(q("table-column-plus-right", "Insert Column Right", $.addColAfter)), a.push(q("align-left", "Align Left", $.deleteCell, {
2045
- active: t.cell_alignment === "left",
2046
- onClick: () => S("left")
2047
- })), a.push(q("align-center", "Align Center", $.deleteCell, {
2048
- active: t.cell_alignment === "center",
2049
- onClick: () => S("center")
2050
- })), a.push(q("align-right", "Align Right", $.deleteCell, {
2051
- active: t.cell_alignment === "right",
2052
- onClick: () => S("right")
2053
- })), a.push(q("trash-2", "Delete Cell", $.deleteCell)), a.push(q("table", "Delete Table", $.deleteCell, { onClick: C }))), D("clearFormatting") && (i(a), a.push(q("eraser", "Clear Formatting", $.bold, { onClick: ie }))), i(a), r(a, "undo", q("undo-2", "Undo", $.undo)), r(a, "redo", q("redo-2", "Redo", $.redo)), a[a.length - 1]?.type === H && a.pop(), ge(a);
2054
- }
2055
- function ge(t) {
2056
- return d("div", {
2332
+ for (let t of s(e)) c.push(t);
2333
+ }
2334
+ return c[c.length - 1]?.type === le && c.pop(), ve(c);
2335
+ }
2336
+ function ve(t) {
2337
+ return f("div", {
2057
2338
  key: "sidebar",
2058
2339
  class: "coar-md-sidebar-wrap",
2059
2340
  onMousedown: (e) => e.preventDefault()
2060
- }, [d(le, {
2341
+ }, [f(ce, {
2061
2342
  collapsed: !0,
2062
2343
  side: e.toolbarPosition,
2063
2344
  size: "s",
@@ -2065,8 +2346,8 @@ var Ln = [
2065
2346
  borderless: !0
2066
2347
  }, { default: () => t })]);
2067
2348
  }
2068
- function ye() {
2069
- let e = (e, t, n, r = {}) => d("button", {
2349
+ function xe() {
2350
+ let e = (e, t, n, r = {}) => f("button", {
2070
2351
  class: [
2071
2352
  "coar-md-float-btn",
2072
2353
  r.isActive ? "coar-md-float-btn--active" : "",
@@ -2078,10 +2359,10 @@ var Ln = [
2078
2359
  onMousedown: (e) => {
2079
2360
  e.preventDefault(), !r.disabled && (r.onClick ?? (() => x(n)))();
2080
2361
  }
2081
- }, [d(B, {
2362
+ }, [f(H, {
2082
2363
  name: e,
2083
2364
  size: "s"
2084
- })]), n = () => d("div", { class: "coar-md-float-sep" }), r = b.value;
2365
+ })]), n = () => f("div", { class: "coar-md-float-sep" }), r = b.value;
2085
2366
  function i(e, t, n) {
2086
2367
  D(t) && e.push(n);
2087
2368
  }
@@ -2091,7 +2372,7 @@ var Ln = [
2091
2372
  let o = [];
2092
2373
  if (i(o, "bold", e("bold", "Bold", $.bold, { isActive: r.strong })), i(o, "italic", e("italic", "Italic", $.italic, { isActive: r.emphasis })), i(o, "strikethrough", e("strikethrough", "Strikethrough", $.strike, { isActive: r.strike_through })), i(o, "inlineCode", e("code", "Inline Code", $.code, { isActive: r.inlineCode })), D("textColor")) {
2093
2374
  let e = r.text_color !== null;
2094
- o.push(d("button", {
2375
+ o.push(f("button", {
2095
2376
  class: ["coar-md-float-btn", e ? "coar-md-float-btn--active" : ""],
2096
2377
  type: "button",
2097
2378
  title: e ? `Text Color (${r.text_color})` : "Text Color",
@@ -2099,22 +2380,22 @@ var Ln = [
2099
2380
  onMousedown: (e) => {
2100
2381
  e.preventDefault(), k(e.currentTarget);
2101
2382
  }
2102
- }, [d(B, {
2383
+ }, [f(H, {
2103
2384
  name: "palette",
2104
2385
  size: "s"
2105
2386
  })]));
2106
2387
  }
2107
- D("headings") && (a(o), o.push(d("div", { class: "coar-md-float-dropdown" }, [d("button", {
2388
+ D("headings") && (a(o), o.push(f("div", { class: "coar-md-float-dropdown" }, [f("button", {
2108
2389
  class: ["coar-md-float-btn", u.value || r.heading != null ? "coar-md-float-btn--active" : ""],
2109
2390
  title: r.heading == null ? "Headings" : `Heading ${r.heading}`,
2110
2391
  type: "button",
2111
2392
  onMousedown: (e) => {
2112
2393
  e.preventDefault(), u.value = !u.value;
2113
2394
  }
2114
- }, [d(B, {
2395
+ }, [f(H, {
2115
2396
  name: "heading",
2116
2397
  size: "s"
2117
- })]), u.value ? d("div", { class: "coar-md-float-submenu" }, [
2398
+ })]), u.value ? f("div", { class: "coar-md-float-submenu" }, [
2118
2399
  {
2119
2400
  label: "Paragraph",
2120
2401
  cmd: $.paragraph,
@@ -2157,16 +2438,16 @@ var Ln = [
2157
2438
  icon: "heading",
2158
2439
  activeLevel: 6
2159
2440
  }
2160
- ].map(({ label: e, cmd: t, icon: n, activeLevel: i }) => d("button", {
2441
+ ].map(({ label: e, cmd: t, icon: n, activeLevel: i }) => f("button", {
2161
2442
  class: ["coar-md-float-submenu-item", (i === 0 ? r.heading == null : r.heading === i) ? "coar-md-float-submenu-item--active" : ""],
2162
2443
  type: "button",
2163
2444
  onMousedown: (e) => {
2164
2445
  e.preventDefault(), x(t), u.value = !1;
2165
2446
  }
2166
- }, [d(B, {
2447
+ }, [f(H, {
2167
2448
  name: n,
2168
2449
  size: "xs"
2169
- }), d("span", null, e)]))) : null]))), a(o), i(o, "bulletList", e("list", "Bullet List", $.bulletList, {
2450
+ }), f("span", null, e)]))) : null]))), a(o), i(o, "bulletList", e("list", "Bullet List", $.bulletList, {
2170
2451
  isActive: r.bullet_list,
2171
2452
  onClick: () => w("bullet_list")
2172
2453
  })), i(o, "orderedList", e("list-ordered", "Ordered List", $.orderedList, {
@@ -2174,8 +2455,8 @@ var Ln = [
2174
2455
  onClick: () => w("ordered_list")
2175
2456
  })), i(o, "taskList", e("clipboard-check", "Task List", $.bulletList, {
2176
2457
  isActive: r.task_list,
2177
- onClick: L
2178
- })), i(o, "outdent", e("indent-decrease", "Outdent", $.outdent, { disabled: r.list_item_depth < 2 })), i(o, "indent", e("indent-increase", "Indent", $.indent, { disabled: r.list_item_depth < 1 })), a(o), i(o, "blockquote", e("text-quote", "Blockquote", $.blockquote, { isActive: r.blockquote })), D("clearFormatting") && (a(o), o.push(e("eraser", "Clear Formatting", $.bold, { onClick: ie }))), o[o.length - 1]?.props?.class === "coar-md-float-sep" && o.pop();
2458
+ onClick: z
2459
+ })), i(o, "outdent", e("indent-decrease", "Outdent", $.outdent, { disabled: r.list_item_depth < 2 })), i(o, "indent", e("indent-increase", "Indent", $.indent, { disabled: r.list_item_depth < 1 })), a(o), i(o, "blockquote", e("text-quote", "Blockquote", $.blockquote, { isActive: r.blockquote })), D("clearFormatting") && (a(o), o.push(e("eraser", "Clear Formatting", $.bold, { onClick: R }))), o[o.length - 1]?.props?.class === "coar-md-float-sep" && o.pop();
2179
2460
  let s = {
2180
2461
  text: o,
2181
2462
  table: D("tableOps") ? [
@@ -2218,16 +2499,16 @@ var Ln = [
2218
2499
  e("trash-2", "Delete Row", $.deleteCell)
2219
2500
  ] : o
2220
2501
  };
2221
- return d(t, { to: "body" }, d("div", {
2502
+ return f(t, { to: "body" }, f("div", {
2222
2503
  class: "coar-md-floating-toolbar",
2223
2504
  style: `left:${c.value.left};top:${c.value.top};`
2224
2505
  }, s[l.value] || o));
2225
2506
  }
2226
2507
  return () => {
2227
2508
  let t = e.toolbarMode === "fixed" || e.toolbarMode === "both", n = e.sourceToggle && e.viewMode === "source", r = !e.readonly && !n && (e.toolbarMode === "floating" || e.toolbarMode === "both"), c = [], l = e.toolbarPosition === "left" || e.toolbarPosition === "top", u = e.toolbarPosition === "right" || e.toolbarPosition === "bottom";
2228
- t && l && c.push(he());
2229
- let f = e.isEmpty && e.placeholder.length > 0 && !n;
2230
- return c.push(d("div", {
2509
+ t && l && c.push(_e());
2510
+ let d = e.isEmpty && e.placeholder.length > 0 && !n;
2511
+ return c.push(f("div", {
2231
2512
  key: "area",
2232
2513
  ref: a,
2233
2514
  class: [
@@ -2235,21 +2516,21 @@ var Ln = [
2235
2516
  "coar-markdown",
2236
2517
  { "coar-md-area--source": n }
2237
2518
  ],
2238
- onMousedown: n ? void 0 : oe
2519
+ onMousedown: n ? void 0 : ae
2239
2520
  }, [
2240
- d(ne),
2241
- f ? d(Rt, {
2521
+ f(re),
2522
+ d ? f(Jt, {
2242
2523
  key: "placeholder",
2243
2524
  source: e.placeholder
2244
2525
  }) : null,
2245
- !e.readonly && !n && E.value.gfm ? d(Dn, {
2526
+ !e.readonly && !n && E.value.gfm ? f(Gn, {
2246
2527
  key: "table-handles",
2247
2528
  area: a.value,
2248
2529
  onMenuToggle: (e) => {
2249
2530
  s.value = e;
2250
2531
  }
2251
2532
  }) : null,
2252
- n ? d("textarea", {
2533
+ n ? f("textarea", {
2253
2534
  key: "source",
2254
2535
  class: "coar-md-source-area",
2255
2536
  value: e.sourceValue,
@@ -2259,7 +2540,7 @@ var Ln = [
2259
2540
  placeholder: e.placeholder || void 0,
2260
2541
  onInput: (t) => e.onSourceInput?.(t.target.value)
2261
2542
  }) : null,
2262
- e.sourceToggle && !t ? d("button", {
2543
+ e.sourceToggle && !t ? f("button", {
2263
2544
  key: "source-corner",
2264
2545
  class: "coar-md-source-corner",
2265
2546
  type: "button",
@@ -2268,11 +2549,11 @@ var Ln = [
2268
2549
  onMousedown: (t) => {
2269
2550
  t.preventDefault(), e.onToggleView?.(n ? "rendered" : "source");
2270
2551
  }
2271
- }, [d(B, {
2552
+ }, [f(H, {
2272
2553
  name: n ? "eye" : "code",
2273
2554
  size: "s"
2274
2555
  })]) : null
2275
- ])), t && u && c.push(he()), o.value && r && !s.value && c.push(ye()), d("div", {
2556
+ ])), t && u && c.push(_e()), o.value && r && !s.value && c.push(xe()), f("div", {
2276
2557
  class: {
2277
2558
  "coar-md-root": !0,
2278
2559
  [`coar-md-root--toolbar-${e.toolbarPosition}`]: !0,
@@ -2291,7 +2572,7 @@ var Ln = [
2291
2572
  }, c);
2292
2573
  };
2293
2574
  }
2294
- }), Bn = u({
2575
+ }), ir = u({
2295
2576
  name: "CoarMarkdownEditor",
2296
2577
  props: {
2297
2578
  modelValue: {
@@ -2353,19 +2634,23 @@ var Ln = [
2353
2634
  pickImage: {
2354
2635
  type: Function,
2355
2636
  default: void 0
2637
+ },
2638
+ embeds: {
2639
+ type: Object,
2640
+ default: void 0
2356
2641
  }
2357
2642
  },
2358
2643
  emits: ["update:modelValue"],
2359
2644
  setup(e, { emit: t }) {
2360
- let r = e.modelValue, i = b({ value: e.modelValue });
2361
- D(() => e.modelValue, (e) => {
2645
+ let r = e.modelValue, i = te({ value: e.modelValue });
2646
+ O(() => e.modelValue, (e) => {
2362
2647
  i.value = { value: e };
2363
2648
  });
2364
- let a = f(G, void 0), o = `coar-markdown-editor-${C()}`, s = n(() => e.id || a?.inputId.value || o), c = n(() => e.error || (a?.hasError.value ?? !1)), l = n(() => a?.messageId.value), u = n(() => e.disabled || (a?.disabled.value ?? !1)), p = n(() => e.readonly || u.value);
2365
- return () => d(re, null, () => d(Rn, {
2649
+ let a = p(de, void 0), o = `coar-markdown-editor-${w()}`, s = n(() => e.id || a?.inputId.value || o), c = n(() => e.error || (a?.hasError.value ?? !1)), l = n(() => a?.messageId.value), u = n(() => e.disabled || (a?.disabled.value ?? !1)), d = n(() => e.readonly || u.value);
2650
+ return () => f(R, null, () => f(nr, {
2366
2651
  initialValue: r,
2367
2652
  externalValue: i.value,
2368
- readonly: p.value,
2653
+ readonly: d.value,
2369
2654
  disabled: u.value,
2370
2655
  sourceToggle: e.sourceToggle,
2371
2656
  toolbarMode: e.toolbarMode,
@@ -2380,9 +2665,10 @@ var Ln = [
2380
2665
  placeholder: e.placeholder,
2381
2666
  uploadImage: e.uploadImage,
2382
2667
  pickImage: e.pickImage,
2668
+ embeds: e.embeds,
2383
2669
  onMarkdownChange: (e) => t("update:modelValue", e)
2384
2670
  }));
2385
2671
  }
2386
2672
  });
2387
2673
  //#endregion
2388
- export { Ln as COAR_MARKDOWN_EDITOR_ALL_TOOLS, Bn as CoarMarkdownEditor, Ct as resolveCapabilities };
2674
+ export { tr as COAR_MARKDOWN_EDITOR_ALL_TOOLS, ir as CoarMarkdownEditor, Je as EmbedRenderer, Xe as MARKDOWN_EMBEDS_KEY, Nt as resolveCapabilities, Ze as resolveEmbed };