@vespercms/admin 0.1.0-next.0 → 0.1.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{BodyEditor-CAGNfofv.js → BodyEditor-_mkh0BSQ.js} +735 -735
- package/dist/{markdown-KUkv11EB.js → markdown-4fVeej3c.js} +14 -14
- package/dist/schedule/times.d.ts +1 -3
- package/dist/screens/EntryList.d.ts +0 -2
- package/dist/screens/status.d.ts +36 -0
- package/dist/{shortcuts-B_JMAvF9.js → shortcuts-CarKeDqp.js} +534 -498
- package/dist/studio.css +1 -1
- package/dist/studio.js +1873 -1736
- package/dist/widgets/blank-date.d.ts +8 -0
- package/package.json +2 -2
- package/src/github/GitHubGate.tsx +47 -10
- package/src/schedule/ScheduleDialog.tsx +3 -0
- package/src/schedule/times.ts +0 -11
- package/src/screens/EntryEditor.tsx +23 -9
- package/src/screens/EntryList.tsx +24 -26
- package/src/screens/ListPane.tsx +48 -30
- package/src/screens/PageTree.tsx +45 -25
- package/src/screens/status.tsx +104 -0
- package/src/studio.css +5 -0
- package/src/widgets/basic.tsx +5 -1
- package/src/widgets/blank-date.ts +32 -0
- package/src/widgets/special.tsx +5 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { t as e } from "./checks-C-0xDu-I.js";
|
|
2
|
-
import { $ as t,
|
|
3
|
-
import { Fragment as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { assembleBody as
|
|
6
|
-
import { Extension as
|
|
7
|
-
import
|
|
8
|
-
import { Markdown as
|
|
9
|
-
import { NodeSelection as
|
|
10
|
-
import { EditorContent as
|
|
11
|
-
import
|
|
12
|
-
import { Fragment as
|
|
13
|
-
import { closeHistory as
|
|
2
|
+
import { $ as t, A as n, B as r, C as i, H as a, I as o, V as s, X as c, b as l, c as u, ct as d, et as f, ft as p, ht as m, it as h, k as g, lt as _, m as v, mt as ee, n as y, nt as b, o as x, ot as S, r as C, s as te, st as w, t as T, tt as E, w as D, x as O, z as k } from "./shortcuts-CarKeDqp.js";
|
|
3
|
+
import { Fragment as ne, createContext as A, useContext as j, useEffect as M, useId as N, useMemo as P, useRef as F, useState as I } from "react";
|
|
4
|
+
import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
|
|
5
|
+
import { assembleBody as B, deepEqual as V, editJsxTag as re, editMarkdocTag as H, editTable as ie, escapePipes as U, humanize as ae, jsxClosing as oe, jsxOpening as se, jsxTagLayout as ce, markdocClosing as le, markdocOpening as ue, markdocTagLayout as de, markdocTags as fe, mediaReference as pe, parseBody as me, tableValue as he, unescapePipes as ge } from "@vespercms/core";
|
|
6
|
+
import { Extension as W, Node as G } from "@tiptap/core";
|
|
7
|
+
import _e from "@tiptap/extension-image";
|
|
8
|
+
import { Markdown as ve } from "@tiptap/markdown";
|
|
9
|
+
import { NodeSelection as K, Plugin as ye, PluginKey as be, Selection as xe, TextSelection as Se } from "@tiptap/pm/state";
|
|
10
|
+
import { EditorContent as Ce, NodeViewContent as we, NodeViewWrapper as q, ReactNodeViewRenderer as J, useEditor as Te, useEditorState as Y } from "@tiptap/react";
|
|
11
|
+
import Ee from "@tiptap/starter-kit";
|
|
12
|
+
import { Fragment as De } from "@tiptap/pm/model";
|
|
13
|
+
import { closeHistory as Oe } from "@tiptap/pm/history";
|
|
14
14
|
//#region src/body/catalog.ts
|
|
15
|
-
var
|
|
15
|
+
var ke = {
|
|
16
16
|
path: ["file"],
|
|
17
17
|
kind: "string",
|
|
18
18
|
required: !0,
|
|
19
19
|
label: "File",
|
|
20
20
|
description: "The partial’s file, shown here as part of this page."
|
|
21
21
|
};
|
|
22
|
-
function
|
|
22
|
+
function Ae(e, t) {
|
|
23
23
|
let n = /* @__PURE__ */ new Map();
|
|
24
24
|
if (t === "mdoc") {
|
|
25
25
|
for (let t of e.markdoc?.tags ?? []) {
|
|
@@ -49,7 +49,7 @@ function je(e, t) {
|
|
|
49
49
|
block: "card",
|
|
50
50
|
inline: !1,
|
|
51
51
|
selfClosing: !0,
|
|
52
|
-
fields: [
|
|
52
|
+
fields: [ke],
|
|
53
53
|
order: ["file", "variables"],
|
|
54
54
|
builtin: "partial"
|
|
55
55
|
}), n.set("markdoc:if", {
|
|
@@ -95,7 +95,7 @@ function je(e, t) {
|
|
|
95
95
|
find: (e, t) => n.get(`${e}:${t}`)
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
var
|
|
98
|
+
var je = {
|
|
99
99
|
key: "table",
|
|
100
100
|
syntax: "markdoc",
|
|
101
101
|
name: "table",
|
|
@@ -107,80 +107,80 @@ var Me = {
|
|
|
107
107
|
order: [],
|
|
108
108
|
builtin: "table"
|
|
109
109
|
};
|
|
110
|
-
function
|
|
111
|
-
return [...[...e.kinds.values()].filter((e) => e.builtin !== "if" && e.builtin !== "else"),
|
|
110
|
+
function Me(e) {
|
|
111
|
+
return [...[...e.kinds.values()].filter((e) => e.builtin !== "if" && e.builtin !== "else"), je];
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function Ne(e, t, n, r = "") {
|
|
114
114
|
let i = e.order.map((e) => [e, t[e]]), a = n === "card" || n === "inline" && e.selfClosing;
|
|
115
115
|
if (e.syntax === "markdoc") {
|
|
116
|
-
let t =
|
|
116
|
+
let t = ue(e.name, i, a), o = a ? "" : le(e.name);
|
|
117
117
|
return {
|
|
118
118
|
open: t,
|
|
119
119
|
close: o,
|
|
120
120
|
whole: n === "inline" ? t + r + o : t
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
let o =
|
|
123
|
+
let o = se(e.name, i, a), s = a ? "" : oe(e.name);
|
|
124
124
|
return {
|
|
125
125
|
open: o,
|
|
126
126
|
close: s,
|
|
127
127
|
whole: n === "inline" ? o + r + s : o
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
return e === "mdx" ? t :
|
|
130
|
+
function X(e, t) {
|
|
131
|
+
return e === "mdx" ? t : ae(t);
|
|
132
132
|
}
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/body/chips.ts
|
|
135
|
-
var
|
|
136
|
-
function
|
|
135
|
+
var Pe = "", Fe = "", Ie = /([0-9a-f]*)/g, Le = new TextEncoder(), Re = new TextDecoder();
|
|
136
|
+
function ze(e) {
|
|
137
137
|
let t = "";
|
|
138
|
-
for (let n of
|
|
139
|
-
return `${
|
|
138
|
+
for (let n of Le.encode(e)) t += n.toString(16).padStart(2, "0");
|
|
139
|
+
return `${Pe}${t}${Fe}`;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Be(e) {
|
|
142
142
|
let t = new Uint8Array(e.length / 2);
|
|
143
143
|
for (let n = 0; n < t.length; n++) t[n] = parseInt(e.slice(n * 2, n * 2 + 2), 16);
|
|
144
|
-
return
|
|
144
|
+
return Re.decode(t);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
return e.replace(
|
|
146
|
+
function Ve(e) {
|
|
147
|
+
return e.replace(Ie, (e, t) => Be(t));
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function He(e, t) {
|
|
150
150
|
let n = "", r = 0;
|
|
151
|
-
for (let i of t) n += e.slice(r, i.start) +
|
|
151
|
+
for (let i of t) n += e.slice(r, i.start) + ze(e.slice(i.start, i.end)), r = i.end;
|
|
152
152
|
return n + e.slice(r);
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
return e.includes(
|
|
154
|
+
function Ue(e) {
|
|
155
|
+
return e.includes(Pe) || e.includes(Fe);
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function We(e, t) {
|
|
158
158
|
let n = {}, r = {};
|
|
159
159
|
if (e === "markdoc") {
|
|
160
|
-
let [e] =
|
|
161
|
-
for (let t of e?.attributes ?? []) t.type === "attribute" && t.name !== "primary" && (
|
|
160
|
+
let [e] = fe(t);
|
|
161
|
+
for (let t of e?.attributes ?? []) t.type === "attribute" && t.name !== "primary" && (Ge(t.value) ? r[t.name] = Ke(t.value) : n[t.name] = t.value);
|
|
162
162
|
return {
|
|
163
163
|
values: n,
|
|
164
164
|
code: r
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
let i =
|
|
167
|
+
let i = ce(t);
|
|
168
168
|
for (let e of i?.attributes ?? []) e.name && (e.readable ? n[e.name] = e.value : r[e.name] = t.slice(e.start, e.end));
|
|
169
169
|
return {
|
|
170
170
|
values: n,
|
|
171
171
|
code: r
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
return typeof e != "object" || !e ? !1 : "$$mdtype" in e || Object.values(e).some(
|
|
174
|
+
function Ge(e) {
|
|
175
|
+
return typeof e != "object" || !e ? !1 : "$$mdtype" in e || Object.values(e).some(Ge);
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function Ke(e) {
|
|
178
178
|
let t = e;
|
|
179
179
|
return t.$$mdtype === "Variable" && Array.isArray(t.path) ? `$${t.path.join(".")}` : t.$$mdtype === "Function" && t.name ? `${t.name}(…)` : "a value set by code";
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function qe(e) {
|
|
182
182
|
if (e.startsWith("{%")) {
|
|
183
|
-
let t =
|
|
183
|
+
let t = fe(e), n = t[0], r = t.at(-1);
|
|
184
184
|
if (!n || n.kind === "variable") return {
|
|
185
185
|
syntax: "markdoc",
|
|
186
186
|
kind: "variable"
|
|
@@ -209,7 +209,7 @@ function Je(e) {
|
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
211
|
if (e.startsWith("<")) {
|
|
212
|
-
let t =
|
|
212
|
+
let t = ce(e);
|
|
213
213
|
if (!t) return {
|
|
214
214
|
syntax: "mdx",
|
|
215
215
|
kind: "component"
|
|
@@ -231,28 +231,28 @@ function Je(e) {
|
|
|
231
231
|
}
|
|
232
232
|
//#endregion
|
|
233
233
|
//#region src/body/table.ts
|
|
234
|
-
var
|
|
234
|
+
var Je = /* @__PURE__ */ new Set([
|
|
235
235
|
"text",
|
|
236
236
|
"image",
|
|
237
237
|
"vesperInline"
|
|
238
|
-
]),
|
|
239
|
-
function
|
|
238
|
+
]), Ye = /&(?!(?:lt|gt|quot|amp);)[A-Za-z][A-Za-z0-9]*;/;
|
|
239
|
+
function Xe(e) {
|
|
240
240
|
let t = /^(\d{1,9})[.)](\s|$)/.exec(e);
|
|
241
241
|
return t?.[1] ? `${t[1]}\\${e.slice(t[1].length)}` : /^(#{1,6}(\s|$)|[-+*](\s|$)|>|([-*_][ \t]*){3,}$|`{3}|~{3})/.test(e) ? `\\${e}` : e;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function Ze(e, t) {
|
|
244
244
|
try {
|
|
245
|
-
let n = e.parse(
|
|
245
|
+
let n = e.parse(Xe(ge(t))).content ?? [];
|
|
246
246
|
if (n.length === 0) return [];
|
|
247
247
|
let [r] = n;
|
|
248
248
|
if (n.length !== 1 || r?.type !== "paragraph") return null;
|
|
249
249
|
let i = r.content ?? [];
|
|
250
|
-
return i.every((e) =>
|
|
250
|
+
return i.every((e) => Je.has(e.type ?? "")) ? i : null;
|
|
251
251
|
} catch {
|
|
252
252
|
return null;
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
function
|
|
255
|
+
function Qe(e, t) {
|
|
256
256
|
if (t.length === 0) return "";
|
|
257
257
|
let n = {
|
|
258
258
|
type: "doc",
|
|
@@ -261,23 +261,23 @@ function $e(e, t) {
|
|
|
261
261
|
content: [...t]
|
|
262
262
|
}]
|
|
263
263
|
};
|
|
264
|
-
return
|
|
264
|
+
return U(e.serialize(n).trim());
|
|
265
265
|
}
|
|
266
|
-
function
|
|
267
|
-
let n =
|
|
268
|
-
if (!n || n.some((e) => e.type === "text" &&
|
|
269
|
-
let r =
|
|
266
|
+
function $e(e, t) {
|
|
267
|
+
let n = Ze(e, t);
|
|
268
|
+
if (!n || n.some((e) => e.type === "text" && Ye.test(e.text ?? ""))) return null;
|
|
269
|
+
let r = Ze(e, Qe(e, n));
|
|
270
270
|
return JSON.stringify(r) === JSON.stringify(n) ? n : null;
|
|
271
271
|
}
|
|
272
|
-
function
|
|
273
|
-
let n =
|
|
272
|
+
function et(e, t) {
|
|
273
|
+
let n = he(e, t), r = [t.header, ...t.rows];
|
|
274
274
|
return {
|
|
275
275
|
...n,
|
|
276
276
|
rows: n.rows.map((e, t) => ({
|
|
277
277
|
...e,
|
|
278
278
|
cells: e.cells.map((e, n) => {
|
|
279
279
|
let i = r[t]?.cells[n], a = i?.contentStart ?? 0;
|
|
280
|
-
return
|
|
280
|
+
return He(e, (i?.chips ?? []).map((e) => ({
|
|
281
281
|
start: e.start - a,
|
|
282
282
|
end: e.end - a
|
|
283
283
|
})));
|
|
@@ -285,16 +285,16 @@ function tt(e, t) {
|
|
|
285
285
|
}))
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
|
-
function
|
|
288
|
+
function tt(e) {
|
|
289
289
|
return {
|
|
290
290
|
...e,
|
|
291
291
|
rows: e.rows.map((e) => ({
|
|
292
292
|
...e,
|
|
293
|
-
cells: e.cells.map(
|
|
293
|
+
cells: e.cells.map(Ve)
|
|
294
294
|
}))
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function nt() {
|
|
298
298
|
return {
|
|
299
299
|
align: [null, null],
|
|
300
300
|
columns: [null, null],
|
|
@@ -307,7 +307,7 @@ function rt() {
|
|
|
307
307
|
}]
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function rt(e, t, n, r) {
|
|
311
311
|
return {
|
|
312
312
|
...e,
|
|
313
313
|
rows: e.rows.map((e, i) => i === t ? {
|
|
@@ -316,7 +316,7 @@ function it(e, t, n, r) {
|
|
|
316
316
|
} : e)
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function it(e, t) {
|
|
320
320
|
let n = [...e.rows];
|
|
321
321
|
return n.splice(Math.max(1, t), 0, {
|
|
322
322
|
from: null,
|
|
@@ -326,7 +326,7 @@ function at(e, t) {
|
|
|
326
326
|
rows: n
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
|
-
function
|
|
329
|
+
function at(e, t) {
|
|
330
330
|
let n = (e, n) => [
|
|
331
331
|
...e.slice(0, t),
|
|
332
332
|
n,
|
|
@@ -341,7 +341,7 @@ function ot(e, t) {
|
|
|
341
341
|
}))
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function ot(e, t, n) {
|
|
345
345
|
if (t < 1 || n < 1 || n >= e.rows.length || t >= e.rows.length) return e;
|
|
346
346
|
let r = [...e.rows], [i] = r.splice(t, 1);
|
|
347
347
|
return i && r.splice(n, 0, i), {
|
|
@@ -349,7 +349,7 @@ function st(e, t, n) {
|
|
|
349
349
|
rows: r
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function st(e, t, n) {
|
|
353
353
|
let r = e.columns.length;
|
|
354
354
|
if (t < 0 || n < 0 || t >= r || n >= r) return e;
|
|
355
355
|
let i = (e) => {
|
|
@@ -365,13 +365,13 @@ function ct(e, t, n) {
|
|
|
365
365
|
}))
|
|
366
366
|
};
|
|
367
367
|
}
|
|
368
|
-
function
|
|
368
|
+
function ct(e, t) {
|
|
369
369
|
return t < 1 ? e : {
|
|
370
370
|
...e,
|
|
371
371
|
rows: e.rows.filter((e, n) => n !== t)
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function lt(e, t) {
|
|
375
375
|
if (e.columns.length <= 1) return e;
|
|
376
376
|
let n = (e) => e.filter((e, n) => n !== t);
|
|
377
377
|
return {
|
|
@@ -383,7 +383,7 @@ function ut(e, t) {
|
|
|
383
383
|
}))
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function ut(e, t, n) {
|
|
387
387
|
return {
|
|
388
388
|
...e,
|
|
389
389
|
align: e.align.map((e, r) => r === t ? n : e)
|
|
@@ -391,26 +391,26 @@ function dt(e, t, n) {
|
|
|
391
391
|
}
|
|
392
392
|
//#endregion
|
|
393
393
|
//#region src/body/commands.ts
|
|
394
|
-
function
|
|
394
|
+
function dt(e, t) {
|
|
395
395
|
return e === "vesperCard" || e === "vesperInline" || e === "vesperTable" || e === "sourceBlock" || t.kindOf(e) !== void 0;
|
|
396
396
|
}
|
|
397
|
-
function
|
|
397
|
+
function ft(e, t) {
|
|
398
398
|
let { selection: n } = e.state;
|
|
399
|
-
return n instanceof
|
|
399
|
+
return n instanceof K && dt(n.node.type.name, t) ? {
|
|
400
400
|
pos: n.from,
|
|
401
401
|
type: n.node.type.name
|
|
402
402
|
} : null;
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function pt(e, t) {
|
|
405
405
|
let { $from: n } = e.state.selection;
|
|
406
406
|
for (let e = n.depth; e > 0; e--) if (t.kindOf(n.node(e).type.name)) return n.before(e);
|
|
407
407
|
return null;
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
let n = e.state.tr.setSelection(
|
|
409
|
+
function mt(e, t) {
|
|
410
|
+
let n = e.state.tr.setSelection(K.create(e.state.doc, t));
|
|
411
411
|
e.view.dispatch(n.scrollIntoView()), e.view.focus();
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function ht(e, t, n) {
|
|
414
414
|
let { state: r } = e, i = r.doc.resolve(t), a = r.doc.nodeAt(t);
|
|
415
415
|
if (!a || a.isInline) return null;
|
|
416
416
|
let o = i.parent, s = i.index() + n;
|
|
@@ -424,20 +424,20 @@ function gt(e, t, n) {
|
|
|
424
424
|
let e = t + c.nodeSize;
|
|
425
425
|
l.insert(e, a), u = e;
|
|
426
426
|
}
|
|
427
|
-
return l.setSelection(
|
|
427
|
+
return l.setSelection(K.create(l.doc, u)).scrollIntoView(), e.view.dispatch(l), e.view.focus(), u;
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function gt(e, t) {
|
|
430
430
|
let n = e.state.doc.nodeAt(t);
|
|
431
431
|
if (!n) return;
|
|
432
432
|
let r = e.state.tr.delete(t, t + n.nodeSize), i = Math.min(t, r.doc.content.size);
|
|
433
|
-
r.setSelection(
|
|
433
|
+
r.setSelection(Se.near(r.doc.resolve(i))), e.view.dispatch(r.scrollIntoView()), e.view.focus();
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function _t(e, t, n, r = {}, i = "") {
|
|
436
436
|
if (e.builtin === "table") return {
|
|
437
437
|
type: "vesperTable",
|
|
438
|
-
attrs: { value:
|
|
438
|
+
attrs: { value: nt() }
|
|
439
439
|
};
|
|
440
|
-
let a =
|
|
440
|
+
let a = Ne(e, r, t, i);
|
|
441
441
|
if (t === "inline") return {
|
|
442
442
|
type: "vesperInline",
|
|
443
443
|
attrs: { source: a.whole }
|
|
@@ -461,21 +461,21 @@ function vt(e, t, n, r = {}, i = "") {
|
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function vt(e, t, n) {
|
|
465
465
|
let { $from: r } = e.selection, i = r.parent;
|
|
466
466
|
if (!i.isTextblock) return null;
|
|
467
467
|
let a = i.type.name === "paragraph" && /^\/?[^\s]*$/.test(i.textContent);
|
|
468
468
|
if (t.block && (a || !t.inline) && ((i) => {
|
|
469
469
|
let o = r.depth - 1;
|
|
470
470
|
if (o < 0) return !1;
|
|
471
|
-
let s = e.schema.nodeFromJSON(
|
|
472
|
-
return a ? c.canReplace(l, l + 1,
|
|
471
|
+
let s = e.schema.nodeFromJSON(_t(t, i, n)), c = r.node(o), l = r.index(o);
|
|
472
|
+
return a ? c.canReplace(l, l + 1, De.from(s)) : c.canReplaceWith(l + 1, l + 1, s.type);
|
|
473
473
|
})(t.block)) return t.block;
|
|
474
474
|
let o = e.schema.nodes.vesperInline;
|
|
475
475
|
return t.inline && o && i.canReplaceWith(r.index(), r.index(), o) ? "inline" : null;
|
|
476
476
|
}
|
|
477
|
-
function
|
|
478
|
-
let o =
|
|
477
|
+
function yt(e, t, n, r, i, a = {}) {
|
|
478
|
+
let o = _t(t, n, r, a), s = e.chain().focus();
|
|
479
479
|
i && (s = s.deleteRange(i));
|
|
480
480
|
let c = i ? i.from : e.state.selection.from;
|
|
481
481
|
if (!s.insertContent(o).run()) return null;
|
|
@@ -484,7 +484,7 @@ function bt(e, t, n, r, i, a = {}) {
|
|
|
484
484
|
}
|
|
485
485
|
//#endregion
|
|
486
486
|
//#region src/body/nodes.ts
|
|
487
|
-
var
|
|
487
|
+
var bt = /* @__PURE__ */ new Set([
|
|
488
488
|
"paragraph",
|
|
489
489
|
"heading",
|
|
490
490
|
"bulletList",
|
|
@@ -492,19 +492,19 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
492
492
|
"blockquote",
|
|
493
493
|
"codeBlock",
|
|
494
494
|
"horizontalRule"
|
|
495
|
-
]),
|
|
495
|
+
]), xt = {
|
|
496
496
|
default: null,
|
|
497
497
|
keepOnSplit: !1,
|
|
498
498
|
rendered: !1
|
|
499
|
-
},
|
|
499
|
+
}, St = W.create({
|
|
500
500
|
name: "vesperBlockIndex",
|
|
501
501
|
addGlobalAttributes() {
|
|
502
502
|
return [{
|
|
503
|
-
types: [...
|
|
504
|
-
attributes: { vesperBlock:
|
|
503
|
+
types: [...bt],
|
|
504
|
+
attributes: { vesperBlock: xt }
|
|
505
505
|
}];
|
|
506
506
|
}
|
|
507
|
-
}),
|
|
507
|
+
}), Ct = G.create({
|
|
508
508
|
name: "sourceBlock",
|
|
509
509
|
group: "block",
|
|
510
510
|
atom: !0,
|
|
@@ -512,7 +512,7 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
512
512
|
draggable: !1,
|
|
513
513
|
addAttributes() {
|
|
514
514
|
return {
|
|
515
|
-
vesperBlock:
|
|
515
|
+
vesperBlock: xt,
|
|
516
516
|
text: {
|
|
517
517
|
default: "",
|
|
518
518
|
rendered: !1
|
|
@@ -539,7 +539,7 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
539
539
|
"data-block-type": String(e.attrs.blockType ?? "")
|
|
540
540
|
}];
|
|
541
541
|
}
|
|
542
|
-
}),
|
|
542
|
+
}), wt = G.create({
|
|
543
543
|
name: "vesperCard",
|
|
544
544
|
group: "block vesperTag",
|
|
545
545
|
atom: !0,
|
|
@@ -547,7 +547,7 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
547
547
|
draggable: !1,
|
|
548
548
|
addAttributes() {
|
|
549
549
|
return {
|
|
550
|
-
vesperBlock:
|
|
550
|
+
vesperBlock: xt,
|
|
551
551
|
syntax: {
|
|
552
552
|
default: "markdoc",
|
|
553
553
|
rendered: !1
|
|
@@ -580,7 +580,7 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
580
580
|
"data-source": String(e.attrs.source)
|
|
581
581
|
}];
|
|
582
582
|
}
|
|
583
|
-
}),
|
|
583
|
+
}), Tt = G.create({
|
|
584
584
|
name: "vesperTable",
|
|
585
585
|
group: "block",
|
|
586
586
|
atom: !0,
|
|
@@ -588,7 +588,7 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
588
588
|
draggable: !1,
|
|
589
589
|
addAttributes() {
|
|
590
590
|
return {
|
|
591
|
-
vesperBlock:
|
|
591
|
+
vesperBlock: xt,
|
|
592
592
|
value: {
|
|
593
593
|
default: null,
|
|
594
594
|
rendered: !1
|
|
@@ -613,7 +613,7 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
613
613
|
"data-value": JSON.stringify(e.attrs.value)
|
|
614
614
|
}];
|
|
615
615
|
}
|
|
616
|
-
}),
|
|
616
|
+
}), Et = G.create({
|
|
617
617
|
name: "vesperInline",
|
|
618
618
|
group: "inline",
|
|
619
619
|
inline: !0,
|
|
@@ -651,9 +651,9 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
651
651
|
} : void 0;
|
|
652
652
|
}
|
|
653
653
|
},
|
|
654
|
-
parseMarkdown: (e, t) => t.createNode("vesperInline", { source:
|
|
655
|
-
renderMarkdown: (e) =>
|
|
656
|
-
}),
|
|
654
|
+
parseMarkdown: (e, t) => t.createNode("vesperInline", { source: Be(String(e.hex ?? "")) }),
|
|
655
|
+
renderMarkdown: (e) => ze(String(e.attrs?.source ?? ""))
|
|
656
|
+
}), Dt = {
|
|
657
657
|
paragraph: ["paragraph"],
|
|
658
658
|
list: ["bulletList", "orderedList"],
|
|
659
659
|
heading: ["heading"],
|
|
@@ -664,16 +664,16 @@ var xt = /* @__PURE__ */ new Set([
|
|
|
664
664
|
table: ["vesperTable"],
|
|
665
665
|
tag: ["vesperTag"]
|
|
666
666
|
};
|
|
667
|
-
function
|
|
667
|
+
function Ot(e) {
|
|
668
668
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = [], a = 0;
|
|
669
669
|
for (let o of e.kinds.values()) {
|
|
670
670
|
if (o.block !== "container") continue;
|
|
671
671
|
let e = `vesperTag${String(a++)}_${o.name.replace(/[^A-Za-z0-9]/g, "")}`;
|
|
672
672
|
t.set(e, o), n.set(o.key, e);
|
|
673
|
-
let s = o.children?.flatMap((e) =>
|
|
673
|
+
let s = o.children?.flatMap((e) => Dt[e] ?? []), c = s ? /* @__PURE__ */ new Set([...s, "sourceBlock"]) : null;
|
|
674
674
|
r.set(o.key, c);
|
|
675
675
|
let l = c ? `(${[...c].join(" | ")})+` : "block+";
|
|
676
|
-
i.push(
|
|
676
|
+
i.push(kt(e, l, o));
|
|
677
677
|
}
|
|
678
678
|
return {
|
|
679
679
|
extensions: i,
|
|
@@ -685,8 +685,8 @@ function kt(e) {
|
|
|
685
685
|
}
|
|
686
686
|
};
|
|
687
687
|
}
|
|
688
|
-
function
|
|
689
|
-
return
|
|
688
|
+
function kt(e, t, n) {
|
|
689
|
+
return G.create({
|
|
690
690
|
name: e,
|
|
691
691
|
group: "block vesperTag",
|
|
692
692
|
content: t,
|
|
@@ -696,7 +696,7 @@ function At(e, t, n) {
|
|
|
696
696
|
selectable: !0,
|
|
697
697
|
addAttributes() {
|
|
698
698
|
return {
|
|
699
|
-
vesperBlock:
|
|
699
|
+
vesperBlock: xt,
|
|
700
700
|
syntax: {
|
|
701
701
|
default: n.syntax,
|
|
702
702
|
rendered: !1
|
|
@@ -739,8 +739,8 @@ function At(e, t, n) {
|
|
|
739
739
|
}
|
|
740
740
|
//#endregion
|
|
741
741
|
//#region src/body/document.ts
|
|
742
|
-
function
|
|
743
|
-
let n =
|
|
742
|
+
function At(e, t) {
|
|
743
|
+
let n = me(e, t.format, t.markdoc ? { markdoc: t.markdoc } : {}), r = Mt(n.text, n.blocks, null, "", t, null);
|
|
744
744
|
return {
|
|
745
745
|
parsed: n,
|
|
746
746
|
doc: {
|
|
@@ -749,14 +749,14 @@ function jt(e, t) {
|
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
751
|
}
|
|
752
|
-
var
|
|
753
|
-
function
|
|
752
|
+
var jt = (e, t) => e === null ? String(t) : `${e}.${String(t)}`;
|
|
753
|
+
function Mt(e, t, n, r, i, a) {
|
|
754
754
|
return t.map((t, o) => {
|
|
755
|
-
let s =
|
|
756
|
-
return a && !a(c.type ?? "") ?
|
|
755
|
+
let s = jt(n, o), c = Pt(e, t, s, r, i);
|
|
756
|
+
return a && !a(c.type ?? "") ? Nt(e, t, s) : c;
|
|
757
757
|
});
|
|
758
758
|
}
|
|
759
|
-
function
|
|
759
|
+
function Nt(e, t, n) {
|
|
760
760
|
return {
|
|
761
761
|
type: "sourceBlock",
|
|
762
762
|
attrs: {
|
|
@@ -766,36 +766,36 @@ function Pt(e, t, n) {
|
|
|
766
766
|
}
|
|
767
767
|
};
|
|
768
768
|
}
|
|
769
|
-
function
|
|
769
|
+
function Pt(e, t, n, r, i) {
|
|
770
770
|
let a = e.slice(t.start, t.end);
|
|
771
|
-
if (t.kind === "markdown" && !
|
|
772
|
-
let o =
|
|
771
|
+
if (t.kind === "markdown" && !Ue(a)) {
|
|
772
|
+
let o = Ft(He(a, (t.chips ?? []).map((e) => ({
|
|
773
773
|
start: e.start - t.start,
|
|
774
774
|
end: e.end - t.start
|
|
775
|
-
}))), r), s = o === null ? null :
|
|
775
|
+
}))), r), s = o === null ? null : It(i.markdown, o);
|
|
776
776
|
return s ? {
|
|
777
777
|
...s,
|
|
778
778
|
attrs: {
|
|
779
779
|
...s.attrs,
|
|
780
780
|
vesperBlock: n
|
|
781
781
|
}
|
|
782
|
-
} :
|
|
782
|
+
} : Nt(e, t, n);
|
|
783
783
|
}
|
|
784
784
|
if (t.kind === "table" && t.table) {
|
|
785
|
-
let r =
|
|
786
|
-
return r.rows.every((e) => e.cells.every((e) => !
|
|
785
|
+
let r = et(e, t.table);
|
|
786
|
+
return r.rows.every((e) => e.cells.every((e) => !Ue(Ve(e)) && $e(i.markdown, e))) ? {
|
|
787
787
|
type: "vesperTable",
|
|
788
788
|
attrs: {
|
|
789
789
|
vesperBlock: n,
|
|
790
790
|
value: r
|
|
791
791
|
}
|
|
792
|
-
} :
|
|
792
|
+
} : Nt(e, t, n);
|
|
793
793
|
}
|
|
794
794
|
let o = t.tag, s = t.kind === "tag" && o ? i.catalog.find(o.syntax, o.name) : void 0;
|
|
795
|
-
if (!o || !s) return
|
|
795
|
+
if (!o || !s) return Nt(e, t, n);
|
|
796
796
|
let c = i.containers.typeOf(s);
|
|
797
797
|
if (c && o.children && o.closeStart !== void 0) {
|
|
798
|
-
let r =
|
|
798
|
+
let r = Mt(e, o.children, n, o.indent ?? "", i, (e) => i.containers.allows(s, e));
|
|
799
799
|
return {
|
|
800
800
|
type: c,
|
|
801
801
|
attrs: {
|
|
@@ -818,7 +818,7 @@ function Ft(e, t, n, r, i) {
|
|
|
818
818
|
}
|
|
819
819
|
};
|
|
820
820
|
}
|
|
821
|
-
function
|
|
821
|
+
function Ft(e, t) {
|
|
822
822
|
if (t === "") return e;
|
|
823
823
|
let n = e.split("\n"), r = [];
|
|
824
824
|
for (let [e, i] of n.entries()) if (e === 0) r.push(i);
|
|
@@ -827,10 +827,10 @@ function It(e, t) {
|
|
|
827
827
|
else return null;
|
|
828
828
|
return r.join("\n");
|
|
829
829
|
}
|
|
830
|
-
function
|
|
830
|
+
function It(e, t) {
|
|
831
831
|
try {
|
|
832
832
|
let n = e.parse(t).content ?? [], [r] = n;
|
|
833
|
-
if (n.length !== 1 || !r?.type || !
|
|
833
|
+
if (n.length !== 1 || !r?.type || !bt.has(r.type)) return null;
|
|
834
834
|
let i = e.parse(e.serialize({
|
|
835
835
|
type: "doc",
|
|
836
836
|
content: [r]
|
|
@@ -840,25 +840,25 @@ function Lt(e, t) {
|
|
|
840
840
|
return null;
|
|
841
841
|
}
|
|
842
842
|
}
|
|
843
|
-
var
|
|
844
|
-
function
|
|
843
|
+
var Lt = (e, t) => e.type !== void 0 && t.kindOf(e.type) !== void 0;
|
|
844
|
+
function Rt(e, t) {
|
|
845
845
|
let n = /* @__PURE__ */ new Map(), r = (e) => {
|
|
846
846
|
for (let i of e ?? []) {
|
|
847
847
|
let e = i.attrs?.vesperBlock;
|
|
848
|
-
typeof e == "string" && !n.has(e) && n.set(e,
|
|
848
|
+
typeof e == "string" && !n.has(e) && n.set(e, Lt(i, t) ? JSON.stringify({ open: i.attrs?.open }) : JSON.stringify(i)), Lt(i, t) && r(i.content);
|
|
849
849
|
}
|
|
850
850
|
};
|
|
851
851
|
return r(e.content), n;
|
|
852
852
|
}
|
|
853
|
-
function
|
|
853
|
+
function zt(e, t) {
|
|
854
854
|
if (typeof e != "string") return null;
|
|
855
855
|
let n = e.lastIndexOf(".");
|
|
856
856
|
return (n === -1 ? null : e.slice(0, n)) === t ? Number(e.slice(n + 1)) : null;
|
|
857
857
|
}
|
|
858
|
-
function
|
|
859
|
-
return
|
|
858
|
+
function Bt(e, t, n) {
|
|
859
|
+
return Wt(e.content, null, t, n);
|
|
860
860
|
}
|
|
861
|
-
function
|
|
861
|
+
function Vt(e, t) {
|
|
862
862
|
let n = e.blocks, r = "", i = t.split(".");
|
|
863
863
|
for (let [e, t] of i.entries()) {
|
|
864
864
|
let a = n[Number(t)];
|
|
@@ -872,7 +872,7 @@ function Ht(e, t) {
|
|
|
872
872
|
}
|
|
873
873
|
return null;
|
|
874
874
|
}
|
|
875
|
-
function
|
|
875
|
+
function Ht(e) {
|
|
876
876
|
let t = [], n = (e) => e.type === "vesperInline" ? (t.push(String(e.attrs?.source ?? "")), {
|
|
877
877
|
...e,
|
|
878
878
|
attrs: {
|
|
@@ -888,10 +888,10 @@ function Ut(e) {
|
|
|
888
888
|
shape: JSON.stringify(n(e))
|
|
889
889
|
};
|
|
890
890
|
}
|
|
891
|
-
function
|
|
892
|
-
let i = n.get(t), a = r ?
|
|
891
|
+
function Ut(e, t, n, r) {
|
|
892
|
+
let i = n.get(t), a = r ? Vt(r, t) : null;
|
|
893
893
|
if (!i || !r || !a?.block.chips) return null;
|
|
894
|
-
let o =
|
|
894
|
+
let o = Ht(JSON.parse(i)), s = Ht(e), c = a.block.chips;
|
|
895
895
|
if (o.shape !== s.shape || s.sources.length !== c.length) return null;
|
|
896
896
|
let l = r.text.slice(a.block.start, a.block.end);
|
|
897
897
|
for (let e = c.length - 1; e >= 0; e--) {
|
|
@@ -900,16 +900,16 @@ function Wt(e, t, n, r) {
|
|
|
900
900
|
let n = t.start - a.block.start, r = t.end - a.block.start;
|
|
901
901
|
l = l.slice(0, n) + (s.sources[e] ?? "") + l.slice(r);
|
|
902
902
|
}
|
|
903
|
-
return
|
|
903
|
+
return Ft(l, a.indent);
|
|
904
904
|
}
|
|
905
|
-
function
|
|
905
|
+
function Wt(e, t, n, r) {
|
|
906
906
|
let i = [];
|
|
907
907
|
for (let a of e ?? []) {
|
|
908
|
-
let e = a.attrs?.vesperBlock, o =
|
|
909
|
-
if (
|
|
908
|
+
let e = a.attrs?.vesperBlock, o = zt(e, t);
|
|
909
|
+
if (Lt(a, r.containers)) {
|
|
910
910
|
let t = String(a.attrs?.open ?? "");
|
|
911
911
|
if (o !== null && typeof e == "string") {
|
|
912
|
-
let s = n.get(e), c =
|
|
912
|
+
let s = n.get(e), c = Wt(a.content, e, n, r);
|
|
913
913
|
i.push({
|
|
914
914
|
replaces: o,
|
|
915
915
|
...s === JSON.stringify({ open: t }) ? {} : { open: t },
|
|
@@ -918,7 +918,7 @@ function Gt(e, t, n, r) {
|
|
|
918
918
|
} else i.push({
|
|
919
919
|
open: t,
|
|
920
920
|
close: String(a.attrs?.close ?? ""),
|
|
921
|
-
children:
|
|
921
|
+
children: Wt(a.content, null, n, r)
|
|
922
922
|
});
|
|
923
923
|
continue;
|
|
924
924
|
}
|
|
@@ -927,7 +927,7 @@ function Gt(e, t, n, r) {
|
|
|
927
927
|
continue;
|
|
928
928
|
}
|
|
929
929
|
if (a.type === "vesperTable") {
|
|
930
|
-
let t =
|
|
930
|
+
let t = Gt(typeof e == "string" ? e : null, a.attrs?.value, r);
|
|
931
931
|
if (!t.ok) throw Error(t.reason);
|
|
932
932
|
i.push(o === null ? { text: t.text } : {
|
|
933
933
|
text: t.text,
|
|
@@ -935,7 +935,7 @@ function Gt(e, t, n, r) {
|
|
|
935
935
|
});
|
|
936
936
|
continue;
|
|
937
937
|
}
|
|
938
|
-
let s = (o !== null && typeof e == "string" ?
|
|
938
|
+
let s = (o !== null && typeof e == "string" ? Ut(a, e, n, r.parsed) : null) ?? Kt(a, r.markdown);
|
|
939
939
|
(s !== "" || o !== null) && i.push(o === null ? { text: s } : {
|
|
940
940
|
text: s,
|
|
941
941
|
replaces: o
|
|
@@ -943,23 +943,23 @@ function Gt(e, t, n, r) {
|
|
|
943
943
|
}
|
|
944
944
|
return i;
|
|
945
945
|
}
|
|
946
|
-
function
|
|
946
|
+
function Gt(e, t, n) {
|
|
947
947
|
if (!n.format) throw Error("Saving a table needs the body’s format.");
|
|
948
948
|
let r = {
|
|
949
949
|
format: n.format,
|
|
950
950
|
...n.markdoc ? { markdoc: n.markdoc } : {}
|
|
951
|
-
}, i = e !== null && n.parsed ?
|
|
951
|
+
}, i = e !== null && n.parsed ? Vt(n.parsed, e) : null, a = i?.block.table, o = i && a && n.parsed ? {
|
|
952
952
|
text: n.parsed.text,
|
|
953
953
|
table: a,
|
|
954
954
|
indent: i.indent
|
|
955
955
|
} : null;
|
|
956
|
-
return
|
|
956
|
+
return ie(o, tt(t), r);
|
|
957
957
|
}
|
|
958
|
-
function
|
|
958
|
+
function Kt(e, t) {
|
|
959
959
|
if (e.type === "sourceBlock") return String(e.attrs?.text ?? "");
|
|
960
960
|
if (e.type === "vesperCard") return String(e.attrs?.source ?? "");
|
|
961
961
|
let { vesperBlock: n, ...r } = e.attrs ?? {};
|
|
962
|
-
return
|
|
962
|
+
return Ve(t.serialize({
|
|
963
963
|
type: "doc",
|
|
964
964
|
content: [{
|
|
965
965
|
...e,
|
|
@@ -967,7 +967,7 @@ function qt(e, t) {
|
|
|
967
967
|
}]
|
|
968
968
|
}).replace(/\s+$/, ""));
|
|
969
969
|
}
|
|
970
|
-
function
|
|
970
|
+
function qt(e) {
|
|
971
971
|
return {
|
|
972
972
|
mdxjsEsm: "Import",
|
|
973
973
|
mdxJsxFlowElement: "Component",
|
|
@@ -984,35 +984,35 @@ function Jt(e) {
|
|
|
984
984
|
}
|
|
985
985
|
//#endregion
|
|
986
986
|
//#region src/body/insert.tsx
|
|
987
|
-
var
|
|
988
|
-
function
|
|
989
|
-
return
|
|
990
|
-
let r =
|
|
987
|
+
var Z = new be("vesperSlash");
|
|
988
|
+
function Jt(e, t, n) {
|
|
989
|
+
return Me(t).flatMap((t) => {
|
|
990
|
+
let r = vt(e, t, n);
|
|
991
991
|
return r ? [{
|
|
992
992
|
kind: t,
|
|
993
993
|
shape: r
|
|
994
994
|
}] : [];
|
|
995
995
|
}).sort((e, t) => e.kind.label.localeCompare(t.kind.label));
|
|
996
996
|
}
|
|
997
|
-
function
|
|
998
|
-
let t =
|
|
997
|
+
function Yt(e) {
|
|
998
|
+
let t = Z.getState(e);
|
|
999
999
|
return t?.active ? e.doc.textBetween(t.from + 1, e.selection.from, "\n") : null;
|
|
1000
1000
|
}
|
|
1001
|
-
function
|
|
1001
|
+
function Xt(e, t) {
|
|
1002
1002
|
let n = t.toLowerCase();
|
|
1003
1003
|
return e.filter((e) => e.kind.label.toLowerCase().includes(n) || e.kind.name.toLowerCase().includes(n));
|
|
1004
1004
|
}
|
|
1005
|
-
function
|
|
1006
|
-
return
|
|
1005
|
+
function Zt(e) {
|
|
1006
|
+
return W.create({
|
|
1007
1007
|
name: "vesperSlash",
|
|
1008
1008
|
priority: 1e3,
|
|
1009
1009
|
addProseMirrorPlugins() {
|
|
1010
|
-
return [new
|
|
1011
|
-
key:
|
|
1010
|
+
return [new ye({
|
|
1011
|
+
key: Z,
|
|
1012
1012
|
state: {
|
|
1013
1013
|
init: () => ({ active: !1 }),
|
|
1014
1014
|
apply(e, t, n, r) {
|
|
1015
|
-
let i = e.getMeta(
|
|
1015
|
+
let i = e.getMeta(Z), a = t, o = i !== void 0 && "active" in i;
|
|
1016
1016
|
if (o ? a = i : i && a.active && (a = {
|
|
1017
1017
|
...a,
|
|
1018
1018
|
index: i.index
|
|
@@ -1030,21 +1030,21 @@ function Qt(e) {
|
|
|
1030
1030
|
let a = t.state.doc.resolve(n);
|
|
1031
1031
|
if (a.parent.type.name !== "paragraph") return !1;
|
|
1032
1032
|
let o = a.parent.textBetween(0, a.parentOffset, "\n");
|
|
1033
|
-
return o !== "" && !/\s$/.test(o) ? !1 : (t.dispatch(t.state.tr.insertText("/", n, r).setMeta(
|
|
1033
|
+
return o !== "" && !/\s$/.test(o) ? !1 : (t.dispatch(t.state.tr.insertText("/", n, r).setMeta(Z, {
|
|
1034
1034
|
active: !0,
|
|
1035
1035
|
from: n,
|
|
1036
1036
|
index: 0
|
|
1037
1037
|
})), !0);
|
|
1038
1038
|
},
|
|
1039
1039
|
handleKeyDown(t, n) {
|
|
1040
|
-
let r =
|
|
1040
|
+
let r = Z.getState(t.state);
|
|
1041
1041
|
if (!r?.active) return !1;
|
|
1042
|
-
let i =
|
|
1043
|
-
if (n.key === "Escape") return t.dispatch(t.state.tr.setMeta(
|
|
1042
|
+
let i = Yt(t.state) ?? "", a = Xt(e.choices(t.state), i);
|
|
1043
|
+
if (n.key === "Escape") return t.dispatch(t.state.tr.setMeta(Z, { active: !1 })), !0;
|
|
1044
1044
|
if (a.length === 0) return !1;
|
|
1045
1045
|
if (n.key === "ArrowDown" || n.key === "ArrowUp") {
|
|
1046
1046
|
let e = n.key === "ArrowDown" ? 1 : -1, i = (r.index + e + a.length) % a.length;
|
|
1047
|
-
return t.dispatch(t.state.tr.setMeta(
|
|
1047
|
+
return t.dispatch(t.state.tr.setMeta(Z, { index: i })), !0;
|
|
1048
1048
|
}
|
|
1049
1049
|
if (n.key === "Enter" || n.key === "Tab") {
|
|
1050
1050
|
let n = a[Math.min(r.index, a.length - 1)];
|
|
@@ -1053,7 +1053,7 @@ function Qt(e) {
|
|
|
1053
1053
|
from: r.from,
|
|
1054
1054
|
to: t.state.selection.from
|
|
1055
1055
|
};
|
|
1056
|
-
return t.dispatch(t.state.tr.setMeta(
|
|
1056
|
+
return t.dispatch(t.state.tr.setMeta(Z, { active: !1 })), e.choose(n, i), !0;
|
|
1057
1057
|
}
|
|
1058
1058
|
return !1;
|
|
1059
1059
|
}
|
|
@@ -1062,13 +1062,13 @@ function Qt(e) {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
});
|
|
1064
1064
|
}
|
|
1065
|
-
function
|
|
1066
|
-
let n =
|
|
1065
|
+
function Qt(e, t) {
|
|
1066
|
+
let n = Z.getState(e);
|
|
1067
1067
|
if (!n?.active) return {
|
|
1068
1068
|
role: "textbox",
|
|
1069
1069
|
"aria-multiline": "true"
|
|
1070
1070
|
};
|
|
1071
|
-
let r = t.count(
|
|
1071
|
+
let r = t.count(Yt(e) ?? "");
|
|
1072
1072
|
return {
|
|
1073
1073
|
role: "combobox",
|
|
1074
1074
|
"aria-expanded": "true",
|
|
@@ -1077,24 +1077,24 @@ function $t(e, t) {
|
|
|
1077
1077
|
...r > 0 ? { "aria-activedescendant": t.optionId(Math.min(n.index, r - 1)) } : {}
|
|
1078
1078
|
};
|
|
1079
1079
|
}
|
|
1080
|
-
function
|
|
1081
|
-
let a =
|
|
1080
|
+
function $t({ editor: e, listboxId: t, optionId: n, choices: r, onChoose: i }) {
|
|
1081
|
+
let a = Y({
|
|
1082
1082
|
editor: e,
|
|
1083
1083
|
selector: ({ editor: e }) => {
|
|
1084
|
-
let t =
|
|
1084
|
+
let t = Z.getState(e.state);
|
|
1085
1085
|
return t?.active ? {
|
|
1086
1086
|
from: t.from,
|
|
1087
1087
|
to: e.state.selection.from,
|
|
1088
1088
|
index: t.index,
|
|
1089
|
-
query:
|
|
1090
|
-
place:
|
|
1089
|
+
query: Yt(e.state) ?? "",
|
|
1090
|
+
place: en(e, t.from)
|
|
1091
1091
|
} : null;
|
|
1092
1092
|
},
|
|
1093
1093
|
equalityFn: (e, t) => JSON.stringify(e) === JSON.stringify(t)
|
|
1094
1094
|
});
|
|
1095
1095
|
if (!a) return null;
|
|
1096
|
-
let { place: o } = a, s =
|
|
1097
|
-
return /* @__PURE__ */
|
|
1096
|
+
let { place: o } = a, s = Xt(r(e.state), a.query), c = Math.min(a.index, Math.max(0, s.length - 1));
|
|
1097
|
+
return /* @__PURE__ */ R("div", {
|
|
1098
1098
|
id: t,
|
|
1099
1099
|
role: "listbox",
|
|
1100
1100
|
"aria-label": "Insert a block",
|
|
@@ -1102,34 +1102,34 @@ function en({ editor: e, listboxId: t, optionId: n, choices: r, onChoose: i }) {
|
|
|
1102
1102
|
top: o.top,
|
|
1103
1103
|
left: o.left
|
|
1104
1104
|
} : void 0,
|
|
1105
|
-
className:
|
|
1106
|
-
children: s.length === 0 ? /* @__PURE__ */
|
|
1105
|
+
className: m("fixed z-40 max-h-64 min-w-56 overflow-y-auto", S),
|
|
1106
|
+
children: s.length === 0 ? /* @__PURE__ */ R("div", {
|
|
1107
1107
|
role: "option",
|
|
1108
1108
|
tabIndex: -1,
|
|
1109
1109
|
"aria-selected": "false",
|
|
1110
1110
|
"aria-disabled": "true",
|
|
1111
1111
|
className: "px-3 py-2 text-small text-content-muted",
|
|
1112
1112
|
children: "Nothing fits here"
|
|
1113
|
-
}) : s.map((e, t) => /* @__PURE__ */
|
|
1113
|
+
}) : s.map((e, t) => /* @__PURE__ */ z("div", {
|
|
1114
1114
|
id: n(t),
|
|
1115
1115
|
role: "option",
|
|
1116
1116
|
tabIndex: -1,
|
|
1117
1117
|
"aria-selected": t === c,
|
|
1118
|
-
className:
|
|
1118
|
+
className: m("flex min-h-9 cursor-default items-center rounded-md px-3 text-body text-content", t === c && "bg-accent-subtle"),
|
|
1119
1119
|
onMouseDown: (t) => {
|
|
1120
1120
|
t.preventDefault(), i(e, {
|
|
1121
1121
|
from: a.from,
|
|
1122
1122
|
to: a.to
|
|
1123
1123
|
});
|
|
1124
1124
|
},
|
|
1125
|
-
children: [e.kind.label, e.shape === "inline" && /* @__PURE__ */
|
|
1125
|
+
children: [e.kind.label, e.shape === "inline" && /* @__PURE__ */ R("span", {
|
|
1126
1126
|
className: "text-content-muted",
|
|
1127
1127
|
children: " (in this line)"
|
|
1128
1128
|
})]
|
|
1129
1129
|
}, e.kind.key))
|
|
1130
1130
|
});
|
|
1131
1131
|
}
|
|
1132
|
-
function
|
|
1132
|
+
function en(e, t) {
|
|
1133
1133
|
try {
|
|
1134
1134
|
let n = e.view.coordsAtPos(t);
|
|
1135
1135
|
return {
|
|
@@ -1140,12 +1140,12 @@ function tn(e, t) {
|
|
|
1140
1140
|
return null;
|
|
1141
1141
|
}
|
|
1142
1142
|
}
|
|
1143
|
-
function
|
|
1144
|
-
let i =
|
|
1143
|
+
function tn({ editor: e, choices: t, onChoose: n, disabled: r }) {
|
|
1144
|
+
let i = Y({
|
|
1145
1145
|
editor: e,
|
|
1146
1146
|
selector: ({ editor: e }) => t(e.state).map((e) => `${e.kind.key}|${e.shape}`).join(",")
|
|
1147
1147
|
}), a = t(e.state);
|
|
1148
|
-
return r || i === "" || a.length === 0 ? null : /* @__PURE__ */
|
|
1148
|
+
return r || i === "" || a.length === 0 ? null : /* @__PURE__ */ R(h, {
|
|
1149
1149
|
label: "Insert a block",
|
|
1150
1150
|
triggerText: "Insert",
|
|
1151
1151
|
triggerIcon: "add",
|
|
@@ -1159,8 +1159,8 @@ function nn({ editor: e, choices: t, onChoose: n, disabled: r }) {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
});
|
|
1161
1161
|
}
|
|
1162
|
-
function
|
|
1163
|
-
let e =
|
|
1162
|
+
function nn() {
|
|
1163
|
+
let e = N().replace(/:/g, "");
|
|
1164
1164
|
return {
|
|
1165
1165
|
listboxId: `${e}-insert`,
|
|
1166
1166
|
optionId: (t) => `${e}-insert-${String(t)}`
|
|
@@ -1168,7 +1168,7 @@ function rn() {
|
|
|
1168
1168
|
}
|
|
1169
1169
|
//#endregion
|
|
1170
1170
|
//#region src/body/reveal.ts
|
|
1171
|
-
function
|
|
1171
|
+
function rn(e, t) {
|
|
1172
1172
|
let n = [], r = e;
|
|
1173
1173
|
for (; r.length > 0;) {
|
|
1174
1174
|
let e = r.findIndex((e) => t >= e.start && t <= e.end);
|
|
@@ -1179,7 +1179,7 @@ function an(e, t) {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
return n;
|
|
1181
1181
|
}
|
|
1182
|
-
function
|
|
1182
|
+
function an(e, t) {
|
|
1183
1183
|
let n = e, r = 0, i = null;
|
|
1184
1184
|
for (let e of t) {
|
|
1185
1185
|
if (n.childCount === 0) break;
|
|
@@ -1194,30 +1194,30 @@ function on(e, t) {
|
|
|
1194
1194
|
}
|
|
1195
1195
|
return i;
|
|
1196
1196
|
}
|
|
1197
|
-
function
|
|
1198
|
-
let i =
|
|
1197
|
+
function on(e, t, n, r) {
|
|
1198
|
+
let i = me(t, r.format, r.markdoc ? { markdoc: r.markdoc } : {}), a = an(e.state.doc, rn(i.blocks, n));
|
|
1199
1199
|
if (e.view.focus(), !a) return;
|
|
1200
1200
|
let { doc: o } = e.state, s;
|
|
1201
|
-
s = a.node.isTextblock ?
|
|
1201
|
+
s = a.node.isTextblock ? Se.create(o, a.pos + 1) : dt(a.node.type.name, r.containers) ? K.create(o, a.pos) : Se.near(o.resolve(a.pos + 1)), e.view.dispatch(e.state.tr.setSelection(s).scrollIntoView());
|
|
1202
1202
|
}
|
|
1203
|
-
function
|
|
1203
|
+
function sn(e, t, n) {
|
|
1204
1204
|
e.setSelectionRange(t, n), e.blur(), e.focus();
|
|
1205
1205
|
}
|
|
1206
1206
|
//#endregion
|
|
1207
1207
|
//#region src/body/scroll.ts
|
|
1208
|
-
var
|
|
1209
|
-
function
|
|
1208
|
+
var cn = "sticky top-[var(--sticky-top,0px)] z-1 rounded-t-md border-b border-border bg-surface-raised p-1", ln = 4;
|
|
1209
|
+
function un(e, t) {
|
|
1210
1210
|
if (!t) return !1;
|
|
1211
1211
|
let { selection: n } = e.state, r;
|
|
1212
1212
|
try {
|
|
1213
|
-
r = e.coordsAtPos(n instanceof
|
|
1213
|
+
r = e.coordsAtPos(n instanceof K ? n.from : n.head).top;
|
|
1214
1214
|
} catch {
|
|
1215
1215
|
return !1;
|
|
1216
1216
|
}
|
|
1217
|
-
let i = t.getBoundingClientRect().bottom +
|
|
1218
|
-
return r >= i || r < e.dom.getBoundingClientRect().top ||
|
|
1217
|
+
let i = t.getBoundingClientRect().bottom + ln;
|
|
1218
|
+
return r >= i || r < e.dom.getBoundingClientRect().top || dn(e.dom).scrollBy(0, r - i), !1;
|
|
1219
1219
|
}
|
|
1220
|
-
function
|
|
1220
|
+
function dn(e) {
|
|
1221
1221
|
for (let t = e.parentElement; t; t = t.parentElement) {
|
|
1222
1222
|
let { overflowY: e } = getComputedStyle(t);
|
|
1223
1223
|
if ((e === "auto" || e === "scroll") && t.scrollHeight > t.clientHeight) return t;
|
|
@@ -1226,15 +1226,15 @@ function fn(e) {
|
|
|
1226
1226
|
}
|
|
1227
1227
|
//#endregion
|
|
1228
1228
|
//#region src/body/ui.ts
|
|
1229
|
-
var
|
|
1230
|
-
function
|
|
1231
|
-
let e =
|
|
1229
|
+
var fn = A(null);
|
|
1230
|
+
function Q() {
|
|
1231
|
+
let e = j(fn);
|
|
1232
1232
|
if (!e) throw Error("useBodyUi() must be used inside the body editor.");
|
|
1233
1233
|
return e;
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1236
|
-
let { checks: t } =
|
|
1237
|
-
return
|
|
1235
|
+
function pn(e) {
|
|
1236
|
+
let { checks: t } = Q(), n = P(() => t.validateSync(e), [t, e]), [r, i] = I([]);
|
|
1237
|
+
return M(() => {
|
|
1238
1238
|
if (n !== null) return;
|
|
1239
1239
|
let r = !0;
|
|
1240
1240
|
return t.validate(e).then((e) => {
|
|
@@ -1248,7 +1248,7 @@ function mn(e) {
|
|
|
1248
1248
|
n
|
|
1249
1249
|
]), n ?? r;
|
|
1250
1250
|
}
|
|
1251
|
-
function
|
|
1251
|
+
function mn(e, t) {
|
|
1252
1252
|
if (!e) return "";
|
|
1253
1253
|
let n = e.summary ?? (e.builtin === "partial" ? "file" : void 0);
|
|
1254
1254
|
if (!n) return "";
|
|
@@ -1259,9 +1259,9 @@ function hn(e, t) {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
//#endregion
|
|
1261
1261
|
//#region src/body/settings.tsx
|
|
1262
|
-
var
|
|
1263
|
-
function
|
|
1264
|
-
let r =
|
|
1262
|
+
var $ = (e) => typeof e == "string" ? e : "";
|
|
1263
|
+
function hn({ editor: e, pos: t, onClose: n }) {
|
|
1264
|
+
let r = Q(), i = Y({
|
|
1265
1265
|
editor: e,
|
|
1266
1266
|
selector: ({ editor: e }) => {
|
|
1267
1267
|
if (t === null) return null;
|
|
@@ -1274,31 +1274,31 @@ function gn({ editor: e, pos: t, onClose: n }) {
|
|
|
1274
1274
|
} : null;
|
|
1275
1275
|
},
|
|
1276
1276
|
equalityFn: (e, t) => JSON.stringify(e) === JSON.stringify(t)
|
|
1277
|
-
}), a = i ?
|
|
1278
|
-
return /* @__PURE__ */
|
|
1277
|
+
}), a = i ? _n(i, r) : null;
|
|
1278
|
+
return /* @__PURE__ */ R(b, {
|
|
1279
1279
|
title: a?.title ?? "Settings",
|
|
1280
1280
|
isOpen: t !== null && i !== null,
|
|
1281
1281
|
onOpenChange: (e) => {
|
|
1282
1282
|
e || n();
|
|
1283
1283
|
},
|
|
1284
|
-
children: i && a && /* @__PURE__ */
|
|
1284
|
+
children: i && a && /* @__PURE__ */ z(gn, {
|
|
1285
1285
|
className: "flex flex-col gap-6",
|
|
1286
1286
|
children: [
|
|
1287
|
-
a.mode === "tag" && a.kind && /* @__PURE__ */
|
|
1287
|
+
a.mode === "tag" && a.kind && /* @__PURE__ */ R(xn, {
|
|
1288
1288
|
editor: e,
|
|
1289
1289
|
target: i,
|
|
1290
1290
|
kind: a.kind
|
|
1291
1291
|
}),
|
|
1292
|
-
a.mode === "condition" && /* @__PURE__ */
|
|
1292
|
+
a.mode === "condition" && /* @__PURE__ */ R(En, {
|
|
1293
1293
|
editor: e,
|
|
1294
1294
|
target: i
|
|
1295
1295
|
}),
|
|
1296
|
-
a.mode === "raw" && /* @__PURE__ */
|
|
1296
|
+
a.mode === "raw" && /* @__PURE__ */ R(Dn, {
|
|
1297
1297
|
editor: e,
|
|
1298
1298
|
target: i,
|
|
1299
1299
|
label: a.label
|
|
1300
1300
|
}),
|
|
1301
|
-
/* @__PURE__ */
|
|
1301
|
+
/* @__PURE__ */ R(On, {
|
|
1302
1302
|
editor: e,
|
|
1303
1303
|
target: i,
|
|
1304
1304
|
onClose: n
|
|
@@ -1307,9 +1307,9 @@ function gn({ editor: e, pos: t, onClose: n }) {
|
|
|
1307
1307
|
})
|
|
1308
1308
|
});
|
|
1309
1309
|
}
|
|
1310
|
-
function
|
|
1311
|
-
let n =
|
|
1312
|
-
return
|
|
1310
|
+
function gn({ className: e, children: t }) {
|
|
1311
|
+
let n = F(null);
|
|
1312
|
+
return M(() => {
|
|
1313
1313
|
let e = setTimeout(() => {
|
|
1314
1314
|
let e = n.current?.querySelector("input:not([type=hidden]):not([disabled]), textarea:not([disabled]), button:not([disabled])");
|
|
1315
1315
|
((e?.type === "radio" ? n.current?.querySelector(`input[type=radio][name="${CSS.escape(e.name)}"]:checked`) : null) ?? e)?.focus();
|
|
@@ -1317,15 +1317,15 @@ function _n({ className: e, children: t }) {
|
|
|
1317
1317
|
return () => {
|
|
1318
1318
|
clearTimeout(e);
|
|
1319
1319
|
};
|
|
1320
|
-
}, []), /* @__PURE__ */
|
|
1320
|
+
}, []), /* @__PURE__ */ R("div", {
|
|
1321
1321
|
ref: n,
|
|
1322
1322
|
className: e,
|
|
1323
1323
|
children: t
|
|
1324
1324
|
});
|
|
1325
1325
|
}
|
|
1326
|
-
function
|
|
1326
|
+
function _n(e, t) {
|
|
1327
1327
|
if (e.type === "sourceBlock") {
|
|
1328
|
-
let t =
|
|
1328
|
+
let t = qt($(e.attrs.blockType));
|
|
1329
1329
|
return {
|
|
1330
1330
|
mode: "raw",
|
|
1331
1331
|
title: `Edit ${t.toLowerCase()} as text`,
|
|
@@ -1344,7 +1344,7 @@ function vn(e, t) {
|
|
|
1344
1344
|
kind: n
|
|
1345
1345
|
};
|
|
1346
1346
|
if (e.type === "vesperCard") {
|
|
1347
|
-
let n = e.attrs.syntax, r =
|
|
1347
|
+
let n = e.attrs.syntax, r = $(e.attrs.name), i = t.catalog.find(n, r);
|
|
1348
1348
|
if (i && !i.builtin) return {
|
|
1349
1349
|
mode: "tag",
|
|
1350
1350
|
title: `${i.label} settings`,
|
|
@@ -1357,30 +1357,30 @@ function vn(e, t) {
|
|
|
1357
1357
|
label: i.label,
|
|
1358
1358
|
kind: i
|
|
1359
1359
|
};
|
|
1360
|
-
let a = i?.label ??
|
|
1360
|
+
let a = i?.label ?? X(n, r);
|
|
1361
1361
|
return {
|
|
1362
1362
|
mode: "raw",
|
|
1363
1363
|
title: `Edit ${a} as text`,
|
|
1364
1364
|
label: a
|
|
1365
1365
|
};
|
|
1366
1366
|
}
|
|
1367
|
-
let r =
|
|
1367
|
+
let r = qe($(e.attrs.source)), i = r.name ? t.catalog.find(r.syntax, r.name) : void 0;
|
|
1368
1368
|
if (i && !i.builtin && (r.kind === "tag" || r.kind === "component")) return {
|
|
1369
1369
|
mode: "tag",
|
|
1370
1370
|
title: `${i.label} settings`,
|
|
1371
1371
|
label: i.label,
|
|
1372
1372
|
kind: i
|
|
1373
1373
|
};
|
|
1374
|
-
let a = r.kind === "variable" ? "Variable" : r.kind === "annotation" ? "Annotation" : r.kind === "expression" ? "Expression" : r.name ?
|
|
1374
|
+
let a = r.kind === "variable" ? "Variable" : r.kind === "annotation" ? "Annotation" : r.kind === "expression" ? "Expression" : r.name ? X(r.syntax, r.name) : "Tag";
|
|
1375
1375
|
return {
|
|
1376
1376
|
mode: "raw",
|
|
1377
1377
|
title: `Edit ${a.toLowerCase()} as text`,
|
|
1378
1378
|
label: a
|
|
1379
1379
|
};
|
|
1380
1380
|
}
|
|
1381
|
-
function
|
|
1381
|
+
function vn(e) {
|
|
1382
1382
|
if (e.type === "vesperInline") {
|
|
1383
|
-
let t =
|
|
1383
|
+
let t = $(e.attrs.source), n = qe(t);
|
|
1384
1384
|
return {
|
|
1385
1385
|
syntax: n.syntax,
|
|
1386
1386
|
open: n.open ?? t,
|
|
@@ -1391,7 +1391,7 @@ function yn(e) {
|
|
|
1391
1391
|
}
|
|
1392
1392
|
let t = e.attrs.syntax;
|
|
1393
1393
|
if (e.type === "vesperCard") {
|
|
1394
|
-
let n =
|
|
1394
|
+
let n = $(e.attrs.source), r = t === "markdoc" ? fe(n)[0]?.end ?? n.length : ce(n)?.openEnd ?? n.length;
|
|
1395
1395
|
return {
|
|
1396
1396
|
syntax: t,
|
|
1397
1397
|
open: n.slice(0, r),
|
|
@@ -1400,11 +1400,11 @@ function yn(e) {
|
|
|
1400
1400
|
}
|
|
1401
1401
|
return {
|
|
1402
1402
|
syntax: t,
|
|
1403
|
-
open:
|
|
1403
|
+
open: $(e.attrs.open),
|
|
1404
1404
|
rest: ""
|
|
1405
1405
|
};
|
|
1406
1406
|
}
|
|
1407
|
-
function
|
|
1407
|
+
function yn(e, t, n) {
|
|
1408
1408
|
let r = e.state.tr.setNodeMarkup(t.pos, void 0, {
|
|
1409
1409
|
...t.attrs,
|
|
1410
1410
|
...n
|
|
@@ -1412,80 +1412,80 @@ function $(e, t, n) {
|
|
|
1412
1412
|
e.view.dispatch(r);
|
|
1413
1413
|
}
|
|
1414
1414
|
function bn(e, t, n) {
|
|
1415
|
-
let r =
|
|
1416
|
-
t.type === "vesperInline" || t.type === "vesperCard" ?
|
|
1415
|
+
let r = vn(t);
|
|
1416
|
+
t.type === "vesperInline" || t.type === "vesperCard" ? yn(e, t, { source: n + r.rest }) : yn(e, t, { open: n });
|
|
1417
1417
|
}
|
|
1418
|
-
function xn({ editor: e, target: t, kind:
|
|
1419
|
-
let
|
|
1418
|
+
function xn({ editor: e, target: t, kind: r }) {
|
|
1419
|
+
let a = Q(), o = D(), s = vn(t), { values: c, code: l } = We(s.syntax, s.open), [u, f] = I(null), p = pn(t.type === "vesperInline" || t.type === "vesperCard" ? $(t.attrs.source) : s.syntax === "mdx" ? `${s.open}\n\n${$(t.attrs.close)}` : `${s.open}\n${$(t.attrs.close)}`), m = P(() => {
|
|
1420
1420
|
let e = {};
|
|
1421
|
-
for (let t of
|
|
1421
|
+
for (let t of r.fields) {
|
|
1422
1422
|
let n = t.path[0] ?? "", r = n in c ? c[n] : t.default;
|
|
1423
1423
|
r !== void 0 && (e[n] = r);
|
|
1424
1424
|
}
|
|
1425
1425
|
return e;
|
|
1426
|
-
}, [
|
|
1426
|
+
}, [r.fields, c]), h = P(() => {
|
|
1427
1427
|
let e = /* @__PURE__ */ new Map();
|
|
1428
1428
|
for (let t of p) {
|
|
1429
1429
|
if (!t.attribute || t.level !== "error") continue;
|
|
1430
|
-
let n =
|
|
1430
|
+
let n = g([t.attribute]), r = t.message.replace(/^[^:]+: /, "");
|
|
1431
1431
|
e.set(n, [...e.get(n) ?? [], r]);
|
|
1432
1432
|
}
|
|
1433
1433
|
return e;
|
|
1434
|
-
}, [p]),
|
|
1435
|
-
...
|
|
1434
|
+
}, [p]), _ = r.builtin === "partial" ? r.fields.filter((e) => e.path[0] !== "file") : r.fields, v = {
|
|
1435
|
+
...o,
|
|
1436
1436
|
values: m,
|
|
1437
1437
|
issues: h,
|
|
1438
|
-
disabled:
|
|
1438
|
+
disabled: a.disabled,
|
|
1439
1439
|
idPrefix: `block${String(t.pos)}`,
|
|
1440
|
-
setValue: (
|
|
1441
|
-
let
|
|
1442
|
-
|
|
1440
|
+
setValue: (i, a) => {
|
|
1441
|
+
let o = String(i[0]), c = i.length > 1 ? n(m, i, a)[o] ?? null : a, l = r.fields.find((e) => e.path[0] === o), u = l?.default !== void 0 && V(c, l.default) ? void 0 : c, d = (s.syntax === "markdoc" ? H : re)(s.open, [[o, u]], r.order);
|
|
1442
|
+
d === null ? f("This tag is written in a way the form can’t change. Edit it as Markdoc instead.") : (f(null), bn(e, t, d));
|
|
1443
1443
|
}
|
|
1444
1444
|
};
|
|
1445
|
-
return /* @__PURE__ */
|
|
1446
|
-
value:
|
|
1445
|
+
return /* @__PURE__ */ z(i.Provider, {
|
|
1446
|
+
value: v,
|
|
1447
1447
|
children: [
|
|
1448
|
-
|
|
1448
|
+
r.description && /* @__PURE__ */ R("p", {
|
|
1449
1449
|
className: "text-small text-content-muted",
|
|
1450
|
-
children:
|
|
1450
|
+
children: r.description
|
|
1451
1451
|
}),
|
|
1452
|
-
|
|
1452
|
+
u && /* @__PURE__ */ R("p", {
|
|
1453
1453
|
role: "alert",
|
|
1454
1454
|
className: "text-small text-danger",
|
|
1455
|
-
children:
|
|
1455
|
+
children: u
|
|
1456
1456
|
}),
|
|
1457
|
-
|
|
1457
|
+
r.builtin === "partial" && /* @__PURE__ */ R(Sn, {
|
|
1458
1458
|
value: typeof c.file == "string" ? c.file : "",
|
|
1459
1459
|
message: p.find((e) => e.code === "partial-missing")?.message,
|
|
1460
|
-
onChange: (
|
|
1461
|
-
let i =
|
|
1460
|
+
onChange: (n) => {
|
|
1461
|
+
let i = H(s.open, [["file", n]], r.order);
|
|
1462
1462
|
i && bn(e, t, i);
|
|
1463
1463
|
}
|
|
1464
1464
|
}),
|
|
1465
|
-
|
|
1465
|
+
_.map((e) => /* @__PURE__ */ R(C, {
|
|
1466
1466
|
field: e,
|
|
1467
1467
|
path: e.path
|
|
1468
1468
|
}, e.path.join("."))),
|
|
1469
|
-
t.type === "vesperInline" && s.close !== "" && /* @__PURE__ */
|
|
1469
|
+
t.type === "vesperInline" && s.close !== "" && /* @__PURE__ */ R(d, {
|
|
1470
1470
|
label: "Text",
|
|
1471
1471
|
description: "What the reader sees.",
|
|
1472
1472
|
value: s.inner ?? "",
|
|
1473
|
-
isDisabled:
|
|
1473
|
+
isDisabled: a.disabled,
|
|
1474
1474
|
onChange: (n) => {
|
|
1475
|
-
|
|
1475
|
+
yn(e, t, { source: s.open + n + (s.close ?? "") });
|
|
1476
1476
|
}
|
|
1477
1477
|
}),
|
|
1478
|
-
Object.keys(
|
|
1478
|
+
Object.keys(l).length > 0 && /* @__PURE__ */ z("div", {
|
|
1479
1479
|
className: "text-small text-content-muted",
|
|
1480
|
-
children: [/* @__PURE__ */
|
|
1480
|
+
children: [/* @__PURE__ */ R("p", { children: "Set in the page’s code, so kept as written:" }), /* @__PURE__ */ R("ul", {
|
|
1481
1481
|
className: "list-disc pl-6",
|
|
1482
|
-
children: Object.entries(
|
|
1483
|
-
/* @__PURE__ */
|
|
1482
|
+
children: Object.entries(l).map(([e, t]) => /* @__PURE__ */ z("li", { children: [
|
|
1483
|
+
/* @__PURE__ */ R("code", {
|
|
1484
1484
|
className: "font-mono",
|
|
1485
1485
|
children: e
|
|
1486
1486
|
}),
|
|
1487
1487
|
": ",
|
|
1488
|
-
/* @__PURE__ */
|
|
1488
|
+
/* @__PURE__ */ R("code", {
|
|
1489
1489
|
className: "font-mono",
|
|
1490
1490
|
children: t
|
|
1491
1491
|
})
|
|
@@ -1495,20 +1495,20 @@ function xn({ editor: e, target: t, kind: n }) {
|
|
|
1495
1495
|
]
|
|
1496
1496
|
});
|
|
1497
1497
|
}
|
|
1498
|
-
function Sn({ value: e, message:
|
|
1499
|
-
let
|
|
1500
|
-
return /* @__PURE__ */
|
|
1498
|
+
function Sn({ value: e, message: n, onChange: r }) {
|
|
1499
|
+
let i = Q(), a = Cn(i.partials ?? [], i.entryPath, e);
|
|
1500
|
+
return /* @__PURE__ */ R(t, {
|
|
1501
1501
|
label: "File",
|
|
1502
1502
|
description: "Text kept in its own file and shown here. Files whose names start with an underscore, or that sit in a partials folder, are listed.",
|
|
1503
|
-
options:
|
|
1503
|
+
options: a,
|
|
1504
1504
|
value: e === "" ? null : e,
|
|
1505
1505
|
onChange: (e) => {
|
|
1506
|
-
e !== null &&
|
|
1506
|
+
e !== null && r(e);
|
|
1507
1507
|
},
|
|
1508
|
-
isInvalid:
|
|
1509
|
-
errorMessage:
|
|
1508
|
+
isInvalid: n !== void 0,
|
|
1509
|
+
errorMessage: n?.replace(/^[^:]+: /, ""),
|
|
1510
1510
|
isRequired: !0,
|
|
1511
|
-
isDisabled:
|
|
1511
|
+
isDisabled: i.disabled
|
|
1512
1512
|
});
|
|
1513
1513
|
}
|
|
1514
1514
|
function Cn(e, t, n) {
|
|
@@ -1531,13 +1531,13 @@ function Tn(e, t) {
|
|
|
1531
1531
|
return [...Array(n.length - i).fill(".."), ...r.slice(i)].join("/");
|
|
1532
1532
|
}
|
|
1533
1533
|
function En({ editor: e, target: t }) {
|
|
1534
|
-
let n =
|
|
1535
|
-
return !i || !a ? /* @__PURE__ */
|
|
1534
|
+
let n = Q(), r = $(t.attrs.open), i = de(r), a = i?.attributes.find((e) => e.kind === "primary"), [o, s] = I(a ? r.slice(a.valueStart, a.valueEnd) : ""), [c, l] = I(!1);
|
|
1535
|
+
return !i || !a ? /* @__PURE__ */ R(Dn, {
|
|
1536
1536
|
editor: e,
|
|
1537
1537
|
target: t,
|
|
1538
1538
|
label: "Condition",
|
|
1539
1539
|
field: "open"
|
|
1540
|
-
}) : /* @__PURE__ */
|
|
1540
|
+
}) : /* @__PURE__ */ R(d, {
|
|
1541
1541
|
label: "Shown when",
|
|
1542
1542
|
description: "A Markdoc condition, such as $product.beta or equals($tier, \"free\"). The content inside is shown only when it’s true.",
|
|
1543
1543
|
value: o,
|
|
@@ -1547,14 +1547,14 @@ function En({ editor: e, target: t }) {
|
|
|
1547
1547
|
inputClassName: "font-mono",
|
|
1548
1548
|
onChange: (n) => {
|
|
1549
1549
|
s(n);
|
|
1550
|
-
let i = r.slice(0, a.valueStart) + n + r.slice(a.valueEnd), o = n.trim() !== "" &&
|
|
1551
|
-
l(!o), o &&
|
|
1550
|
+
let i = r.slice(0, a.valueStart) + n + r.slice(a.valueEnd), o = n.trim() !== "" && de(i)?.attributes.some((e) => e.kind === "primary");
|
|
1551
|
+
l(!o), o && yn(e, t, { open: i });
|
|
1552
1552
|
}
|
|
1553
1553
|
});
|
|
1554
1554
|
}
|
|
1555
1555
|
function Dn({ editor: e, target: t, label: n, field: r }) {
|
|
1556
|
-
let i =
|
|
1557
|
-
return /* @__PURE__ */
|
|
1556
|
+
let i = Q(), a = r ?? (t.type === "sourceBlock" ? "text" : "source"), o = $(t.attrs[a]);
|
|
1557
|
+
return /* @__PURE__ */ R(w, {
|
|
1558
1558
|
label: n,
|
|
1559
1559
|
description: "Kept exactly as written: Vesper never reformats it. Change it with care; the site reads it as code.",
|
|
1560
1560
|
value: o,
|
|
@@ -1562,29 +1562,29 @@ function Dn({ editor: e, target: t, label: n, field: r }) {
|
|
|
1562
1562
|
isDisabled: i.disabled,
|
|
1563
1563
|
inputClassName: "font-mono text-small",
|
|
1564
1564
|
onChange: (n) => {
|
|
1565
|
-
|
|
1565
|
+
yn(e, t, { [a]: n });
|
|
1566
1566
|
}
|
|
1567
1567
|
});
|
|
1568
1568
|
}
|
|
1569
1569
|
function On({ editor: e, target: t, onClose: n }) {
|
|
1570
|
-
let r =
|
|
1571
|
-
return /* @__PURE__ */
|
|
1570
|
+
let r = Q(), i = e.state.doc.resolve(t.pos), a = i.index(), o = i.parent.childCount;
|
|
1571
|
+
return /* @__PURE__ */ z("div", {
|
|
1572
1572
|
className: "flex flex-wrap items-center justify-between gap-3 border-t border-border pt-4",
|
|
1573
|
-
children: [/* @__PURE__ */
|
|
1573
|
+
children: [/* @__PURE__ */ z("div", {
|
|
1574
1574
|
className: "flex flex-wrap gap-2",
|
|
1575
|
-
children: [!t.inline && /* @__PURE__ */
|
|
1575
|
+
children: [!t.inline && /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(_, {
|
|
1576
1576
|
isDisabled: r.disabled || a === 0,
|
|
1577
1577
|
onPress: () => {
|
|
1578
1578
|
r.move(t.pos, -1);
|
|
1579
1579
|
},
|
|
1580
1580
|
children: "Move up"
|
|
1581
|
-
}), /* @__PURE__ */
|
|
1581
|
+
}), /* @__PURE__ */ R(_, {
|
|
1582
1582
|
isDisabled: r.disabled || a >= o - 1,
|
|
1583
1583
|
onPress: () => {
|
|
1584
1584
|
r.move(t.pos, 1);
|
|
1585
1585
|
},
|
|
1586
1586
|
children: "Move down"
|
|
1587
|
-
})] }), /* @__PURE__ */
|
|
1587
|
+
})] }), /* @__PURE__ */ R(_, {
|
|
1588
1588
|
variant: "quiet",
|
|
1589
1589
|
isDisabled: r.disabled,
|
|
1590
1590
|
onPress: () => {
|
|
@@ -1592,7 +1592,7 @@ function On({ editor: e, target: t, onClose: n }) {
|
|
|
1592
1592
|
},
|
|
1593
1593
|
children: "Remove"
|
|
1594
1594
|
})]
|
|
1595
|
-
}), /* @__PURE__ */
|
|
1595
|
+
}), /* @__PURE__ */ R(_, {
|
|
1596
1596
|
variant: "primary",
|
|
1597
1597
|
onPress: n,
|
|
1598
1598
|
children: "Done"
|
|
@@ -1601,7 +1601,7 @@ function On({ editor: e, target: t, onClose: n }) {
|
|
|
1601
1601
|
}
|
|
1602
1602
|
//#endregion
|
|
1603
1603
|
//#region src/body/TableView.tsx
|
|
1604
|
-
var kn =
|
|
1604
|
+
var kn = m("in-[.ProseMirror-focused]:outline-2 in-[.ProseMirror-focused]:outline-solid in-[.ProseMirror-focused]:outline-offset-2 in-[.ProseMirror-focused]:outline-focus", "in-[.ProseMirror-focused]:ring-6 in-[.ProseMirror-focused]:ring-(color:--glow-focus)"), An = [
|
|
1605
1605
|
{
|
|
1606
1606
|
id: "left",
|
|
1607
1607
|
label: "Left",
|
|
@@ -1628,7 +1628,7 @@ var kn = S("in-[.ProseMirror-focused]:outline-2 in-[.ProseMirror-focused]:outlin
|
|
|
1628
1628
|
right: "text-right"
|
|
1629
1629
|
};
|
|
1630
1630
|
function Mn(e, t) {
|
|
1631
|
-
let n =
|
|
1631
|
+
let n = qe(t), r = (n.name ? e.catalog.find(n.syntax, n.name) : void 0)?.label ?? (n.name && (n.kind === "tag" || n.kind === "component") ? X(n.syntax, n.name) : null);
|
|
1632
1632
|
if (r === null) return t.length > 40 ? `${t.slice(0, 37)}…` : t;
|
|
1633
1633
|
let i = n.inner ?? "";
|
|
1634
1634
|
return i && !/[{<*_`[\]\\]/.test(i) ? `${r} · ${i}` : r;
|
|
@@ -1637,31 +1637,31 @@ function Nn(e, t) {
|
|
|
1637
1637
|
return t.map((t) => t.type === "text" ? t.text ?? "" : t.type === "image" ? String(t.attrs?.alt ?? "") : t.type === "vesperInline" ? Mn(e, String(t.attrs?.source ?? "")) : "").join("").trim();
|
|
1638
1638
|
}
|
|
1639
1639
|
function Pn({ inline: e }) {
|
|
1640
|
-
let t =
|
|
1640
|
+
let t = Q();
|
|
1641
1641
|
return e.map((e, n) => {
|
|
1642
1642
|
if (e.type === "image") {
|
|
1643
1643
|
let t = String(e.attrs?.alt ?? "");
|
|
1644
|
-
return /* @__PURE__ */
|
|
1644
|
+
return /* @__PURE__ */ R("span", {
|
|
1645
1645
|
className: "text-content-muted",
|
|
1646
1646
|
children: t ? `Image: ${t}` : "Image"
|
|
1647
1647
|
}, n);
|
|
1648
1648
|
}
|
|
1649
|
-
if (e.type === "vesperInline") return /* @__PURE__ */
|
|
1649
|
+
if (e.type === "vesperInline") return /* @__PURE__ */ R("span", {
|
|
1650
1650
|
className: "mx-0.5 rounded-sm border border-border-strong bg-surface-sunken px-1 py-0.5 text-small",
|
|
1651
1651
|
children: Mn(t, String(e.attrs?.source ?? ""))
|
|
1652
1652
|
}, n);
|
|
1653
1653
|
let r = e.text ?? "";
|
|
1654
|
-
for (let t of e.marks ?? []) t.type === "bold" ? r = /* @__PURE__ */
|
|
1654
|
+
for (let t of e.marks ?? []) t.type === "bold" ? r = /* @__PURE__ */ R("strong", {
|
|
1655
1655
|
className: "font-semibold",
|
|
1656
1656
|
children: r
|
|
1657
|
-
}) : t.type === "italic" ? r = /* @__PURE__ */
|
|
1657
|
+
}) : t.type === "italic" ? r = /* @__PURE__ */ R("em", { children: r }) : t.type === "strike" ? r = /* @__PURE__ */ R("s", { children: r }) : t.type === "code" ? r = /* @__PURE__ */ R("code", {
|
|
1658
1658
|
className: "font-mono text-small",
|
|
1659
1659
|
children: r
|
|
1660
|
-
}) : t.type === "link" && (r = /* @__PURE__ */
|
|
1660
|
+
}) : t.type === "link" && (r = /* @__PURE__ */ R("span", {
|
|
1661
1661
|
className: "text-accent underline",
|
|
1662
1662
|
children: r
|
|
1663
1663
|
}));
|
|
1664
|
-
return /* @__PURE__ */
|
|
1664
|
+
return /* @__PURE__ */ R(ne, { children: r }, n);
|
|
1665
1665
|
});
|
|
1666
1666
|
}
|
|
1667
1667
|
var Fn = class {
|
|
@@ -1676,14 +1676,14 @@ var Fn = class {
|
|
|
1676
1676
|
finish(e, t) {
|
|
1677
1677
|
return this.done || (this.done = !0, this.onFinish(this.changed ? e.getJSON().content[0]?.content ?? [] : null, t)), !0;
|
|
1678
1678
|
}
|
|
1679
|
-
}, In =
|
|
1679
|
+
}, In = G.create({
|
|
1680
1680
|
name: "doc",
|
|
1681
1681
|
topNode: !0,
|
|
1682
1682
|
content: "paragraph"
|
|
1683
1683
|
});
|
|
1684
1684
|
function Ln({ inline: e, label: t, describedBy: n, chipName: r, onFinish: i }) {
|
|
1685
|
-
let [a, o] =
|
|
1686
|
-
|
|
1685
|
+
let [a, o] = I(!1), [s] = I(() => new Fn());
|
|
1686
|
+
M(() => {
|
|
1687
1687
|
s.update({
|
|
1688
1688
|
onFinish: i,
|
|
1689
1689
|
linkOpen: a,
|
|
@@ -1692,9 +1692,9 @@ function Ln({ inline: e, label: t, describedBy: n, chipName: r, onFinish: i }) {
|
|
|
1692
1692
|
}
|
|
1693
1693
|
});
|
|
1694
1694
|
});
|
|
1695
|
-
let [c] =
|
|
1695
|
+
let [c] = I(() => [
|
|
1696
1696
|
In,
|
|
1697
|
-
|
|
1697
|
+
Ee.configure({
|
|
1698
1698
|
document: !1,
|
|
1699
1699
|
heading: !1,
|
|
1700
1700
|
blockquote: !1,
|
|
@@ -1713,15 +1713,15 @@ function Ln({ inline: e, label: t, describedBy: n, chipName: r, onFinish: i }) {
|
|
|
1713
1713
|
defaultProtocol: "https"
|
|
1714
1714
|
}
|
|
1715
1715
|
}),
|
|
1716
|
-
|
|
1717
|
-
|
|
1716
|
+
_e.configure({ inline: !0 }),
|
|
1717
|
+
Et.extend({ addNodeView() {
|
|
1718
1718
|
return ({ node: e }) => {
|
|
1719
1719
|
let t = document.createElement("span");
|
|
1720
1720
|
return t.className = "mx-0.5 rounded-sm border border-border-strong bg-surface-sunken px-1 py-0.5 text-small", t.textContent = r(String(e.attrs.source)), { dom: t };
|
|
1721
1721
|
};
|
|
1722
1722
|
} }),
|
|
1723
|
-
|
|
1724
|
-
|
|
1723
|
+
ve,
|
|
1724
|
+
W.create({
|
|
1725
1725
|
name: "vesperCellKeys",
|
|
1726
1726
|
addKeyboardShortcuts() {
|
|
1727
1727
|
let e = this.editor;
|
|
@@ -1735,7 +1735,7 @@ function Ln({ inline: e, label: t, describedBy: n, chipName: r, onFinish: i }) {
|
|
|
1735
1735
|
};
|
|
1736
1736
|
}
|
|
1737
1737
|
}),
|
|
1738
|
-
|
|
1738
|
+
W.create({
|
|
1739
1739
|
name: "vesperCellBlur",
|
|
1740
1740
|
onUpdate() {
|
|
1741
1741
|
s.changed = !0;
|
|
@@ -1747,7 +1747,7 @@ function Ln({ inline: e, label: t, describedBy: n, chipName: r, onFinish: i }) {
|
|
|
1747
1747
|
}, 0);
|
|
1748
1748
|
}
|
|
1749
1749
|
})
|
|
1750
|
-
]), l =
|
|
1750
|
+
]), l = Te({
|
|
1751
1751
|
immediatelyRender: !0,
|
|
1752
1752
|
shouldRerenderOnTransaction: !1,
|
|
1753
1753
|
extensions: c,
|
|
@@ -1766,7 +1766,7 @@ function Ln({ inline: e, label: t, describedBy: n, chipName: r, onFinish: i }) {
|
|
|
1766
1766
|
class: "vesper-body min-h-6 w-full min-w-24 text-body text-content outline-none"
|
|
1767
1767
|
} }
|
|
1768
1768
|
});
|
|
1769
|
-
return
|
|
1769
|
+
return M(() => {
|
|
1770
1770
|
let e = () => {
|
|
1771
1771
|
l.commands.setTextSelection(l.state.doc.content.size - 1), l.view.focus();
|
|
1772
1772
|
};
|
|
@@ -1777,7 +1777,7 @@ function Ln({ inline: e, label: t, describedBy: n, chipName: r, onFinish: i }) {
|
|
|
1777
1777
|
return () => {
|
|
1778
1778
|
cancelAnimationFrame(t);
|
|
1779
1779
|
};
|
|
1780
|
-
}, [l, s]), /* @__PURE__ */
|
|
1780
|
+
}, [l, s]), /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(Ce, { editor: l }), /* @__PURE__ */ R(dr, {
|
|
1781
1781
|
editor: l,
|
|
1782
1782
|
isOpen: a,
|
|
1783
1783
|
onOpenChange: (e) => {
|
|
@@ -1786,154 +1786,154 @@ function Ln({ inline: e, label: t, describedBy: n, chipName: r, onFinish: i }) {
|
|
|
1786
1786
|
})] });
|
|
1787
1787
|
}
|
|
1788
1788
|
function Rn({ node: e, getPos: t, selected: n, editor: r }) {
|
|
1789
|
-
let i =
|
|
1789
|
+
let i = Q(), a = e.attrs.value, o = e.attrs.vesperBlock ?? null, s = r.markdown, c = a.rows.length, l = a.columns.length, u = N(), d = N(), f = N(), [g, _] = I({
|
|
1790
1790
|
row: 0,
|
|
1791
1791
|
col: 0
|
|
1792
|
-
}), [
|
|
1793
|
-
row: Math.min(
|
|
1794
|
-
col: Math.min(
|
|
1795
|
-
},
|
|
1796
|
-
at:
|
|
1797
|
-
editing:
|
|
1792
|
+
}), [v, ee] = I(null), [b, x] = I(null), [S, C] = I(!1), [te, w] = I(null), E = F(/* @__PURE__ */ new Map()), D = {
|
|
1793
|
+
row: Math.min(g.row, c - 1),
|
|
1794
|
+
col: Math.min(g.col, l - 1)
|
|
1795
|
+
}, O = F({
|
|
1796
|
+
at: D,
|
|
1797
|
+
editing: v
|
|
1798
1798
|
});
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
at:
|
|
1802
|
-
editing:
|
|
1799
|
+
M(() => {
|
|
1800
|
+
O.current = {
|
|
1801
|
+
at: D,
|
|
1802
|
+
editing: v
|
|
1803
1803
|
};
|
|
1804
1804
|
});
|
|
1805
|
-
let
|
|
1805
|
+
let k = P(() => a.rows.map((e) => e.cells.map((e) => Ze(s, e) ?? [])), [a, s]), ne = (k[0] ?? []).map((e, t) => Nn(i, e) || `column ${String(t + 1)}`), A = (e) => ne[e] ?? `column ${String(e + 1)}`, j = () => {
|
|
1806
1806
|
setTimeout(() => {
|
|
1807
|
-
let { at: e, editing: t } =
|
|
1808
|
-
t ||
|
|
1807
|
+
let { at: e, editing: t } = O.current;
|
|
1808
|
+
t || E.current.get(`${String(e.row)}:${String(e.col)}`)?.focus();
|
|
1809
1809
|
}, 0);
|
|
1810
|
-
},
|
|
1810
|
+
}, L = (e, t, n = a) => {
|
|
1811
1811
|
let r = {
|
|
1812
1812
|
row: Math.max(0, Math.min(n.rows.length - 1, e)),
|
|
1813
1813
|
col: Math.max(0, Math.min(n.columns.length - 1, t))
|
|
1814
1814
|
};
|
|
1815
|
-
|
|
1816
|
-
...
|
|
1815
|
+
O.current = {
|
|
1816
|
+
...O.current,
|
|
1817
1817
|
at: r
|
|
1818
|
-
},
|
|
1819
|
-
},
|
|
1820
|
-
|
|
1821
|
-
at: e ??
|
|
1818
|
+
}, _(r), j();
|
|
1819
|
+
}, B = (e) => {
|
|
1820
|
+
O.current = {
|
|
1821
|
+
at: e ?? O.current.at,
|
|
1822
1822
|
editing: e
|
|
1823
|
-
}, e &&
|
|
1823
|
+
}, e && _(e), ee(e);
|
|
1824
1824
|
};
|
|
1825
|
-
|
|
1826
|
-
i.takeNewTable() &&
|
|
1825
|
+
M(() => {
|
|
1826
|
+
i.takeNewTable() && B({
|
|
1827
1827
|
row: 0,
|
|
1828
1828
|
col: 0
|
|
1829
1829
|
});
|
|
1830
1830
|
}, []);
|
|
1831
|
-
let
|
|
1831
|
+
let V = (e, n) => {
|
|
1832
1832
|
let a = i.checkTable(o, e);
|
|
1833
|
-
if (!a.ok) return
|
|
1833
|
+
if (!a.ok) return w(a.reason), i.announce(a.reason), !1;
|
|
1834
1834
|
let s = t(), c = typeof s == "number" ? r.state.doc.nodeAt(s) : null;
|
|
1835
|
-
return typeof s != "number" || c?.type.name !== "vesperTable" ? !1 : (
|
|
1835
|
+
return typeof s != "number" || c?.type.name !== "vesperTable" ? !1 : (w(null), r.view.dispatch(Oe(r.state.tr.setNodeMarkup(s, void 0, {
|
|
1836
1836
|
...c.attrs,
|
|
1837
1837
|
value: e
|
|
1838
1838
|
}))), n && i.announce(n), !0);
|
|
1839
|
-
},
|
|
1839
|
+
}, re = () => {
|
|
1840
1840
|
let e = t();
|
|
1841
|
-
typeof e == "number" &&
|
|
1842
|
-
},
|
|
1843
|
-
let r =
|
|
1841
|
+
typeof e == "number" && mt(r, e);
|
|
1842
|
+
}, H = (e) => e === 0 ? "the header row" : `row ${String(e + 1)}`, ie = (e, { row: t, col: n }) => {
|
|
1843
|
+
let r = A(n), i = String(t + 1);
|
|
1844
1844
|
return e === "row-above" && t > 0 ? [
|
|
1845
|
-
|
|
1846
|
-
`Row added above ${
|
|
1845
|
+
it(a, t),
|
|
1846
|
+
`Row added above ${H(t)}.`,
|
|
1847
1847
|
{
|
|
1848
1848
|
row: t,
|
|
1849
1849
|
col: n
|
|
1850
1850
|
}
|
|
1851
1851
|
] : e === "row-below" ? [
|
|
1852
|
-
|
|
1853
|
-
`Row added below ${
|
|
1852
|
+
it(a, t + 1),
|
|
1853
|
+
`Row added below ${H(t)}.`,
|
|
1854
1854
|
{
|
|
1855
1855
|
row: t + 1,
|
|
1856
1856
|
col: n
|
|
1857
1857
|
}
|
|
1858
1858
|
] : e === "column-left" ? [
|
|
1859
|
-
|
|
1859
|
+
at(a, n),
|
|
1860
1860
|
`Column added left of ${r}.`,
|
|
1861
1861
|
{
|
|
1862
1862
|
row: t,
|
|
1863
1863
|
col: n
|
|
1864
1864
|
}
|
|
1865
1865
|
] : e === "column-right" ? [
|
|
1866
|
-
|
|
1866
|
+
at(a, n + 1),
|
|
1867
1867
|
`Column added right of ${r}.`,
|
|
1868
1868
|
{
|
|
1869
1869
|
row: t,
|
|
1870
1870
|
col: n + 1
|
|
1871
1871
|
}
|
|
1872
1872
|
] : e === "row-up" && t > 1 ? [
|
|
1873
|
-
|
|
1873
|
+
ot(a, t, t - 1),
|
|
1874
1874
|
`Row ${i} moved up.`,
|
|
1875
1875
|
{
|
|
1876
1876
|
row: t - 1,
|
|
1877
1877
|
col: n
|
|
1878
1878
|
}
|
|
1879
1879
|
] : e === "row-down" && t > 0 && t < c - 1 ? [
|
|
1880
|
-
|
|
1880
|
+
ot(a, t, t + 1),
|
|
1881
1881
|
`Row ${i} moved down.`,
|
|
1882
1882
|
{
|
|
1883
1883
|
row: t + 1,
|
|
1884
1884
|
col: n
|
|
1885
1885
|
}
|
|
1886
1886
|
] : e === "column-move-left" && n > 0 ? [
|
|
1887
|
-
|
|
1887
|
+
st(a, n, n - 1),
|
|
1888
1888
|
`Column ${r} moved left.`,
|
|
1889
1889
|
{
|
|
1890
1890
|
row: t,
|
|
1891
1891
|
col: n - 1
|
|
1892
1892
|
}
|
|
1893
1893
|
] : e === "column-move-right" && n < l - 1 ? [
|
|
1894
|
-
|
|
1894
|
+
st(a, n, n + 1),
|
|
1895
1895
|
`Column ${r} moved right.`,
|
|
1896
1896
|
{
|
|
1897
1897
|
row: t,
|
|
1898
1898
|
col: n + 1
|
|
1899
1899
|
}
|
|
1900
1900
|
] : e === "row-delete" && t > 0 ? [
|
|
1901
|
-
|
|
1901
|
+
ct(a, t),
|
|
1902
1902
|
`Row ${i} deleted.`,
|
|
1903
1903
|
{
|
|
1904
1904
|
row: t,
|
|
1905
1905
|
col: n
|
|
1906
1906
|
}
|
|
1907
1907
|
] : e === "column-delete" && l > 1 ? [
|
|
1908
|
-
|
|
1908
|
+
lt(a, n),
|
|
1909
1909
|
`Column ${r} deleted.`,
|
|
1910
1910
|
{
|
|
1911
1911
|
row: t,
|
|
1912
1912
|
col: n
|
|
1913
1913
|
}
|
|
1914
1914
|
] : null;
|
|
1915
|
-
},
|
|
1916
|
-
let t =
|
|
1917
|
-
t &&
|
|
1918
|
-
},
|
|
1919
|
-
let t = An.find((t) => t.id === e), { col: n } =
|
|
1915
|
+
}, U = (e) => {
|
|
1916
|
+
let t = ie(e, D);
|
|
1917
|
+
t && V(t[0], t[1]) ? L(t[2].row, t[2].col, t[0]) : L(D.row, D.col);
|
|
1918
|
+
}, ae = (e) => {
|
|
1919
|
+
let t = An.find((t) => t.id === e), { col: n } = D;
|
|
1920
1920
|
if (!t || a.align[n] === t.align) return;
|
|
1921
1921
|
let r = t.align === null ? "as written" : t.id === "center" ? "centre" : t.id;
|
|
1922
|
-
|
|
1923
|
-
},
|
|
1924
|
-
|
|
1922
|
+
V(ut(a, n, t.align), `Column ${A(n)} aligned ${r}.`);
|
|
1923
|
+
}, oe = (e) => (t, n) => {
|
|
1924
|
+
B(null);
|
|
1925
1925
|
let r = a, o;
|
|
1926
1926
|
if (t) {
|
|
1927
|
-
let n =
|
|
1928
|
-
if (!o ||
|
|
1927
|
+
let n = Qe(s, t), o = Ze(s, n);
|
|
1928
|
+
if (!o || Qe(s, o) !== n) {
|
|
1929
1929
|
let t = "That can’t be written in a table cell, so the cell wasn’t changed.";
|
|
1930
|
-
|
|
1930
|
+
w(t), i.announce(t), L(e.row, e.col);
|
|
1931
1931
|
return;
|
|
1932
1932
|
}
|
|
1933
|
-
n !== a.rows[e.row]?.cells[e.col] && (r =
|
|
1933
|
+
n !== a.rows[e.row]?.cells[e.col] && (r = rt(r, e.row, e.col, n));
|
|
1934
1934
|
}
|
|
1935
1935
|
let u = e.row === c - 1 && e.col === l - 1, d = null;
|
|
1936
|
-
n === "next" && u ? (r =
|
|
1936
|
+
n === "next" && u ? (r = it(r, c), o = "Row added.", d = {
|
|
1937
1937
|
row: c,
|
|
1938
1938
|
col: 0
|
|
1939
1939
|
}) : n === "next" ? d = e.col < l - 1 ? {
|
|
@@ -1948,35 +1948,35 @@ function Rn({ node: e, getPos: t, selected: n, editor: r }) {
|
|
|
1948
1948
|
} : e.row > 0 ? {
|
|
1949
1949
|
row: e.row - 1,
|
|
1950
1950
|
col: l - 1
|
|
1951
|
-
} : null), r !== a && !
|
|
1952
|
-
},
|
|
1953
|
-
if (
|
|
1954
|
-
let { row: t, col: n } =
|
|
1955
|
-
if (e.altKey && s && o === "ArrowUp")
|
|
1956
|
-
else if (e.altKey && s && o === "ArrowDown")
|
|
1957
|
-
else if (e.altKey && s && o === "ArrowLeft")
|
|
1958
|
-
else if (e.altKey && s && o === "ArrowRight")
|
|
1959
|
-
else if (o === "ArrowUp")
|
|
1960
|
-
else if (o === "ArrowDown")
|
|
1961
|
-
else if (o === "ArrowLeft")
|
|
1962
|
-
else if (o === "ArrowRight")
|
|
1963
|
-
else if (o === "Home")
|
|
1964
|
-
else if (o === "End")
|
|
1965
|
-
else if ((o === "Enter" || o === "F2") && s)
|
|
1951
|
+
} : null), r !== a && !V(r, o) ? L(e.row, e.col) : n !== "leave" && (d ? B(d) : L(e.row, e.col));
|
|
1952
|
+
}, se = (e) => {
|
|
1953
|
+
if (v) return;
|
|
1954
|
+
let { row: t, col: n } = D, a = T ? e.metaKey : e.ctrlKey, o = e.key, s = !i.disabled;
|
|
1955
|
+
if (e.altKey && s && o === "ArrowUp") U("row-up");
|
|
1956
|
+
else if (e.altKey && s && o === "ArrowDown") U("row-down");
|
|
1957
|
+
else if (e.altKey && s && o === "ArrowLeft") U("column-move-left");
|
|
1958
|
+
else if (e.altKey && s && o === "ArrowRight") U("column-move-right");
|
|
1959
|
+
else if (o === "ArrowUp") L(t - 1, n);
|
|
1960
|
+
else if (o === "ArrowDown") L(t + 1, n);
|
|
1961
|
+
else if (o === "ArrowLeft") L(t, n - 1);
|
|
1962
|
+
else if (o === "ArrowRight") L(t, n + 1);
|
|
1963
|
+
else if (o === "Home") L(e.ctrlKey || e.metaKey ? 0 : t, 0);
|
|
1964
|
+
else if (o === "End") L(e.ctrlKey || e.metaKey ? c - 1 : t, l - 1);
|
|
1965
|
+
else if ((o === "Enter" || o === "F2") && s) B({
|
|
1966
1966
|
row: t,
|
|
1967
1967
|
col: n
|
|
1968
1968
|
});
|
|
1969
|
-
else if (o === "Escape")
|
|
1970
|
-
else if ((o === "F10" && e.shiftKey || o === "ContextMenu") && s)
|
|
1969
|
+
else if (o === "Escape") re();
|
|
1970
|
+
else if ((o === "F10" && e.shiftKey || o === "ContextMenu") && s) x("cell");
|
|
1971
1971
|
else if (a && o.toLowerCase() === "z") e.shiftKey ? r.commands.redo() : r.commands.undo();
|
|
1972
1972
|
else if (a && o.toLowerCase() === "y") r.commands.redo();
|
|
1973
1973
|
else return;
|
|
1974
1974
|
e.preventDefault(), e.stopPropagation();
|
|
1975
|
-
},
|
|
1975
|
+
}, ce = [
|
|
1976
1976
|
{
|
|
1977
1977
|
id: "row-above",
|
|
1978
1978
|
label: "Insert row above",
|
|
1979
|
-
isDisabled:
|
|
1979
|
+
isDisabled: D.row === 0
|
|
1980
1980
|
},
|
|
1981
1981
|
{
|
|
1982
1982
|
id: "row-below",
|
|
@@ -1993,28 +1993,28 @@ function Rn({ node: e, getPos: t, selected: n, editor: r }) {
|
|
|
1993
1993
|
{
|
|
1994
1994
|
id: "row-up",
|
|
1995
1995
|
label: "Move row up",
|
|
1996
|
-
isDisabled:
|
|
1996
|
+
isDisabled: D.row <= 1
|
|
1997
1997
|
},
|
|
1998
1998
|
{
|
|
1999
1999
|
id: "row-down",
|
|
2000
2000
|
label: "Move row down",
|
|
2001
|
-
isDisabled:
|
|
2001
|
+
isDisabled: D.row === 0 || D.row === c - 1
|
|
2002
2002
|
},
|
|
2003
2003
|
{
|
|
2004
2004
|
id: "column-move-left",
|
|
2005
2005
|
label: "Move column left",
|
|
2006
|
-
isDisabled:
|
|
2006
|
+
isDisabled: D.col === 0
|
|
2007
2007
|
},
|
|
2008
2008
|
{
|
|
2009
2009
|
id: "column-move-right",
|
|
2010
2010
|
label: "Move column right",
|
|
2011
|
-
isDisabled:
|
|
2011
|
+
isDisabled: D.col === l - 1
|
|
2012
2012
|
},
|
|
2013
2013
|
{
|
|
2014
2014
|
id: "row-delete",
|
|
2015
2015
|
label: "Delete row",
|
|
2016
2016
|
isDanger: !0,
|
|
2017
|
-
isDisabled:
|
|
2017
|
+
isDisabled: D.row === 0
|
|
2018
2018
|
},
|
|
2019
2019
|
{
|
|
2020
2020
|
id: "column-delete",
|
|
@@ -2022,88 +2022,88 @@ function Rn({ node: e, getPos: t, selected: n, editor: r }) {
|
|
|
2022
2022
|
isDanger: !0,
|
|
2023
2023
|
isDisabled: l <= 1
|
|
2024
2024
|
}
|
|
2025
|
-
],
|
|
2026
|
-
return /* @__PURE__ */
|
|
2025
|
+
], le = An.find((e) => e.align === (a.align[D.col] ?? null)) ?? An[3], ue = l === 1 ? "column" : "columns";
|
|
2026
|
+
return /* @__PURE__ */ z(q, {
|
|
2027
2027
|
as: "div",
|
|
2028
2028
|
role: "group",
|
|
2029
2029
|
"aria-labelledby": u,
|
|
2030
|
-
"aria-describedby":
|
|
2030
|
+
"aria-describedby": te ? d : void 0,
|
|
2031
2031
|
onFocus: () => {
|
|
2032
|
-
|
|
2032
|
+
C(!0);
|
|
2033
2033
|
},
|
|
2034
2034
|
onBlur: (e) => {
|
|
2035
|
-
e.currentTarget.contains(e.relatedTarget) ||
|
|
2035
|
+
e.currentTarget.contains(e.relatedTarget) || C(!1);
|
|
2036
2036
|
},
|
|
2037
|
-
className:
|
|
2037
|
+
className: m("my-3", n && kn),
|
|
2038
2038
|
children: [
|
|
2039
|
-
/* @__PURE__ */
|
|
2039
|
+
/* @__PURE__ */ z("div", {
|
|
2040
2040
|
"data-vesper-table-ui": "",
|
|
2041
2041
|
className: "mb-1 flex items-center justify-between gap-2",
|
|
2042
|
-
children: [/* @__PURE__ */
|
|
2042
|
+
children: [/* @__PURE__ */ z("p", {
|
|
2043
2043
|
id: u,
|
|
2044
2044
|
className: "text-label text-content-muted",
|
|
2045
2045
|
children: [
|
|
2046
2046
|
"Table · ",
|
|
2047
2047
|
l,
|
|
2048
2048
|
" ",
|
|
2049
|
-
|
|
2049
|
+
ue
|
|
2050
2050
|
]
|
|
2051
|
-
}), !i.disabled && /* @__PURE__ */
|
|
2051
|
+
}), !i.disabled && /* @__PURE__ */ R(h, {
|
|
2052
2052
|
label: "Table actions",
|
|
2053
|
-
trigger: /* @__PURE__ */
|
|
2053
|
+
trigger: /* @__PURE__ */ R(p, {
|
|
2054
2054
|
icon: "more",
|
|
2055
2055
|
label: "Table actions",
|
|
2056
|
-
excludeFromTabOrder: !
|
|
2056
|
+
excludeFromTabOrder: !S,
|
|
2057
2057
|
className: "size-8"
|
|
2058
2058
|
}),
|
|
2059
|
-
items:
|
|
2060
|
-
onAction:
|
|
2059
|
+
items: ce,
|
|
2060
|
+
onAction: U,
|
|
2061
2061
|
choice: {
|
|
2062
2062
|
title: "Align column",
|
|
2063
2063
|
options: An.map((e) => ({
|
|
2064
2064
|
id: e.id,
|
|
2065
2065
|
label: e.label
|
|
2066
2066
|
})),
|
|
2067
|
-
selected:
|
|
2068
|
-
onChange:
|
|
2067
|
+
selected: le?.id ?? "none",
|
|
2068
|
+
onChange: ae
|
|
2069
2069
|
},
|
|
2070
|
-
isOpen:
|
|
2070
|
+
isOpen: b !== null,
|
|
2071
2071
|
onOpenChange: (e) => {
|
|
2072
|
-
let t =
|
|
2073
|
-
|
|
2072
|
+
let t = b;
|
|
2073
|
+
x(e ? t ?? "button" : null), !e && t === "cell" && j();
|
|
2074
2074
|
}
|
|
2075
2075
|
})]
|
|
2076
2076
|
}),
|
|
2077
|
-
/* @__PURE__ */
|
|
2077
|
+
/* @__PURE__ */ R("div", {
|
|
2078
2078
|
"data-vesper-table-ui": "",
|
|
2079
2079
|
className: "overflow-x-auto rounded-md border border-border bg-surface-raised",
|
|
2080
|
-
children: /* @__PURE__ */
|
|
2080
|
+
children: /* @__PURE__ */ R("table", {
|
|
2081
2081
|
role: "grid",
|
|
2082
|
-
"aria-label": `Table: ${
|
|
2082
|
+
"aria-label": `Table: ${ne.join(", ")}`,
|
|
2083
2083
|
"aria-rowcount": c,
|
|
2084
2084
|
"aria-colcount": l,
|
|
2085
2085
|
"aria-describedby": f,
|
|
2086
|
-
onKeyDown:
|
|
2086
|
+
onKeyDown: se,
|
|
2087
2087
|
className: "w-full border-collapse text-body",
|
|
2088
2088
|
children: [a.rows.slice(0, 1), a.rows.slice(1)].map((e, t) => {
|
|
2089
2089
|
let n = e.map((e, n) => {
|
|
2090
2090
|
let r = t === 0 ? n : n + 1;
|
|
2091
|
-
return /* @__PURE__ */
|
|
2091
|
+
return /* @__PURE__ */ R("tr", {
|
|
2092
2092
|
"aria-rowindex": r + 1,
|
|
2093
2093
|
children: e.cells.map((e, t) => {
|
|
2094
|
-
let n =
|
|
2095
|
-
return /* @__PURE__ */
|
|
2094
|
+
let n = D.row === r && D.col === t, o = v?.row === r && v.col === t;
|
|
2095
|
+
return /* @__PURE__ */ R(r === 0 ? "th" : "td", {
|
|
2096
2096
|
ref: (e) => {
|
|
2097
2097
|
let n = `${String(r)}:${String(t)}`;
|
|
2098
|
-
e ?
|
|
2098
|
+
e ? E.current.set(n, e) : E.current.delete(n);
|
|
2099
2099
|
},
|
|
2100
2100
|
role: r === 0 ? "columnheader" : "gridcell",
|
|
2101
2101
|
"aria-colindex": t + 1,
|
|
2102
|
-
tabIndex: n &&
|
|
2102
|
+
tabIndex: n && S && !o ? 0 : -1,
|
|
2103
2103
|
"data-vesper-active": n ? "" : void 0,
|
|
2104
2104
|
onFocus: (e) => {
|
|
2105
2105
|
if (o) return;
|
|
2106
|
-
|
|
2106
|
+
_({
|
|
2107
2107
|
row: r,
|
|
2108
2108
|
col: t
|
|
2109
2109
|
});
|
|
@@ -2111,51 +2111,51 @@ function Rn({ node: e, getPos: t, selected: n, editor: r }) {
|
|
|
2111
2111
|
n?.anchorNode && !e.currentTarget.contains(n.anchorNode) && n.removeAllRanges();
|
|
2112
2112
|
},
|
|
2113
2113
|
onDoubleClick: () => {
|
|
2114
|
-
i.disabled ||
|
|
2114
|
+
i.disabled || B({
|
|
2115
2115
|
row: r,
|
|
2116
2116
|
col: t
|
|
2117
2117
|
});
|
|
2118
2118
|
},
|
|
2119
|
-
className:
|
|
2120
|
-
children: o ? /* @__PURE__ */
|
|
2121
|
-
inline:
|
|
2122
|
-
label: `${
|
|
2119
|
+
className: m("border border-border px-3 py-2 align-top outline-none", r === 0 ? "bg-surface-sunken text-label text-content" : "text-content", jn[a.align[t] ?? ""] ?? "text-left", "focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-focus", o && "outline-2 outline-solid -outline-offset-2 outline-focus"),
|
|
2120
|
+
children: o ? /* @__PURE__ */ R(Ln, {
|
|
2121
|
+
inline: k[r]?.[t] ?? [],
|
|
2122
|
+
label: `${A(t)}, ${H(r)}`,
|
|
2123
2123
|
describedBy: f,
|
|
2124
2124
|
chipName: (e) => Mn(i, e),
|
|
2125
|
-
onFinish:
|
|
2125
|
+
onFinish: oe({
|
|
2126
2126
|
row: r,
|
|
2127
2127
|
col: t
|
|
2128
2128
|
})
|
|
2129
|
-
}) : /* @__PURE__ */
|
|
2129
|
+
}) : /* @__PURE__ */ R(Pn, { inline: k[r]?.[t] ?? [] })
|
|
2130
2130
|
}, t);
|
|
2131
2131
|
})
|
|
2132
2132
|
}, r);
|
|
2133
2133
|
});
|
|
2134
|
-
return t === 0 ? /* @__PURE__ */
|
|
2134
|
+
return t === 0 ? /* @__PURE__ */ R("thead", { children: n }, "head") : /* @__PURE__ */ R("tbody", { children: n }, "body");
|
|
2135
2135
|
})
|
|
2136
2136
|
})
|
|
2137
2137
|
}),
|
|
2138
|
-
/* @__PURE__ */
|
|
2138
|
+
/* @__PURE__ */ R("p", {
|
|
2139
2139
|
id: f,
|
|
2140
2140
|
className: "sr-only",
|
|
2141
|
-
children:
|
|
2141
|
+
children: v ? `Enter or Escape keeps the cell, Tab goes to the next. ${y("Mod", "B").text} bold, ${y("Mod", "I").text} italic, ${y("Mod", "E").text} code, ${y("Mod", "K").text} link.` : "Enter edits the cell. Shift+F10 for row and column actions. Escape returns to the text."
|
|
2142
2142
|
}),
|
|
2143
|
-
|
|
2143
|
+
te && /* @__PURE__ */ R("p", {
|
|
2144
2144
|
id: d,
|
|
2145
2145
|
className: "mt-2 text-small text-danger",
|
|
2146
|
-
children:
|
|
2146
|
+
children: te
|
|
2147
2147
|
})
|
|
2148
2148
|
]
|
|
2149
2149
|
});
|
|
2150
2150
|
}
|
|
2151
2151
|
//#endregion
|
|
2152
2152
|
//#region src/body/views.tsx
|
|
2153
|
-
var zn =
|
|
2153
|
+
var zn = m("in-[.ProseMirror-focused]:outline-2 in-[.ProseMirror-focused]:outline-solid in-[.ProseMirror-focused]:outline-offset-2 in-[.ProseMirror-focused]:outline-focus", "in-[.ProseMirror-focused]:ring-6 in-[.ProseMirror-focused]:ring-(color:--glow-focus)");
|
|
2154
2154
|
function Bn({ id: e, issues: t }) {
|
|
2155
|
-
return t.length === 0 ? null : /* @__PURE__ */
|
|
2155
|
+
return t.length === 0 ? null : /* @__PURE__ */ R("ul", {
|
|
2156
2156
|
id: e,
|
|
2157
2157
|
className: "mt-2 flex flex-col gap-1 text-small",
|
|
2158
|
-
children: t.map((e) => /* @__PURE__ */
|
|
2158
|
+
children: t.map((e) => /* @__PURE__ */ R("li", {
|
|
2159
2159
|
className: e.level === "error" ? "text-danger" : "text-content-muted",
|
|
2160
2160
|
children: e.level === "error" ? e.message : `Note: ${e.message}`
|
|
2161
2161
|
}, `${String(e.line)}${e.message}`))
|
|
@@ -2165,7 +2165,7 @@ function Vn(e, t) {
|
|
|
2165
2165
|
return t ? `${e} · ${t}` : e;
|
|
2166
2166
|
}
|
|
2167
2167
|
function Hn({ node: e, getPos: t, selected: n, editor: r }) {
|
|
2168
|
-
let i =
|
|
2168
|
+
let i = Q(), a = N(), o = N(), s = e.attrs.syntax, c = String(e.attrs.name), l = String(e.attrs.open), u = String(e.attrs.close), d = i.catalog.find(s, c), f = d?.label ?? X(s, c), p = d?.builtin === "if" ? `shown when ${Gn(l)}` : mn(d, We(s, l).values), h = pn(s === "mdx" ? `${l}\n\n${u}` : `${l}\n${u}`), g = Y({
|
|
2169
2169
|
editor: r,
|
|
2170
2170
|
selector: ({ editor: n }) => {
|
|
2171
2171
|
let r = t();
|
|
@@ -2174,40 +2174,40 @@ function Hn({ node: e, getPos: t, selected: n, editor: r }) {
|
|
|
2174
2174
|
return i > r && a < r + e.nodeSize;
|
|
2175
2175
|
}
|
|
2176
2176
|
});
|
|
2177
|
-
return /* @__PURE__ */
|
|
2177
|
+
return /* @__PURE__ */ z(q, {
|
|
2178
2178
|
as: "div",
|
|
2179
2179
|
role: "group",
|
|
2180
2180
|
"aria-labelledby": a,
|
|
2181
|
-
"aria-describedby":
|
|
2182
|
-
className:
|
|
2181
|
+
"aria-describedby": h.length > 0 ? o : void 0,
|
|
2182
|
+
className: m("my-3 rounded-md border border-border p-3", h.some((e) => e.level === "error") && "border-danger", n && zn),
|
|
2183
2183
|
children: [
|
|
2184
|
-
/* @__PURE__ */
|
|
2184
|
+
/* @__PURE__ */ z("div", {
|
|
2185
2185
|
contentEditable: !1,
|
|
2186
2186
|
className: "mb-2 flex items-center justify-between gap-2",
|
|
2187
|
-
children: [/* @__PURE__ */
|
|
2187
|
+
children: [/* @__PURE__ */ R("p", {
|
|
2188
2188
|
id: a,
|
|
2189
2189
|
className: "text-label text-content-muted",
|
|
2190
2190
|
children: Vn(f, p)
|
|
2191
|
-
}), /* @__PURE__ */
|
|
2191
|
+
}), /* @__PURE__ */ R(Un, {
|
|
2192
2192
|
label: f,
|
|
2193
2193
|
getPos: t,
|
|
2194
|
-
inTabOrder:
|
|
2194
|
+
inTabOrder: g
|
|
2195
2195
|
})]
|
|
2196
2196
|
}),
|
|
2197
|
-
/* @__PURE__ */
|
|
2198
|
-
/* @__PURE__ */
|
|
2197
|
+
/* @__PURE__ */ R(we, { className: "vesper-container-content" }),
|
|
2198
|
+
/* @__PURE__ */ R("div", {
|
|
2199
2199
|
contentEditable: !1,
|
|
2200
|
-
children: /* @__PURE__ */
|
|
2200
|
+
children: /* @__PURE__ */ R(Bn, {
|
|
2201
2201
|
id: o,
|
|
2202
|
-
issues:
|
|
2202
|
+
issues: h
|
|
2203
2203
|
})
|
|
2204
2204
|
})
|
|
2205
2205
|
]
|
|
2206
2206
|
});
|
|
2207
2207
|
}
|
|
2208
2208
|
function Un({ label: e, getPos: t, inTabOrder: n }) {
|
|
2209
|
-
let r =
|
|
2210
|
-
return /* @__PURE__ */
|
|
2209
|
+
let r = Q();
|
|
2210
|
+
return /* @__PURE__ */ R(_, {
|
|
2211
2211
|
variant: "quiet",
|
|
2212
2212
|
excludeFromTabOrder: !n,
|
|
2213
2213
|
"aria-label": `Settings for ${e}`,
|
|
@@ -2221,26 +2221,26 @@ function Un({ label: e, getPos: t, inTabOrder: n }) {
|
|
|
2221
2221
|
});
|
|
2222
2222
|
}
|
|
2223
2223
|
function Wn({ node: e, getPos: t, selected: n }) {
|
|
2224
|
-
let r =
|
|
2225
|
-
return /* @__PURE__ */
|
|
2224
|
+
let r = Q(), i = N(), a = N(), o = e.attrs.syntax, s = String(e.attrs.name), c = String(e.attrs.source), l = r.catalog.find(o, s), u = l?.label ?? X(o, s), d = l?.builtin === "else" ? Gn(c) : l?.builtin === "if" ? "" : mn(l, We(o, c).values), f = pn(c);
|
|
2225
|
+
return /* @__PURE__ */ z(q, {
|
|
2226
2226
|
as: "div",
|
|
2227
2227
|
contentEditable: !1,
|
|
2228
2228
|
role: "group",
|
|
2229
2229
|
"aria-labelledby": i,
|
|
2230
2230
|
"aria-describedby": f.length > 0 ? a : void 0,
|
|
2231
|
-
className:
|
|
2232
|
-
children: [/* @__PURE__ */
|
|
2231
|
+
className: m("my-3 rounded-md border border-border bg-surface p-3", f.some((e) => e.level === "error") && "border-danger", n && zn),
|
|
2232
|
+
children: [/* @__PURE__ */ z("div", {
|
|
2233
2233
|
className: "flex items-center justify-between gap-2",
|
|
2234
|
-
children: [/* @__PURE__ */
|
|
2234
|
+
children: [/* @__PURE__ */ R("p", {
|
|
2235
2235
|
id: i,
|
|
2236
2236
|
className: "text-label text-content",
|
|
2237
2237
|
children: Vn(u, d)
|
|
2238
|
-
}), /* @__PURE__ */
|
|
2238
|
+
}), /* @__PURE__ */ R(Un, {
|
|
2239
2239
|
label: u,
|
|
2240
2240
|
getPos: t,
|
|
2241
2241
|
inTabOrder: !1
|
|
2242
2242
|
})]
|
|
2243
|
-
}), /* @__PURE__ */
|
|
2243
|
+
}), /* @__PURE__ */ R(Bn, {
|
|
2244
2244
|
id: a,
|
|
2245
2245
|
issues: f
|
|
2246
2246
|
})]
|
|
@@ -2250,11 +2250,11 @@ function Gn(e) {
|
|
|
2250
2250
|
return e.replace(/^\{%\s*(if|else)\b/, "").replace(/\/?%\}$/, "").trim();
|
|
2251
2251
|
}
|
|
2252
2252
|
function Kn({ node: e, selected: t }) {
|
|
2253
|
-
let n =
|
|
2254
|
-
return /* @__PURE__ */
|
|
2253
|
+
let n = Q(), r = String(e.attrs.source), i = qe(r), a = i.name ? n.catalog.find(i.syntax, i.name) : void 0, o = i.kind === "tag" || i.kind === "component", s = pn(o ? r : "").filter((e) => e.level === "error"), c = a && o, l = c ? Vn(a.label, qn(i.inner) || mn(a, We(i.syntax, i.open ?? "").values)) : r.length > 80 ? `${r.slice(0, 77)}…` : r;
|
|
2254
|
+
return /* @__PURE__ */ z(q, {
|
|
2255
2255
|
as: "span",
|
|
2256
|
-
className:
|
|
2257
|
-
children: [l, s.length > 0 && /* @__PURE__ */
|
|
2256
|
+
className: m("mx-0.5 rounded-sm border border-border-strong bg-surface-sunken px-1 py-0.5 text-small", !c && "font-mono", s.length > 0 && "border-danger", t && zn),
|
|
2257
|
+
children: [l, s.length > 0 && /* @__PURE__ */ z("span", {
|
|
2258
2258
|
className: "text-danger",
|
|
2259
2259
|
children: [
|
|
2260
2260
|
" (",
|
|
@@ -2268,17 +2268,17 @@ function qn(e) {
|
|
|
2268
2268
|
return !e || /[{<*_`[\]\\]/.test(e) ? "" : e;
|
|
2269
2269
|
}
|
|
2270
2270
|
function Jn({ node: e, getPos: t, selected: n }) {
|
|
2271
|
-
let r =
|
|
2272
|
-
return /* @__PURE__ */
|
|
2271
|
+
let r = Q(), i = String(e.attrs.text ?? "").split("\n"), a = qt(String(e.attrs.blockType ?? ""));
|
|
2272
|
+
return /* @__PURE__ */ z(q, {
|
|
2273
2273
|
as: "div",
|
|
2274
2274
|
contentEditable: !1,
|
|
2275
|
-
className:
|
|
2276
|
-
children: [/* @__PURE__ */
|
|
2275
|
+
className: m("my-3 rounded-md border border-dashed border-border-strong bg-surface-sunken p-3", n && zn),
|
|
2276
|
+
children: [/* @__PURE__ */ z("div", {
|
|
2277
2277
|
className: "mb-1 flex items-center justify-between gap-2",
|
|
2278
|
-
children: [/* @__PURE__ */
|
|
2278
|
+
children: [/* @__PURE__ */ z("p", {
|
|
2279
2279
|
className: "text-label text-content-muted",
|
|
2280
2280
|
children: [a, ", kept as written."]
|
|
2281
|
-
}), /* @__PURE__ */
|
|
2281
|
+
}), /* @__PURE__ */ R(_, {
|
|
2282
2282
|
variant: "quiet",
|
|
2283
2283
|
excludeFromTabOrder: !0,
|
|
2284
2284
|
"aria-label": `Edit as text: ${a}`,
|
|
@@ -2290,7 +2290,7 @@ function Jn({ node: e, getPos: t, selected: n }) {
|
|
|
2290
2290
|
className: "min-h-8 px-2 text-small",
|
|
2291
2291
|
children: "Edit as text"
|
|
2292
2292
|
})]
|
|
2293
|
-
}), /* @__PURE__ */
|
|
2293
|
+
}), /* @__PURE__ */ z("pre", {
|
|
2294
2294
|
className: "overflow-x-auto font-mono text-small whitespace-pre-wrap text-content",
|
|
2295
2295
|
children: [i.slice(0, 6).join("\n"), i.length > 6 ? `\n… ${String(i.length - 6)} more lines` : ""]
|
|
2296
2296
|
})]
|
|
@@ -2304,36 +2304,36 @@ var Yn = {
|
|
|
2304
2304
|
mdoc: "Markdoc"
|
|
2305
2305
|
};
|
|
2306
2306
|
function Xn(e) {
|
|
2307
|
-
let [t, n] =
|
|
2308
|
-
|
|
2307
|
+
let [t, n] = I("writing"), [r, i] = I(0), a = Yn[e.format], o = (e.issues ?? []).filter((e) => e.level === "error"), s = e.notes ?? [], c = F(null), l = F(t);
|
|
2308
|
+
M(() => {
|
|
2309
2309
|
l.current = t;
|
|
2310
2310
|
}, [t]);
|
|
2311
2311
|
let u = (e) => {
|
|
2312
2312
|
if (e.target.kind !== "body") return;
|
|
2313
2313
|
let t = document.getElementById("entry-body");
|
|
2314
|
-
l.current === "source" && t instanceof HTMLTextAreaElement ?
|
|
2315
|
-
}, d =
|
|
2316
|
-
|
|
2314
|
+
l.current === "source" && t instanceof HTMLTextAreaElement ? sn(t, e.target.start, e.target.end) : c.current?.(e.target.start);
|
|
2315
|
+
}, d = F(u);
|
|
2316
|
+
M(() => {
|
|
2317
2317
|
d.current = u;
|
|
2318
2318
|
});
|
|
2319
2319
|
let { apiRef: f } = e;
|
|
2320
|
-
return
|
|
2320
|
+
return M(() => {
|
|
2321
2321
|
if (f) return f.current = { reveal: (e) => {
|
|
2322
2322
|
d.current(e);
|
|
2323
2323
|
} }, () => {
|
|
2324
2324
|
f.current = null;
|
|
2325
2325
|
};
|
|
2326
|
-
}, [f]), /* @__PURE__ */
|
|
2326
|
+
}, [f]), /* @__PURE__ */ z("section", {
|
|
2327
2327
|
"aria-labelledby": "entry-body-label",
|
|
2328
2328
|
className: "flex flex-col gap-2",
|
|
2329
2329
|
children: [
|
|
2330
|
-
/* @__PURE__ */
|
|
2330
|
+
/* @__PURE__ */ z("div", {
|
|
2331
2331
|
className: "flex flex-wrap items-center justify-between gap-2",
|
|
2332
|
-
children: [/* @__PURE__ */
|
|
2332
|
+
children: [/* @__PURE__ */ R("span", {
|
|
2333
2333
|
id: "entry-body-label",
|
|
2334
2334
|
className: "text-label text-content",
|
|
2335
2335
|
children: "Body"
|
|
2336
|
-
}), /* @__PURE__ */
|
|
2336
|
+
}), /* @__PURE__ */ R(_, {
|
|
2337
2337
|
variant: "quiet",
|
|
2338
2338
|
onPress: () => {
|
|
2339
2339
|
t === "source" && i((e) => e + 1), n(t === "writing" ? "source" : "writing");
|
|
@@ -2341,14 +2341,14 @@ function Xn(e) {
|
|
|
2341
2341
|
children: t === "writing" ? `Edit as ${a}` : "Back to the writing view"
|
|
2342
2342
|
})]
|
|
2343
2343
|
}),
|
|
2344
|
-
t === "writing" ? /* @__PURE__ */
|
|
2344
|
+
t === "writing" ? /* @__PURE__ */ R(cr, {
|
|
2345
2345
|
...e,
|
|
2346
2346
|
revealRef: c
|
|
2347
|
-
}, r) : /* @__PURE__ */
|
|
2348
|
-
/* @__PURE__ */
|
|
2347
|
+
}, r) : /* @__PURE__ */ z(L, { children: [
|
|
2348
|
+
/* @__PURE__ */ R("textarea", {
|
|
2349
2349
|
id: "entry-body",
|
|
2350
2350
|
"aria-labelledby": "entry-body-label",
|
|
2351
|
-
"aria-describedby":
|
|
2351
|
+
"aria-describedby": m("entry-body-source-help", o.length > 0 && "entry-body-issues"),
|
|
2352
2352
|
"aria-invalid": o.length > 0 || void 0,
|
|
2353
2353
|
value: e.value,
|
|
2354
2354
|
onChange: (t) => {
|
|
@@ -2357,9 +2357,9 @@ function Xn(e) {
|
|
|
2357
2357
|
rows: 20,
|
|
2358
2358
|
spellCheck: !1,
|
|
2359
2359
|
disabled: e.disabled,
|
|
2360
|
-
className:
|
|
2360
|
+
className: m(O, "resize-y font-mono text-small leading-relaxed")
|
|
2361
2361
|
}),
|
|
2362
|
-
/* @__PURE__ */
|
|
2362
|
+
/* @__PURE__ */ z("p", {
|
|
2363
2363
|
id: "entry-body-source-help",
|
|
2364
2364
|
className: "text-small text-content-muted",
|
|
2365
2365
|
children: [
|
|
@@ -2368,10 +2368,10 @@ function Xn(e) {
|
|
|
2368
2368
|
", exactly as it’s saved."
|
|
2369
2369
|
]
|
|
2370
2370
|
}),
|
|
2371
|
-
o.length > 0 && /* @__PURE__ */
|
|
2371
|
+
o.length > 0 && /* @__PURE__ */ R("ul", {
|
|
2372
2372
|
id: "entry-body-issues",
|
|
2373
2373
|
className: "flex flex-col gap-1 text-small text-danger",
|
|
2374
|
-
children: o.map((e) => /* @__PURE__ */
|
|
2374
|
+
children: o.map((e) => /* @__PURE__ */ z("li", { children: [
|
|
2375
2375
|
"Line ",
|
|
2376
2376
|
e.line,
|
|
2377
2377
|
": ",
|
|
@@ -2379,7 +2379,7 @@ function Xn(e) {
|
|
|
2379
2379
|
] }, `${String(e.line)}${e.message}`))
|
|
2380
2380
|
})
|
|
2381
2381
|
] }),
|
|
2382
|
-
/* @__PURE__ */
|
|
2382
|
+
/* @__PURE__ */ R(Zn, {
|
|
2383
2383
|
notes: s,
|
|
2384
2384
|
lines: t === "source",
|
|
2385
2385
|
onShow: u
|
|
@@ -2388,28 +2388,28 @@ function Xn(e) {
|
|
|
2388
2388
|
});
|
|
2389
2389
|
}
|
|
2390
2390
|
function Zn({ notes: e, lines: t, onShow: n }) {
|
|
2391
|
-
return e.length === 0 ? null : /* @__PURE__ */
|
|
2391
|
+
return e.length === 0 ? null : /* @__PURE__ */ z("div", {
|
|
2392
2392
|
className: "flex flex-col gap-2",
|
|
2393
|
-
children: [/* @__PURE__ */
|
|
2393
|
+
children: [/* @__PURE__ */ R("p", {
|
|
2394
2394
|
id: "entry-body-a11y-label",
|
|
2395
2395
|
className: "text-label text-content",
|
|
2396
2396
|
children: "Accessibility notes in the body"
|
|
2397
|
-
}), /* @__PURE__ */
|
|
2397
|
+
}), /* @__PURE__ */ R("ul", {
|
|
2398
2398
|
"aria-labelledby": "entry-body-a11y-label",
|
|
2399
2399
|
className: "m-0 flex list-none flex-col gap-2 p-0",
|
|
2400
2400
|
children: e.map((e, r) => {
|
|
2401
2401
|
let i = `entry-body-a11y-${String(r)}`;
|
|
2402
|
-
return /* @__PURE__ */
|
|
2402
|
+
return /* @__PURE__ */ z("li", {
|
|
2403
2403
|
className: "flex flex-wrap items-start justify-between gap-2 text-small text-content",
|
|
2404
|
-
children: [/* @__PURE__ */
|
|
2404
|
+
children: [/* @__PURE__ */ z("p", {
|
|
2405
2405
|
id: i,
|
|
2406
2406
|
className: "m-0 flex min-w-0 flex-1 gap-2",
|
|
2407
|
-
children: [/* @__PURE__ */
|
|
2407
|
+
children: [/* @__PURE__ */ R(ee, {
|
|
2408
2408
|
name: "warning",
|
|
2409
2409
|
size: 16,
|
|
2410
2410
|
className: "mt-0.5 text-warning"
|
|
2411
|
-
}), /* @__PURE__ */
|
|
2412
|
-
}), /* @__PURE__ */
|
|
2411
|
+
}), /* @__PURE__ */ z("span", { children: [t && e.target.kind === "body" ? `Line ${String(e.target.line)}. ` : "", /* @__PURE__ */ R(v, { note: e })] })]
|
|
2412
|
+
}), /* @__PURE__ */ R(_, {
|
|
2413
2413
|
variant: "quiet",
|
|
2414
2414
|
"aria-describedby": i,
|
|
2415
2415
|
onPress: () => {
|
|
@@ -2422,14 +2422,14 @@ function Zn({ notes: e, lines: t, onShow: n }) {
|
|
|
2422
2422
|
})]
|
|
2423
2423
|
});
|
|
2424
2424
|
}
|
|
2425
|
-
var Qn =
|
|
2426
|
-
return
|
|
2427
|
-
} }), $n =
|
|
2428
|
-
return
|
|
2429
|
-
} }), er =
|
|
2430
|
-
return
|
|
2431
|
-
} }), tr =
|
|
2432
|
-
return
|
|
2425
|
+
var Qn = Ct.extend({ addNodeView() {
|
|
2426
|
+
return J(Jn);
|
|
2427
|
+
} }), $n = wt.extend({ addNodeView() {
|
|
2428
|
+
return J(Wn);
|
|
2429
|
+
} }), er = Et.extend({ addNodeView() {
|
|
2430
|
+
return J(Kn, { as: "span" });
|
|
2431
|
+
} }), tr = Tt.extend({ addNodeView() {
|
|
2432
|
+
return J(Rn, { stopEvent: ({ event: e }) => e.target instanceof Element && e.target.closest("[data-vesper-table-ui]") !== null });
|
|
2433
2433
|
} }), nr = class {
|
|
2434
2434
|
actions = {
|
|
2435
2435
|
open: () => void 0,
|
|
@@ -2443,45 +2443,45 @@ var Qn = wt.extend({ addNodeView() {
|
|
|
2443
2443
|
function rr(e) {
|
|
2444
2444
|
let { containers: t, actions: n } = e, r = (e, r) => {
|
|
2445
2445
|
if (n().disabled) return !1;
|
|
2446
|
-
let i =
|
|
2447
|
-
return a !== null && (
|
|
2446
|
+
let i = ft(e, t), a = i && i.type !== "vesperInline" ? i.pos : pt(e, t);
|
|
2447
|
+
return a !== null && (ht(e, a, r), !0);
|
|
2448
2448
|
};
|
|
2449
|
-
return
|
|
2449
|
+
return W.create({
|
|
2450
2450
|
name: "vesperShortcuts",
|
|
2451
2451
|
addKeyboardShortcuts() {
|
|
2452
2452
|
let i = this.editor;
|
|
2453
2453
|
return {
|
|
2454
2454
|
"Mod-k": () => (e.onLink(), !0),
|
|
2455
2455
|
Escape: () => {
|
|
2456
|
-
if (!
|
|
2457
|
-
let e =
|
|
2458
|
-
if (e !== null) return
|
|
2456
|
+
if (!ft(i, t)) {
|
|
2457
|
+
let e = pt(i, t);
|
|
2458
|
+
if (e !== null) return mt(i, e), !0;
|
|
2459
2459
|
}
|
|
2460
2460
|
return i.view.dom.closest("[data-vesper-body]")?.querySelector("[role=\"toolbar\"] button")?.focus(), !0;
|
|
2461
2461
|
},
|
|
2462
2462
|
Enter: () => {
|
|
2463
|
-
let e =
|
|
2463
|
+
let e = ft(i, t);
|
|
2464
2464
|
return !e || n().disabled ? !1 : (n().open(e.pos), !0);
|
|
2465
2465
|
},
|
|
2466
2466
|
"Alt-ArrowUp": () => r(i, -1),
|
|
2467
2467
|
"Alt-ArrowDown": () => r(i, 1),
|
|
2468
|
-
[
|
|
2469
|
-
[
|
|
2468
|
+
[T ? "Mod-ArrowUp" : "Mod-Home"]: () => ir(i, "start"),
|
|
2469
|
+
[T ? "Mod-ArrowDown" : "Mod-End"]: () => ir(i, "end")
|
|
2470
2470
|
};
|
|
2471
2471
|
},
|
|
2472
2472
|
addProseMirrorPlugins() {
|
|
2473
|
-
return [new
|
|
2473
|
+
return [new ye({ props: { handleDOMEvents: { keydown: (e, t) => ar(e, t) } } })];
|
|
2474
2474
|
}
|
|
2475
2475
|
});
|
|
2476
2476
|
}
|
|
2477
2477
|
function ir(e, t) {
|
|
2478
|
-
let { doc: n } = e.state, r = t === "start" ?
|
|
2478
|
+
let { doc: n } = e.state, r = t === "start" ? xe.atStart(n) : xe.atEnd(n);
|
|
2479
2479
|
return e.view.dispatch(e.state.tr.setSelection(r).scrollIntoView()), !0;
|
|
2480
2480
|
}
|
|
2481
2481
|
function ar(e, t) {
|
|
2482
|
-
if (!
|
|
2482
|
+
if (!T || !t.shiftKey || !t.metaKey || t.altKey || t.ctrlKey || t.key !== "ArrowLeft" && t.key !== "ArrowRight") return !1;
|
|
2483
2483
|
let { selection: n } = e.state;
|
|
2484
|
-
if (!(n instanceof
|
|
2484
|
+
if (!(n instanceof Se)) return !1;
|
|
2485
2485
|
let r = t.key === "ArrowLeft" == (getComputedStyle(e.dom).direction === "rtl") ? n.$head.nodeAfter : n.$head.nodeBefore;
|
|
2486
2486
|
return r !== null && !r.isText && r.isLeaf;
|
|
2487
2487
|
}
|
|
@@ -2490,7 +2490,7 @@ function or(e) {
|
|
|
2490
2490
|
}
|
|
2491
2491
|
function sr(e, t) {
|
|
2492
2492
|
if (!e.isFocused) return "";
|
|
2493
|
-
let n =
|
|
2493
|
+
let n = ft(e, t.containers);
|
|
2494
2494
|
if (!n) return "";
|
|
2495
2495
|
let r = e.state.doc.nodeAt(n.pos);
|
|
2496
2496
|
if (!r) return "";
|
|
@@ -2499,31 +2499,31 @@ function sr(e, t) {
|
|
|
2499
2499
|
return `Table, ${String(t)} ${t === 1 ? "column" : "columns"} and ${String(n)} ${n === 1 ? "row" : "rows"}, selected. Press Enter to edit its cells.`;
|
|
2500
2500
|
}
|
|
2501
2501
|
let i;
|
|
2502
|
-
if (r.type.name === "sourceBlock") i =
|
|
2502
|
+
if (r.type.name === "sourceBlock") i = qt(String(r.attrs.blockType ?? ""));
|
|
2503
2503
|
else if (r.type.name === "vesperInline") {
|
|
2504
|
-
let e =
|
|
2504
|
+
let e = qe(String(r.attrs.source));
|
|
2505
2505
|
i = (e.name ? t.catalog.find(e.syntax, e.name) : void 0)?.label ?? (e.kind === "variable" ? "Variable" : e.kind === "annotation" ? "Annotation" : "Tag");
|
|
2506
2506
|
} else {
|
|
2507
2507
|
let e = r.attrs.syntax, n = String(r.attrs.name);
|
|
2508
|
-
i = t.catalog.find(e, n)?.label ??
|
|
2508
|
+
i = t.catalog.find(e, n)?.label ?? X(e, n);
|
|
2509
2509
|
}
|
|
2510
2510
|
return `${i} selected. Press Enter for its settings.`;
|
|
2511
2511
|
}
|
|
2512
|
-
function cr({ value: t, onChange: n, format: r, disabled:
|
|
2513
|
-
let { manifest:
|
|
2514
|
-
|
|
2515
|
-
|
|
2512
|
+
function cr({ value: t, onChange: n, format: r, disabled: i, entryPath: a, imageFolder: s, partials: c = null, headingStart: d = 2, revealRef: f }) {
|
|
2513
|
+
let { manifest: p, loadMdxProps: h } = o(), g = F(null), _ = F(n);
|
|
2514
|
+
M(() => {
|
|
2515
|
+
_.current = n;
|
|
2516
2516
|
});
|
|
2517
|
-
let [
|
|
2518
|
-
let e =
|
|
2517
|
+
let [v, ee] = I(!1), y = F(null), [b, x] = I(!1), [S, C] = I(null), te = l(S), [w, T] = I(null), E = nn(), [D, O] = I(""), k = F(!1), [ne] = I(() => {
|
|
2518
|
+
let e = Ae(p, r);
|
|
2519
2519
|
return {
|
|
2520
2520
|
catalog: e,
|
|
2521
|
-
containers:
|
|
2521
|
+
containers: Ot(e)
|
|
2522
2522
|
};
|
|
2523
|
-
}), { catalog:
|
|
2524
|
-
let e = (e) =>
|
|
2523
|
+
}), { catalog: A, containers: j } = ne, [N] = I(() => new nr()), [L] = I(() => {
|
|
2524
|
+
let e = (e) => Jt(e, A, j);
|
|
2525
2525
|
return [
|
|
2526
|
-
|
|
2526
|
+
Ee.configure({
|
|
2527
2527
|
underline: !1,
|
|
2528
2528
|
trailingNode: !1,
|
|
2529
2529
|
link: {
|
|
@@ -2532,285 +2532,285 @@ function cr({ value: t, onChange: n, format: r, disabled: a, entryPath: o, image
|
|
|
2532
2532
|
defaultProtocol: "https"
|
|
2533
2533
|
}
|
|
2534
2534
|
}),
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2535
|
+
_e.configure({ inline: !0 }),
|
|
2536
|
+
ve,
|
|
2537
|
+
St,
|
|
2538
2538
|
Qn,
|
|
2539
2539
|
$n,
|
|
2540
2540
|
er,
|
|
2541
2541
|
tr,
|
|
2542
|
-
...
|
|
2543
|
-
return
|
|
2542
|
+
...j.extensions.map((e) => e.extend({ addNodeView() {
|
|
2543
|
+
return J(Hn);
|
|
2544
2544
|
} })),
|
|
2545
|
-
|
|
2545
|
+
Zt({
|
|
2546
2546
|
...E,
|
|
2547
2547
|
choices: e,
|
|
2548
2548
|
choose: (e, t) => {
|
|
2549
|
-
|
|
2549
|
+
N.actions.insert(e, t);
|
|
2550
2550
|
},
|
|
2551
|
-
disabled: () =>
|
|
2551
|
+
disabled: () => N.actions.disabled
|
|
2552
2552
|
}),
|
|
2553
2553
|
rr({
|
|
2554
|
-
containers:
|
|
2555
|
-
actions: () =>
|
|
2554
|
+
containers: j,
|
|
2555
|
+
actions: () => N.actions,
|
|
2556
2556
|
onLink: () => {
|
|
2557
|
-
|
|
2557
|
+
ee(!0);
|
|
2558
2558
|
}
|
|
2559
2559
|
})
|
|
2560
2560
|
];
|
|
2561
|
-
}),
|
|
2561
|
+
}), V = Te({
|
|
2562
2562
|
immediatelyRender: !0,
|
|
2563
2563
|
shouldRerenderOnTransaction: !1,
|
|
2564
|
-
editable: !
|
|
2565
|
-
extensions:
|
|
2564
|
+
editable: !i,
|
|
2565
|
+
extensions: L,
|
|
2566
2566
|
editorProps: {
|
|
2567
|
-
handleScrollToSelection: (e) =>
|
|
2567
|
+
handleScrollToSelection: (e) => un(e, y.current),
|
|
2568
2568
|
attributes: (e) => ({
|
|
2569
2569
|
id: "entry-body",
|
|
2570
2570
|
"aria-labelledby": "entry-body-label",
|
|
2571
2571
|
"aria-describedby": "entry-body-help",
|
|
2572
2572
|
class: "vesper-body min-h-72 resize-y overflow-y-auto px-4 py-3 text-body outline-none",
|
|
2573
|
-
|
|
2573
|
+
...Qt(e, {
|
|
2574
2574
|
...E,
|
|
2575
|
-
count: (t) =>
|
|
2575
|
+
count: (t) => Xt(Jt(e, A, j), t).length
|
|
2576
2576
|
})
|
|
2577
2577
|
})
|
|
2578
2578
|
},
|
|
2579
2579
|
onCreate: ({ editor: e }) => {
|
|
2580
|
-
let n =
|
|
2580
|
+
let n = At(t, {
|
|
2581
2581
|
format: r,
|
|
2582
2582
|
markdown: e.markdown,
|
|
2583
|
-
catalog:
|
|
2584
|
-
containers:
|
|
2585
|
-
...
|
|
2583
|
+
catalog: A,
|
|
2584
|
+
containers: j,
|
|
2585
|
+
...p.markdoc ? { markdoc: p.markdoc.options } : {}
|
|
2586
2586
|
});
|
|
2587
2587
|
e.commands.setContent(n.doc, { emitUpdate: !1 });
|
|
2588
|
-
let i =
|
|
2589
|
-
i && e.view.dispatch(e.state.tr.setSelection(i)),
|
|
2588
|
+
let i = xe.findFrom(e.state.doc.resolve(0), 1, !0);
|
|
2589
|
+
i && e.view.dispatch(e.state.tr.setSelection(i)), g.current = {
|
|
2590
2590
|
built: n,
|
|
2591
|
-
initial:
|
|
2591
|
+
initial: Rt(e.getJSON(), j)
|
|
2592
2592
|
};
|
|
2593
2593
|
},
|
|
2594
2594
|
onUpdate: ({ editor: e }) => {
|
|
2595
|
-
if (!
|
|
2596
|
-
let t =
|
|
2595
|
+
if (!g.current) return;
|
|
2596
|
+
let t = Bt(e.getJSON(), g.current.initial, {
|
|
2597
2597
|
markdown: e.markdown,
|
|
2598
|
-
containers:
|
|
2599
|
-
parsed:
|
|
2598
|
+
containers: j,
|
|
2599
|
+
parsed: g.current.built.parsed,
|
|
2600
2600
|
format: r,
|
|
2601
|
-
...
|
|
2601
|
+
...p.markdoc ? { markdoc: p.markdoc.options } : {}
|
|
2602
2602
|
});
|
|
2603
|
-
|
|
2603
|
+
_.current(B(g.current.built.parsed, t));
|
|
2604
2604
|
}
|
|
2605
2605
|
});
|
|
2606
|
-
function
|
|
2607
|
-
|
|
2608
|
-
let n =
|
|
2606
|
+
function re(e, t) {
|
|
2607
|
+
k.current = e.kind.builtin === "table";
|
|
2608
|
+
let n = yt(V, e.kind, e.shape, j, t, H(e));
|
|
2609
2609
|
n !== null && (e.kind.fields.length > 0 || e.shape === "inline") && T(n);
|
|
2610
2610
|
}
|
|
2611
|
-
function
|
|
2611
|
+
function H(e) {
|
|
2612
2612
|
if (e.kind.builtin !== "partial") return {};
|
|
2613
|
-
let [t] = wn(c ?? [],
|
|
2614
|
-
return t ? { file: Tn(
|
|
2613
|
+
let [t] = wn(c ?? [], a);
|
|
2614
|
+
return t ? { file: Tn(a, t) } : {};
|
|
2615
2615
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2616
|
+
M(() => {
|
|
2617
|
+
N.update({
|
|
2618
2618
|
open: (e) => {
|
|
2619
|
-
if (
|
|
2620
|
-
let t =
|
|
2619
|
+
if (V.state.doc.nodeAt(e)?.type.name === "vesperTable") {
|
|
2620
|
+
let t = V.view.nodeDOM(e);
|
|
2621
2621
|
t instanceof HTMLElement && or(t);
|
|
2622
2622
|
} else T(e);
|
|
2623
2623
|
},
|
|
2624
|
-
insert:
|
|
2625
|
-
disabled:
|
|
2624
|
+
insert: re,
|
|
2625
|
+
disabled: i
|
|
2626
2626
|
});
|
|
2627
2627
|
});
|
|
2628
|
-
let
|
|
2629
|
-
manifest:
|
|
2628
|
+
let ie = P(() => e({
|
|
2629
|
+
manifest: p,
|
|
2630
2630
|
format: r,
|
|
2631
|
-
loadMdxProps:
|
|
2631
|
+
loadMdxProps: h,
|
|
2632
2632
|
partials: c,
|
|
2633
|
-
entryPath:
|
|
2633
|
+
entryPath: a
|
|
2634
2634
|
}), [
|
|
2635
|
-
|
|
2635
|
+
p,
|
|
2636
2636
|
r,
|
|
2637
|
-
|
|
2637
|
+
h,
|
|
2638
2638
|
c,
|
|
2639
|
-
|
|
2640
|
-
]),
|
|
2641
|
-
catalog:
|
|
2642
|
-
containers:
|
|
2643
|
-
disabled:
|
|
2644
|
-
checks:
|
|
2639
|
+
a
|
|
2640
|
+
]), U = P(() => ({
|
|
2641
|
+
catalog: A,
|
|
2642
|
+
containers: j,
|
|
2643
|
+
disabled: i,
|
|
2644
|
+
checks: ie,
|
|
2645
2645
|
partials: c,
|
|
2646
|
-
entryPath:
|
|
2646
|
+
entryPath: a,
|
|
2647
2647
|
openSettings: (e) => {
|
|
2648
2648
|
T(e);
|
|
2649
2649
|
},
|
|
2650
2650
|
move: (e, t) => {
|
|
2651
|
-
let n =
|
|
2651
|
+
let n = ht(V, e, t);
|
|
2652
2652
|
n !== null && T((e) => e === null ? null : n);
|
|
2653
2653
|
},
|
|
2654
2654
|
remove: (e) => {
|
|
2655
|
-
|
|
2655
|
+
gt(V, e);
|
|
2656
2656
|
},
|
|
2657
2657
|
announce: (e) => {
|
|
2658
|
-
|
|
2658
|
+
O((t) => t === e ? `${e}\u00a0` : e);
|
|
2659
2659
|
},
|
|
2660
|
-
checkTable: (e, t) =>
|
|
2661
|
-
markdown:
|
|
2662
|
-
containers:
|
|
2660
|
+
checkTable: (e, t) => Gt(e, t, {
|
|
2661
|
+
markdown: V.markdown,
|
|
2662
|
+
containers: j,
|
|
2663
2663
|
format: r,
|
|
2664
|
-
...
|
|
2665
|
-
...
|
|
2664
|
+
...g.current ? { parsed: g.current.built.parsed } : {},
|
|
2665
|
+
...p.markdoc ? { markdoc: p.markdoc.options } : {}
|
|
2666
2666
|
}),
|
|
2667
2667
|
takeNewTable: () => {
|
|
2668
|
-
let e =
|
|
2669
|
-
return
|
|
2668
|
+
let e = k.current;
|
|
2669
|
+
return k.current = !1, e;
|
|
2670
2670
|
}
|
|
2671
2671
|
}), [
|
|
2672
|
-
k,
|
|
2673
2672
|
A,
|
|
2674
|
-
|
|
2675
|
-
|
|
2673
|
+
j,
|
|
2674
|
+
i,
|
|
2675
|
+
ie,
|
|
2676
2676
|
c,
|
|
2677
|
-
|
|
2678
|
-
|
|
2677
|
+
a,
|
|
2678
|
+
V,
|
|
2679
2679
|
r,
|
|
2680
|
-
|
|
2681
|
-
]),
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
}),
|
|
2685
|
-
|
|
2680
|
+
p.markdoc
|
|
2681
|
+
]), ae = F(t);
|
|
2682
|
+
M(() => {
|
|
2683
|
+
ae.current = t;
|
|
2684
|
+
}), M(() => (f.current = (e) => {
|
|
2685
|
+
on(V, ae.current, e, {
|
|
2686
2686
|
format: r,
|
|
2687
|
-
containers:
|
|
2688
|
-
...
|
|
2687
|
+
containers: j,
|
|
2688
|
+
...p.markdoc ? { markdoc: p.markdoc.options } : {}
|
|
2689
2689
|
});
|
|
2690
2690
|
}, () => {
|
|
2691
|
-
|
|
2691
|
+
f.current = null;
|
|
2692
2692
|
}), [
|
|
2693
|
-
|
|
2693
|
+
V,
|
|
2694
2694
|
r,
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2695
|
+
j,
|
|
2696
|
+
p.markdoc,
|
|
2697
|
+
f
|
|
2698
2698
|
]);
|
|
2699
|
-
let
|
|
2700
|
-
editor:
|
|
2699
|
+
let oe = Y({
|
|
2700
|
+
editor: V,
|
|
2701
2701
|
selector: ({ editor: e }) => sr(e, {
|
|
2702
|
-
catalog:
|
|
2703
|
-
containers:
|
|
2702
|
+
catalog: A,
|
|
2703
|
+
containers: j
|
|
2704
2704
|
})
|
|
2705
|
-
}),
|
|
2706
|
-
return /* @__PURE__ */
|
|
2707
|
-
value:
|
|
2708
|
-
children: /* @__PURE__ */
|
|
2705
|
+
}), se = A.kinds.size > 0;
|
|
2706
|
+
return /* @__PURE__ */ R(fn.Provider, {
|
|
2707
|
+
value: U,
|
|
2708
|
+
children: /* @__PURE__ */ z("div", {
|
|
2709
2709
|
"data-vesper-body": "",
|
|
2710
2710
|
className: "flex flex-col gap-2",
|
|
2711
2711
|
children: [
|
|
2712
|
-
/* @__PURE__ */
|
|
2713
|
-
className:
|
|
2714
|
-
children: [/* @__PURE__ */
|
|
2715
|
-
ref:
|
|
2716
|
-
className:
|
|
2717
|
-
children: /* @__PURE__ */
|
|
2718
|
-
editor:
|
|
2719
|
-
disabled:
|
|
2720
|
-
headingStart:
|
|
2712
|
+
/* @__PURE__ */ z("div", {
|
|
2713
|
+
className: m("rounded-md border border-border-strong bg-surface-raised", "has-[#entry-body:focus-visible]:outline-2 has-[#entry-body:focus-visible]:outline-solid has-[#entry-body:focus-visible]:outline-offset-2 has-[#entry-body:focus-visible]:outline-focus", "has-[#entry-body:focus-visible]:ring-6 has-[#entry-body:focus-visible]:ring-(color:--glow-focus)"),
|
|
2714
|
+
children: [/* @__PURE__ */ R("div", {
|
|
2715
|
+
ref: y,
|
|
2716
|
+
className: cn,
|
|
2717
|
+
children: /* @__PURE__ */ R(lr, {
|
|
2718
|
+
editor: V,
|
|
2719
|
+
disabled: i,
|
|
2720
|
+
headingStart: d,
|
|
2721
2721
|
onLink: () => {
|
|
2722
|
-
|
|
2722
|
+
ee(!0);
|
|
2723
2723
|
},
|
|
2724
2724
|
onImage: () => {
|
|
2725
|
-
|
|
2725
|
+
x(!0);
|
|
2726
2726
|
},
|
|
2727
|
-
insert: /* @__PURE__ */
|
|
2728
|
-
editor:
|
|
2729
|
-
choices: (e) =>
|
|
2727
|
+
insert: /* @__PURE__ */ R(tn, {
|
|
2728
|
+
editor: V,
|
|
2729
|
+
choices: (e) => Jt(e, A, j),
|
|
2730
2730
|
onChoose: (e) => {
|
|
2731
|
-
|
|
2731
|
+
re(e);
|
|
2732
2732
|
},
|
|
2733
|
-
disabled:
|
|
2733
|
+
disabled: i
|
|
2734
2734
|
})
|
|
2735
2735
|
})
|
|
2736
|
-
}), /* @__PURE__ */
|
|
2736
|
+
}), /* @__PURE__ */ R(Ce, { editor: V })]
|
|
2737
2737
|
}),
|
|
2738
|
-
/* @__PURE__ */
|
|
2739
|
-
editor:
|
|
2738
|
+
/* @__PURE__ */ R($t, {
|
|
2739
|
+
editor: V,
|
|
2740
2740
|
...E,
|
|
2741
|
-
choices: (e) =>
|
|
2741
|
+
choices: (e) => Jt(e, A, j),
|
|
2742
2742
|
onChoose: (e, t) => {
|
|
2743
|
-
|
|
2743
|
+
re(e, t);
|
|
2744
2744
|
}
|
|
2745
2745
|
}),
|
|
2746
|
-
/* @__PURE__ */
|
|
2746
|
+
/* @__PURE__ */ R("p", {
|
|
2747
2747
|
className: "sr-only",
|
|
2748
2748
|
role: "status",
|
|
2749
|
-
children:
|
|
2749
|
+
children: oe
|
|
2750
2750
|
}),
|
|
2751
|
-
/* @__PURE__ */
|
|
2751
|
+
/* @__PURE__ */ R("div", {
|
|
2752
2752
|
className: "sr-only",
|
|
2753
2753
|
role: "status",
|
|
2754
|
-
children:
|
|
2754
|
+
children: D
|
|
2755
2755
|
}),
|
|
2756
|
-
/* @__PURE__ */
|
|
2756
|
+
/* @__PURE__ */ z("p", {
|
|
2757
2757
|
id: "entry-body-help",
|
|
2758
2758
|
className: "text-small text-content-muted",
|
|
2759
2759
|
children: [
|
|
2760
2760
|
"Ctrl+B bold, Ctrl+I italic, Ctrl+K link.",
|
|
2761
|
-
|
|
2761
|
+
se ? " Type / to insert a block or a table. Arrow onto a block and press Enter for its settings, or onto a table for its cells; Alt+↑ and Alt+↓ move it." : " Type / to insert a table. Arrow onto a table and press Enter for its cells; Alt+↑ and Alt+↓ move it.",
|
|
2762
2762
|
" ",
|
|
2763
2763
|
"Escape leaves a block, then the text. Dashed boxes are kept exactly as written."
|
|
2764
2764
|
]
|
|
2765
2765
|
}),
|
|
2766
|
-
/* @__PURE__ */
|
|
2767
|
-
editor:
|
|
2766
|
+
/* @__PURE__ */ R(hn, {
|
|
2767
|
+
editor: V,
|
|
2768
2768
|
pos: w,
|
|
2769
2769
|
onClose: () => {
|
|
2770
2770
|
let e = w;
|
|
2771
2771
|
T(null);
|
|
2772
|
-
let t =
|
|
2773
|
-
if (n ||
|
|
2774
|
-
n = !0, t.removeEventListener("focusin", i),
|
|
2775
|
-
let r = e === null ? null :
|
|
2776
|
-
e !== null && r &&
|
|
2772
|
+
let t = V.view.dom, n = !1, r = () => {
|
|
2773
|
+
if (n || V.isDestroyed) return;
|
|
2774
|
+
n = !0, t.removeEventListener("focusin", i), V.view.focus();
|
|
2775
|
+
let r = e === null ? null : V.state.doc.nodeAt(e);
|
|
2776
|
+
e !== null && r && dt(r.type.name, j) && V.view.dispatch(V.state.tr.setSelection(K.create(V.state.doc, e)));
|
|
2777
2777
|
}, i = () => setTimeout(r, 0);
|
|
2778
2778
|
t.addEventListener("focusin", i), setTimeout(r, 500);
|
|
2779
2779
|
}
|
|
2780
2780
|
}),
|
|
2781
|
-
/* @__PURE__ */
|
|
2782
|
-
editor:
|
|
2783
|
-
isOpen:
|
|
2784
|
-
onOpenChange:
|
|
2781
|
+
/* @__PURE__ */ R(dr, {
|
|
2782
|
+
editor: V,
|
|
2783
|
+
isOpen: v,
|
|
2784
|
+
onOpenChange: ee
|
|
2785
2785
|
}),
|
|
2786
|
-
/* @__PURE__ */
|
|
2787
|
-
isOpen:
|
|
2788
|
-
onOpenChange:
|
|
2786
|
+
/* @__PURE__ */ R(u, {
|
|
2787
|
+
isOpen: b,
|
|
2788
|
+
onOpenChange: x,
|
|
2789
2789
|
kind: "image",
|
|
2790
2790
|
folder: s,
|
|
2791
2791
|
onChoose: (e) => {
|
|
2792
|
-
|
|
2792
|
+
C(e);
|
|
2793
2793
|
}
|
|
2794
2794
|
}),
|
|
2795
|
-
/* @__PURE__ */
|
|
2796
|
-
path:
|
|
2797
|
-
previewUrl:
|
|
2795
|
+
/* @__PURE__ */ R(pr, {
|
|
2796
|
+
path: S,
|
|
2797
|
+
previewUrl: te,
|
|
2798
2798
|
onCancel: () => {
|
|
2799
|
-
|
|
2799
|
+
C(null), V.commands.focus();
|
|
2800
2800
|
},
|
|
2801
2801
|
onInsert: (e) => {
|
|
2802
|
-
|
|
2803
|
-
src:
|
|
2802
|
+
S && (V.chain().focus().setImage({
|
|
2803
|
+
src: pe(S, a),
|
|
2804
2804
|
alt: e
|
|
2805
|
-
}).run(),
|
|
2805
|
+
}).run(), C(null));
|
|
2806
2806
|
}
|
|
2807
2807
|
})
|
|
2808
2808
|
]
|
|
2809
2809
|
})
|
|
2810
2810
|
});
|
|
2811
2811
|
}
|
|
2812
|
-
function lr({ editor: e, disabled: t, headingStart:
|
|
2813
|
-
let
|
|
2812
|
+
function lr({ editor: e, disabled: t, headingStart: n, onLink: i, onImage: o, insert: c }) {
|
|
2813
|
+
let l = Y({
|
|
2814
2814
|
editor: e,
|
|
2815
2815
|
selector: ({ editor: e }) => ({
|
|
2816
2816
|
bold: e.isActive("bold"),
|
|
@@ -2822,86 +2822,86 @@ function lr({ editor: e, disabled: t, headingStart: r, onLink: i, onImage: a, in
|
|
|
2822
2822
|
quote: e.isActive("blockquote"),
|
|
2823
2823
|
link: e.isActive("link")
|
|
2824
2824
|
})
|
|
2825
|
-
}),
|
|
2826
|
-
return /* @__PURE__ */
|
|
2825
|
+
}), u = () => e.chain().focus();
|
|
2826
|
+
return /* @__PURE__ */ z(s, {
|
|
2827
2827
|
label: "Formatting",
|
|
2828
2828
|
children: [
|
|
2829
|
-
/* @__PURE__ */
|
|
2829
|
+
/* @__PURE__ */ R(k, {
|
|
2830
2830
|
icon: "bold",
|
|
2831
2831
|
label: "Bold",
|
|
2832
2832
|
shortcut: y("Mod", "B"),
|
|
2833
2833
|
isDisabled: t,
|
|
2834
|
-
isSelected:
|
|
2835
|
-
onChange: () =>
|
|
2834
|
+
isSelected: l.bold,
|
|
2835
|
+
onChange: () => u().toggleBold().run()
|
|
2836
2836
|
}),
|
|
2837
|
-
/* @__PURE__ */
|
|
2837
|
+
/* @__PURE__ */ R(k, {
|
|
2838
2838
|
icon: "italic",
|
|
2839
2839
|
label: "Italic",
|
|
2840
2840
|
shortcut: y("Mod", "I"),
|
|
2841
2841
|
isDisabled: t,
|
|
2842
|
-
isSelected:
|
|
2843
|
-
onChange: () =>
|
|
2842
|
+
isSelected: l.italic,
|
|
2843
|
+
onChange: () => u().toggleItalic().run()
|
|
2844
2844
|
}),
|
|
2845
|
-
/* @__PURE__ */
|
|
2846
|
-
/* @__PURE__ */
|
|
2845
|
+
/* @__PURE__ */ R(a, {}),
|
|
2846
|
+
/* @__PURE__ */ R(ur, {
|
|
2847
2847
|
editor: e,
|
|
2848
|
-
level:
|
|
2849
|
-
start:
|
|
2848
|
+
level: l.level,
|
|
2849
|
+
start: n,
|
|
2850
2850
|
disabled: t
|
|
2851
2851
|
}),
|
|
2852
|
-
/* @__PURE__ */
|
|
2853
|
-
/* @__PURE__ */
|
|
2852
|
+
/* @__PURE__ */ R(a, {}),
|
|
2853
|
+
/* @__PURE__ */ R(k, {
|
|
2854
2854
|
icon: "bullets",
|
|
2855
2855
|
label: "Bullets",
|
|
2856
2856
|
shortcut: y("Mod", "Shift", "8"),
|
|
2857
2857
|
isDisabled: t,
|
|
2858
|
-
isSelected:
|
|
2859
|
-
onChange: () =>
|
|
2858
|
+
isSelected: l.bullets,
|
|
2859
|
+
onChange: () => u().toggleBulletList().run()
|
|
2860
2860
|
}),
|
|
2861
|
-
/* @__PURE__ */
|
|
2861
|
+
/* @__PURE__ */ R(k, {
|
|
2862
2862
|
icon: "numbers",
|
|
2863
2863
|
label: "Numbers",
|
|
2864
2864
|
shortcut: y("Mod", "Shift", "7"),
|
|
2865
2865
|
isDisabled: t,
|
|
2866
|
-
isSelected:
|
|
2867
|
-
onChange: () =>
|
|
2866
|
+
isSelected: l.numbers,
|
|
2867
|
+
onChange: () => u().toggleOrderedList().run()
|
|
2868
2868
|
}),
|
|
2869
|
-
/* @__PURE__ */
|
|
2869
|
+
/* @__PURE__ */ R(k, {
|
|
2870
2870
|
icon: "quote",
|
|
2871
2871
|
label: "Quote",
|
|
2872
2872
|
shortcut: y("Mod", "Shift", "B"),
|
|
2873
2873
|
isDisabled: t,
|
|
2874
|
-
isSelected:
|
|
2875
|
-
onChange: () =>
|
|
2874
|
+
isSelected: l.quote,
|
|
2875
|
+
onChange: () => u().toggleBlockquote().run()
|
|
2876
2876
|
}),
|
|
2877
|
-
/* @__PURE__ */
|
|
2877
|
+
/* @__PURE__ */ R(k, {
|
|
2878
2878
|
icon: "code",
|
|
2879
2879
|
label: "Code",
|
|
2880
2880
|
shortcut: y("Mod", "E"),
|
|
2881
2881
|
isDisabled: t,
|
|
2882
|
-
isSelected:
|
|
2883
|
-
onChange: () =>
|
|
2882
|
+
isSelected: l.code,
|
|
2883
|
+
onChange: () => u().toggleCode().run()
|
|
2884
2884
|
}),
|
|
2885
|
-
/* @__PURE__ */
|
|
2886
|
-
/* @__PURE__ */
|
|
2885
|
+
/* @__PURE__ */ R(a, {}),
|
|
2886
|
+
/* @__PURE__ */ R(r, {
|
|
2887
2887
|
icon: "link",
|
|
2888
|
-
label:
|
|
2888
|
+
label: l.link ? "Edit link" : "Link",
|
|
2889
2889
|
shortcut: y("Mod", "K"),
|
|
2890
2890
|
isDisabled: t,
|
|
2891
2891
|
onPress: i
|
|
2892
2892
|
}),
|
|
2893
|
-
/* @__PURE__ */
|
|
2893
|
+
/* @__PURE__ */ R(r, {
|
|
2894
2894
|
icon: "image",
|
|
2895
2895
|
label: "Image",
|
|
2896
2896
|
isDisabled: t,
|
|
2897
|
-
onPress:
|
|
2897
|
+
onPress: o
|
|
2898
2898
|
}),
|
|
2899
|
-
|
|
2899
|
+
c
|
|
2900
2900
|
]
|
|
2901
2901
|
});
|
|
2902
2902
|
}
|
|
2903
|
-
function ur({ editor: e, level:
|
|
2904
|
-
let a =
|
|
2903
|
+
function ur({ editor: e, level: t, start: n, disabled: i }) {
|
|
2904
|
+
let a = t === 0 ? "Paragraph" : `Heading ${String(t)}`, o = [{
|
|
2905
2905
|
id: "0",
|
|
2906
2906
|
label: "Paragraph"
|
|
2907
2907
|
}, ...[
|
|
@@ -2911,27 +2911,27 @@ function ur({ editor: e, level: n, start: r, disabled: i }) {
|
|
|
2911
2911
|
4,
|
|
2912
2912
|
5,
|
|
2913
2913
|
6
|
|
2914
|
-
].filter((e) => e >= Math.min(
|
|
2914
|
+
].filter((e) => e >= Math.min(n, 6)).map((e) => ({
|
|
2915
2915
|
id: String(e),
|
|
2916
2916
|
label: `Heading ${String(e)}`
|
|
2917
2917
|
}))];
|
|
2918
|
-
return /* @__PURE__ */
|
|
2918
|
+
return /* @__PURE__ */ R(h, {
|
|
2919
2919
|
label: "Text style",
|
|
2920
2920
|
items: [],
|
|
2921
2921
|
onAction: () => void 0,
|
|
2922
|
-
trigger: /* @__PURE__ */
|
|
2922
|
+
trigger: /* @__PURE__ */ z(r, {
|
|
2923
2923
|
"aria-label": `Text style: ${a}`,
|
|
2924
2924
|
isDisabled: i,
|
|
2925
2925
|
className: "w-28 gap-1",
|
|
2926
|
-
children: [/* @__PURE__ */
|
|
2926
|
+
children: [/* @__PURE__ */ R("span", {
|
|
2927
2927
|
className: "min-w-0 flex-1 truncate text-left",
|
|
2928
2928
|
children: a
|
|
2929
|
-
}), /* @__PURE__ */
|
|
2929
|
+
}), /* @__PURE__ */ R(E, {})]
|
|
2930
2930
|
}),
|
|
2931
2931
|
choice: {
|
|
2932
2932
|
title: "Text style",
|
|
2933
2933
|
options: o,
|
|
2934
|
-
selected: String(
|
|
2934
|
+
selected: String(t),
|
|
2935
2935
|
onChange: (t) => {
|
|
2936
2936
|
let n = Number(t);
|
|
2937
2937
|
n === 0 ? e.chain().setParagraph().run() : e.chain().setHeading({ level: n }).run();
|
|
@@ -2946,13 +2946,13 @@ function dr({ editor: e, isOpen: t, onOpenChange: n }) {
|
|
|
2946
2946
|
let r = e.getAttributes("link").href, i = () => {
|
|
2947
2947
|
n(!1), e.commands.focus();
|
|
2948
2948
|
};
|
|
2949
|
-
return /* @__PURE__ */
|
|
2949
|
+
return /* @__PURE__ */ R(b, {
|
|
2950
2950
|
title: r ? "Edit link" : "Add a link",
|
|
2951
2951
|
isOpen: t,
|
|
2952
2952
|
onOpenChange: (e) => {
|
|
2953
2953
|
e ? n(!0) : i();
|
|
2954
2954
|
},
|
|
2955
|
-
children: t && /* @__PURE__ */
|
|
2955
|
+
children: t && /* @__PURE__ */ R(fr, {
|
|
2956
2956
|
editor: e,
|
|
2957
2957
|
current: r,
|
|
2958
2958
|
onDone: i
|
|
@@ -2960,30 +2960,30 @@ function dr({ editor: e, isOpen: t, onOpenChange: n }) {
|
|
|
2960
2960
|
});
|
|
2961
2961
|
}
|
|
2962
2962
|
function fr({ editor: e, current: t, onDone: n }) {
|
|
2963
|
-
let [r, i] =
|
|
2964
|
-
return /* @__PURE__ */
|
|
2963
|
+
let [r, i] = I(t ?? ""), a = te(), o = P(() => x(a), [a]);
|
|
2964
|
+
return /* @__PURE__ */ z("form", {
|
|
2965
2965
|
className: "flex flex-col gap-4",
|
|
2966
2966
|
onSubmit: (t) => {
|
|
2967
2967
|
t.preventDefault();
|
|
2968
2968
|
let i = r.trim();
|
|
2969
2969
|
i === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: i }).run(), n();
|
|
2970
2970
|
},
|
|
2971
|
-
children: [/* @__PURE__ */
|
|
2971
|
+
children: [/* @__PURE__ */ R(f, {
|
|
2972
2972
|
label: "Page or web address",
|
|
2973
2973
|
description: "Search pages by title, or type an address such as https://example.com.",
|
|
2974
2974
|
value: r,
|
|
2975
2975
|
onChange: i,
|
|
2976
2976
|
suggestions: o,
|
|
2977
2977
|
inputMode: "url"
|
|
2978
|
-
}), /* @__PURE__ */
|
|
2978
|
+
}), /* @__PURE__ */ z("div", {
|
|
2979
2979
|
className: "flex flex-wrap justify-end gap-3",
|
|
2980
|
-
children: [t && /* @__PURE__ */
|
|
2980
|
+
children: [t && /* @__PURE__ */ R(_, {
|
|
2981
2981
|
variant: "quiet",
|
|
2982
2982
|
onPress: () => {
|
|
2983
2983
|
e.chain().focus().extendMarkRange("link").unsetLink().run(), n();
|
|
2984
2984
|
},
|
|
2985
2985
|
children: "Remove link"
|
|
2986
|
-
}), /* @__PURE__ */
|
|
2986
|
+
}), /* @__PURE__ */ R(_, {
|
|
2987
2987
|
type: "submit",
|
|
2988
2988
|
variant: "primary",
|
|
2989
2989
|
children: t ? "Update link" : "Add link"
|
|
@@ -2992,48 +2992,48 @@ function fr({ editor: e, current: t, onDone: n }) {
|
|
|
2992
2992
|
});
|
|
2993
2993
|
}
|
|
2994
2994
|
function pr({ path: e, previewUrl: t, onCancel: n, onInsert: r }) {
|
|
2995
|
-
let [i,
|
|
2996
|
-
return /* @__PURE__ */
|
|
2995
|
+
let [i, a] = I(""), [o, s] = I(!1), [l, u] = I(!1);
|
|
2996
|
+
return /* @__PURE__ */ R(b, {
|
|
2997
2997
|
title: "Describe the image",
|
|
2998
2998
|
isOpen: e !== null,
|
|
2999
2999
|
onOpenChange: (e) => {
|
|
3000
3000
|
e || n();
|
|
3001
3001
|
},
|
|
3002
|
-
children: /* @__PURE__ */
|
|
3002
|
+
children: /* @__PURE__ */ z("form", {
|
|
3003
3003
|
className: "flex flex-col gap-4",
|
|
3004
3004
|
onSubmit: (e) => {
|
|
3005
|
-
e.preventDefault(), !
|
|
3005
|
+
e.preventDefault(), !o && i.trim() === "" ? u(!0) : (r(o ? "" : i.trim()), a(""), s(!1), u(!1));
|
|
3006
3006
|
},
|
|
3007
3007
|
children: [
|
|
3008
|
-
t && /* @__PURE__ */
|
|
3008
|
+
t && /* @__PURE__ */ R("img", {
|
|
3009
3009
|
src: t,
|
|
3010
3010
|
alt: "",
|
|
3011
3011
|
className: "max-h-40 self-start rounded-md object-contain"
|
|
3012
3012
|
}),
|
|
3013
|
-
e && /* @__PURE__ */
|
|
3013
|
+
e && /* @__PURE__ */ R("p", {
|
|
3014
3014
|
className: "text-small text-content-muted",
|
|
3015
3015
|
children: e.slice(e.lastIndexOf("/") + 1)
|
|
3016
3016
|
}),
|
|
3017
|
-
!
|
|
3017
|
+
!o && /* @__PURE__ */ R(w, {
|
|
3018
3018
|
label: "Alt text",
|
|
3019
3019
|
isRequired: !0,
|
|
3020
3020
|
description: "Describe what this image communicates here.",
|
|
3021
3021
|
value: i,
|
|
3022
3022
|
onChange: (e) => {
|
|
3023
|
-
|
|
3023
|
+
a(e), u(!1);
|
|
3024
3024
|
},
|
|
3025
3025
|
isInvalid: l,
|
|
3026
3026
|
errorMessage: "Describe the image, or mark it decorative.",
|
|
3027
3027
|
rows: 2
|
|
3028
3028
|
}),
|
|
3029
|
-
/* @__PURE__ */
|
|
3030
|
-
isSelected:
|
|
3031
|
-
onChange:
|
|
3029
|
+
/* @__PURE__ */ R(c, {
|
|
3030
|
+
isSelected: o,
|
|
3031
|
+
onChange: s,
|
|
3032
3032
|
children: "Decorative image (it adds nothing a reader needs)"
|
|
3033
3033
|
}),
|
|
3034
|
-
/* @__PURE__ */
|
|
3034
|
+
/* @__PURE__ */ R("div", {
|
|
3035
3035
|
className: "flex justify-end",
|
|
3036
|
-
children: /* @__PURE__ */
|
|
3036
|
+
children: /* @__PURE__ */ R(_, {
|
|
3037
3037
|
type: "submit",
|
|
3038
3038
|
variant: "primary",
|
|
3039
3039
|
children: "Insert image"
|
|
@@ -3044,4 +3044,4 @@ function pr({ path: e, previewUrl: t, onCancel: n, onInsert: r }) {
|
|
|
3044
3044
|
});
|
|
3045
3045
|
}
|
|
3046
3046
|
//#endregion
|
|
3047
|
-
export { Xn as BodyEditor, dr as LinkDialog,
|
|
3047
|
+
export { Xn as BodyEditor, dr as LinkDialog, cn as n, un as t };
|