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