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