@cocoar/vue-markdown-editor 2.7.0 → 2.8.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,26 +1,39 @@
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, createVNode as c, defineComponent as l, h as u, inject as d, markRaw as f, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as ee, onMounted as te, openBlock as h, ref as g, renderList as _, shallowRef as ne, unref as v, useId as y, useTemplateRef as b, vModelText as x, vShow as S, watch as C, withDirectives as w, withModifiers as T } from "vue";
2
- import { Editor as E, commandsCtx as D, defaultValueCtx as O, editorViewCtx as k, editorViewOptionsCtx as A, rootCtx as j } from "@milkdown/core";
3
- import { Milkdown as re, MilkdownProvider as M, useEditor as N, useInstance as P } from "@milkdown/vue";
4
- import { CoarCodeBlock as F, CoarIcon as I, CoarSelect as L, CoarSidebar as ie, CoarSidebarDivider as R, CoarSidebarGroup as ae, CoarSidebarItem as z, FORM_FIELD_INJECTION_KEY as B, menuPreset as oe, useOverlay as se } from "@cocoar/vue-ui";
5
- import { codeBlockSchema as V, commonmark as ce, createCodeBlockCommand as le, insertHrCommand as ue, liftListItemCommand as H, sinkListItemCommand as de, toggleEmphasisCommand as fe, toggleInlineCodeCommand as pe, toggleStrongCommand as me, turnIntoTextCommand as U, wrapInBlockquoteCommand as he, wrapInBulletListCommand as W, wrapInHeadingCommand as G, wrapInOrderedListCommand as ge } from "@milkdown/preset-commonmark";
6
- import { Plugin as _e, TextSelection as K } from "@milkdown/prose/state";
7
- import { $markSchema as ve, $prose as ye, $remark as be, $view as xe, replaceAll as q } from "@milkdown/utils";
8
- import { isColorSpanClose as Se, parseColorSpanOpen as J, sanitizeColor as Y, serializeColorSpanClose as Ce, serializeColorSpanOpen as we } from "@cocoar/vue-markdown-core";
9
- import { addColAfterCommand as Te, addColBeforeCommand as Ee, addRowAfterCommand as De, addRowBeforeCommand as Oe, deleteSelectedCellsCommand as ke, gfm as Ae, insertTableCommand as je, toggleStrikethroughCommand as Me } from "@milkdown/preset-gfm";
10
- import { history as Ne, redoCommand as Pe, undoCommand as Fe } from "@milkdown/plugin-history";
11
- import { clipboard as Ie } from "@milkdown/plugin-clipboard";
12
- import { listener as Le, listenerCtx as X } 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, createVNode as c, defineComponent as l, h as u, inject as d, markRaw as f, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as h, onMounted as g, openBlock as _, ref as v, renderList as y, shallowRef as b, unref as x, useId as ee, useTemplateRef as te, vModelText as S, vShow as C, watch as w, withDirectives as T, withModifiers as E } from "vue";
2
+ import { Editor as ne, commandsCtx as D, defaultValueCtx as re, editorViewCtx as O, editorViewOptionsCtx as k, rootCtx as A } from "@milkdown/core";
3
+ import { Milkdown as ie, MilkdownProvider as j, useEditor as M, useInstance as ae } from "@milkdown/vue";
4
+ import { CoarCodeBlock as N, CoarIcon as P, CoarSelect as oe, CoarSidebar as se, CoarSidebarDivider as F, CoarSidebarGroup as ce, CoarSidebarItem as I, FORM_FIELD_INJECTION_KEY as L, menuPreset as le, useOverlay as ue } from "@cocoar/vue-ui";
5
+ import { codeBlockSchema as R, commonmark as z, createCodeBlockCommand as de, insertHrCommand as fe, liftListItemCommand as B, sinkListItemCommand as pe, toggleEmphasisCommand as me, toggleInlineCodeCommand as he, toggleStrongCommand as ge, turnIntoTextCommand as _e, wrapInBlockquoteCommand as ve, wrapInBulletListCommand as ye, wrapInHeadingCommand as V, wrapInOrderedListCommand as be } from "@milkdown/preset-commonmark";
6
+ import { Plugin as xe, TextSelection as Se } from "@milkdown/prose/state";
7
+ import { $markSchema as Ce, $nodeSchema as we, $prose as Te, $remark as Ee, $view as De, replaceAll as H } from "@milkdown/utils";
8
+ import { isColorSpanClose as Oe, parse as ke, parseColorSpanOpen as Ae, parseFrontmatter as je, sanitizeColor as U, serializeColorSpanClose as Me, serializeColorSpanOpen as Ne } from "@cocoar/vue-markdown-core";
9
+ import { CoarMarkdown as Pe } from "@cocoar/vue-markdown";
10
+ import { addColAfterCommand as Fe, addColBeforeCommand as Ie, addRowAfterCommand as Le, addRowBeforeCommand as Re, deleteSelectedCellsCommand as ze, gfm as Be, insertTableCommand as Ve, toggleStrikethroughCommand as He } from "@milkdown/preset-gfm";
11
+ import { history as Ue, redoCommand as We, undoCommand as Ge } from "@milkdown/plugin-history";
12
+ import { clipboard as Ke } from "@milkdown/plugin-clipboard";
13
+ import { listener as qe, listenerCtx as Je } from "@milkdown/plugin-listener";
14
+ //#region \0rolldown/runtime.js
15
+ var Ye = Object.create, Xe = Object.defineProperty, Ze = Object.getOwnPropertyDescriptor, Qe = Object.getOwnPropertyNames, $e = Object.getPrototypeOf, et = Object.prototype.hasOwnProperty, tt = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), nt = (e, t, n, r) => {
16
+ if (t && typeof t == "object" || typeof t == "function") for (var i = Qe(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !et.call(e, s) && s !== n && Xe(e, s, {
17
+ get: ((e) => t[e]).bind(null, s),
18
+ enumerable: !(r = Ze(t, s)) || r.enumerable
19
+ });
20
+ return e;
21
+ }, rt = (e, t, n) => (n = e == null ? {} : Ye($e(e)), nt(t || !e || !e.__esModule ? Xe(n, "default", {
22
+ value: e,
23
+ enumerable: !0
24
+ }) : n, e));
25
+ //#endregion
13
26
  //#region src/toolbar-helpers.ts
14
- function Re(e, t) {
27
+ function it(e, t) {
15
28
  return t === void 0 ? !0 : "has" in t ? t.has(e) : t.includes(e);
16
29
  }
17
- function ze(e) {
30
+ function at(e) {
18
31
  let { target: t, inBulletList: n, inOrderedList: r } = e;
19
32
  return (t === "bullet_list" ? n : r) ? "lift" : (t === "bullet_list" ? r : n) ? "switch" : "wrap";
20
33
  }
21
34
  //#endregion
22
35
  //#region src/code-block-view/CodeBlockShell.vue?vue&type=script&setup=true&lang.ts
23
- var Be = { class: "coar-md-code-render" }, Ve = { class: "coar-md-code-edit" }, He = { class: "coar-md-code-lang-row" }, Ue = /* @__PURE__ */ l({
36
+ var ot = { class: "coar-md-code-render" }, st = { class: "coar-md-code-edit" }, ct = { class: "coar-md-code-lang-row" }, lt = /* @__PURE__ */ l({
24
37
  __name: "CodeBlockShell",
25
38
  props: {
26
39
  text: {},
@@ -63,13 +76,13 @@ var Be = { class: "coar-md-code-render" }, Ve = { class: "coar-md-code-edit" },
63
76
  value: "bash",
64
77
  label: "Bash"
65
78
  }
66
- ], a = b("contentMount");
67
- return C([a, () => n.contentDOM], ([e, t]) => {
79
+ ], a = te("contentMount");
80
+ return w([a, () => n.contentDOM], ([e, t]) => {
68
81
  e && t && t.parentElement !== e && e.appendChild(t);
69
82
  }, {
70
83
  immediate: !0,
71
84
  flush: "post"
72
- }), (t, n) => (h(), o("div", { class: p(["coar-md-code-host", { "coar-md-code-host--editing": e.editing }]) }, [w(s("div", Be, [c(v(F), {
85
+ }), (t, n) => (_(), o("div", { class: p(["coar-md-code-host", { "coar-md-code-host--editing": e.editing }]) }, [T(s("div", ot, [c(x(N), {
73
86
  code: e.text,
74
87
  language: e.language || "text",
75
88
  collapsible: !1,
@@ -78,11 +91,11 @@ var Be = { class: "coar-md-code-render" }, Ve = { class: "coar-md-code-edit" },
78
91
  class: "coar-md-code-edit-btn",
79
92
  type: "button",
80
93
  title: "Edit code block",
81
- onMousedown: n[0] ||= T((e) => r("enterEdit"), ["prevent"])
82
- }, [c(v(I), {
94
+ onMousedown: n[0] ||= E((e) => r("enterEdit"), ["prevent"])
95
+ }, [c(x(P), {
83
96
  name: "pencil",
84
97
  size: "xs"
85
- }), n[2] ||= s("span", null, "Edit", -1)], 32)], 512), [[S, !e.editing]]), w(s("div", Ve, [s("div", He, [c(v(L), {
98
+ }), n[2] ||= s("span", null, "Edit", -1)], 32)], 512), [[C, !e.editing]]), T(s("div", st, [s("div", ct, [c(x(oe), {
86
99
  class: "coar-md-code-lang-select",
87
100
  "model-value": e.language,
88
101
  options: i,
@@ -92,21 +105,21 @@ var Be = { class: "coar-md-code-render" }, Ve = { class: "coar-md-code-edit" },
92
105
  ref_key: "contentMount",
93
106
  ref: a,
94
107
  class: "coar-md-code-content"
95
- }, null, 512)], 512), [[S, e.editing]])], 2));
108
+ }, null, 512)], 512), [[C, e.editing]])], 2));
96
109
  }
97
- }), Z = /* @__PURE__ */ new Set(), We = class {
110
+ }), W = /* @__PURE__ */ new Set(), ut = class {
98
111
  dom;
99
112
  contentDOM;
100
113
  app;
101
- text = g("");
102
- language = g("");
103
- editing = g(!1);
114
+ text = v("");
115
+ language = v("");
116
+ editing = v(!1);
104
117
  constructor(e, t, n) {
105
- this.node = e, this.view = t, this.getPos = n, Z.add(this), this.dom = document.createElement("div"), this.dom.className = "coar-md-code-host-mount";
118
+ this.node = e, this.view = t, this.getPos = n, W.add(this), this.dom = document.createElement("div"), this.dom.className = "coar-md-code-host-mount";
106
119
  let i = document.createElement("pre"), a = document.createElement("code");
107
120
  i.appendChild(a), this.contentDOM = a, this.text.value = e.textContent, this.language.value = e.attrs.language ?? "", this.app = r({
108
121
  name: "CodeBlockShellRoot",
109
- setup: () => () => u(Ue, {
122
+ setup: () => () => u(lt, {
110
123
  text: this.text.value,
111
124
  language: this.language.value,
112
125
  editing: this.editing.value,
@@ -128,7 +141,7 @@ var Be = { class: "coar-md-code-render" }, Ve = { class: "coar-md-code-edit" },
128
141
  this.editing.value = !1;
129
142
  }
130
143
  destroy() {
131
- Z.delete(this), this.app.unmount();
144
+ W.delete(this), this.app.unmount();
132
145
  }
133
146
  notifySelectionChanged() {
134
147
  let e = this.getPos();
@@ -146,20 +159,20 @@ var Be = { class: "coar-md-code-render" }, Ve = { class: "coar-md-code-edit" },
146
159
  let e = this.getPos();
147
160
  if (e == null) return;
148
161
  let { tr: t } = this.view.state;
149
- t.setSelection(K.create(this.view.state.doc, e + 1)), this.view.dispatch(t), this.view.focus();
162
+ t.setSelection(Se.create(this.view.state.doc, e + 1)), this.view.dispatch(t), this.view.focus();
150
163
  };
151
164
  handleLanguageChange = (e) => {
152
165
  let t = this.getPos();
153
166
  t != null && this.view.dispatch(this.view.state.tr.setNodeAttribute(t, "language", e));
154
167
  };
155
- }, Ge = [xe(V.node, () => (e, t, n) => new We(e, t, n)), ye(() => new _e({ view: () => ({ update(e, t) {
156
- e.state.selection.eq(t.selection) || Z.forEach((t) => {
168
+ }, dt = [De(R.node, () => (e, t, n) => new ut(e, t, n)), Te(() => new xe({ view: () => ({ update(e, t) {
169
+ e.state.selection.eq(t.selection) || W.forEach((t) => {
157
170
  t.view === e && t.notifySelectionChanged();
158
171
  });
159
- } }) }))].flat(), Ke = function() {
172
+ } }) }))].flat(), ft = function() {
160
173
  let e = this.data();
161
174
  return (e.toMarkdownExtensions ??= []).push({ handlers: { colorTextSpan(e, t, n) {
162
- let r = Y(e.color ?? "") ?? "";
175
+ let r = U(e.color ?? "") ?? "";
163
176
  if (r.length === 0) return n.containerPhrasing(e, {
164
177
  before: "",
165
178
  after: ""
@@ -168,45 +181,45 @@ var Be = { class: "coar-md-code-render" }, Ve = { class: "coar-md-code-edit" },
168
181
  before: ">",
169
182
  after: "<"
170
183
  });
171
- return `${we(r)}${i}${Ce()}`;
184
+ return `${Ne(r)}${i}${Me()}`;
172
185
  } } }), (e) => {
173
186
  t(e);
174
187
  };
175
188
  function t(e) {
176
189
  if (Array.isArray(e.children)) {
177
- let n = Je(e.children);
190
+ let n = ht(e.children);
178
191
  e.children = n;
179
192
  for (let e of n) t(e);
180
193
  }
181
194
  }
182
195
  };
183
- function Q(e) {
196
+ function pt(e) {
184
197
  return !!e && e.type === "html" && typeof e.value == "string";
185
198
  }
186
- function qe(e, t) {
199
+ function mt(e, t) {
187
200
  let n = 1;
188
201
  for (let r = t + 1; r < e.length; r++) {
189
202
  let t = e[r];
190
- if (Q(t)) {
191
- if (J(t.value)) {
203
+ if (pt(t)) {
204
+ if (Ae(t.value)) {
192
205
  n++;
193
206
  continue;
194
207
  }
195
- if (Se(t.value) && (n--, n === 0)) return r;
208
+ if (Oe(t.value) && (n--, n === 0)) return r;
196
209
  }
197
210
  }
198
211
  return null;
199
212
  }
200
- function Je(e) {
213
+ function ht(e) {
201
214
  let t = [], n = 0;
202
215
  for (; n < e.length;) {
203
216
  let r = e[n];
204
- if (Q(r)) {
205
- let i = J(r.value);
217
+ if (pt(r)) {
218
+ let i = Ae(r.value);
206
219
  if (i) {
207
- let r = qe(e, n);
220
+ let r = mt(e, n);
208
221
  if (r !== null) {
209
- let a = Je(e.slice(n + 1, r)), o = {
222
+ let a = ht(e.slice(n + 1, r)), o = {
210
223
  type: "colorTextSpan",
211
224
  color: i.color,
212
225
  children: a,
@@ -221,7 +234,7 @@ function Je(e) {
221
234
  }
222
235
  return t;
223
236
  }
224
- var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
237
+ var gt = [Ee("textColor", () => ft), Ce("text_color", () => ({
225
238
  attrs: { color: { default: "" } },
226
239
  inclusive: !0,
227
240
  parseDOM: [{
@@ -234,12 +247,12 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
234
247
  if (n.length !== 1) return !1;
235
248
  let r = n[0], i = r.indexOf(":");
236
249
  if (i < 0 || r.slice(0, i).trim().toLowerCase() !== "color") return !1;
237
- let a = Y(r.slice(i + 1));
250
+ let a = U(r.slice(i + 1));
238
251
  return a === null ? !1 : { color: a };
239
252
  }
240
253
  }],
241
254
  toDOM: (e) => {
242
- let t = Y(String(e.attrs.color ?? "")) ?? "";
255
+ let t = U(String(e.attrs.color ?? "")) ?? "";
243
256
  return t.length === 0 ? [
244
257
  "span",
245
258
  {},
@@ -253,7 +266,7 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
253
266
  parseMarkdown: {
254
267
  match: (e) => e.type === "colorTextSpan",
255
268
  runner: (e, t, n) => {
256
- let r = Y(typeof t.color == "string" ? t.color : typeof t.data?.color == "string" ? t.data.color : "") ?? "";
269
+ let r = U(typeof t.color == "string" ? t.color : typeof t.data?.color == "string" ? t.data.color : "") ?? "";
257
270
  if (r.length === 0) {
258
271
  e.next(t.children);
259
272
  return;
@@ -264,11 +277,11 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
264
277
  toMarkdown: {
265
278
  match: (e) => e.type.name === "text_color",
266
279
  runner: (e, t) => {
267
- let n = Y(String(t.attrs.color ?? "")) ?? "";
280
+ let n = U(String(t.attrs.color ?? "")) ?? "";
268
281
  n.length !== 0 && e.withMark(t, "colorTextSpan", void 0, { color: n });
269
282
  }
270
283
  }
271
- }))].flat(), Xe = [
284
+ }))].flat(), _t = [
272
285
  {
273
286
  name: "Default",
274
287
  value: ""
@@ -305,23 +318,347 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
305
318
  name: "Gray",
306
319
  value: "#6b7280"
307
320
  }
308
- ], Ze = { class: "coar-md-color-grid" }, Qe = [
321
+ ], vt = {
322
+ class: "coar-md-placeholder",
323
+ "aria-hidden": "true"
324
+ }, yt = /* @__PURE__ */ l({
325
+ __name: "PlaceholderOverlay",
326
+ props: { source: {} },
327
+ setup(e) {
328
+ let t = e, r = n(() => ke(t.source));
329
+ return (e, t) => (_(), o("div", vt, [c(x(Pe), { doc: r.value }, null, 8, ["doc"])]));
330
+ }
331
+ });
332
+ function G(e) {
333
+ return e !== null && e < -2;
334
+ }
335
+ function K(e) {
336
+ return e === -2 || e === -1 || e === 32;
337
+ }
338
+ //#endregion
339
+ //#region ../../node_modules/.pnpm/fault@2.0.1/node_modules/fault/index.js
340
+ var bt = /* @__PURE__ */ rt((/* @__PURE__ */ tt(((e, t) => {
341
+ (function() {
342
+ var e = t === void 0 ? function() {
343
+ return this || (0, eval)("this");
344
+ }() : t.exports = i;
345
+ e.format = i, e.vsprintf = r, typeof console < "u" && typeof console.log == "function" && (e.printf = n);
346
+ function n() {
347
+ console.log(i.apply(null, arguments));
348
+ }
349
+ function r(e, t) {
350
+ return i.apply(null, [e].concat(t));
351
+ }
352
+ function i(e) {
353
+ for (var t = 1, n = [].slice.call(arguments), r = 0, i = e.length, a = "", o, s = !1, c, l, u = !1, d, f = function() {
354
+ return n[t++];
355
+ }, p = function() {
356
+ for (var t = ""; /\d/.test(e[r]);) t += e[r++], o = e[r];
357
+ return t.length > 0 ? parseInt(t) : null;
358
+ }; r < i; ++r) if (o = e[r], s) switch (s = !1, o == "." ? (u = !1, o = e[++r]) : o == "0" && e[r + 1] == "." ? (u = !0, r += 2, o = e[r]) : u = !0, d = p(), o) {
359
+ case "b":
360
+ a += parseInt(f(), 10).toString(2);
361
+ break;
362
+ case "c":
363
+ c = f(), typeof c == "string" || c instanceof String ? a += c : a += String.fromCharCode(parseInt(c, 10));
364
+ break;
365
+ case "d":
366
+ a += parseInt(f(), 10);
367
+ break;
368
+ case "f":
369
+ l = String(parseFloat(f()).toFixed(d || 6)), a += u ? l : l.replace(/^0/, "");
370
+ break;
371
+ case "j":
372
+ a += JSON.stringify(f());
373
+ break;
374
+ case "o":
375
+ a += "0" + parseInt(f(), 10).toString(8);
376
+ break;
377
+ case "s":
378
+ a += f();
379
+ break;
380
+ case "x":
381
+ a += "0x" + parseInt(f(), 10).toString(16);
382
+ break;
383
+ case "X":
384
+ a += "0x" + parseInt(f(), 10).toString(16).toUpperCase();
385
+ break;
386
+ default:
387
+ a += o;
388
+ break;
389
+ }
390
+ else o === "%" ? s = !0 : a += o;
391
+ return a;
392
+ }
393
+ })();
394
+ })))(), 1), q = Object.assign(J(Error), {
395
+ eval: J(EvalError),
396
+ range: J(RangeError),
397
+ reference: J(ReferenceError),
398
+ syntax: J(SyntaxError),
399
+ type: J(TypeError),
400
+ uri: J(URIError)
401
+ });
402
+ function J(e) {
403
+ return t.displayName = e.displayName || e.name, t;
404
+ function t(t, ...n) {
405
+ return new e(t && (0, bt.default)(t, ...n));
406
+ }
407
+ }
408
+ //#endregion
409
+ //#region ../../node_modules/.pnpm/micromark-extension-frontmatter@2.0.0/node_modules/micromark-extension-frontmatter/lib/to-matters.js
410
+ var Y = {}.hasOwnProperty, xt = {
411
+ yaml: "-",
412
+ toml: "+"
413
+ };
414
+ function X(e) {
415
+ let t = [], n = -1, r = Array.isArray(e) ? e : e ? [e] : ["yaml"];
416
+ for (; ++n < r.length;) t[n] = St(r[n]);
417
+ return t;
418
+ }
419
+ function St(e) {
420
+ let t = e;
421
+ if (typeof t == "string") {
422
+ if (!Y.call(xt, t)) throw q("Missing matter definition for `%s`", t);
423
+ t = {
424
+ type: t,
425
+ marker: xt[t]
426
+ };
427
+ } else if (typeof t != "object") throw q("Expected matter to be an object, not `%j`", t);
428
+ if (!Y.call(t, "type")) throw q("Missing `type` in matter `%j`", t);
429
+ if (!Y.call(t, "fence") && !Y.call(t, "marker")) throw q("Missing `marker` or `fence` in matter `%j`", t);
430
+ return t;
431
+ }
432
+ //#endregion
433
+ //#region ../../node_modules/.pnpm/micromark-extension-frontmatter@2.0.0/node_modules/micromark-extension-frontmatter/lib/syntax.js
434
+ function Ct(e) {
435
+ let t = X(e), n = {}, r = -1;
436
+ for (; ++r < t.length;) {
437
+ let e = t[r], i = Z(e, "open").charCodeAt(0), a = wt(e), o = n[i];
438
+ Array.isArray(o) ? o.push(a) : n[i] = [a];
439
+ }
440
+ return { flow: n };
441
+ }
442
+ function wt(e) {
443
+ let t = e.anywhere, n = e.type, r = n + "Fence", i = r + "Sequence", a = n + "Value", o = {
444
+ tokenize: u,
445
+ partial: !0
446
+ }, s, c = 0;
447
+ return {
448
+ tokenize: l,
449
+ concrete: !0
450
+ };
451
+ function l(l, u, d) {
452
+ let f = this;
453
+ return p;
454
+ function p(a) {
455
+ let o = f.now();
456
+ return o.column === 1 && (o.line === 1 || t) && (s = Z(e, "open"), c = 0, a === s.charCodeAt(c)) ? (l.enter(n), l.enter(r), l.enter(i), m(a)) : d(a);
457
+ }
458
+ function m(e) {
459
+ return c === s.length ? (l.exit(i), K(e) ? (l.enter("whitespace"), h(e)) : g(e)) : e === s.charCodeAt(c++) ? (l.consume(e), m) : d(e);
460
+ }
461
+ function h(e) {
462
+ return K(e) ? (l.consume(e), h) : (l.exit("whitespace"), g(e));
463
+ }
464
+ function g(t) {
465
+ return G(t) ? (l.exit(r), l.enter("lineEnding"), l.consume(t), l.exit("lineEnding"), s = Z(e, "close"), c = 0, l.attempt(o, b, _)) : d(t);
466
+ }
467
+ function _(e) {
468
+ return e === null || G(e) ? y(e) : (l.enter(a), v(e));
469
+ }
470
+ function v(e) {
471
+ return e === null || G(e) ? (l.exit(a), y(e)) : (l.consume(e), v);
472
+ }
473
+ function y(e) {
474
+ return e === null ? d(e) : (l.enter("lineEnding"), l.consume(e), l.exit("lineEnding"), l.attempt(o, b, _));
475
+ }
476
+ function b(e) {
477
+ return l.exit(n), u(e);
478
+ }
479
+ }
480
+ function u(e, t, n) {
481
+ let a = 0;
482
+ return o;
483
+ function o(t) {
484
+ return t === s.charCodeAt(a) ? (e.enter(r), e.enter(i), c(t)) : n(t);
485
+ }
486
+ function c(t) {
487
+ return a === s.length ? (e.exit(i), K(t) ? (e.enter("whitespace"), l(t)) : u(t)) : t === s.charCodeAt(a++) ? (e.consume(t), c) : n(t);
488
+ }
489
+ function l(t) {
490
+ return K(t) ? (e.consume(t), l) : (e.exit("whitespace"), u(t));
491
+ }
492
+ function u(i) {
493
+ return i === null || G(i) ? (e.exit(r), t(i)) : n(i);
494
+ }
495
+ }
496
+ }
497
+ function Z(e, t) {
498
+ return e.marker ? Tt(e.marker, t).repeat(3) : Tt(e.fence, t);
499
+ }
500
+ function Tt(e, t) {
501
+ return typeof e == "string" ? e : e[t];
502
+ }
503
+ //#endregion
504
+ //#region ../../node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
505
+ function Et(e) {
506
+ if (typeof e != "string") throw TypeError("Expected a string");
507
+ return e.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
508
+ }
509
+ //#endregion
510
+ //#region ../../node_modules/.pnpm/mdast-util-frontmatter@2.0.1/node_modules/mdast-util-frontmatter/lib/index.js
511
+ function Dt(e) {
512
+ let t = X(e), n = {}, r = {}, i = -1;
513
+ for (; ++i < t.length;) {
514
+ let e = t[i];
515
+ n[e.type] = Ot(e), r[e.type] = kt, r[e.type + "Value"] = At;
516
+ }
517
+ return {
518
+ enter: n,
519
+ exit: r
520
+ };
521
+ }
522
+ function Ot(e) {
523
+ return t;
524
+ function t(t) {
525
+ this.enter({
526
+ type: e.type,
527
+ value: ""
528
+ }, t), this.buffer();
529
+ }
530
+ }
531
+ function kt(e) {
532
+ let t = this.resume(), n = this.stack[this.stack.length - 1];
533
+ "value" in n, this.exit(e), n.value = t.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
534
+ }
535
+ function At(e) {
536
+ this.config.enter.data.call(this, e), this.config.exit.data.call(this, e);
537
+ }
538
+ function jt(e) {
539
+ let t = [], n = {}, r = X(e), i = -1;
540
+ for (; ++i < r.length;) {
541
+ let e = r[i];
542
+ n[e.type] = Mt(e);
543
+ let a = Q(e, "open");
544
+ t.push({
545
+ atBreak: !0,
546
+ character: a.charAt(0),
547
+ after: Et(a.charAt(1))
548
+ });
549
+ }
550
+ return {
551
+ unsafe: t,
552
+ handlers: n
553
+ };
554
+ }
555
+ function Mt(e) {
556
+ let t = Q(e, "open"), n = Q(e, "close");
557
+ return r;
558
+ function r(e) {
559
+ return t + (e.value ? "\n" + e.value : "") + "\n" + n;
560
+ }
561
+ }
562
+ function Q(e, t) {
563
+ return e.marker ? Nt(e.marker, t).repeat(3) : Nt(e.fence, t);
564
+ }
565
+ function Nt(e, t) {
566
+ return typeof e == "string" ? e : e[t];
567
+ }
568
+ //#endregion
569
+ //#region ../../node_modules/.pnpm/remark-frontmatter@5.0.0/node_modules/remark-frontmatter/lib/index.js
570
+ var Pt = "yaml";
571
+ function Ft(e) {
572
+ let t = this, n = e || Pt, r = t.data(), i = r.micromarkExtensions ||= [], a = r.fromMarkdownExtensions ||= [], o = r.toMarkdownExtensions ||= [];
573
+ i.push(Ct(n)), a.push(Dt(n)), o.push(jt(n));
574
+ }
575
+ //#endregion
576
+ //#region src/frontmatter/index.ts
577
+ var It = Ee("coarRemarkFrontmatter", () => Ft, ["yaml"]), Lt = we("frontmatter", () => ({
578
+ group: "block",
579
+ atom: !0,
580
+ marks: "",
581
+ selectable: !1,
582
+ draggable: !1,
583
+ attrs: { value: { default: "" } },
584
+ parseDOM: [{
585
+ tag: "div[data-type=\"frontmatter\"]",
586
+ getAttrs: (e) => ({ value: e.getAttribute("data-value") ?? "" })
587
+ }],
588
+ toDOM: (e) => ["div", {
589
+ "data-type": "frontmatter",
590
+ "data-value": e.attrs.value ?? ""
591
+ }],
592
+ parseMarkdown: {
593
+ match: (e) => e.type === "yaml",
594
+ runner: (e, t, n) => {
595
+ e.addNode(n, { value: typeof t.value == "string" ? t.value : "" });
596
+ }
597
+ },
598
+ toMarkdown: {
599
+ match: (e) => e.type.name === "frontmatter",
600
+ runner: (e, t) => {
601
+ e.addNode("yaml", void 0, t.attrs.value ?? "");
602
+ }
603
+ }
604
+ }));
605
+ function Rt(e, t) {
606
+ let { entries: n } = je(t);
607
+ if (e.replaceChildren(), n.length === 0) {
608
+ let n = document.createElement("pre");
609
+ n.className = "coar-markdown-frontmatter__raw", n.textContent = t, e.appendChild(n);
610
+ return;
611
+ }
612
+ for (let t of n) {
613
+ let n = document.createElement("div");
614
+ n.className = "coar-markdown-frontmatter__entry";
615
+ let r = document.createElement("span");
616
+ r.className = "coar-markdown-frontmatter__key", r.textContent = t.key;
617
+ let i = document.createElement("span");
618
+ i.className = "coar-markdown-frontmatter__value", i.textContent = t.value, n.append(r, document.createTextNode(": "), i), e.appendChild(n);
619
+ }
620
+ }
621
+ var zt = class {
622
+ dom;
623
+ node;
624
+ constructor(e) {
625
+ 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();
626
+ }
627
+ renderCard() {
628
+ Rt(this.dom, this.node.attrs.value ?? "");
629
+ }
630
+ update(e) {
631
+ if (e.type !== this.node.type) return !1;
632
+ let t = e.attrs.value !== this.node.attrs.value;
633
+ return this.node = e, t && this.renderCard(), !0;
634
+ }
635
+ ignoreMutation() {
636
+ return !0;
637
+ }
638
+ stopEvent() {
639
+ return !1;
640
+ }
641
+ }, Bt = [
642
+ It,
643
+ Lt,
644
+ De(Lt.node, () => (e) => new zt(e))
645
+ ].flat(), Vt = { class: "coar-md-color-grid" }, Ht = [
309
646
  "title",
310
647
  "aria-label",
311
648
  "onMousedown"
312
- ], $e = { class: "coar-md-color-custom" }, et = /* @__PURE__ */ l({
649
+ ], Ut = { class: "coar-md-color-custom" }, Wt = /* @__PURE__ */ l({
313
650
  __name: "ColorPickerPanel",
314
651
  props: {
315
652
  currentColor: {},
316
653
  pick: { type: Function }
317
654
  },
318
655
  setup(t) {
319
- let n = g(t.currentColor ?? "#000000");
320
- return (r, c) => (h(), o("div", {
656
+ let n = v(t.currentColor ?? "#000000");
657
+ return (r, c) => (_(), o("div", {
321
658
  class: "coar-md-color-picker",
322
659
  role: "menu",
323
- onMousedown: c[2] ||= T(() => {}, ["stop"])
324
- }, [s("div", Ze, [(h(!0), o(e, null, _(v(Xe), (e) => (h(), o("button", {
660
+ onMousedown: c[2] ||= E(() => {}, ["stop"])
661
+ }, [s("div", Vt, [(_(!0), o(e, null, y(x(_t), (e) => (_(), o("button", {
325
662
  key: e.value || "default",
326
663
  type: "button",
327
664
  class: p([
@@ -332,23 +669,23 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
332
669
  style: m(e.value ? { "--coar-md-swatch": e.value } : void 0),
333
670
  title: e.name,
334
671
  "aria-label": e.name,
335
- onMousedown: T((n) => t.pick(e.value === "" ? null : e.value), ["prevent"])
336
- }, [e.value === "" ? (h(), i(v(I), {
672
+ onMousedown: E((n) => t.pick(e.value === "" ? null : e.value), ["prevent"])
673
+ }, [e.value === "" ? (_(), i(x(P), {
337
674
  key: 0,
338
675
  name: "ban",
339
676
  size: "s"
340
- })) : a("", !0)], 46, Qe))), 128))]), s("div", $e, [c[3] ||= s("label", {
677
+ })) : a("", !0)], 46, Ht))), 128))]), s("div", Ut, [c[3] ||= s("label", {
341
678
  class: "coar-md-color-custom-label",
342
679
  for: "coar-md-color-custom-input"
343
- }, " Custom ", -1), w(s("input", {
680
+ }, " Custom ", -1), T(s("input", {
344
681
  id: "coar-md-color-custom-input",
345
682
  "onUpdate:modelValue": c[0] ||= (e) => n.value = e,
346
683
  type: "color",
347
684
  class: "coar-md-color-custom-input",
348
685
  onChange: c[1] ||= (e) => t.pick(n.value)
349
- }, null, 544), [[x, n.value]])])], 32));
686
+ }, null, 544), [[S, n.value]])])], 32));
350
687
  }
351
- }), tt = [
688
+ }), Gt = [
352
689
  "bold",
353
690
  "italic",
354
691
  "strikethrough",
@@ -369,51 +706,51 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
369
706
  "undo",
370
707
  "redo"
371
708
  ], $ = {
372
- bold: { command: me },
373
- italic: { command: fe },
374
- strike: { command: Me },
375
- code: { command: pe },
376
- bulletList: { command: W },
377
- orderedList: { command: ge },
378
- blockquote: { command: he },
379
- hr: { command: ue },
380
- codeBlock: { command: le },
381
- table: { command: je },
382
- undo: { command: Fe },
383
- redo: { command: Pe },
384
- paragraph: { command: U },
385
- addRowBefore: { command: Oe },
386
- addRowAfter: { command: De },
387
- addColBefore: { command: Ee },
388
- addColAfter: { command: Te },
389
- deleteCell: { command: ke },
390
- indent: { command: de },
391
- outdent: { command: H },
709
+ bold: { command: ge },
710
+ italic: { command: me },
711
+ strike: { command: He },
712
+ code: { command: he },
713
+ bulletList: { command: ye },
714
+ orderedList: { command: be },
715
+ blockquote: { command: ve },
716
+ hr: { command: fe },
717
+ codeBlock: { command: de },
718
+ table: { command: Ve },
719
+ undo: { command: Ge },
720
+ redo: { command: We },
721
+ paragraph: { command: _e },
722
+ addRowBefore: { command: Re },
723
+ addRowAfter: { command: Le },
724
+ addColBefore: { command: Ie },
725
+ addColAfter: { command: Fe },
726
+ deleteCell: { command: ze },
727
+ indent: { command: pe },
728
+ outdent: { command: B },
392
729
  h1: {
393
- command: G,
730
+ command: V,
394
731
  payload: 1
395
732
  },
396
733
  h2: {
397
- command: G,
734
+ command: V,
398
735
  payload: 2
399
736
  },
400
737
  h3: {
401
- command: G,
738
+ command: V,
402
739
  payload: 3
403
740
  },
404
741
  h4: {
405
- command: G,
742
+ command: V,
406
743
  payload: 4
407
744
  },
408
745
  h5: {
409
- command: G,
746
+ command: V,
410
747
  payload: 5
411
748
  },
412
749
  h6: {
413
- command: G,
750
+ command: V,
414
751
  payload: 6
415
752
  }
416
- }, nt = l({
753
+ }, Kt = l({
417
754
  props: {
418
755
  initialValue: {
419
756
  type: String,
@@ -463,45 +800,61 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
463
800
  type: Boolean,
464
801
  required: !0
465
802
  },
803
+ placeholder: {
804
+ type: String,
805
+ default: ""
806
+ },
807
+ sourceToggle: {
808
+ type: Boolean,
809
+ default: !1
810
+ },
466
811
  onMarkdownChange: {
467
812
  type: Function,
468
813
  required: !0
469
814
  }
470
815
  },
471
816
  setup(e) {
472
- let t = g(e.initialValue);
473
- N((n) => E.make().config((r) => {
474
- r.set(j, n), r.set(O, e.initialValue), r.update(A, (t) => ({
817
+ let t = v(e.initialValue), n = v("rendered");
818
+ M((n) => ne.make().config((r) => {
819
+ r.set(A, n), r.set(re, e.initialValue), r.update(k, (t) => ({
475
820
  ...t,
476
821
  editable: () => !e.readonly
477
- })), r.get(X).markdownUpdated((n, r) => {
822
+ })), r.get(Je).markdownUpdated((n, r) => {
478
823
  r !== t.value && (t.value = r, e.onMarkdownChange(r));
479
824
  });
480
- }).use(ce).use(Ae).use(Ne).use(Ie).use(Le).use(Ye).use(Ge));
481
- let [n, r] = P(), i = g(null);
482
- return C(() => e.externalValue.value, (e) => {
825
+ }).use(z).use(Be).use(Bt).use(Ue).use(Ke).use(qe).use(gt).use(dt));
826
+ let [r, i] = ae(), a = v(null);
827
+ return w(() => e.externalValue.value, (e) => {
483
828
  if (e === t.value) return;
484
- let n = r();
485
- if (!n) {
486
- i.value = e;
829
+ if (n.value === "source") {
830
+ t.value = e;
487
831
  return;
488
832
  }
489
- i.value = null, t.value = e, n.action(q(e));
490
- }), C(n, (e) => {
491
- if (e || i.value === null) return;
492
- let n = r();
833
+ let r = i();
834
+ if (!r) {
835
+ a.value = e;
836
+ return;
837
+ }
838
+ a.value = null, t.value = e, r.action(H(e));
839
+ }), w(n, (e) => {
840
+ if (e !== "rendered") return;
841
+ let n = i();
842
+ n && n.action(H(t.value));
843
+ }), w(r, (e) => {
844
+ if (e || a.value === null) return;
845
+ let n = i();
493
846
  if (!n) return;
494
- let a = i.value;
495
- i.value = null, a !== t.value && (t.value = a, n.action(q(a)));
496
- }, { immediate: !0 }), C(() => e.readonly, () => {
497
- let t = r();
847
+ let r = a.value;
848
+ a.value = null, r !== t.value && (t.value = r, n.action(H(r)));
849
+ }, { immediate: !0 }), w(() => e.readonly, () => {
850
+ let t = i();
498
851
  t && t.action((t) => {
499
- t.update(A, (t) => ({
852
+ t.update(k, (t) => ({
500
853
  ...t,
501
854
  editable: () => !e.readonly
502
- })), t.get(k).update(t.get(k).props);
855
+ })), t.get(O).update(t.get(O).props);
503
856
  });
504
- }), () => u(rt, {
857
+ }), () => u(qt, {
505
858
  readonly: e.readonly,
506
859
  disabled: e.disabled,
507
860
  toolbarMode: e.toolbarMode,
@@ -511,10 +864,21 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
511
864
  hasError: e.hasError,
512
865
  describedBy: e.describedBy,
513
866
  name: e.name,
514
- required: e.required
867
+ required: e.required,
868
+ placeholder: e.placeholder,
869
+ isEmpty: t.value.trim() === "",
870
+ sourceToggle: e.sourceToggle,
871
+ viewMode: n.value,
872
+ sourceValue: t.value,
873
+ onToggleView: (e) => {
874
+ n.value = e;
875
+ },
876
+ onSourceInput: (n) => {
877
+ n !== t.value && (t.value = n, e.onMarkdownChange(n));
878
+ }
515
879
  });
516
880
  }
517
- }), rt = l({
881
+ }), qt = l({
518
882
  props: {
519
883
  readonly: {
520
884
  type: Boolean,
@@ -555,13 +919,41 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
555
919
  required: {
556
920
  type: Boolean,
557
921
  required: !0
922
+ },
923
+ placeholder: {
924
+ type: String,
925
+ default: ""
926
+ },
927
+ isEmpty: {
928
+ type: Boolean,
929
+ default: !1
930
+ },
931
+ sourceToggle: {
932
+ type: Boolean,
933
+ default: !1
934
+ },
935
+ viewMode: {
936
+ type: String,
937
+ default: "rendered"
938
+ },
939
+ sourceValue: {
940
+ type: String,
941
+ default: ""
942
+ },
943
+ onToggleView: {
944
+ type: Function,
945
+ default: void 0
946
+ },
947
+ onSourceInput: {
948
+ type: Function,
949
+ default: void 0
558
950
  }
559
951
  },
560
952
  setup(e) {
561
- let [, r] = P(), i = g(null), a = g(!1), o = g({
953
+ let [, r] = ae(), i = v(null), a = v(!1), o = v({
562
954
  left: "0px",
563
955
  top: "0px"
564
- }), s = g("text"), c = g(!1), l = {
956
+ }), s = v("text"), c = v(!1), l = {
565
957
  strong: !1,
566
958
  emphasis: !1,
567
959
  strike_through: !1,
@@ -575,38 +967,38 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
575
967
  table: !1,
576
968
  code_block: !1,
577
969
  list_item_depth: 0
578
- }, d = se(), p = null, m = g({ ...l });
579
- function h(t) {
970
+ }, d = ue(), p = null, m = v({ ...l });
971
+ function _(t) {
580
972
  if (e.readonly) return;
581
973
  let n = r();
582
974
  n && (n.action((e) => {
583
975
  e.get(D).call(t.command.key, t.payload);
584
- }), w());
976
+ }), T());
585
977
  }
586
- function _(t) {
978
+ function y(t) {
587
979
  if (e.readonly) return;
588
- let n = t === "bullet_list" ? $.bulletList : $.orderedList, r = ze({
980
+ let n = t === "bullet_list" ? $.bulletList : $.orderedList, r = at({
589
981
  target: t,
590
982
  inBulletList: m.value.bullet_list,
591
983
  inOrderedList: m.value.ordered_list
592
984
  });
593
985
  if (r === "lift") {
594
- h({ command: H });
986
+ _({ command: B });
595
987
  return;
596
988
  }
597
- r === "switch" && h({ command: H }), h(n);
989
+ r === "switch" && _({ command: B }), _(n);
598
990
  }
599
- let ne = n(() => e.tools ? new Set(e.tools) : void 0);
600
- function v(e) {
601
- return Re(e, ne.value);
991
+ let b = n(() => e.tools ? new Set(e.tools) : void 0);
992
+ function x(e) {
993
+ return it(e, b.value);
602
994
  }
603
- function y(t) {
995
+ function ee(t) {
604
996
  if (e.readonly) return;
605
997
  let n = r();
606
998
  if (!n) return;
607
- let i = t === null ? null : Y(t);
999
+ let i = t === null ? null : U(t);
608
1000
  n.action((e) => {
609
- let t = e.get(k), { state: n } = t, r = n.schema.marks.text_color;
1001
+ let t = e.get(O), { state: n } = t, r = n.schema.marks.text_color;
610
1002
  if (!r) return;
611
1003
  let { from: a, to: o, empty: s } = n.selection;
612
1004
  if (s) {
@@ -616,17 +1008,17 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
616
1008
  let e = n.tr.removeMark(a, o, r);
617
1009
  i && (e = e.addMark(a, o, r.create({ color: i }))), t.dispatch(e);
618
1010
  }
619
- }), x(), w();
1011
+ }), S(), T();
620
1012
  }
621
- function b(e) {
1013
+ function te(e) {
622
1014
  if (e) {
623
1015
  if (p && !p.isClosed) {
624
- x();
1016
+ S();
625
1017
  return;
626
1018
  }
627
1019
  p = d.open({
628
1020
  spec: {
629
- ...oe,
1021
+ ...le,
630
1022
  anchor: {
631
1023
  kind: "element",
632
1024
  element: e
@@ -634,35 +1026,35 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
634
1026
  },
635
1027
  content: {
636
1028
  kind: "component",
637
- component: f(et)
1029
+ component: f(Wt)
638
1030
  },
639
1031
  inputs: {
640
1032
  currentColor: m.value.text_color,
641
- pick: (e) => y(e)
1033
+ pick: (e) => ee(e)
642
1034
  }
643
1035
  }), p.afterClosed.then(() => {
644
1036
  p?.isClosed && (p = null);
645
1037
  });
646
1038
  }
647
1039
  }
648
- function x() {
1040
+ function S() {
649
1041
  p && !p.isClosed && p.close(), p = null;
650
1042
  }
651
- function S() {
1043
+ function C() {
652
1044
  if (e.readonly) return;
653
1045
  let t = r();
654
1046
  t && t.action((e) => {
655
- let t = e.get(k), { state: n } = t, r = n.tr, { from: i, to: a, empty: o } = n.selection;
1047
+ let t = e.get(O), { state: n } = t, r = n.tr, { from: i, to: a, empty: o } = n.selection;
656
1048
  o ? r = r.setStoredMarks([]) : Object.values(n.schema.marks).forEach((e) => {
657
1049
  r = r.removeMark(i, a, e);
658
- }), t.dispatch(r), e.get(D).call(U.key);
1050
+ }), t.dispatch(r), e.get(D).call(_e.key);
659
1051
  });
660
1052
  }
661
- function C() {
1053
+ function w() {
662
1054
  if (e.readonly) return;
663
1055
  let t = r();
664
1056
  t && t.action((e) => {
665
- let n = e.get(k), { $from: r } = n.state.selection;
1057
+ let n = e.get(O), { $from: r } = n.state.selection;
666
1058
  for (let e = r.depth; e > 0; e--) {
667
1059
  let t = r.node(e);
668
1060
  if (t.type.name === "list_item") {
@@ -671,9 +1063,9 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
671
1063
  return;
672
1064
  }
673
1065
  }
674
- e.get(D).call(W.key), queueMicrotask(() => {
1066
+ e.get(D).call(ye.key), queueMicrotask(() => {
675
1067
  t.action((e) => {
676
- let t = e.get(k), { $from: n } = t.state.selection;
1068
+ let t = e.get(O), { $from: n } = t.state.selection;
677
1069
  for (let e = n.depth; e > 0; e--) if (n.node(e).type.name === "list_item") {
678
1070
  t.dispatch(t.state.tr.setNodeAttribute(n.before(e), "checked", !1));
679
1071
  return;
@@ -682,11 +1074,11 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
682
1074
  });
683
1075
  });
684
1076
  }
685
- function w() {
1077
+ function T() {
686
1078
  let e = r();
687
1079
  if (e) try {
688
1080
  e.action((e) => {
689
- let t = e.get(k).state, { from: n, to: r, empty: i, $from: a } = t.selection, o = t.storedMarks, s = { ...l }, c = (e) => {
1081
+ let t = e.get(O).state, { from: n, to: r, empty: i, $from: a } = t.selection, o = t.storedMarks, s = { ...l }, c = (e) => {
690
1082
  let s = t.schema.marks[e];
691
1083
  if (!s) return !1;
692
1084
  if (i) {
@@ -700,7 +1092,7 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
700
1092
  u && (s.text_color = (() => {
701
1093
  if (i) {
702
1094
  let e = (o ?? a.marks()).find((e) => e.type === u), t = typeof e?.attrs.color == "string" ? e.attrs.color : null;
703
- return t ? Y(t) : null;
1095
+ return t ? U(t) : null;
704
1096
  }
705
1097
  let e = null;
706
1098
  return t.doc.nodesBetween(n, r, (t) => {
@@ -708,7 +1100,7 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
708
1100
  let n = t.marks.find((e) => e.type === u);
709
1101
  if (n) {
710
1102
  let t = typeof n.attrs.color == "string" ? n.attrs.color : null;
711
- e = t ? Y(t) : null;
1103
+ e = t ? U(t) : null;
712
1104
  }
713
1105
  return e === null;
714
1106
  }), e;
@@ -723,29 +1115,29 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
723
1115
  m.value = { ...l };
724
1116
  }
725
1117
  }
726
- function T(t) {
1118
+ function E(t) {
727
1119
  if (e.readonly) return;
728
1120
  let n = t.target, i = n.closest("li[data-item-type=\"task\"]");
729
1121
  if (i) {
730
1122
  let e = i.getBoundingClientRect();
731
1123
  if (t.clientX - e.left < 18) {
732
- t.preventDefault(), E(i);
1124
+ t.preventDefault(), ne(i);
733
1125
  return;
734
1126
  }
735
1127
  }
736
1128
  if (n.closest(".ProseMirror")) return;
737
1129
  let a = r();
738
1130
  a && (t.preventDefault(), a.action((e) => {
739
- let t = e.get(k);
1131
+ let t = e.get(O);
740
1132
  t.focus();
741
- let n = t.state.tr.setSelection(K.atEnd(t.state.doc));
1133
+ let n = t.state.tr.setSelection(Se.atEnd(t.state.doc));
742
1134
  t.dispatch(n);
743
1135
  }));
744
1136
  }
745
- function E(e) {
1137
+ function ne(e) {
746
1138
  let t = r();
747
1139
  t && t.action((t) => {
748
- let n = t.get(k), r = n.posAtDOM(e, 0);
1140
+ let n = t.get(O), r = n.posAtDOM(e, 0);
749
1141
  if (r < 0) return;
750
1142
  let i = n.state.doc.resolve(r);
751
1143
  for (let e = i.depth; e >= 0; e--) {
@@ -758,13 +1150,13 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
758
1150
  }
759
1151
  });
760
1152
  }
761
- function O() {
1153
+ function re() {
762
1154
  let e = r();
763
1155
  if (!e) return "text";
764
1156
  try {
765
1157
  let t = "text";
766
1158
  return e.action((e) => {
767
- let { $from: n } = e.get(k).state.selection;
1159
+ let { $from: n } = e.get(O).state.selection;
768
1160
  for (let e = n.depth; e > 0; e--) if (n.node(e).type.name === "table") {
769
1161
  t = "table";
770
1162
  break;
@@ -774,14 +1166,14 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
774
1166
  return "text";
775
1167
  }
776
1168
  }
777
- function A(e) {
1169
+ function k(e) {
778
1170
  let t = e.left + e.width / 2, n = e.top - 8;
779
1171
  t = Math.max(108, Math.min(t, window.innerWidth - 108)), n < 50 && (n = e.bottom + 8), o.value = {
780
1172
  left: `${t}px`,
781
1173
  top: `${n}px`
782
1174
  };
783
1175
  }
784
- function j() {
1176
+ function A() {
785
1177
  if (e.readonly || e.toolbarMode === "fixed") {
786
1178
  a.value = !1;
787
1179
  return;
@@ -796,141 +1188,154 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
796
1188
  a.value = !1, c.value = !1;
797
1189
  return;
798
1190
  }
799
- A(n.getBoundingClientRect()), s.value = O(), a.value = !0, c.value = !1;
1191
+ k(n.getBoundingClientRect()), s.value = re(), a.value = !0, c.value = !1;
800
1192
  }
801
- function M(e) {
1193
+ function j(e) {
802
1194
  let t = e.target;
803
1195
  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)) && (a.value = !1, c.value = !1);
804
1196
  }
805
- let N = null;
806
- function F(e = 20) {
1197
+ let M = null;
1198
+ function N(e = 20) {
807
1199
  let t = r();
808
1200
  if (!t) {
809
- e > 0 && setTimeout(() => F(e - 1), 50);
1201
+ e > 0 && setTimeout(() => N(e - 1), 50);
810
1202
  return;
811
1203
  }
812
1204
  try {
813
1205
  t.action((e) => {
814
- let t = e.get(X);
815
- N = () => queueMicrotask(w), t.selectionUpdated(N);
1206
+ let t = e.get(Je);
1207
+ M = () => queueMicrotask(T), t.selectionUpdated(M);
816
1208
  });
817
1209
  } catch {
818
- e > 0 && setTimeout(() => F(e - 1), 50);
1210
+ e > 0 && setTimeout(() => N(e - 1), 50);
819
1211
  }
820
1212
  }
821
- function L() {
822
- if (!N) return;
1213
+ function oe() {
1214
+ if (!M) return;
823
1215
  let e = r();
824
1216
  if (e) {
825
1217
  try {
826
1218
  e.action((e) => {
827
- let t = e.get(X).listeners.selectionUpdated, n = t.indexOf(N);
1219
+ let t = e.get(Je).listeners.selectionUpdated, n = t.indexOf(M);
828
1220
  n >= 0 && t.splice(n, 1);
829
1221
  });
830
1222
  } catch {}
831
- N = null;
1223
+ M = null;
832
1224
  }
833
1225
  }
834
- te(() => {
835
- document.addEventListener("selectionchange", j), document.addEventListener("mousedown", M, !0), F();
836
- }), ee(() => {
837
- document.removeEventListener("selectionchange", j), document.removeEventListener("mousedown", M, !0), L(), x();
1226
+ g(() => {
1227
+ document.addEventListener("selectionchange", A), document.addEventListener("mousedown", j, !0), N();
1228
+ }), h(() => {
1229
+ document.removeEventListener("selectionchange", A), document.removeEventListener("mousedown", j, !0), oe(), S();
838
1230
  });
839
- function B(e, t, n, r = {}) {
840
- return u(z, {
1231
+ function L(e, t, n, r = {}) {
1232
+ return u(I, {
841
1233
  icon: e,
842
1234
  label: t,
843
1235
  active: r.active ?? !1,
844
1236
  disabled: r.disabled ?? !1,
845
- onClick: r.disabled ? () => {} : r.onClick ?? (() => h(n))
1237
+ onClick: r.disabled ? () => {} : r.onClick ?? (() => _(n))
846
1238
  });
847
1239
  }
848
- function V() {
1240
+ function R() {
849
1241
  let t = m.value, n = t.heading != null;
850
1242
  function r(e, t, n) {
851
- v(t) && e.push(n);
1243
+ x(t) && e.push(n);
852
1244
  }
853
1245
  function i(e) {
854
- e.length !== 0 && e[e.length - 1]?.type !== R && e.push(u(R));
1246
+ e.length !== 0 && e[e.length - 1]?.type !== F && e.push(u(F));
855
1247
  }
856
1248
  let a = [];
857
- return r(a, "bold", B("bold", "Bold", $.bold, { active: t.strong })), r(a, "italic", B("italic", "Italic", $.italic, { active: t.emphasis })), r(a, "strikethrough", B("strikethrough", "Strikethrough", $.strike, { active: t.strike_through })), r(a, "inlineCode", B("code", "Inline Code", $.code, { active: t.inlineCode })), r(a, "textColor", u(z, {
1249
+ if (e.sourceToggle) {
1250
+ let t = e.viewMode === "source";
1251
+ if (a.push(u(I, {
1252
+ icon: t ? "eye" : "code",
1253
+ label: t ? "Rendered" : "Source",
1254
+ active: t,
1255
+ onClick: () => e.onToggleView?.(t ? "rendered" : "source")
1256
+ })), t) return z(a);
1257
+ i(a);
1258
+ }
1259
+ return r(a, "bold", L("bold", "Bold", $.bold, { active: t.strong })), r(a, "italic", L("italic", "Italic", $.italic, { active: t.emphasis })), r(a, "strikethrough", L("strikethrough", "Strikethrough", $.strike, { active: t.strike_through })), r(a, "inlineCode", L("code", "Inline Code", $.code, { active: t.inlineCode })), r(a, "textColor", u(I, {
858
1260
  icon: "palette",
859
1261
  label: "Text Color",
860
1262
  active: t.text_color !== null,
861
1263
  onClick: (e) => {
862
- b(e.currentTarget ?? e.target);
1264
+ te(e.currentTarget ?? e.target);
863
1265
  }
864
- })), r(a, "headings", u(ae, {
1266
+ })), r(a, "headings", u(ce, {
865
1267
  icon: "hash",
866
1268
  label: n ? `Heading ${t.heading}` : "Headings",
867
1269
  mode: "flyout",
868
1270
  openOnHover: !0
869
1271
  }, { default: () => [
870
- u(z, {
1272
+ u(I, {
871
1273
  icon: "pilcrow",
872
1274
  label: "Paragraph",
873
1275
  active: !n,
874
- onClick: () => h($.paragraph)
1276
+ onClick: () => _($.paragraph)
875
1277
  }),
876
- u(z, {
1278
+ u(I, {
877
1279
  icon: "heading",
878
1280
  label: "Heading 1",
879
1281
  active: t.heading === 1,
880
- onClick: () => h($.h1)
1282
+ onClick: () => _($.h1)
881
1283
  }),
882
- u(z, {
1284
+ u(I, {
883
1285
  icon: "heading",
884
1286
  label: "Heading 2",
885
1287
  active: t.heading === 2,
886
- onClick: () => h($.h2)
1288
+ onClick: () => _($.h2)
887
1289
  }),
888
- u(z, {
1290
+ u(I, {
889
1291
  icon: "heading",
890
1292
  label: "Heading 3",
891
1293
  active: t.heading === 3,
892
- onClick: () => h($.h3)
1294
+ onClick: () => _($.h3)
893
1295
  }),
894
- u(z, {
1296
+ u(I, {
895
1297
  icon: "heading",
896
1298
  label: "Heading 4",
897
1299
  active: t.heading === 4,
898
- onClick: () => h($.h4)
1300
+ onClick: () => _($.h4)
899
1301
  }),
900
- u(z, {
1302
+ u(I, {
901
1303
  icon: "heading",
902
1304
  label: "Heading 5",
903
1305
  active: t.heading === 5,
904
- onClick: () => h($.h5)
1306
+ onClick: () => _($.h5)
905
1307
  }),
906
- u(z, {
1308
+ u(I, {
907
1309
  icon: "heading",
908
1310
  label: "Heading 6",
909
1311
  active: t.heading === 6,
910
- onClick: () => h($.h6)
1312
+ onClick: () => _($.h6)
911
1313
  })
912
- ] })), i(a), r(a, "bulletList", B("list", "Bullet List", $.bulletList, {
1314
+ ] })), i(a), r(a, "bulletList", L("list", "Bullet List", $.bulletList, {
913
1315
  active: t.bullet_list,
914
- onClick: () => _("bullet_list")
915
- })), r(a, "orderedList", B("list-ordered", "Ordered List", $.orderedList, {
1316
+ onClick: () => y("bullet_list")
1317
+ })), r(a, "orderedList", L("list-ordered", "Ordered List", $.orderedList, {
916
1318
  active: t.ordered_list,
917
- onClick: () => _("ordered_list")
918
- })), r(a, "taskList", B("clipboard-check", "Task List", $.bulletList, {
1319
+ onClick: () => y("ordered_list")
1320
+ })), r(a, "taskList", L("clipboard-check", "Task List", $.bulletList, {
919
1321
  active: t.task_list,
920
- onClick: C
921
- })), r(a, "outdent", B("indent-decrease", "Outdent", $.outdent, { disabled: t.list_item_depth < 2 })), r(a, "indent", B("indent-increase", "Indent", $.indent, { disabled: t.list_item_depth < 1 })), r(a, "blockquote", B("text-quote", "Blockquote", $.blockquote, { active: t.blockquote })), r(a, "horizontalRule", B("minus", "Horizontal Rule", $.hr)), i(a), r(a, "codeBlock", B("square-code", "Code Block", $.codeBlock, { active: t.code_block })), r(a, "table", B("table", "Insert Table", $.table, { active: t.table })), t.table && v("tableOps") && (i(a), a.push(B("between-vertical-start", "Insert Row Above", $.addRowBefore)), a.push(B("between-vertical-end", "Insert Row Below", $.addRowAfter)), a.push(B("between-horizontal-start", "Insert Column Left", $.addColBefore)), a.push(B("between-horizontal-end", "Insert Column Right", $.addColAfter)), a.push(B("trash-2", "Delete Cell", $.deleteCell))), v("clearFormatting") && (i(a), a.push(B("eraser", "Clear Formatting", $.bold, { onClick: S }))), i(a), r(a, "undo", B("undo-2", "Undo", $.undo)), r(a, "redo", B("redo-2", "Redo", $.redo)), a[a.length - 1]?.type === R && a.pop(), u("div", {
1322
+ onClick: w
1323
+ })), r(a, "outdent", L("indent-decrease", "Outdent", $.outdent, { disabled: t.list_item_depth < 2 })), r(a, "indent", L("indent-increase", "Indent", $.indent, { disabled: t.list_item_depth < 1 })), r(a, "blockquote", L("text-quote", "Blockquote", $.blockquote, { active: t.blockquote })), r(a, "horizontalRule", L("minus", "Horizontal Rule", $.hr)), i(a), r(a, "codeBlock", L("square-code", "Code Block", $.codeBlock, { active: t.code_block })), r(a, "table", L("table", "Insert Table", $.table, { active: t.table })), t.table && x("tableOps") && (i(a), a.push(L("between-vertical-start", "Insert Row Above", $.addRowBefore)), a.push(L("between-vertical-end", "Insert Row Below", $.addRowAfter)), a.push(L("between-horizontal-start", "Insert Column Left", $.addColBefore)), a.push(L("between-horizontal-end", "Insert Column Right", $.addColAfter)), a.push(L("trash-2", "Delete Cell", $.deleteCell))), x("clearFormatting") && (i(a), a.push(L("eraser", "Clear Formatting", $.bold, { onClick: C }))), i(a), r(a, "undo", L("undo-2", "Undo", $.undo)), r(a, "redo", L("redo-2", "Redo", $.redo)), a[a.length - 1]?.type === F && a.pop(), z(a);
1324
+ }
1325
+ function z(t) {
1326
+ return u("div", {
922
1327
  key: "sidebar",
923
1328
  class: "coar-md-sidebar-wrap",
924
1329
  onMousedown: (e) => e.preventDefault()
925
- }, [u(ie, {
1330
+ }, [u(se, {
926
1331
  collapsed: !0,
927
1332
  side: e.toolbarPosition,
928
1333
  size: "s",
929
1334
  variant: "primary",
930
1335
  borderless: !0
931
- }, { default: () => a })]);
1336
+ }, { default: () => t })]);
932
1337
  }
933
- function ce() {
1338
+ function de() {
934
1339
  let e = (e, t, n, r = {}) => u("button", {
935
1340
  class: [
936
1341
  "coar-md-float-btn",
@@ -941,20 +1346,20 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
941
1346
  type: "button",
942
1347
  disabled: r.disabled ?? !1,
943
1348
  onMousedown: (e) => {
944
- e.preventDefault(), !r.disabled && (r.onClick ?? (() => h(n)))();
1349
+ e.preventDefault(), !r.disabled && (r.onClick ?? (() => _(n)))();
945
1350
  }
946
- }, [u(I, {
1351
+ }, [u(P, {
947
1352
  name: e,
948
1353
  size: "s"
949
1354
  })]), n = () => u("div", { class: "coar-md-float-sep" }), r = m.value;
950
1355
  function i(e, t, n) {
951
- v(t) && e.push(n);
1356
+ x(t) && e.push(n);
952
1357
  }
953
1358
  function a(e) {
954
1359
  e.length !== 0 && e[e.length - 1]?.props?.class !== "coar-md-float-sep" && e.push(n());
955
1360
  }
956
1361
  let l = [];
957
- if (i(l, "bold", e("bold", "Bold", $.bold, { isActive: r.strong })), i(l, "italic", e("italic", "Italic", $.italic, { isActive: r.emphasis })), i(l, "strikethrough", e("strikethrough", "Strikethrough", $.strike, { isActive: r.strike_through })), i(l, "inlineCode", e("code", "Inline Code", $.code, { isActive: r.inlineCode })), v("textColor")) {
1362
+ if (i(l, "bold", e("bold", "Bold", $.bold, { isActive: r.strong })), i(l, "italic", e("italic", "Italic", $.italic, { isActive: r.emphasis })), i(l, "strikethrough", e("strikethrough", "Strikethrough", $.strike, { isActive: r.strike_through })), i(l, "inlineCode", e("code", "Inline Code", $.code, { isActive: r.inlineCode })), x("textColor")) {
958
1363
  let e = r.text_color !== null;
959
1364
  l.push(u("button", {
960
1365
  class: ["coar-md-float-btn", e ? "coar-md-float-btn--active" : ""],
@@ -962,21 +1367,21 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
962
1367
  title: e ? `Text Color (${r.text_color})` : "Text Color",
963
1368
  style: e ? `--coar-md-color-indicator: ${r.text_color};` : void 0,
964
1369
  onMousedown: (e) => {
965
- e.preventDefault(), b(e.currentTarget);
1370
+ e.preventDefault(), te(e.currentTarget);
966
1371
  }
967
- }, [u(I, {
1372
+ }, [u(P, {
968
1373
  name: "palette",
969
1374
  size: "s"
970
1375
  })]));
971
1376
  }
972
- v("headings") && (a(l), l.push(u("div", { class: "coar-md-float-dropdown" }, [u("button", {
1377
+ x("headings") && (a(l), l.push(u("div", { class: "coar-md-float-dropdown" }, [u("button", {
973
1378
  class: ["coar-md-float-btn", c.value || r.heading != null ? "coar-md-float-btn--active" : ""],
974
1379
  title: r.heading == null ? "Headings" : `Heading ${r.heading}`,
975
1380
  type: "button",
976
1381
  onMousedown: (e) => {
977
1382
  e.preventDefault(), c.value = !c.value;
978
1383
  }
979
- }, [u(I, {
1384
+ }, [u(P, {
980
1385
  name: "heading",
981
1386
  size: "s"
982
1387
  })]), c.value ? u("div", { class: "coar-md-float-submenu" }, [
@@ -1026,24 +1431,24 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
1026
1431
  class: ["coar-md-float-submenu-item", (i === 0 ? r.heading == null : r.heading === i) ? "coar-md-float-submenu-item--active" : ""],
1027
1432
  type: "button",
1028
1433
  onMousedown: (e) => {
1029
- e.preventDefault(), h(t), c.value = !1;
1434
+ e.preventDefault(), _(t), c.value = !1;
1030
1435
  }
1031
- }, [u(I, {
1436
+ }, [u(P, {
1032
1437
  name: n,
1033
1438
  size: "xs"
1034
1439
  }), u("span", null, e)]))) : null]))), a(l), i(l, "bulletList", e("list", "Bullet List", $.bulletList, {
1035
1440
  isActive: r.bullet_list,
1036
- onClick: () => _("bullet_list")
1441
+ onClick: () => y("bullet_list")
1037
1442
  })), i(l, "orderedList", e("list-ordered", "Ordered List", $.orderedList, {
1038
1443
  isActive: r.ordered_list,
1039
- onClick: () => _("ordered_list")
1444
+ onClick: () => y("ordered_list")
1040
1445
  })), i(l, "taskList", e("clipboard-check", "Task List", $.bulletList, {
1041
1446
  isActive: r.task_list,
1042
- onClick: C
1043
- })), i(l, "outdent", e("indent-decrease", "Outdent", $.outdent, { disabled: r.list_item_depth < 2 })), i(l, "indent", e("indent-increase", "Indent", $.indent, { disabled: r.list_item_depth < 1 })), a(l), i(l, "blockquote", e("text-quote", "Blockquote", $.blockquote, { isActive: r.blockquote })), v("clearFormatting") && (a(l), l.push(e("eraser", "Clear Formatting", $.bold, { onClick: S }))), l[l.length - 1]?.props?.class === "coar-md-float-sep" && l.pop();
1447
+ onClick: w
1448
+ })), i(l, "outdent", e("indent-decrease", "Outdent", $.outdent, { disabled: r.list_item_depth < 2 })), i(l, "indent", e("indent-increase", "Indent", $.indent, { disabled: r.list_item_depth < 1 })), a(l), i(l, "blockquote", e("text-quote", "Blockquote", $.blockquote, { isActive: r.blockquote })), x("clearFormatting") && (a(l), l.push(e("eraser", "Clear Formatting", $.bold, { onClick: C }))), l[l.length - 1]?.props?.class === "coar-md-float-sep" && l.pop();
1044
1449
  let d = {
1045
1450
  text: l,
1046
- table: v("tableOps") ? [
1451
+ table: x("tableOps") ? [
1047
1452
  e("between-vertical-start", "Insert Row Above", $.addRowBefore),
1048
1453
  e("between-vertical-end", "Insert Row Below", $.addRowAfter),
1049
1454
  n(),
@@ -1051,18 +1456,18 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
1051
1456
  e("between-horizontal-end", "Insert Column Right", $.addColAfter),
1052
1457
  n(),
1053
1458
  e("trash-2", "Delete", $.deleteCell),
1054
- ...v("bold") || v("italic") || v("inlineCode") ? [n()] : [],
1055
- ...v("bold") ? [e("bold", "Bold", $.bold)] : [],
1056
- ...v("italic") ? [e("italic", "Italic", $.italic)] : [],
1057
- ...v("inlineCode") ? [e("code", "Code", $.code)] : []
1459
+ ...x("bold") || x("italic") || x("inlineCode") ? [n()] : [],
1460
+ ...x("bold") ? [e("bold", "Bold", $.bold)] : [],
1461
+ ...x("italic") ? [e("italic", "Italic", $.italic)] : [],
1462
+ ...x("inlineCode") ? [e("code", "Code", $.code)] : []
1058
1463
  ] : l,
1059
- "col-selection": v("tableOps") ? [
1464
+ "col-selection": x("tableOps") ? [
1060
1465
  e("between-horizontal-start", "Insert Column Left", $.addColBefore),
1061
1466
  e("between-horizontal-end", "Insert Column Right", $.addColAfter),
1062
1467
  n(),
1063
1468
  e("trash-2", "Delete Column", $.deleteCell)
1064
1469
  ] : l,
1065
- "row-selection": v("tableOps") ? [
1470
+ "row-selection": x("tableOps") ? [
1066
1471
  e("between-vertical-start", "Insert Row Above", $.addRowBefore),
1067
1472
  e("between-vertical-end", "Insert Row Below", $.addRowAfter),
1068
1473
  n(),
@@ -1075,12 +1480,47 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
1075
1480
  }, d[s.value] || l));
1076
1481
  }
1077
1482
  return () => {
1078
- let t = e.toolbarMode === "fixed" || e.toolbarMode === "both", n = !e.readonly && (e.toolbarMode === "floating" || e.toolbarMode === "both"), r = [], o = e.toolbarPosition === "left" || e.toolbarPosition === "top", s = e.toolbarPosition === "right" || e.toolbarPosition === "bottom";
1079
- return t && o && r.push(V()), r.push(u("div", {
1483
+ let t = e.toolbarMode === "fixed" || e.toolbarMode === "both", n = e.sourceToggle && e.viewMode === "source", r = !e.readonly && !n && (e.toolbarMode === "floating" || e.toolbarMode === "both"), o = [], s = e.toolbarPosition === "left" || e.toolbarPosition === "top", c = e.toolbarPosition === "right" || e.toolbarPosition === "bottom";
1484
+ t && s && o.push(R());
1485
+ let l = e.isEmpty && e.placeholder.length > 0 && !n;
1486
+ return o.push(u("div", {
1080
1487
  key: "area",
1081
- class: ["coar-md-area", "coar-markdown"],
1082
- onMousedown: T
1083
- }, [u(re)])), t && s && r.push(V()), a.value && n && r.push(ce()), u("div", {
1488
+ class: [
1489
+ "coar-md-area",
1490
+ "coar-markdown",
1491
+ { "coar-md-area--source": n }
1492
+ ],
1493
+ onMousedown: n ? void 0 : E
1494
+ }, [
1495
+ u(ie),
1496
+ l ? u(yt, {
1497
+ key: "placeholder",
1498
+ source: e.placeholder
1499
+ }) : null,
1500
+ n ? u("textarea", {
1501
+ key: "source",
1502
+ class: "coar-md-source-area",
1503
+ value: e.sourceValue,
1504
+ readonly: e.readonly || void 0,
1505
+ disabled: e.disabled || void 0,
1506
+ spellcheck: "false",
1507
+ placeholder: e.placeholder || void 0,
1508
+ onInput: (t) => e.onSourceInput?.(t.target.value)
1509
+ }) : null,
1510
+ e.sourceToggle && !t ? u("button", {
1511
+ key: "source-corner",
1512
+ class: "coar-md-source-corner",
1513
+ type: "button",
1514
+ title: n ? "Show rendered" : "Edit source",
1515
+ "aria-label": n ? "Show rendered" : "Edit source",
1516
+ onMousedown: (t) => {
1517
+ t.preventDefault(), e.onToggleView?.(n ? "rendered" : "source");
1518
+ }
1519
+ }, [u(P, {
1520
+ name: n ? "eye" : "code",
1521
+ size: "s"
1522
+ })]) : null
1523
+ ])), t && c && o.push(R()), a.value && r && o.push(de()), u("div", {
1084
1524
  class: {
1085
1525
  "coar-md-root": !0,
1086
1526
  [`coar-md-root--toolbar-${e.toolbarPosition}`]: !0,
@@ -1096,10 +1536,10 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
1096
1536
  "aria-readonly": e.readonly && !e.disabled ? "true" : void 0,
1097
1537
  "aria-required": e.required ? "true" : void 0,
1098
1538
  "data-name": e.name
1099
- }, r);
1539
+ }, o);
1100
1540
  };
1101
1541
  }
1102
- }), it = l({
1542
+ }), Jt = l({
1103
1543
  name: "CoarMarkdownEditor",
1104
1544
  props: {
1105
1545
  modelValue: {
@@ -1130,6 +1570,14 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
1130
1570
  type: Boolean,
1131
1571
  default: !1
1132
1572
  },
1573
+ placeholder: {
1574
+ type: String,
1575
+ default: ""
1576
+ },
1577
+ sourceToggle: {
1578
+ type: Boolean,
1579
+ default: !1
1580
+ },
1133
1581
  toolbarMode: {
1134
1582
  type: String,
1135
1583
  default: "floating"
@@ -1145,16 +1593,17 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
1145
1593
  },
1146
1594
  emits: ["update:modelValue"],
1147
1595
  setup(e, { emit: t }) {
1148
- let r = e.modelValue, i = ne({ value: e.modelValue });
1149
- C(() => e.modelValue, (e) => {
1596
+ let r = e.modelValue, i = b({ value: e.modelValue });
1597
+ w(() => e.modelValue, (e) => {
1150
1598
  i.value = { value: e };
1151
1599
  });
1152
- let a = d(B, void 0), o = `coar-markdown-editor-${y()}`, s = n(() => e.id || a?.inputId.value || o), c = n(() => e.error || (a?.hasError.value ?? !1)), l = n(() => a?.messageId.value), f = n(() => e.disabled || (a?.disabled.value ?? !1)), p = n(() => e.readonly || f.value);
1153
- return () => u(M, null, () => u(nt, {
1600
+ let a = d(L, void 0), o = `coar-markdown-editor-${ee()}`, s = n(() => e.id || a?.inputId.value || o), c = n(() => e.error || (a?.hasError.value ?? !1)), l = n(() => a?.messageId.value), f = n(() => e.disabled || (a?.disabled.value ?? !1)), p = n(() => e.readonly || f.value);
1601
+ return () => u(j, null, () => u(Kt, {
1154
1602
  initialValue: r,
1155
1603
  externalValue: i.value,
1156
1604
  readonly: p.value,
1157
1605
  disabled: f.value,
1606
+ sourceToggle: e.sourceToggle,
1158
1607
  toolbarMode: e.toolbarMode,
1159
1608
  toolbarPosition: e.toolbarPosition,
1160
1609
  tools: e.tools,
@@ -1163,9 +1612,10 @@ var Ye = [be("textColor", () => Ke), ve("text_color", () => ({
1163
1612
  describedBy: l.value,
1164
1613
  name: e.name,
1165
1614
  required: e.required,
1615
+ placeholder: e.placeholder,
1166
1616
  onMarkdownChange: (e) => t("update:modelValue", e)
1167
1617
  }));
1168
1618
  }
1169
1619
  });
1170
1620
  //#endregion
1171
- export { tt as COAR_MARKDOWN_EDITOR_ALL_TOOLS, it as CoarMarkdownEditor };
1621
+ export { Gt as COAR_MARKDOWN_EDITOR_ALL_TOOLS, Jt as CoarMarkdownEditor };