@cocoar/vue-markdown-editor 1.14.0 → 1.16.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,25 +1,26 @@
1
- import { Teleport as e, computed as t, createApp as n, createElementBlock as r, createElementVNode as i, createVNode as a, defineComponent as o, h as s, inject as c, normalizeClass as l, onBeforeUnmount as u, onMounted as d, openBlock as f, ref as p, shallowRef as m, unref as h, useId as g, useTemplateRef as _, vShow as v, watch as y, withDirectives as b, withModifiers as x } from "vue";
2
- import { Editor as S, commandsCtx as C, defaultValueCtx as w, editorViewCtx as T, editorViewOptionsCtx as E, rootCtx as D } from "@milkdown/core";
3
- import { Milkdown as ee, MilkdownProvider as O, useEditor as k, useInstance as A } from "@milkdown/vue";
4
- import { CoarCodeBlock as j, CoarIcon as M, CoarSelect as N, CoarSidebar as te, CoarSidebarDivider as P, CoarSidebarGroup as F, CoarSidebarItem as I, FORM_FIELD_INJECTION_KEY as L } from "@cocoar/vue-ui";
5
- import { codeBlockSchema as R, commonmark as z, createCodeBlockCommand as B, insertHrCommand as V, liftListItemCommand as H, sinkListItemCommand as ne, toggleEmphasisCommand as re, toggleInlineCodeCommand as ie, toggleStrongCommand as ae, turnIntoTextCommand as U, wrapInBlockquoteCommand as W, wrapInBulletListCommand as G, wrapInHeadingCommand as K, wrapInOrderedListCommand as q } from "@milkdown/preset-commonmark";
6
- import { Plugin as J, TextSelection as Y } from "@milkdown/prose/state";
7
- import { $prose as X, $view as oe, replaceAll as se } from "@milkdown/utils";
8
- import { addColAfterCommand as ce, addColBeforeCommand as le, addRowAfterCommand as ue, addRowBeforeCommand as de, deleteSelectedCellsCommand as fe, gfm as pe, insertTableCommand as me, toggleStrikethroughCommand as he } from "@milkdown/preset-gfm";
9
- import { history as ge, redoCommand as _e, undoCommand as ve } from "@milkdown/plugin-history";
10
- import { clipboard as ye } from "@milkdown/plugin-clipboard";
11
- import { listener as be, listenerCtx as Z } 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 ee, onMounted as te, openBlock as h, ref as g, renderList as _, shallowRef as v, unref as y, useId as ne, 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 H, createCodeBlockCommand as ce, insertHrCommand as le, liftListItemCommand as U, sinkListItemCommand as ue, toggleEmphasisCommand as de, toggleInlineCodeCommand as fe, toggleStrongCommand as pe, turnIntoTextCommand as W, wrapInBlockquoteCommand as me, wrapInBulletListCommand as G, wrapInHeadingCommand as K, wrapInOrderedListCommand as he } from "@milkdown/preset-commonmark";
6
+ import { Plugin as ge, TextSelection as q } from "@milkdown/prose/state";
7
+ import { $markSchema as _e, $prose as ve, $remark as ye, $view as be, replaceAll as xe } 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";
12
13
  //#region src/toolbar-helpers.ts
13
- function xe(e, t) {
14
+ function Re(e, t) {
14
15
  return t === void 0 ? !0 : "has" in t ? t.has(e) : t.includes(e);
15
16
  }
16
- function Se(e) {
17
+ function ze(e) {
17
18
  let { target: t, inBulletList: n, inOrderedList: r } = e;
18
19
  return (t === "bullet_list" ? n : r) ? "lift" : (t === "bullet_list" ? r : n) ? "switch" : "wrap";
19
20
  }
20
21
  //#endregion
21
22
  //#region src/code-block-view/CodeBlockShell.vue?vue&type=script&setup=true&lang.ts
22
- var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" }, Te = { class: "coar-md-code-lang-row" }, Ee = /* @__PURE__ */ o({
23
+ var Be = { class: "coar-md-code-render" }, Ve = { class: "coar-md-code-edit" }, He = { class: "coar-md-code-lang-row" }, Ue = /* @__PURE__ */ l({
23
24
  __name: "CodeBlockShell",
24
25
  props: {
25
26
  text: {},
@@ -29,7 +30,7 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
29
30
  },
30
31
  emits: ["enterEdit", "languageChange"],
31
32
  setup(e, { emit: t }) {
32
- let n = e, o = t, s = [
33
+ let n = e, r = t, i = [
33
34
  {
34
35
  value: "",
35
36
  label: "Plain text"
@@ -62,50 +63,50 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
62
63
  value: "bash",
63
64
  label: "Bash"
64
65
  }
65
- ], c = _("contentMount");
66
- return y([c, () => n.contentDOM], ([e, t]) => {
66
+ ], a = b("contentMount");
67
+ return C([a, () => n.contentDOM], ([e, t]) => {
67
68
  e && t && t.parentElement !== e && e.appendChild(t);
68
69
  }, {
69
70
  immediate: !0,
70
71
  flush: "post"
71
- }), (t, n) => (f(), r("div", { class: l(["coar-md-code-host", { "coar-md-code-host--editing": e.editing }]) }, [b(i("div", Ce, [a(h(j), {
72
+ }), (t, n) => (h(), o("div", { class: p(["coar-md-code-host", { "coar-md-code-host--editing": e.editing }]) }, [w(s("div", Be, [c(y(F), {
72
73
  code: e.text,
73
74
  language: e.language || "text",
74
75
  collapsible: !1,
75
76
  "show-copy": !1
76
- }, null, 8, ["code", "language"]), i("button", {
77
+ }, null, 8, ["code", "language"]), s("button", {
77
78
  class: "coar-md-code-edit-btn",
78
79
  type: "button",
79
80
  title: "Edit code block",
80
- onMousedown: n[0] ||= x((e) => o("enterEdit"), ["prevent"])
81
- }, [a(h(M), {
81
+ onMousedown: n[0] ||= T((e) => r("enterEdit"), ["prevent"])
82
+ }, [c(y(I), {
82
83
  name: "pencil",
83
84
  size: "xs"
84
- }), n[2] ||= i("span", null, "Edit", -1)], 32)], 512), [[v, !e.editing]]), b(i("div", we, [i("div", Te, [a(h(N), {
85
+ }), n[2] ||= s("span", null, "Edit", -1)], 32)], 512), [[S, !e.editing]]), w(s("div", Ve, [s("div", He, [c(y(L), {
85
86
  class: "coar-md-code-lang-select",
86
87
  "model-value": e.language,
87
- options: s,
88
+ options: i,
88
89
  size: "s",
89
- "onUpdate:modelValue": n[1] ||= (e) => o("languageChange", String(e))
90
- }, null, 8, ["model-value"])]), i("div", {
90
+ "onUpdate:modelValue": n[1] ||= (e) => r("languageChange", String(e))
91
+ }, null, 8, ["model-value"])]), s("div", {
91
92
  ref_key: "contentMount",
92
- ref: c,
93
+ ref: a,
93
94
  class: "coar-md-code-content"
94
- }, null, 512)], 512), [[v, e.editing]])], 2));
95
+ }, null, 512)], 512), [[S, e.editing]])], 2));
95
96
  }
96
- }), Q = /* @__PURE__ */ new Set(), De = class {
97
+ }), Z = /* @__PURE__ */ new Set(), We = class {
97
98
  dom;
98
99
  contentDOM;
99
100
  app;
100
- text = p("");
101
- language = p("");
102
- editing = p(!1);
103
- constructor(e, t, r) {
104
- this.node = e, this.view = t, this.getPos = r, Q.add(this), this.dom = document.createElement("div"), this.dom.className = "coar-md-code-host-mount";
101
+ text = g("");
102
+ language = g("");
103
+ editing = g(!1);
104
+ 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";
105
106
  let i = document.createElement("pre"), a = document.createElement("code");
106
- i.appendChild(a), this.contentDOM = a, this.text.value = e.textContent, this.language.value = e.attrs.language ?? "", this.app = n({
107
+ i.appendChild(a), this.contentDOM = a, this.text.value = e.textContent, this.language.value = e.attrs.language ?? "", this.app = r({
107
108
  name: "CodeBlockShellRoot",
108
- setup: () => () => s(Ee, {
109
+ setup: () => () => u(Ue, {
109
110
  text: this.text.value,
110
111
  language: this.language.value,
111
112
  editing: this.editing.value,
@@ -127,7 +128,7 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
127
128
  this.editing.value = !1;
128
129
  }
129
130
  destroy() {
130
- Q.delete(this), this.app.unmount();
131
+ Z.delete(this), this.app.unmount();
131
132
  }
132
133
  notifySelectionChanged() {
133
134
  let e = this.getPos();
@@ -145,21 +146,214 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
145
146
  let e = this.getPos();
146
147
  if (e == null) return;
147
148
  let { tr: t } = this.view.state;
148
- t.setSelection(Y.create(this.view.state.doc, e + 1)), this.view.dispatch(t), this.view.focus();
149
+ t.setSelection(q.create(this.view.state.doc, e + 1)), this.view.dispatch(t), this.view.focus();
149
150
  };
150
151
  handleLanguageChange = (e) => {
151
152
  let t = this.getPos();
152
153
  t != null && this.view.dispatch(this.view.state.tr.setNodeAttribute(t, "language", e));
153
154
  };
154
- }, Oe = [oe(R.node, () => (e, t, n) => new De(e, t, n)), X(() => new J({ view: () => ({ update(e, t) {
155
- e.state.selection.eq(t.selection) || Q.forEach((t) => {
155
+ }, Ge = [be(V.node, () => (e, t, n) => new We(e, t, n)), ve(() => new ge({ view: () => ({ update(e, t) {
156
+ e.state.selection.eq(t.selection) || Z.forEach((t) => {
156
157
  t.view === e && t.notifySelectionChanged();
157
158
  });
158
- } }) }))].flat(), ke = [
159
+ } }) }))].flat(), Ke = function() {
160
+ let e = this.data();
161
+ return (e.toMarkdownExtensions ??= []).push({ handlers: { colorTextSpan(e, t, n) {
162
+ let r = Y(e.color ?? "") ?? "";
163
+ if (r.length === 0) return n.containerPhrasing(e, {
164
+ before: "",
165
+ after: ""
166
+ });
167
+ let i = n.containerPhrasing(e, {
168
+ before: ">",
169
+ after: "<"
170
+ });
171
+ return `${we(r)}${i}${Ce()}`;
172
+ } } }), (e) => {
173
+ t(e);
174
+ };
175
+ function t(e) {
176
+ if (Array.isArray(e.children)) {
177
+ let n = Je(e.children);
178
+ e.children = n;
179
+ for (let e of n) t(e);
180
+ }
181
+ }
182
+ };
183
+ function Q(e) {
184
+ return !!e && e.type === "html" && typeof e.value == "string";
185
+ }
186
+ function qe(e, t) {
187
+ let n = 1;
188
+ for (let r = t + 1; r < e.length; r++) {
189
+ let t = e[r];
190
+ if (Q(t)) {
191
+ if (J(t.value)) {
192
+ n++;
193
+ continue;
194
+ }
195
+ if (Se(t.value) && (n--, n === 0)) return r;
196
+ }
197
+ }
198
+ return null;
199
+ }
200
+ function Je(e) {
201
+ let t = [], n = 0;
202
+ for (; n < e.length;) {
203
+ let r = e[n];
204
+ if (Q(r)) {
205
+ let i = J(r.value);
206
+ if (i) {
207
+ let r = qe(e, n);
208
+ if (r !== null) {
209
+ let a = Je(e.slice(n + 1, r)), o = {
210
+ type: "colorTextSpan",
211
+ color: i.color,
212
+ children: a,
213
+ data: { color: i.color }
214
+ };
215
+ t.push(o), n = r + 1;
216
+ continue;
217
+ }
218
+ }
219
+ }
220
+ t.push(r), n++;
221
+ }
222
+ return t;
223
+ }
224
+ var Ye = [ye("textColor", () => Ke), _e("text_color", () => ({
225
+ attrs: { color: { default: "" } },
226
+ inclusive: !0,
227
+ parseDOM: [{
228
+ tag: "span[style*=\"color\"]",
229
+ getAttrs(e) {
230
+ if (typeof e == "string") return !1;
231
+ let t = e;
232
+ for (let e of Array.from(t.attributes)) if (!(e.name === "style" || e.name === "class")) return !1;
233
+ let n = (t.getAttribute("style") ?? "").split(";").map((e) => e.trim()).filter((e) => e.length > 0);
234
+ if (n.length !== 1) return !1;
235
+ let r = n[0], i = r.indexOf(":");
236
+ if (i < 0 || r.slice(0, i).trim().toLowerCase() !== "color") return !1;
237
+ let a = Y(r.slice(i + 1));
238
+ return a === null ? !1 : { color: a };
239
+ }
240
+ }],
241
+ toDOM: (e) => {
242
+ let t = Y(String(e.attrs.color ?? "")) ?? "";
243
+ return t.length === 0 ? [
244
+ "span",
245
+ {},
246
+ 0
247
+ ] : [
248
+ "span",
249
+ { style: `color: ${t}` },
250
+ 0
251
+ ];
252
+ },
253
+ parseMarkdown: {
254
+ match: (e) => e.type === "colorTextSpan",
255
+ runner: (e, t, n) => {
256
+ let r = Y(typeof t.color == "string" ? t.color : typeof t.data?.color == "string" ? t.data.color : "") ?? "";
257
+ if (r.length === 0) {
258
+ e.next(t.children);
259
+ return;
260
+ }
261
+ e.openMark(n, { color: r }), e.next(t.children), e.closeMark(n);
262
+ }
263
+ },
264
+ toMarkdown: {
265
+ match: (e) => e.type.name === "text_color",
266
+ runner: (e, t) => {
267
+ let n = Y(String(t.attrs.color ?? "")) ?? "";
268
+ n.length !== 0 && e.withMark(t, "colorTextSpan", void 0, { color: n });
269
+ }
270
+ }
271
+ }))].flat(), Xe = [
272
+ {
273
+ name: "Default",
274
+ value: ""
275
+ },
276
+ {
277
+ name: "Red",
278
+ value: "#dc2626"
279
+ },
280
+ {
281
+ name: "Orange",
282
+ value: "#ea580c"
283
+ },
284
+ {
285
+ name: "Yellow",
286
+ value: "#ca8a04"
287
+ },
288
+ {
289
+ name: "Green",
290
+ value: "#16a34a"
291
+ },
292
+ {
293
+ name: "Blue",
294
+ value: "#2563eb"
295
+ },
296
+ {
297
+ name: "Purple",
298
+ value: "#7c3aed"
299
+ },
300
+ {
301
+ name: "Pink",
302
+ value: "#db2777"
303
+ },
304
+ {
305
+ name: "Gray",
306
+ value: "#6b7280"
307
+ }
308
+ ], Ze = { class: "coar-md-color-grid" }, Qe = [
309
+ "title",
310
+ "aria-label",
311
+ "onMousedown"
312
+ ], $e = { class: "coar-md-color-custom" }, et = /* @__PURE__ */ l({
313
+ __name: "ColorPickerPanel",
314
+ props: {
315
+ currentColor: {},
316
+ pick: { type: Function }
317
+ },
318
+ setup(t) {
319
+ let n = g(t.currentColor ?? "#000000");
320
+ return (r, c) => (h(), o("div", {
321
+ class: "coar-md-color-picker",
322
+ role: "menu",
323
+ onMousedown: c[2] ||= T(() => {}, ["stop"])
324
+ }, [s("div", Ze, [(h(!0), o(e, null, _(y(Xe), (e) => (h(), o("button", {
325
+ key: e.value || "default",
326
+ type: "button",
327
+ class: p([
328
+ "coar-md-color-swatch",
329
+ e.value === "" ? "coar-md-color-swatch--clear" : "",
330
+ e.value !== "" && t.currentColor === e.value ? "coar-md-color-swatch--active" : ""
331
+ ]),
332
+ style: m(e.value ? { "--coar-md-swatch": e.value } : void 0),
333
+ title: e.name,
334
+ "aria-label": e.name,
335
+ onMousedown: T((n) => t.pick(e.value === "" ? null : e.value), ["prevent"])
336
+ }, [e.value === "" ? (h(), i(y(I), {
337
+ key: 0,
338
+ name: "ban",
339
+ size: "s"
340
+ })) : a("", !0)], 46, Qe))), 128))]), s("div", $e, [c[3] ||= s("label", {
341
+ class: "coar-md-color-custom-label",
342
+ for: "coar-md-color-custom-input"
343
+ }, " Custom ", -1), w(s("input", {
344
+ id: "coar-md-color-custom-input",
345
+ "onUpdate:modelValue": c[0] ||= (e) => n.value = e,
346
+ type: "color",
347
+ class: "coar-md-color-custom-input",
348
+ onChange: c[1] ||= (e) => t.pick(n.value)
349
+ }, null, 544), [[x, n.value]])])], 32));
350
+ }
351
+ }), tt = [
159
352
  "bold",
160
353
  "italic",
161
354
  "strikethrough",
162
355
  "inlineCode",
356
+ "textColor",
163
357
  "headings",
164
358
  "bulletList",
165
359
  "orderedList",
@@ -175,26 +369,26 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
175
369
  "undo",
176
370
  "redo"
177
371
  ], $ = {
178
- bold: { command: ae },
179
- italic: { command: re },
180
- strike: { command: he },
181
- code: { command: ie },
372
+ bold: { command: pe },
373
+ italic: { command: de },
374
+ strike: { command: Me },
375
+ code: { command: fe },
182
376
  bulletList: { command: G },
183
- orderedList: { command: q },
184
- blockquote: { command: W },
185
- hr: { command: V },
186
- codeBlock: { command: B },
187
- table: { command: me },
188
- undo: { command: ve },
189
- redo: { command: _e },
190
- paragraph: { command: U },
191
- addRowBefore: { command: de },
192
- addRowAfter: { command: ue },
193
- addColBefore: { command: le },
194
- addColAfter: { command: ce },
195
- deleteCell: { command: fe },
196
- indent: { command: ne },
197
- outdent: { command: H },
377
+ orderedList: { command: he },
378
+ blockquote: { command: me },
379
+ hr: { command: le },
380
+ codeBlock: { command: ce },
381
+ table: { command: je },
382
+ undo: { command: Fe },
383
+ redo: { command: Pe },
384
+ paragraph: { command: W },
385
+ addRowBefore: { command: Oe },
386
+ addRowAfter: { command: De },
387
+ addColBefore: { command: Ee },
388
+ addColAfter: { command: Te },
389
+ deleteCell: { command: ke },
390
+ indent: { command: ue },
391
+ outdent: { command: U },
198
392
  h1: {
199
393
  command: K,
200
394
  payload: 1
@@ -219,7 +413,7 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
219
413
  command: K,
220
414
  payload: 6
221
415
  }
222
- }, Ae = o({
416
+ }, nt = l({
223
417
  props: {
224
418
  initialValue: {
225
419
  type: String,
@@ -275,29 +469,29 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
275
469
  }
276
470
  },
277
471
  setup(e) {
278
- let t = p(e.initialValue);
279
- k((n) => S.make().config((r) => {
280
- r.set(D, n), r.set(w, e.initialValue), r.update(E, (t) => ({
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) => ({
281
475
  ...t,
282
476
  editable: () => !e.readonly
283
- })), r.get(Z).markdownUpdated((n, r) => {
477
+ })), r.get(X).markdownUpdated((n, r) => {
284
478
  r !== t.value && (t.value = r, e.onMarkdownChange(r));
285
479
  });
286
- }).use(z).use(pe).use(ge).use(ye).use(be).use(Oe));
287
- let [, n] = A();
288
- return y(() => e.externalValue.value, (e) => {
480
+ }).use(H).use(Ae).use(Ne).use(Ie).use(Le).use(Ye).use(Ge));
481
+ let [, n] = P();
482
+ return C(() => e.externalValue.value, (e) => {
289
483
  if (e === t.value) return;
290
484
  let r = n();
291
- r && (t.value = e, r.action(se(e)));
292
- }), y(() => e.readonly, () => {
485
+ r && (t.value = e, r.action(xe(e)));
486
+ }), C(() => e.readonly, () => {
293
487
  let t = n();
294
488
  t && t.action((t) => {
295
- t.update(E, (t) => ({
489
+ t.update(A, (t) => ({
296
490
  ...t,
297
491
  editable: () => !e.readonly
298
- })), t.get(T).update(t.get(T).props);
492
+ })), t.get(k).update(t.get(k).props);
299
493
  });
300
- }), () => s(je, {
494
+ }), () => u(rt, {
301
495
  readonly: e.readonly,
302
496
  disabled: e.disabled,
303
497
  toolbarMode: e.toolbarMode,
@@ -310,7 +504,7 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
310
504
  required: e.required
311
505
  });
312
506
  }
313
- }), je = o({
507
+ }), rt = l({
314
508
  props: {
315
509
  readonly: {
316
510
  type: Boolean,
@@ -353,15 +547,16 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
353
547
  required: !0
354
548
  }
355
549
  },
356
- setup(n) {
357
- let [, r] = A(), i = p(null), a = p(!1), o = p({
550
+ setup(e) {
551
+ let [, r] = P(), i = g(null), a = g(!1), o = g({
358
552
  left: "0px",
359
553
  top: "0px"
360
- }), c = p("text"), l = p(!1), f = {
554
+ }), s = g("text"), c = g(!1), l = {
361
555
  strong: !1,
362
556
  emphasis: !1,
363
557
  strike_through: !1,
364
558
  inlineCode: !1,
559
+ text_color: null,
365
560
  bullet_list: !1,
366
561
  ordered_list: !1,
367
562
  task_list: !1,
@@ -370,46 +565,94 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
370
565
  table: !1,
371
566
  code_block: !1,
372
567
  list_item_depth: 0
373
- }, m = p({ ...f });
374
- function h(e) {
375
- if (n.readonly) return;
376
- let t = r();
377
- t && (t.action((t) => {
378
- t.get(C).call(e.command.key, e.payload);
379
- }), x());
568
+ }, d = se(), p = null, m = g({ ...l });
569
+ function h(t) {
570
+ if (e.readonly) return;
571
+ let n = r();
572
+ n && (n.action((e) => {
573
+ e.get(D).call(t.command.key, t.payload);
574
+ }), w());
380
575
  }
381
- function g(e) {
382
- if (n.readonly) return;
383
- let t = e === "bullet_list" ? $.bulletList : $.orderedList, r = Se({
384
- target: e,
576
+ function _(t) {
577
+ if (e.readonly) return;
578
+ let n = t === "bullet_list" ? $.bulletList : $.orderedList, r = ze({
579
+ target: t,
385
580
  inBulletList: m.value.bullet_list,
386
581
  inOrderedList: m.value.ordered_list
387
582
  });
388
583
  if (r === "lift") {
389
- h({ command: H });
584
+ h({ command: U });
390
585
  return;
391
586
  }
392
- r === "switch" && h({ command: H }), h(t);
587
+ r === "switch" && h({ command: U }), h(n);
393
588
  }
394
- let _ = t(() => n.tools ? new Set(n.tools) : void 0);
395
- function v(e) {
396
- return xe(e, _.value);
589
+ let v = n(() => e.tools ? new Set(e.tools) : void 0);
590
+ function y(e) {
591
+ return Re(e, v.value);
397
592
  }
398
- function y() {
399
- if (n.readonly) return;
400
- let e = r();
401
- e && e.action((e) => {
402
- let t = e.get(T), { state: n } = t, r = n.tr, { from: i, to: a, empty: o } = n.selection;
593
+ function ne(t) {
594
+ if (e.readonly) return;
595
+ let n = r();
596
+ if (!n) return;
597
+ let i = t === null ? null : Y(t);
598
+ n.action((e) => {
599
+ let t = e.get(k), { state: n } = t, r = n.schema.marks.text_color;
600
+ if (!r) return;
601
+ let { from: a, to: o, empty: s } = n.selection;
602
+ if (s) {
603
+ let e = (n.storedMarks ?? n.selection.$from.marks()).filter((e) => e.type !== r), a = i ? [...e, r.create({ color: i })] : e;
604
+ t.dispatch(n.tr.setStoredMarks(a));
605
+ } else {
606
+ let e = n.tr.removeMark(a, o, r);
607
+ i && (e = e.addMark(a, o, r.create({ color: i }))), t.dispatch(e);
608
+ }
609
+ }), x(), w();
610
+ }
611
+ function b(e) {
612
+ if (e) {
613
+ if (p && !p.isClosed) {
614
+ x();
615
+ return;
616
+ }
617
+ p = d.open({
618
+ spec: {
619
+ ...oe,
620
+ anchor: {
621
+ kind: "element",
622
+ element: e
623
+ }
624
+ },
625
+ content: {
626
+ kind: "component",
627
+ component: f(et)
628
+ },
629
+ inputs: {
630
+ currentColor: m.value.text_color,
631
+ pick: (e) => ne(e)
632
+ }
633
+ }), p.afterClosed.then(() => {
634
+ p?.isClosed && (p = null);
635
+ });
636
+ }
637
+ }
638
+ function x() {
639
+ p && !p.isClosed && p.close(), p = null;
640
+ }
641
+ function S() {
642
+ if (e.readonly) return;
643
+ let t = r();
644
+ t && t.action((e) => {
645
+ let t = e.get(k), { state: n } = t, r = n.tr, { from: i, to: a, empty: o } = n.selection;
403
646
  o ? r = r.setStoredMarks([]) : Object.values(n.schema.marks).forEach((e) => {
404
647
  r = r.removeMark(i, a, e);
405
- }), t.dispatch(r), e.get(C).call(U.key);
648
+ }), t.dispatch(r), e.get(D).call(W.key);
406
649
  });
407
650
  }
408
- function b() {
409
- if (n.readonly) return;
410
- let e = r();
411
- e && e.action((t) => {
412
- let n = t.get(T), { $from: r } = n.state.selection;
651
+ function C() {
652
+ if (e.readonly) return;
653
+ let t = r();
654
+ t && t.action((e) => {
655
+ let n = e.get(k), { $from: r } = n.state.selection;
413
656
  for (let e = r.depth; e > 0; e--) {
414
657
  let t = r.node(e);
415
658
  if (t.type.name === "list_item") {
@@ -418,9 +661,9 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
418
661
  return;
419
662
  }
420
663
  }
421
- t.get(C).call(G.key), queueMicrotask(() => {
422
- e.action((e) => {
423
- let t = e.get(T), { $from: n } = t.state.selection;
664
+ e.get(D).call(G.key), queueMicrotask(() => {
665
+ t.action((e) => {
666
+ let t = e.get(k), { $from: n } = t.state.selection;
424
667
  for (let e = n.depth; e > 0; e--) if (n.node(e).type.name === "list_item") {
425
668
  t.dispatch(t.state.tr.setNodeAttribute(n.before(e), "checked", !1));
426
669
  return;
@@ -429,11 +672,11 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
429
672
  });
430
673
  });
431
674
  }
432
- function x() {
675
+ function w() {
433
676
  let e = r();
434
677
  if (e) try {
435
678
  e.action((e) => {
436
- let t = e.get(T).state, { from: n, to: r, empty: i, $from: a } = t.selection, o = t.storedMarks, s = { ...f }, c = (e) => {
679
+ let t = e.get(k).state, { from: n, to: r, empty: i, $from: a } = t.selection, o = t.storedMarks, s = { ...l }, c = (e) => {
437
680
  let s = t.schema.marks[e];
438
681
  if (!s) return !1;
439
682
  if (i) {
@@ -443,6 +686,23 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
443
686
  return t.doc.rangeHasMark(n, r, s);
444
687
  };
445
688
  s.strong = c("strong"), s.emphasis = c("emphasis"), s.strike_through = c("strike_through"), s.inlineCode = c("inlineCode");
689
+ let u = t.schema.marks.text_color;
690
+ u && (s.text_color = (() => {
691
+ if (i) {
692
+ let e = (o ?? a.marks()).find((e) => e.type === u), t = typeof e?.attrs.color == "string" ? e.attrs.color : null;
693
+ return t ? Y(t) : null;
694
+ }
695
+ let e = null;
696
+ return t.doc.nodesBetween(n, r, (t) => {
697
+ if (e) return !1;
698
+ let n = t.marks.find((e) => e.type === u);
699
+ if (n) {
700
+ let t = typeof n.attrs.color == "string" ? n.attrs.color : null;
701
+ e = t ? Y(t) : null;
702
+ }
703
+ return e === null;
704
+ }), e;
705
+ })());
446
706
  for (let e = a.depth; e > 0; e--) {
447
707
  let t = a.node(e), n = t.type.name;
448
708
  n === "bullet_list" ? s.bullet_list = !0 : n === "ordered_list" ? s.ordered_list = !0 : n === "blockquote" ? s.blockquote = !0 : n === "heading" ? s.heading = t.attrs.level ?? null : n === "table" ? s.table = !0 : n === "code_block" ? s.code_block = !0 : n === "list_item" && (s.list_item_depth += 1, t.attrs.checked != null && (s.task_list = !0));
@@ -450,32 +710,32 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
450
710
  m.value = s;
451
711
  });
452
712
  } catch {
453
- m.value = { ...f };
713
+ m.value = { ...l };
454
714
  }
455
715
  }
456
- function S(e) {
457
- if (n.readonly) return;
458
- let t = e.target, i = t.closest("li[data-item-type=\"task\"]");
716
+ function T(t) {
717
+ if (e.readonly) return;
718
+ let n = t.target, i = n.closest("li[data-item-type=\"task\"]");
459
719
  if (i) {
460
- let t = i.getBoundingClientRect();
461
- if (e.clientX - t.left < 18) {
462
- e.preventDefault(), w(i);
720
+ let e = i.getBoundingClientRect();
721
+ if (t.clientX - e.left < 18) {
722
+ t.preventDefault(), E(i);
463
723
  return;
464
724
  }
465
725
  }
466
- if (t.closest(".ProseMirror")) return;
726
+ if (n.closest(".ProseMirror")) return;
467
727
  let a = r();
468
- a && (e.preventDefault(), a.action((e) => {
469
- let t = e.get(T);
728
+ a && (t.preventDefault(), a.action((e) => {
729
+ let t = e.get(k);
470
730
  t.focus();
471
- let n = t.state.tr.setSelection(Y.atEnd(t.state.doc));
731
+ let n = t.state.tr.setSelection(q.atEnd(t.state.doc));
472
732
  t.dispatch(n);
473
733
  }));
474
734
  }
475
- function w(e) {
735
+ function E(e) {
476
736
  let t = r();
477
737
  t && t.action((t) => {
478
- let n = t.get(T), r = n.posAtDOM(e, 0);
738
+ let n = t.get(k), r = n.posAtDOM(e, 0);
479
739
  if (r < 0) return;
480
740
  let i = n.state.doc.resolve(r);
481
741
  for (let e = i.depth; e >= 0; e--) {
@@ -488,13 +748,13 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
488
748
  }
489
749
  });
490
750
  }
491
- function E() {
751
+ function O() {
492
752
  let e = r();
493
753
  if (!e) return "text";
494
754
  try {
495
755
  let t = "text";
496
756
  return e.action((e) => {
497
- let { $from: n } = e.get(T).state.selection;
757
+ let { $from: n } = e.get(k).state.selection;
498
758
  for (let e = n.depth; e > 0; e--) if (n.node(e).type.name === "table") {
499
759
  t = "table";
500
760
  break;
@@ -504,70 +764,70 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
504
764
  return "text";
505
765
  }
506
766
  }
507
- function D(e) {
767
+ function A(e) {
508
768
  let t = e.left + e.width / 2, n = e.top - 8;
509
769
  t = Math.max(108, Math.min(t, window.innerWidth - 108)), n < 50 && (n = e.bottom + 8), o.value = {
510
770
  left: `${t}px`,
511
771
  top: `${n}px`
512
772
  };
513
773
  }
514
- function O() {
515
- if (n.readonly || n.toolbarMode === "fixed") {
774
+ function j() {
775
+ if (e.readonly || e.toolbarMode === "fixed") {
516
776
  a.value = !1;
517
777
  return;
518
778
  }
519
- let e = window.getSelection();
520
- if (!e || e.isCollapsed || !e.rangeCount) {
521
- a.value = !1, l.value = !1;
779
+ let t = window.getSelection();
780
+ if (!t || t.isCollapsed || !t.rangeCount) {
781
+ a.value = !1, c.value = !1;
522
782
  return;
523
783
  }
524
- let t = e.getRangeAt(0), r = i.value?.querySelector(".coar-md-area .milkdown");
525
- if (!r || !r.contains(t.commonAncestorContainer)) {
526
- a.value = !1, l.value = !1;
784
+ let n = t.getRangeAt(0), r = i.value?.querySelector(".coar-md-area .milkdown");
785
+ if (!r || !r.contains(n.commonAncestorContainer)) {
786
+ a.value = !1, c.value = !1;
527
787
  return;
528
788
  }
529
- D(t.getBoundingClientRect()), c.value = E(), a.value = !0, l.value = !1;
789
+ A(n.getBoundingClientRect()), s.value = O(), a.value = !0, c.value = !1;
530
790
  }
531
- function k(e) {
791
+ function M(e) {
532
792
  let t = e.target;
533
- t.closest(".coar-md-floating-toolbar") || t.closest(".coar-md-float-submenu") || (!i.value || !i.value.contains(t)) && (a.value = !1, l.value = !1);
793
+ 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);
534
794
  }
535
- let j = null;
536
- function N(e = 20) {
795
+ let N = null;
796
+ function F(e = 20) {
537
797
  let t = r();
538
798
  if (!t) {
539
- e > 0 && setTimeout(() => N(e - 1), 50);
799
+ e > 0 && setTimeout(() => F(e - 1), 50);
540
800
  return;
541
801
  }
542
802
  try {
543
803
  t.action((e) => {
544
- let t = e.get(Z);
545
- j = () => queueMicrotask(x), t.selectionUpdated(j);
804
+ let t = e.get(X);
805
+ N = () => queueMicrotask(w), t.selectionUpdated(N);
546
806
  });
547
807
  } catch {
548
- e > 0 && setTimeout(() => N(e - 1), 50);
808
+ e > 0 && setTimeout(() => F(e - 1), 50);
549
809
  }
550
810
  }
551
811
  function L() {
552
- if (!j) return;
812
+ if (!N) return;
553
813
  let e = r();
554
814
  if (e) {
555
815
  try {
556
816
  e.action((e) => {
557
- let t = e.get(Z).listeners.selectionUpdated, n = t.indexOf(j);
817
+ let t = e.get(X).listeners.selectionUpdated, n = t.indexOf(N);
558
818
  n >= 0 && t.splice(n, 1);
559
819
  });
560
820
  } catch {}
561
- j = null;
821
+ N = null;
562
822
  }
563
823
  }
564
- d(() => {
565
- document.addEventListener("selectionchange", O), document.addEventListener("mousedown", k, !0), N();
566
- }), u(() => {
567
- document.removeEventListener("selectionchange", O), document.removeEventListener("mousedown", k, !0), L();
824
+ te(() => {
825
+ document.addEventListener("selectionchange", j), document.addEventListener("mousedown", M, !0), F();
826
+ }), ee(() => {
827
+ document.removeEventListener("selectionchange", j), document.removeEventListener("mousedown", M, !0), L(), x();
568
828
  });
569
- function R(e, t, n, r = {}) {
570
- return s(I, {
829
+ function B(e, t, n, r = {}) {
830
+ return u(z, {
571
831
  icon: e,
572
832
  label: t,
573
833
  active: r.active ?? !1,
@@ -575,86 +835,93 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
575
835
  onClick: r.disabled ? () => {} : r.onClick ?? (() => h(n))
576
836
  });
577
837
  }
578
- function z() {
579
- let e = m.value, t = e.heading != null;
838
+ function V() {
839
+ let t = m.value, n = t.heading != null;
580
840
  function r(e, t, n) {
581
- v(t) && e.push(n);
841
+ y(t) && e.push(n);
582
842
  }
583
843
  function i(e) {
584
- e.length !== 0 && e[e.length - 1]?.type !== P && e.push(s(P));
844
+ e.length !== 0 && e[e.length - 1]?.type !== R && e.push(u(R));
585
845
  }
586
846
  let a = [];
587
- return r(a, "bold", R("bold", "Bold", $.bold, { active: e.strong })), r(a, "italic", R("italic", "Italic", $.italic, { active: e.emphasis })), r(a, "strikethrough", R("strikethrough", "Strikethrough", $.strike, { active: e.strike_through })), r(a, "inlineCode", R("code", "Inline Code", $.code, { active: e.inlineCode })), r(a, "headings", s(F, {
847
+ 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, {
848
+ icon: "palette",
849
+ label: "Text Color",
850
+ active: t.text_color !== null,
851
+ onClick: (e) => {
852
+ b(e.currentTarget ?? e.target);
853
+ }
854
+ })), r(a, "headings", u(ae, {
588
855
  icon: "hash",
589
- label: t ? `Heading ${e.heading}` : "Headings",
856
+ label: n ? `Heading ${t.heading}` : "Headings",
590
857
  mode: "flyout",
591
858
  openOnHover: !0
592
859
  }, { default: () => [
593
- s(I, {
860
+ u(z, {
594
861
  icon: "pilcrow",
595
862
  label: "Paragraph",
596
- active: !t,
863
+ active: !n,
597
864
  onClick: () => h($.paragraph)
598
865
  }),
599
- s(I, {
866
+ u(z, {
600
867
  icon: "heading",
601
868
  label: "Heading 1",
602
- active: e.heading === 1,
869
+ active: t.heading === 1,
603
870
  onClick: () => h($.h1)
604
871
  }),
605
- s(I, {
872
+ u(z, {
606
873
  icon: "heading",
607
874
  label: "Heading 2",
608
- active: e.heading === 2,
875
+ active: t.heading === 2,
609
876
  onClick: () => h($.h2)
610
877
  }),
611
- s(I, {
878
+ u(z, {
612
879
  icon: "heading",
613
880
  label: "Heading 3",
614
- active: e.heading === 3,
881
+ active: t.heading === 3,
615
882
  onClick: () => h($.h3)
616
883
  }),
617
- s(I, {
884
+ u(z, {
618
885
  icon: "heading",
619
886
  label: "Heading 4",
620
- active: e.heading === 4,
887
+ active: t.heading === 4,
621
888
  onClick: () => h($.h4)
622
889
  }),
623
- s(I, {
890
+ u(z, {
624
891
  icon: "heading",
625
892
  label: "Heading 5",
626
- active: e.heading === 5,
893
+ active: t.heading === 5,
627
894
  onClick: () => h($.h5)
628
895
  }),
629
- s(I, {
896
+ u(z, {
630
897
  icon: "heading",
631
898
  label: "Heading 6",
632
- active: e.heading === 6,
899
+ active: t.heading === 6,
633
900
  onClick: () => h($.h6)
634
901
  })
635
- ] })), i(a), r(a, "bulletList", R("list", "Bullet List", $.bulletList, {
636
- active: e.bullet_list,
637
- onClick: () => g("bullet_list")
638
- })), r(a, "orderedList", R("list-ordered", "Ordered List", $.orderedList, {
639
- active: e.ordered_list,
640
- onClick: () => g("ordered_list")
641
- })), r(a, "taskList", R("clipboard-check", "Task List", $.bulletList, {
642
- active: e.task_list,
643
- onClick: b
644
- })), r(a, "outdent", R("indent-decrease", "Outdent", $.outdent, { disabled: e.list_item_depth < 2 })), r(a, "indent", R("indent-increase", "Indent", $.indent, { disabled: e.list_item_depth < 1 })), r(a, "blockquote", R("text-quote", "Blockquote", $.blockquote, { active: e.blockquote })), r(a, "horizontalRule", R("minus", "Horizontal Rule", $.hr)), i(a), r(a, "codeBlock", R("square-code", "Code Block", $.codeBlock, { active: e.code_block })), r(a, "table", R("table", "Insert Table", $.table, { active: e.table })), e.table && v("tableOps") && (i(a), a.push(R("between-vertical-start", "Insert Row Above", $.addRowBefore)), a.push(R("between-vertical-end", "Insert Row Below", $.addRowAfter)), a.push(R("between-horizontal-start", "Insert Column Left", $.addColBefore)), a.push(R("between-horizontal-end", "Insert Column Right", $.addColAfter)), a.push(R("trash-2", "Delete Cell", $.deleteCell))), v("clearFormatting") && (i(a), a.push(R("eraser", "Clear Formatting", $.bold, { onClick: y }))), i(a), r(a, "undo", R("undo-2", "Undo", $.undo)), r(a, "redo", R("redo-2", "Redo", $.redo)), a[a.length - 1]?.type === P && a.pop(), s("div", {
902
+ ] })), i(a), r(a, "bulletList", B("list", "Bullet List", $.bulletList, {
903
+ active: t.bullet_list,
904
+ onClick: () => _("bullet_list")
905
+ })), r(a, "orderedList", B("list-ordered", "Ordered List", $.orderedList, {
906
+ active: t.ordered_list,
907
+ onClick: () => _("ordered_list")
908
+ })), r(a, "taskList", B("clipboard-check", "Task List", $.bulletList, {
909
+ active: t.task_list,
910
+ onClick: C
911
+ })), 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 && y("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))), y("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", {
645
912
  key: "sidebar",
646
913
  class: "coar-md-sidebar-wrap",
647
914
  onMousedown: (e) => e.preventDefault()
648
- }, [s(te, {
915
+ }, [u(ie, {
649
916
  collapsed: !0,
650
- side: n.toolbarPosition,
917
+ side: e.toolbarPosition,
651
918
  size: "s",
652
919
  variant: "primary",
653
920
  borderless: !0
654
921
  }, { default: () => a })]);
655
922
  }
656
- function B() {
657
- let t = (e, t, n, r = {}) => s("button", {
923
+ function H() {
924
+ let e = (e, t, n, r = {}) => u("button", {
658
925
  class: [
659
926
  "coar-md-float-btn",
660
927
  r.isActive ? "coar-md-float-btn--active" : "",
@@ -666,28 +933,43 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
666
933
  onMousedown: (e) => {
667
934
  e.preventDefault(), !r.disabled && (r.onClick ?? (() => h(n)))();
668
935
  }
669
- }, [s(M, {
936
+ }, [u(I, {
670
937
  name: e,
671
938
  size: "s"
672
- })]), n = () => s("div", { class: "coar-md-float-sep" }), r = m.value;
939
+ })]), n = () => u("div", { class: "coar-md-float-sep" }), r = m.value;
673
940
  function i(e, t, n) {
674
- v(t) && e.push(n);
941
+ y(t) && e.push(n);
675
942
  }
676
943
  function a(e) {
677
944
  e.length !== 0 && e[e.length - 1]?.props?.class !== "coar-md-float-sep" && e.push(n());
678
945
  }
679
- let u = [];
680
- i(u, "bold", t("bold", "Bold", $.bold, { isActive: r.strong })), i(u, "italic", t("italic", "Italic", $.italic, { isActive: r.emphasis })), i(u, "strikethrough", t("strikethrough", "Strikethrough", $.strike, { isActive: r.strike_through })), i(u, "inlineCode", t("code", "Inline Code", $.code, { isActive: r.inlineCode })), v("headings") && (a(u), u.push(s("div", { class: "coar-md-float-dropdown" }, [s("button", {
681
- class: ["coar-md-float-btn", l.value || r.heading != null ? "coar-md-float-btn--active" : ""],
946
+ let l = [];
947
+ 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 })), y("textColor")) {
948
+ let e = r.text_color !== null;
949
+ l.push(u("button", {
950
+ class: ["coar-md-float-btn", e ? "coar-md-float-btn--active" : ""],
951
+ type: "button",
952
+ title: e ? `Text Color (${r.text_color})` : "Text Color",
953
+ style: e ? `--coar-md-color-indicator: ${r.text_color};` : void 0,
954
+ onMousedown: (e) => {
955
+ e.preventDefault(), b(e.currentTarget);
956
+ }
957
+ }, [u(I, {
958
+ name: "palette",
959
+ size: "s"
960
+ })]));
961
+ }
962
+ y("headings") && (a(l), l.push(u("div", { class: "coar-md-float-dropdown" }, [u("button", {
963
+ class: ["coar-md-float-btn", c.value || r.heading != null ? "coar-md-float-btn--active" : ""],
682
964
  title: r.heading == null ? "Headings" : `Heading ${r.heading}`,
683
965
  type: "button",
684
966
  onMousedown: (e) => {
685
- e.preventDefault(), l.value = !l.value;
967
+ e.preventDefault(), c.value = !c.value;
686
968
  }
687
- }, [s(M, {
969
+ }, [u(I, {
688
970
  name: "heading",
689
971
  size: "s"
690
- })]), l.value ? s("div", { class: "coar-md-float-submenu" }, [
972
+ })]), c.value ? u("div", { class: "coar-md-float-submenu" }, [
691
973
  {
692
974
  label: "Paragraph",
693
975
  cmd: $.paragraph,
@@ -730,84 +1012,84 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
730
1012
  icon: "heading",
731
1013
  activeLevel: 6
732
1014
  }
733
- ].map(({ label: e, cmd: t, icon: n, activeLevel: i }) => s("button", {
1015
+ ].map(({ label: e, cmd: t, icon: n, activeLevel: i }) => u("button", {
734
1016
  class: ["coar-md-float-submenu-item", (i === 0 ? r.heading == null : r.heading === i) ? "coar-md-float-submenu-item--active" : ""],
735
1017
  type: "button",
736
1018
  onMousedown: (e) => {
737
- e.preventDefault(), h(t), l.value = !1;
1019
+ e.preventDefault(), h(t), c.value = !1;
738
1020
  }
739
- }, [s(M, {
1021
+ }, [u(I, {
740
1022
  name: n,
741
1023
  size: "xs"
742
- }), s("span", null, e)]))) : null]))), a(u), i(u, "bulletList", t("list", "Bullet List", $.bulletList, {
1024
+ }), u("span", null, e)]))) : null]))), a(l), i(l, "bulletList", e("list", "Bullet List", $.bulletList, {
743
1025
  isActive: r.bullet_list,
744
- onClick: () => g("bullet_list")
745
- })), i(u, "orderedList", t("list-ordered", "Ordered List", $.orderedList, {
1026
+ onClick: () => _("bullet_list")
1027
+ })), i(l, "orderedList", e("list-ordered", "Ordered List", $.orderedList, {
746
1028
  isActive: r.ordered_list,
747
- onClick: () => g("ordered_list")
748
- })), i(u, "taskList", t("clipboard-check", "Task List", $.bulletList, {
1029
+ onClick: () => _("ordered_list")
1030
+ })), i(l, "taskList", e("clipboard-check", "Task List", $.bulletList, {
749
1031
  isActive: r.task_list,
750
- onClick: b
751
- })), i(u, "outdent", t("indent-decrease", "Outdent", $.outdent, { disabled: r.list_item_depth < 2 })), i(u, "indent", t("indent-increase", "Indent", $.indent, { disabled: r.list_item_depth < 1 })), a(u), i(u, "blockquote", t("text-quote", "Blockquote", $.blockquote, { isActive: r.blockquote })), v("clearFormatting") && (a(u), u.push(t("eraser", "Clear Formatting", $.bold, { onClick: y }))), u[u.length - 1]?.props?.class === "coar-md-float-sep" && u.pop();
1032
+ onClick: C
1033
+ })), 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 })), y("clearFormatting") && (a(l), l.push(e("eraser", "Clear Formatting", $.bold, { onClick: S }))), l[l.length - 1]?.props?.class === "coar-md-float-sep" && l.pop();
752
1034
  let d = {
753
- text: u,
754
- table: v("tableOps") ? [
755
- t("between-vertical-start", "Insert Row Above", $.addRowBefore),
756
- t("between-vertical-end", "Insert Row Below", $.addRowAfter),
1035
+ text: l,
1036
+ table: y("tableOps") ? [
1037
+ e("between-vertical-start", "Insert Row Above", $.addRowBefore),
1038
+ e("between-vertical-end", "Insert Row Below", $.addRowAfter),
757
1039
  n(),
758
- t("between-horizontal-start", "Insert Column Left", $.addColBefore),
759
- t("between-horizontal-end", "Insert Column Right", $.addColAfter),
1040
+ e("between-horizontal-start", "Insert Column Left", $.addColBefore),
1041
+ e("between-horizontal-end", "Insert Column Right", $.addColAfter),
760
1042
  n(),
761
- t("trash-2", "Delete", $.deleteCell),
762
- ...v("bold") || v("italic") || v("inlineCode") ? [n()] : [],
763
- ...v("bold") ? [t("bold", "Bold", $.bold)] : [],
764
- ...v("italic") ? [t("italic", "Italic", $.italic)] : [],
765
- ...v("inlineCode") ? [t("code", "Code", $.code)] : []
766
- ] : u,
767
- "col-selection": v("tableOps") ? [
768
- t("between-horizontal-start", "Insert Column Left", $.addColBefore),
769
- t("between-horizontal-end", "Insert Column Right", $.addColAfter),
1043
+ e("trash-2", "Delete", $.deleteCell),
1044
+ ...y("bold") || y("italic") || y("inlineCode") ? [n()] : [],
1045
+ ...y("bold") ? [e("bold", "Bold", $.bold)] : [],
1046
+ ...y("italic") ? [e("italic", "Italic", $.italic)] : [],
1047
+ ...y("inlineCode") ? [e("code", "Code", $.code)] : []
1048
+ ] : l,
1049
+ "col-selection": y("tableOps") ? [
1050
+ e("between-horizontal-start", "Insert Column Left", $.addColBefore),
1051
+ e("between-horizontal-end", "Insert Column Right", $.addColAfter),
770
1052
  n(),
771
- t("trash-2", "Delete Column", $.deleteCell)
772
- ] : u,
773
- "row-selection": v("tableOps") ? [
774
- t("between-vertical-start", "Insert Row Above", $.addRowBefore),
775
- t("between-vertical-end", "Insert Row Below", $.addRowAfter),
1053
+ e("trash-2", "Delete Column", $.deleteCell)
1054
+ ] : l,
1055
+ "row-selection": y("tableOps") ? [
1056
+ e("between-vertical-start", "Insert Row Above", $.addRowBefore),
1057
+ e("between-vertical-end", "Insert Row Below", $.addRowAfter),
776
1058
  n(),
777
- t("trash-2", "Delete Row", $.deleteCell)
778
- ] : u
1059
+ e("trash-2", "Delete Row", $.deleteCell)
1060
+ ] : l
779
1061
  };
780
- return s(e, { to: "body" }, s("div", {
1062
+ return u(t, { to: "body" }, u("div", {
781
1063
  class: "coar-md-floating-toolbar",
782
1064
  style: `left:${o.value.left};top:${o.value.top};`
783
- }, d[c.value] || u));
1065
+ }, d[s.value] || l));
784
1066
  }
785
1067
  return () => {
786
- let e = n.toolbarMode === "fixed" || n.toolbarMode === "both", t = !n.readonly && (n.toolbarMode === "floating" || n.toolbarMode === "both"), r = [], o = n.toolbarPosition === "left" || n.toolbarPosition === "top", c = n.toolbarPosition === "right" || n.toolbarPosition === "bottom";
787
- return e && o && r.push(z()), r.push(s("div", {
1068
+ 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";
1069
+ return t && o && r.push(V()), r.push(u("div", {
788
1070
  key: "area",
789
1071
  class: ["coar-md-area", "coar-markdown"],
790
- onMousedown: S
791
- }, [s(ee)])), e && c && r.push(z()), a.value && t && r.push(B()), s("div", {
1072
+ onMousedown: T
1073
+ }, [u(re)])), t && s && r.push(V()), a.value && n && r.push(H()), u("div", {
792
1074
  class: {
793
1075
  "coar-md-root": !0,
794
- [`coar-md-root--toolbar-${n.toolbarPosition}`]: !0,
795
- "coar-md-root--disabled": n.disabled,
796
- "coar-md-root--readonly": n.readonly && !n.disabled,
797
- "coar-md-root--error": n.hasError
1076
+ [`coar-md-root--toolbar-${e.toolbarPosition}`]: !0,
1077
+ "coar-md-root--disabled": e.disabled,
1078
+ "coar-md-root--readonly": e.readonly && !e.disabled,
1079
+ "coar-md-root--error": e.hasError
798
1080
  },
799
1081
  ref: i,
800
- id: n.inputId,
801
- "aria-invalid": n.hasError ? "true" : void 0,
802
- "aria-describedby": n.describedBy,
803
- "aria-disabled": n.disabled ? "true" : void 0,
804
- "aria-readonly": n.readonly && !n.disabled ? "true" : void 0,
805
- "aria-required": n.required ? "true" : void 0,
806
- "data-name": n.name
1082
+ id: e.inputId,
1083
+ "aria-invalid": e.hasError ? "true" : void 0,
1084
+ "aria-describedby": e.describedBy,
1085
+ "aria-disabled": e.disabled ? "true" : void 0,
1086
+ "aria-readonly": e.readonly && !e.disabled ? "true" : void 0,
1087
+ "aria-required": e.required ? "true" : void 0,
1088
+ "data-name": e.name
807
1089
  }, r);
808
1090
  };
809
1091
  }
810
- }), Me = o({
1092
+ }), it = l({
811
1093
  name: "CoarMarkdownEditor",
812
1094
  props: {
813
1095
  modelValue: {
@@ -852,13 +1134,13 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
852
1134
  }
853
1135
  },
854
1136
  emits: ["update:modelValue"],
855
- setup(e, { emit: n }) {
856
- let r = e.modelValue, i = m({ value: e.modelValue });
857
- y(() => e.modelValue, (e) => {
1137
+ setup(e, { emit: t }) {
1138
+ let r = e.modelValue, i = v({ value: e.modelValue });
1139
+ C(() => e.modelValue, (e) => {
858
1140
  i.value = { value: e };
859
1141
  });
860
- let a = c(L, void 0), o = `coar-markdown-editor-${g()}`, l = t(() => e.id || a?.inputId.value || o), u = t(() => e.error || (a?.hasError.value ?? !1)), d = t(() => a?.messageId.value), f = t(() => e.disabled || (a?.disabled.value ?? !1)), p = t(() => e.readonly || f.value);
861
- return () => s(O, null, () => s(Ae, {
1142
+ let a = d(B, void 0), o = `coar-markdown-editor-${ne()}`, 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);
1143
+ return () => u(M, null, () => u(nt, {
862
1144
  initialValue: r,
863
1145
  externalValue: i.value,
864
1146
  readonly: p.value,
@@ -866,14 +1148,14 @@ var Ce = { class: "coar-md-code-render" }, we = { class: "coar-md-code-edit" },
866
1148
  toolbarMode: e.toolbarMode,
867
1149
  toolbarPosition: e.toolbarPosition,
868
1150
  tools: e.tools,
869
- inputId: l.value,
870
- hasError: u.value,
871
- describedBy: d.value,
1151
+ inputId: s.value,
1152
+ hasError: c.value,
1153
+ describedBy: l.value,
872
1154
  name: e.name,
873
1155
  required: e.required,
874
- onMarkdownChange: (e) => n("update:modelValue", e)
1156
+ onMarkdownChange: (e) => t("update:modelValue", e)
875
1157
  }));
876
1158
  }
877
1159
  });
878
1160
  //#endregion
879
- export { ke as COAR_MARKDOWN_EDITOR_ALL_TOOLS, Me as CoarMarkdownEditor };
1161
+ export { tt as COAR_MARKDOWN_EDITOR_ALL_TOOLS, it as CoarMarkdownEditor };