@cocoar/vue-markdown-editor 1.14.0 → 1.15.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/CoarMarkdownEditor.vue.d.ts +1 -1
- package/dist/CoarMarkdownEditor.vue.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +535 -253
- package/dist/text-color/ColorPickerPanel.vue.d.ts +9 -0
- package/dist/text-color/ColorPickerPanel.vue.d.ts.map +1 -0
- package/dist/text-color/index.d.ts +23 -0
- package/dist/text-color/index.d.ts.map +1 -0
- package/dist/text-color/textColorMark.d.ts +5 -0
- package/dist/text-color/textColorMark.d.ts.map +1 -0
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Editor as
|
|
3
|
-
import { Milkdown as
|
|
4
|
-
import { CoarCodeBlock as
|
|
5
|
-
import { codeBlockSchema as
|
|
6
|
-
import { Plugin as
|
|
7
|
-
import { $prose as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
-
],
|
|
66
|
-
return
|
|
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) => (
|
|
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"]),
|
|
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] ||=
|
|
81
|
-
}, [
|
|
81
|
+
onMousedown: n[0] ||= T((e) => r("enterEdit"), ["prevent"])
|
|
82
|
+
}, [c(y(I), {
|
|
82
83
|
name: "pencil",
|
|
83
84
|
size: "xs"
|
|
84
|
-
}), n[2] ||=
|
|
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:
|
|
88
|
+
options: i,
|
|
88
89
|
size: "s",
|
|
89
|
-
"onUpdate:modelValue": n[1] ||= (e) =>
|
|
90
|
-
}, null, 8, ["model-value"])]),
|
|
90
|
+
"onUpdate:modelValue": n[1] ||= (e) => r("languageChange", String(e))
|
|
91
|
+
}, null, 8, ["model-value"])]), s("div", {
|
|
91
92
|
ref_key: "contentMount",
|
|
92
|
-
ref:
|
|
93
|
+
ref: a,
|
|
93
94
|
class: "coar-md-code-content"
|
|
94
|
-
}, null, 512)], 512), [[
|
|
95
|
+
}, null, 512)], 512), [[S, e.editing]])], 2));
|
|
95
96
|
}
|
|
96
|
-
}),
|
|
97
|
+
}), Z = /* @__PURE__ */ new Set(), We = class {
|
|
97
98
|
dom;
|
|
98
99
|
contentDOM;
|
|
99
100
|
app;
|
|
100
|
-
text =
|
|
101
|
-
language =
|
|
102
|
-
editing =
|
|
103
|
-
constructor(e, t,
|
|
104
|
-
this.node = e, this.view = t, this.getPos =
|
|
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 =
|
|
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: () => () =>
|
|
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
|
-
|
|
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(
|
|
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
|
-
},
|
|
155
|
-
e.state.selection.eq(t.selection) ||
|
|
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(),
|
|
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:
|
|
179
|
-
italic: { command:
|
|
180
|
-
strike: { command:
|
|
181
|
-
code: { command:
|
|
372
|
+
bold: { command: pe },
|
|
373
|
+
italic: { command: de },
|
|
374
|
+
strike: { command: Me },
|
|
375
|
+
code: { command: fe },
|
|
182
376
|
bulletList: { command: G },
|
|
183
|
-
orderedList: { command:
|
|
184
|
-
blockquote: { command:
|
|
185
|
-
hr: { command:
|
|
186
|
-
codeBlock: { command:
|
|
187
|
-
table: { command:
|
|
188
|
-
undo: { command:
|
|
189
|
-
redo: { command:
|
|
190
|
-
paragraph: { command:
|
|
191
|
-
addRowBefore: { command:
|
|
192
|
-
addRowAfter: { command:
|
|
193
|
-
addColBefore: { command:
|
|
194
|
-
addColAfter: { command:
|
|
195
|
-
deleteCell: { command:
|
|
196
|
-
indent: { command:
|
|
197
|
-
outdent: { command:
|
|
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
|
-
},
|
|
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 =
|
|
279
|
-
|
|
280
|
-
r.set(
|
|
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(
|
|
477
|
+
})), r.get(X).markdownUpdated((n, r) => {
|
|
284
478
|
r !== t.value && (t.value = r, e.onMarkdownChange(r));
|
|
285
479
|
});
|
|
286
|
-
}).use(
|
|
287
|
-
let [, n] =
|
|
288
|
-
return
|
|
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(
|
|
292
|
-
}),
|
|
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(
|
|
489
|
+
t.update(A, (t) => ({
|
|
296
490
|
...t,
|
|
297
491
|
editable: () => !e.readonly
|
|
298
|
-
})), t.get(
|
|
492
|
+
})), t.get(k).update(t.get(k).props);
|
|
299
493
|
});
|
|
300
|
-
}), () =>
|
|
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
|
-
}),
|
|
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(
|
|
357
|
-
let [, r] =
|
|
550
|
+
setup(e) {
|
|
551
|
+
let [, r] = P(), i = g(null), a = g(!1), o = g({
|
|
358
552
|
left: "0px",
|
|
359
553
|
top: "0px"
|
|
360
|
-
}),
|
|
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 =
|
|
374
|
-
function h(
|
|
375
|
-
if (
|
|
376
|
-
let
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}),
|
|
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
|
|
382
|
-
if (
|
|
383
|
-
let
|
|
384
|
-
target:
|
|
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:
|
|
584
|
+
h({ command: U });
|
|
390
585
|
return;
|
|
391
586
|
}
|
|
392
|
-
r === "switch" && h({ command:
|
|
587
|
+
r === "switch" && h({ command: U }), h(n);
|
|
393
588
|
}
|
|
394
|
-
let
|
|
395
|
-
function
|
|
396
|
-
return
|
|
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
|
|
399
|
-
if (
|
|
400
|
-
let
|
|
401
|
-
|
|
402
|
-
|
|
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(
|
|
648
|
+
}), t.dispatch(r), e.get(D).call(W.key);
|
|
406
649
|
});
|
|
407
650
|
}
|
|
408
|
-
function
|
|
409
|
-
if (
|
|
410
|
-
let
|
|
411
|
-
|
|
412
|
-
let n =
|
|
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
|
-
|
|
422
|
-
|
|
423
|
-
let t = e.get(
|
|
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
|
|
675
|
+
function w() {
|
|
433
676
|
let e = r();
|
|
434
677
|
if (e) try {
|
|
435
678
|
e.action((e) => {
|
|
436
|
-
let t = e.get(
|
|
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 = { ...
|
|
713
|
+
m.value = { ...l };
|
|
454
714
|
}
|
|
455
715
|
}
|
|
456
|
-
function
|
|
457
|
-
if (
|
|
458
|
-
let
|
|
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
|
|
461
|
-
if (
|
|
462
|
-
|
|
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 (
|
|
726
|
+
if (n.closest(".ProseMirror")) return;
|
|
467
727
|
let a = r();
|
|
468
|
-
a && (
|
|
469
|
-
let t = e.get(
|
|
728
|
+
a && (t.preventDefault(), a.action((e) => {
|
|
729
|
+
let t = e.get(k);
|
|
470
730
|
t.focus();
|
|
471
|
-
let n = t.state.tr.setSelection(
|
|
731
|
+
let n = t.state.tr.setSelection(q.atEnd(t.state.doc));
|
|
472
732
|
t.dispatch(n);
|
|
473
733
|
}));
|
|
474
734
|
}
|
|
475
|
-
function
|
|
735
|
+
function E(e) {
|
|
476
736
|
let t = r();
|
|
477
737
|
t && t.action((t) => {
|
|
478
|
-
let n = t.get(
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
515
|
-
if (
|
|
774
|
+
function j() {
|
|
775
|
+
if (e.readonly || e.toolbarMode === "fixed") {
|
|
516
776
|
a.value = !1;
|
|
517
777
|
return;
|
|
518
778
|
}
|
|
519
|
-
let
|
|
520
|
-
if (!
|
|
521
|
-
a.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
|
|
525
|
-
if (!r || !r.contains(
|
|
526
|
-
a.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
|
-
|
|
789
|
+
A(n.getBoundingClientRect()), s.value = O(), a.value = !0, c.value = !1;
|
|
530
790
|
}
|
|
531
|
-
function
|
|
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,
|
|
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
|
|
536
|
-
function
|
|
795
|
+
let N = null;
|
|
796
|
+
function F(e = 20) {
|
|
537
797
|
let t = r();
|
|
538
798
|
if (!t) {
|
|
539
|
-
e > 0 && setTimeout(() =>
|
|
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(
|
|
545
|
-
|
|
804
|
+
let t = e.get(X);
|
|
805
|
+
N = () => queueMicrotask(w), t.selectionUpdated(N);
|
|
546
806
|
});
|
|
547
807
|
} catch {
|
|
548
|
-
e > 0 && setTimeout(() =>
|
|
808
|
+
e > 0 && setTimeout(() => F(e - 1), 50);
|
|
549
809
|
}
|
|
550
810
|
}
|
|
551
811
|
function L() {
|
|
552
|
-
if (!
|
|
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(
|
|
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
|
-
|
|
821
|
+
N = null;
|
|
562
822
|
}
|
|
563
823
|
}
|
|
564
|
-
|
|
565
|
-
document.addEventListener("selectionchange",
|
|
566
|
-
}),
|
|
567
|
-
document.removeEventListener("selectionchange",
|
|
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
|
|
570
|
-
return
|
|
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
|
|
579
|
-
let
|
|
838
|
+
function V() {
|
|
839
|
+
let t = m.value, n = t.heading != null;
|
|
580
840
|
function r(e, t, n) {
|
|
581
|
-
|
|
841
|
+
y(t) && e.push(n);
|
|
582
842
|
}
|
|
583
843
|
function i(e) {
|
|
584
|
-
e.length !== 0 && e[e.length - 1]?.type !==
|
|
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",
|
|
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:
|
|
856
|
+
label: n ? `Heading ${t.heading}` : "Headings",
|
|
590
857
|
mode: "flyout",
|
|
591
858
|
openOnHover: !0
|
|
592
859
|
}, { default: () => [
|
|
593
|
-
|
|
860
|
+
u(z, {
|
|
594
861
|
icon: "pilcrow",
|
|
595
862
|
label: "Paragraph",
|
|
596
|
-
active: !
|
|
863
|
+
active: !n,
|
|
597
864
|
onClick: () => h($.paragraph)
|
|
598
865
|
}),
|
|
599
|
-
|
|
866
|
+
u(z, {
|
|
600
867
|
icon: "heading",
|
|
601
868
|
label: "Heading 1",
|
|
602
|
-
active:
|
|
869
|
+
active: t.heading === 1,
|
|
603
870
|
onClick: () => h($.h1)
|
|
604
871
|
}),
|
|
605
|
-
|
|
872
|
+
u(z, {
|
|
606
873
|
icon: "heading",
|
|
607
874
|
label: "Heading 2",
|
|
608
|
-
active:
|
|
875
|
+
active: t.heading === 2,
|
|
609
876
|
onClick: () => h($.h2)
|
|
610
877
|
}),
|
|
611
|
-
|
|
878
|
+
u(z, {
|
|
612
879
|
icon: "heading",
|
|
613
880
|
label: "Heading 3",
|
|
614
|
-
active:
|
|
881
|
+
active: t.heading === 3,
|
|
615
882
|
onClick: () => h($.h3)
|
|
616
883
|
}),
|
|
617
|
-
|
|
884
|
+
u(z, {
|
|
618
885
|
icon: "heading",
|
|
619
886
|
label: "Heading 4",
|
|
620
|
-
active:
|
|
887
|
+
active: t.heading === 4,
|
|
621
888
|
onClick: () => h($.h4)
|
|
622
889
|
}),
|
|
623
|
-
|
|
890
|
+
u(z, {
|
|
624
891
|
icon: "heading",
|
|
625
892
|
label: "Heading 5",
|
|
626
|
-
active:
|
|
893
|
+
active: t.heading === 5,
|
|
627
894
|
onClick: () => h($.h5)
|
|
628
895
|
}),
|
|
629
|
-
|
|
896
|
+
u(z, {
|
|
630
897
|
icon: "heading",
|
|
631
898
|
label: "Heading 6",
|
|
632
|
-
active:
|
|
899
|
+
active: t.heading === 6,
|
|
633
900
|
onClick: () => h($.h6)
|
|
634
901
|
})
|
|
635
|
-
] })), i(a), r(a, "bulletList",
|
|
636
|
-
active:
|
|
637
|
-
onClick: () =>
|
|
638
|
-
})), r(a, "orderedList",
|
|
639
|
-
active:
|
|
640
|
-
onClick: () =>
|
|
641
|
-
})), r(a, "taskList",
|
|
642
|
-
active:
|
|
643
|
-
onClick:
|
|
644
|
-
})), r(a, "outdent",
|
|
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
|
-
}, [
|
|
915
|
+
}, [u(ie, {
|
|
649
916
|
collapsed: !0,
|
|
650
|
-
side:
|
|
917
|
+
side: e.toolbarPosition,
|
|
651
918
|
size: "s",
|
|
652
919
|
variant: "primary",
|
|
653
920
|
borderless: !0
|
|
654
921
|
}, { default: () => a })]);
|
|
655
922
|
}
|
|
656
|
-
function
|
|
657
|
-
let
|
|
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
|
-
}, [
|
|
936
|
+
}, [u(I, {
|
|
670
937
|
name: e,
|
|
671
938
|
size: "s"
|
|
672
|
-
})]), n = () =>
|
|
939
|
+
})]), n = () => u("div", { class: "coar-md-float-sep" }), r = m.value;
|
|
673
940
|
function i(e, t, n) {
|
|
674
|
-
|
|
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
|
|
680
|
-
i(
|
|
681
|
-
|
|
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(),
|
|
967
|
+
e.preventDefault(), c.value = !c.value;
|
|
686
968
|
}
|
|
687
|
-
}, [
|
|
969
|
+
}, [u(I, {
|
|
688
970
|
name: "heading",
|
|
689
971
|
size: "s"
|
|
690
|
-
})]),
|
|
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 }) =>
|
|
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),
|
|
1019
|
+
e.preventDefault(), h(t), c.value = !1;
|
|
738
1020
|
}
|
|
739
|
-
}, [
|
|
1021
|
+
}, [u(I, {
|
|
740
1022
|
name: n,
|
|
741
1023
|
size: "xs"
|
|
742
|
-
}),
|
|
1024
|
+
}), u("span", null, e)]))) : null]))), a(l), i(l, "bulletList", e("list", "Bullet List", $.bulletList, {
|
|
743
1025
|
isActive: r.bullet_list,
|
|
744
|
-
onClick: () =>
|
|
745
|
-
})), i(
|
|
1026
|
+
onClick: () => _("bullet_list")
|
|
1027
|
+
})), i(l, "orderedList", e("list-ordered", "Ordered List", $.orderedList, {
|
|
746
1028
|
isActive: r.ordered_list,
|
|
747
|
-
onClick: () =>
|
|
748
|
-
})), i(
|
|
1029
|
+
onClick: () => _("ordered_list")
|
|
1030
|
+
})), i(l, "taskList", e("clipboard-check", "Task List", $.bulletList, {
|
|
749
1031
|
isActive: r.task_list,
|
|
750
|
-
onClick:
|
|
751
|
-
})), i(
|
|
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:
|
|
754
|
-
table:
|
|
755
|
-
|
|
756
|
-
|
|
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
|
-
|
|
759
|
-
|
|
1040
|
+
e("between-horizontal-start", "Insert Column Left", $.addColBefore),
|
|
1041
|
+
e("between-horizontal-end", "Insert Column Right", $.addColAfter),
|
|
760
1042
|
n(),
|
|
761
|
-
|
|
762
|
-
...
|
|
763
|
-
...
|
|
764
|
-
...
|
|
765
|
-
...
|
|
766
|
-
] :
|
|
767
|
-
"col-selection":
|
|
768
|
-
|
|
769
|
-
|
|
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
|
-
|
|
772
|
-
] :
|
|
773
|
-
"row-selection":
|
|
774
|
-
|
|
775
|
-
|
|
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
|
-
|
|
778
|
-
] :
|
|
1059
|
+
e("trash-2", "Delete Row", $.deleteCell)
|
|
1060
|
+
] : l
|
|
779
1061
|
};
|
|
780
|
-
return
|
|
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[
|
|
1065
|
+
}, d[s.value] || l));
|
|
784
1066
|
}
|
|
785
1067
|
return () => {
|
|
786
|
-
let
|
|
787
|
-
return
|
|
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:
|
|
791
|
-
}, [
|
|
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-${
|
|
795
|
-
"coar-md-root--disabled":
|
|
796
|
-
"coar-md-root--readonly":
|
|
797
|
-
"coar-md-root--error":
|
|
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:
|
|
801
|
-
"aria-invalid":
|
|
802
|
-
"aria-describedby":
|
|
803
|
-
"aria-disabled":
|
|
804
|
-
"aria-readonly":
|
|
805
|
-
"aria-required":
|
|
806
|
-
"data-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
|
-
}),
|
|
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:
|
|
856
|
-
let r = e.modelValue, i =
|
|
857
|
-
|
|
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 =
|
|
861
|
-
return () =>
|
|
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:
|
|
870
|
-
hasError:
|
|
871
|
-
describedBy:
|
|
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) =>
|
|
1156
|
+
onMarkdownChange: (e) => t("update:modelValue", e)
|
|
875
1157
|
}));
|
|
876
1158
|
}
|
|
877
1159
|
});
|
|
878
1160
|
//#endregion
|
|
879
|
-
export {
|
|
1161
|
+
export { tt as COAR_MARKDOWN_EDITOR_ALL_TOOLS, it as CoarMarkdownEditor };
|