@lvl99dotcom/edaha-editor 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -695,20 +695,20 @@ img.ProseMirror-separator {
695
695
  >
696
696
  Add${tN(` to ${this.fieldTitle}`)}
697
697
  </button>
698
- </fieldset>`}renderSelect(e,t){let n=AM(this.schema.$edahaField),r=UM(this.schema),i=n.multiple===!0,a=i?(this.value??[]).map(String):[String(this.value??``)];return E`<select
698
+ </fieldset>`}renderSelect(e,t){let n=AM(this.schema.$edahaField),r=UM(this.schema),i=n.multiple===!0,a=!i&&!r.some(e=>e.value===``),o=i?(this.value??[]).map(String):[String(this.value??``)];return E`<select
699
699
  id=${e}
700
700
  ?multiple=${i}
701
- size=${n.list===!0?r.length+ +!i:D}
701
+ size=${n.list===!0?r.length+ +!!a:D}
702
702
  ?required=${this.required}
703
703
  aria-invalid=${eN(this.problems,this.path).length?`true`:`false`}
704
704
  aria-describedby=${this.describedBy(e)||D}
705
705
  @change=${e=>{let n=[...e.target.selectedOptions].map(e=>r[Number(e.dataset.index)]?.value??void 0);this.change(this.path,i?n:n[0]??YM(t,``))}}
706
706
  >
707
- ${i?D:E`<option value="">—</option>`}
707
+ ${a?E`<option value="">—</option>`:D}
708
708
  ${r.map((e,t)=>E`<option
709
709
  data-index=${t}
710
710
  value=${String(e.value)}
711
- ?selected=${a.includes(String(e.value))}
711
+ ?selected=${o.includes(String(e.value))}
712
712
  >
713
713
  ${e.title??String(e.value)}
714
714
  </option>`)}
@@ -12,7 +12,7 @@
12
12
  document.documentElement.dataset.theme = theme;
13
13
  } catch {}
14
14
  </script>
15
- <script type="module" crossorigin src="/_editor/assets/index-owkKXGfS.js"></script>
15
+ <script type="module" crossorigin src="/_editor/assets/index-B1Dz4z4H.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/_editor/assets/index--k7n6Qb8.css">
17
17
  </head>
18
18
  <body>
@@ -116,7 +116,7 @@ var Ee = {
116
116
  }, Me = (e) => {
117
117
  let t = new URLSearchParams(Object.entries(e).filter(([, e]) => e !== void 0 && e !== "").map(([e, t]) => [e, String(t)]));
118
118
  return t.size ? `?${t}` : "";
119
- }, b = ({ type: e, slug: t, name: n }) => `/api/files/${e}/${t}/${encodeURIComponent(n)}`, Ne = class {
119
+ }, b = ({ type: e, slug: t, name: n }) => `/api/files/${e}/${t}/${encodeURIComponent(n)}`, x = class {
120
120
  fetch;
121
121
  baseUrl;
122
122
  constructor(e = {}) {
@@ -237,15 +237,15 @@ var Ee = {
237
237
  body: r
238
238
  });
239
239
  }
240
- }, x = (e, t) => {
240
+ }, S = (e, t) => {
241
241
  customElements.get(e) || customElements.define(e, t);
242
- }, S = (e) => String(e).padStart(2, "0"), Pe = (e) => {
242
+ }, C = (e) => String(e).padStart(2, "0"), Ne = (e) => {
243
243
  let t = new Date(e);
244
- return `${t.getFullYear()}-${S(t.getMonth() + 1)}-${S(t.getDate())}T${S(t.getHours())}:${S(t.getMinutes())}`;
245
- }, Fe = (e) => {
244
+ return `${t.getFullYear()}-${C(t.getMonth() + 1)}-${C(t.getDate())}T${C(t.getHours())}:${C(t.getMinutes())}`;
245
+ }, Pe = (e) => {
246
246
  let t = new Date(e);
247
247
  return e && !Number.isNaN(t.getTime()) ? t.toISOString() : "";
248
- }, Ie = "<!-- readmore -->", C = /^\[([^\]]*)\]\(([^)\s]*)\)$/, Le = RegExp(`^${f.source}$`), Re = /^([-*+]|\d+[.)]) /, ze = /^#{1,6} /, Be = /^:?-+:?$/, Ve = (e, t) => {
248
+ }, Fe = "<!-- readmore -->", w = /^\[([^\]]*)\]\(([^)\s]*)\)$/, Ie = RegExp(`^${f.source}$`), T = /^([-*+]|\d+[.)]) /, Le = /^#{1,6} /, Re = /^:?-+:?$/, ze = (e, t) => {
249
249
  let n = 0, r = Math.min(e.length, t.length);
250
250
  for (; n < r && e[n] === t[n];) n++;
251
251
  let i = 0;
@@ -255,35 +255,35 @@ var Ee = {
255
255
  end: e.length - i,
256
256
  text: t.slice(n, t.length - i)
257
257
  };
258
- }, w = (e, t, n, r, i = 0, a = r.length) => ({
258
+ }, E = (e, t, n, r, i = 0, a = r.length) => ({
259
259
  value: e.slice(0, t) + r + e.slice(n),
260
260
  start: t + i,
261
261
  end: t + a
262
- }), He = ({ value: e, start: t, end: n }) => {
262
+ }), Be = ({ value: e, start: t, end: n }) => {
263
263
  let r = e.lastIndexOf("\n", t - 1) + 1, i = n > t && e[n - 1] === "\n", a = e.indexOf("\n", i ? n - 1 : n);
264
264
  return [r, a === -1 ? e.length : a];
265
- }, T = (e, t, n, r = "text") => {
265
+ }, D = (e, t, n, r = "text") => {
266
266
  let { value: i, start: a, end: o } = e, s = i.slice(a, o);
267
- if (s.length >= t.length + n.length && s.startsWith(t) && s.endsWith(n)) return w(i, a, o, s.slice(t.length, s.length - n.length));
268
- if (i.slice(a - t.length, a) === t && i.slice(o, o + n.length) === n) return w(i, a - t.length, o + n.length, s);
267
+ if (s.length >= t.length + n.length && s.startsWith(t) && s.endsWith(n)) return E(i, a, o, s.slice(t.length, s.length - n.length));
268
+ if (i.slice(a - t.length, a) === t && i.slice(o, o + n.length) === n) return E(i, a - t.length, o + n.length, s);
269
269
  let c = s || r;
270
- return w(i, a, o, t + c + n, t.length, t.length + c.length);
271
- }, E = (e, t, n, r) => {
272
- let [i, a] = He(e), o = e.value.slice(i, a).split("\n"), s = o.filter((e) => e.trim()), c = s.length > 0 && s.every((e) => t.test(e)), l = 0, u = o.map((e) => !e.trim() && s.length ? e : c ? e.replace(t, "") : n(l++) + (r ? e.replace(r, "") : e)).join("\n");
273
- return e.start === e.end && o.length === 1 ? w(e.value, i, a, u, u.length) : w(e.value, i, a, u);
274
- }, D = (e, t, n) => {
275
- let [r, i] = He(e), a = e.value.slice(r, i);
276
- return a.length >= t.length + n.length + 2 && a.startsWith(`${t}\n`) && a.endsWith(`\n${n}`) ? w(e.value, r, i, a.slice(t.length + 1, a.length - n.length - 1)) : w(e.value, r, i, `${t}\n${a}\n${n}`, t.length + 1, t.length + 1 + a.length);
277
- }, O = ({ value: e, start: t, end: n }, r, i = 0, a = r.length) => {
270
+ return E(i, a, o, t + c + n, t.length, t.length + c.length);
271
+ }, O = (e, t, n, r) => {
272
+ let [i, a] = Be(e), o = e.value.slice(i, a).split("\n"), s = o.filter((e) => e.trim()), c = s.length > 0 && s.every((e) => t.test(e)), l = 0, u = o.map((e) => !e.trim() && s.length ? e : c ? e.replace(t, "") : n(l++) + (r ? e.replace(r, "") : e)).join("\n");
273
+ return e.start === e.end && o.length === 1 ? E(e.value, i, a, u, u.length) : E(e.value, i, a, u);
274
+ }, k = (e, t, n) => {
275
+ let [r, i] = Be(e), a = e.value.slice(r, i);
276
+ return a.length >= t.length + n.length + 2 && a.startsWith(`${t}\n`) && a.endsWith(`\n${n}`) ? E(e.value, r, i, a.slice(t.length + 1, a.length - n.length - 1)) : E(e.value, r, i, `${t}\n${a}\n${n}`, t.length + 1, t.length + 1 + a.length);
277
+ }, A = ({ value: e, start: t, end: n }, r, i = 0, a = r.length) => {
278
278
  let o = e.slice(0, t), s = e.slice(n), c = !o || o.endsWith("\n\n") ? "" : o.endsWith("\n") ? "\n" : "\n\n", l = !s || s.startsWith("\n\n") ? "" : s.startsWith("\n") ? "\n" : "\n\n";
279
- return w(e, t, n, c + r + l, c.length + i, c.length + a);
280
- }, k = ({ value: e, start: t, end: n }, r) => w(e, t, n, r, r.length), Ue = ({ value: e, start: t, end: n }) => C.exec(e.slice(t, n))?.[2], We = (e, t) => {
281
- let { value: n, start: r, end: i } = e, a = n.slice(r, i), o = C.exec(a);
282
- if (!t) return o ? w(n, r, i, o[1]) : void 0;
279
+ return E(e, t, n, c + r + l, c.length + i, c.length + a);
280
+ }, j = ({ value: e, start: t, end: n }, r) => E(e, t, n, r, r.length), Ve = ({ value: e, start: t, end: n }) => w.exec(e.slice(t, n))?.[2], He = (e, t) => {
281
+ let { value: n, start: r, end: i } = e, a = n.slice(r, i), o = w.exec(a);
282
+ if (!t) return o ? E(n, r, i, o[1]) : void 0;
283
283
  let s = o ? o[1] : a || t;
284
- return w(n, r, i, `[${s}](${t})`, 1, 1 + s.length);
285
- }, Ge = (e, t, n, r) => r ? k(e, `![](${t})`) : e.start === e.end ? k(e, `[${n}](${t})`) : We(e, t), A = ({ value: e, start: t, end: n }) => {
286
- let r = Le.exec(e.slice(t, n));
284
+ return E(n, r, i, `[${s}](${t})`, 1, 1 + s.length);
285
+ }, Ue = (e, t, n, r) => r ? j(e, `![](${t})`) : e.start === e.end ? j(e, `[${n}](${t})`) : He(e, t), M = ({ value: e, start: t, end: n }) => {
286
+ let r = Ie.exec(e.slice(t, n));
287
287
  if (!r) return;
288
288
  let { content: i, options: a } = ne(r[2]);
289
289
  return {
@@ -291,21 +291,21 @@ var Ee = {
291
291
  content: i,
292
292
  options: a
293
293
  };
294
- }, Ke = (e, t) => {
294
+ }, We = (e, t) => {
295
295
  let n = p(t.key, t.content, t.options);
296
- return A(e) ? w(e.value, e.start, e.end, n) : O(e, n);
297
- }, qe = (e, t) => O({
296
+ return M(e) ? E(e.value, e.start, e.end, n) : A(e, n);
297
+ }, Ge = (e, t) => A({
298
298
  ...e,
299
299
  start: e.end
300
- }, p(t.key, t.content, t.options)), Je = (e) => e.value.slice(e.start, e.end).trim() === "<!-- readmore -->" ? w(e.value, e.start, e.end, "") : O(e, Ie, 17, 17), Ye = (e) => e.trim().replace(/^\|/, "").replace(/(?<!\\)\|$/, "").split(/(?<!\\)\|/).map((e) => e.trim()), j = (e) => e.map((e) => `| ${e.join(" | ")} |`).join("\n"), M = ({ value: e, start: t }) => {
300
+ }, p(t.key, t.content, t.options)), Ke = (e) => e.value.slice(e.start, e.end).trim() === "<!-- readmore -->" ? E(e.value, e.start, e.end, "") : A(e, Fe, 17, 17), qe = (e) => e.trim().replace(/^\|/, "").replace(/(?<!\\)\|$/, "").split(/(?<!\\)\|/).map((e) => e.trim()), N = (e) => e.map((e) => `| ${e.join(" | ")} |`).join("\n"), P = ({ value: e, start: t }) => {
301
301
  let n = e.split("\n"), r = e.slice(0, t).split("\n").length - 1, i = e.lastIndexOf("\n", t - 1) + 1, a = (e) => n[e]?.trim().startsWith("|");
302
302
  if (!a(r)) return;
303
303
  let o = r;
304
304
  for (; o > 0 && a(o - 1);) o--;
305
305
  let s = r;
306
306
  for (; a(s + 1);) s++;
307
- let c = n.slice(o, s + 1).map(Ye);
308
- if (c.length < 2 || !c[1].every((e) => Be.test(e))) return;
307
+ let c = n.slice(o, s + 1).map(qe);
308
+ if (c.length < 2 || !c[1].every((e) => Re.test(e))) return;
309
309
  let l = n.slice(0, o).join("\n").length + +!!o, u = l + n.slice(o, s + 1).join("\n").length, d = e.slice(i, t).trim().split(/(?<!\\)\|/).length - 1, f = c[0].length;
310
310
  return {
311
311
  from: l,
@@ -314,48 +314,48 @@ var Ee = {
314
314
  row: r - o,
315
315
  column: Math.min(Math.max(d - 1, 0), f - 1)
316
316
  };
317
- }, N = (e, { from: t, to: n }, r, i, a) => {
318
- let o = j(r), s = j(r.slice(0, i)).length + +!!i, c = r[i], l = 2 + c.slice(0, a).reduce((e, t) => e + t.length + 3, 0) + c[a].length;
319
- return w(e, t, n, o, s + l, s + l);
320
- }, Xe = 3, Ze = (e) => {
321
- let t = (e) => Array(Xe).fill(e);
322
- return O(e, j([
317
+ }, F = (e, { from: t, to: n }, r, i, a) => {
318
+ let o = N(r), s = N(r.slice(0, i)).length + +!!i, c = r[i], l = 2 + c.slice(0, a).reduce((e, t) => e + t.length + 3, 0) + c[a].length;
319
+ return E(e, t, n, o, s + l, s + l);
320
+ }, Je = 3, Ye = (e) => {
321
+ let t = (e) => Array(Je).fill(e);
322
+ return A(e, N([
323
323
  t("Header"),
324
324
  t("---"),
325
325
  ...Array.from({ length: 2 }, () => t(""))
326
326
  ]), 2, 8);
327
- }, Qe = (e) => {
328
- let t = M(e);
327
+ }, Xe = (e) => {
328
+ let t = P(e);
329
329
  if (!t) return;
330
330
  let n = Math.max(t.row + 1, 2), r = [...t.rows];
331
- return r.splice(n, 0, Array(r[0].length).fill("")), N(e.value, t, r, n, 0);
332
- }, $e = (e) => {
333
- let t = M(e);
331
+ return r.splice(n, 0, Array(r[0].length).fill("")), F(e.value, t, r, n, 0);
332
+ }, Ze = (e) => {
333
+ let t = P(e);
334
334
  if (!t) return;
335
335
  let n = t.column + 1, r = t.rows.map((e, t) => {
336
336
  let r = [...e];
337
337
  return r.splice(n, 0, t === 1 ? "---" : ""), r;
338
338
  });
339
- return N(e.value, t, r, t.row, n);
340
- }, et = (e) => {
341
- let t = M(e);
339
+ return F(e.value, t, r, t.row, n);
340
+ }, Qe = (e) => {
341
+ let t = P(e);
342
342
  if (!t || t.row < 2) return;
343
343
  let n = t.rows.filter((e, n) => n !== t.row);
344
- return N(e.value, t, n, Math.min(t.row, n.length - 1), t.column);
345
- }, tt = (e) => {
346
- let t = M(e);
344
+ return F(e.value, t, n, Math.min(t.row, n.length - 1), t.column);
345
+ }, $e = (e) => {
346
+ let t = P(e);
347
347
  if (!t) return;
348
- if (t.rows[0].length <= 1) return nt(e);
348
+ if (t.rows[0].length <= 1) return et(e);
349
349
  let n = t.rows.map((e) => e.filter((e, n) => n !== t.column));
350
- return N(e.value, t, n, t.row, Math.min(t.column, n[0].length - 1));
351
- }, nt = (e) => {
352
- let t = M(e);
353
- return t ? w(e.value, t.from, t.to, "") : void 0;
354
- }, rt = (e, t) => {
350
+ return F(e.value, t, n, t.row, Math.min(t.column, n[0].length - 1));
351
+ }, et = (e) => {
352
+ let t = P(e);
353
+ return t ? E(e.value, t.from, t.to, "") : void 0;
354
+ }, tt = (e, t) => {
355
355
  let n = `${"#".repeat(t)} `;
356
- return E(e, RegExp(`^${n}`), () => n, ze);
357
- }, it = (e) => E(e, /^[-*+] /, () => "- ", Re), at = (e) => E(e, /^\d+[.)] /, (e) => `${e + 1}. `, Re), ot = (e) => E(e, /^> ?/, () => "> "), P = (e) => M(e) !== void 0;
358
- x("edaha-markdown", class extends e {
356
+ return O(e, RegExp(`^${n}`), () => n, Le);
357
+ }, nt = (e) => O(e, /^[-*+] /, () => "- ", T), rt = (e) => O(e, /^\d+[.)] /, (e) => `${e + 1}. `, T), it = (e) => O(e, /^> ?/, () => "> "), I = (e) => P(e) !== void 0;
358
+ S("edaha-markdown", class extends e {
359
359
  static properties = {
360
360
  value: { attribute: !1 },
361
361
  textareaId: { attribute: !1 },
@@ -373,106 +373,106 @@ x("edaha-markdown", class extends e {
373
373
  actions = [
374
374
  {
375
375
  label: "Bold",
376
- run: (e) => T(e, "**", "**")
376
+ run: (e) => D(e, "**", "**")
377
377
  },
378
378
  {
379
379
  label: "Italic",
380
- run: (e) => T(e, "_", "_")
380
+ run: (e) => D(e, "_", "_")
381
381
  },
382
382
  {
383
383
  label: "Underline",
384
- run: (e) => T(e, "<u>", "</u>")
384
+ run: (e) => D(e, "<u>", "</u>")
385
385
  },
386
386
  {
387
387
  label: "Strikethrough",
388
- run: (e) => T(e, "~~", "~~")
388
+ run: (e) => D(e, "~~", "~~")
389
389
  },
390
390
  {
391
391
  label: "Small",
392
- run: (e) => T(e, "<small>", "</small>")
392
+ run: (e) => D(e, "<small>", "</small>")
393
393
  },
394
394
  {
395
395
  label: "Big",
396
- run: (e) => T(e, "<big>", "</big>")
396
+ run: (e) => D(e, "<big>", "</big>")
397
397
  },
398
398
  {
399
399
  label: "Link",
400
400
  run: (e) => {
401
- let t = this.prompt("Link URL (empty to remove)", Ue(e));
402
- return t === null ? void 0 : We(e, t.trim());
401
+ let t = this.prompt("Link URL (empty to remove)", Ve(e));
402
+ return t === null ? void 0 : He(e, t.trim());
403
403
  }
404
404
  },
405
405
  {
406
406
  label: "Heading",
407
- run: (e) => rt(e, 2)
407
+ run: (e) => tt(e, 2)
408
408
  },
409
409
  {
410
410
  label: "Subheading",
411
- run: (e) => rt(e, 3)
411
+ run: (e) => tt(e, 3)
412
412
  },
413
413
  {
414
414
  label: "Bullet list",
415
- run: it
415
+ run: nt
416
416
  },
417
417
  {
418
418
  label: "Numbered list",
419
- run: at
419
+ run: rt
420
420
  },
421
421
  {
422
422
  label: "Quote",
423
- run: ot
423
+ run: it
424
424
  },
425
425
  {
426
426
  label: "Code",
427
- run: (e) => D(e, "```", "```")
427
+ run: (e) => k(e, "```", "```")
428
428
  },
429
429
  {
430
430
  label: "Details",
431
- run: (e) => D(e, "<details>\n<summary>Summary</summary>\n", "\n</details>")
431
+ run: (e) => k(e, "<details>\n<summary>Summary</summary>\n", "\n</details>")
432
432
  },
433
433
  {
434
434
  label: "Image URL",
435
435
  run: (e) => {
436
436
  let t = this.prompt("Image URL")?.trim();
437
- return t ? k(e, `![](${t})`) : void 0;
437
+ return t ? j(e, `![](${t})`) : void 0;
438
438
  }
439
439
  },
440
440
  {
441
441
  label: "Table",
442
- run: Ze
442
+ run: Ye
443
443
  },
444
444
  {
445
445
  label: "Add row",
446
- run: Qe,
447
- enabled: P
446
+ run: Xe,
447
+ enabled: I
448
448
  },
449
449
  {
450
450
  label: "Add column",
451
- run: $e,
452
- enabled: P
451
+ run: Ze,
452
+ enabled: I
453
453
  },
454
454
  {
455
455
  label: "Remove row",
456
- run: et,
457
- enabled: P
456
+ run: Qe,
457
+ enabled: I
458
458
  },
459
459
  {
460
460
  label: "Remove column",
461
- run: tt,
462
- enabled: P
461
+ run: $e,
462
+ enabled: I
463
463
  },
464
464
  {
465
465
  label: "Remove table",
466
- run: nt,
467
- enabled: P
466
+ run: et,
467
+ enabled: I
468
468
  },
469
469
  {
470
470
  label: "Raw",
471
- run: (e) => D(e, "<!-- raw -->", "<!-- /raw -->")
471
+ run: (e) => k(e, "<!-- raw -->", "<!-- /raw -->")
472
472
  },
473
473
  {
474
474
  label: "Read more",
475
- run: Je
475
+ run: Ke
476
476
  }
477
477
  ];
478
478
  get textarea() {
@@ -498,7 +498,7 @@ x("edaha-markdown", class extends e {
498
498
  let t = this.textarea;
499
499
  if (e && t) {
500
500
  if (t.focus(), e.value !== t.value) {
501
- let { start: n, end: r, text: i } = Ve(t.value, e.value);
501
+ let { start: n, end: r, text: i } = ze(t.value, e.value);
502
502
  t.setSelectionRange(n, r), typeof document.execCommand == "function" && document.execCommand(i ? "insertText" : "delete", !1, i), t.value !== e.value && (t.value = e.value);
503
503
  }
504
504
  t.setSelectionRange(e.start, e.end), this.sync(), this.requestUpdate();
@@ -510,20 +510,20 @@ x("edaha-markdown", class extends e {
510
510
  let r = this.selection;
511
511
  try {
512
512
  let e = await this.uploadImage(n);
513
- this.apply(k(r, `![](${e})`));
513
+ this.apply(j(r, `![](${e})`));
514
514
  } catch {}
515
515
  }
516
516
  async editEmbed(e, t) {
517
- let n = A(e), r = n?.key !== t, i = await this.embedTools?.edit(r ? {
517
+ let n = M(e), r = n?.key !== t, i = await this.embedTools?.edit(r ? {
518
518
  key: t,
519
519
  content: "",
520
520
  options: {}
521
521
  } : n, r);
522
- i ? this.apply((r ? qe : Ke)(e, i)) : this.textarea?.focus();
522
+ i ? this.apply((r ? Ge : We)(e, i)) : this.textarea?.focus();
523
523
  }
524
524
  async onChooseFile() {
525
525
  let e = this.selection, t = await this.chooseFile?.();
526
- t && this.apply(Ge(e, t.url, t.name, t.kind === "image"));
526
+ t && this.apply(Ue(e, t.url, t.name, t.kind === "image"));
527
527
  }
528
528
  render() {
529
529
  let e = this.selection, n = () => this.requestUpdate();
@@ -544,7 +544,7 @@ x("edaha-markdown", class extends e {
544
544
  ${v(n.label)}
545
545
  </button>`)}
546
546
  ${this.embedTools?.embeds.map((t) => Ae(t, {
547
- pressed: A(e)?.key === t.key,
547
+ pressed: M(e)?.key === t.key,
548
548
  disabled: !1,
549
549
  onClick: () => void this.editEmbed(this.selection, t.key)
550
550
  }))}
@@ -585,7 +585,7 @@ x("edaha-markdown", class extends e {
585
585
  }
586
586
  });
587
587
  // src/client/richtext/extensions/index.ts
588
- var st = "embed-edit", ct = "embed-refresh", F = (e, t, { editor: n, getPos: r }, i = []) => {
588
+ var at = "embed-edit", ot = "embed-refresh", st = (e, t, { editor: n, getPos: r }, i = []) => {
589
589
  let a = document.createElement("div");
590
590
  a.className = e, a.contentEditable = "false";
591
591
  let o = document.createElement("div");
@@ -618,7 +618,7 @@ var st = "embed-edit", ct = "embed-refresh", F = (e, t, { editor: n, getPos: r }
618
618
  dom: a,
619
619
  title: s
620
620
  };
621
- }, lt = h.create({
621
+ }, ct = h.create({
622
622
  name: "readmore",
623
623
  group: "block",
624
624
  atom: !0,
@@ -628,7 +628,7 @@ var st = "embed-edit", ct = "embed-refresh", F = (e, t, { editor: n, getPos: r }
628
628
  class: "readmore",
629
629
  title: "Read more"
630
630
  }],
631
- addNodeView: () => (e) => F("readmore-block", "Read more", e).view,
631
+ addNodeView: () => (e) => st("readmore-block", "Read more", e).view,
632
632
  addCommands() {
633
633
  return { setReadmore: () => ({ chain: e, state: t }) => {
634
634
  let n = [];
@@ -645,7 +645,7 @@ var st = "embed-edit", ct = "embed-refresh", F = (e, t, { editor: n, getPos: r }
645
645
  }).run();
646
646
  } };
647
647
  }
648
- }), ut = h.create({
648
+ }), lt = h.create({
649
649
  name: "raw",
650
650
  group: "block",
651
651
  content: "text*",
@@ -665,7 +665,7 @@ var st = "embed-edit", ct = "embed-refresh", F = (e, t, { editor: n, getPos: r }
665
665
  addCommands() {
666
666
  return { toggleRaw: () => ({ commands: e }) => e.toggleNode(this.name, "paragraph") };
667
667
  }
668
- }), dt = m.create({
668
+ }), ut = m.create({
669
669
  name: "rawInline",
670
670
  code: !0,
671
671
  excludes: "_",
@@ -675,21 +675,21 @@ var st = "embed-edit", ct = "embed-refresh", F = (e, t, { editor: n, getPos: r }
675
675
  { class: "raw" },
676
676
  0
677
677
  ]
678
- }), ft = m.create({
678
+ }), dt = m.create({
679
679
  name: "small",
680
680
  parseHTML: () => [{ tag: "small" }],
681
681
  renderHTML: () => ["small", 0]
682
- }), pt = m.create({
682
+ }), ft = m.create({
683
683
  name: "big",
684
684
  parseHTML: () => [{ tag: "big" }],
685
685
  renderHTML: () => ["big", 0]
686
- }), I = /* @__PURE__ */ new Map();
686
+ }), L = /* @__PURE__ */ new Map();
687
687
  addEventListener("message", (e) => {
688
- let t = e.source && I.get(e.source), n = e.data?.edahaEmbedHeight;
688
+ let t = e.source && L.get(e.source), n = e.data?.edahaEmbedHeight;
689
689
  t && typeof n == "number" && (t.style.height = `${Math.min(Math.max(n, 40), 2e3)}px`);
690
690
  });
691
- var L = (e) => {
692
- for (let [t, n] of I) e.contains(n) && I.delete(t);
691
+ var pt = (e) => {
692
+ for (let [t, n] of L) e.contains(n) && L.delete(t);
693
693
  }, mt = () => document.documentElement.dataset.theme === "dark" || document.documentElement.dataset.theme !== "light" && globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light", ht = h.create({
694
694
  name: "embed",
695
695
  group: "block",
@@ -716,10 +716,10 @@ var L = (e) => {
716
716
  }],
717
717
  addNodeView() {
718
718
  return (e) => {
719
- let { editor: t } = e, n = F("embed-block", "", e, [{
719
+ let { editor: t } = e, n = st("embed-block", "", e, [{
720
720
  text: "Edit",
721
721
  onClick: (e, n) => {
722
- t.commands.setNodeSelection(e), n.dispatchEvent(new Event(st, { bubbles: !0 }));
722
+ t.commands.setNodeSelection(e), n.dispatchEvent(new Event(at, { bubbles: !0 }));
723
723
  }
724
724
  }]), r = n.dom.querySelector("button"), i = document.createElement("span");
725
725
  i.className = "icon embed-icon", i.setAttribute("aria-hidden", "true"), n.title.before(i);
@@ -730,7 +730,7 @@ var L = (e) => {
730
730
  if (t === o) return;
731
731
  o = t;
732
732
  let s = this.options.tools(), c = s?.embeds.find((t) => t.key === e.key);
733
- n.title.textContent = Oe(s?.embeds ?? [], e.key), i.innerHTML = c?.icon ?? "", r.hidden = !c, L(a), a.replaceChildren();
733
+ n.title.textContent = Oe(s?.embeds ?? [], e.key), i.innerHTML = c?.icon ?? "", r.hidden = !c, pt(a), a.replaceChildren();
734
734
  let l = document.createElement("pre");
735
735
  if (l.className = "embed-content", l.textContent = te(e.content, e.options), !s) a.append(l);
736
736
  else {
@@ -760,18 +760,18 @@ var L = (e) => {
760
760
  return;
761
761
  }
762
762
  let i = document.createElement("iframe");
763
- i.className = "embed-frame", i.title = `${n.title.textContent}: preview`, i.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox"), i.src = je(`${r.url}?theme=${mt()}`), a.append(i), i.contentWindow && I.set(i.contentWindow, i);
763
+ i.className = "embed-frame", i.title = `${n.title.textContent}: preview`, i.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox"), i.src = je(`${r.url}?theme=${mt()}`), a.append(i), i.contentWindow && L.set(i.contentWindow, i);
764
764
  } catch (e) {
765
765
  o === t && (a.textContent = `No preview: ${e.message}`);
766
766
  }
767
767
  }
768
768
  };
769
- return c(s), n.dom.addEventListener(ct, () => {
769
+ return c(s), n.dom.addEventListener(ot, () => {
770
770
  o = "", c(s);
771
771
  }), {
772
772
  ...n.view,
773
773
  update: (e) => e.type === this.type && (s = e.attrs, c(s), !0),
774
- destroy: () => L(a)
774
+ destroy: () => pt(a)
775
775
  };
776
776
  };
777
777
  },
@@ -865,12 +865,12 @@ var L = (e) => {
865
865
  le,
866
866
  ce,
867
867
  _t,
868
+ dt,
868
869
  ft,
869
- pt,
870
870
  gt,
871
+ ct,
871
872
  lt,
872
873
  ut,
873
- dt,
874
874
  ht.configure({ tools: r }),
875
875
  ...i ? [oe.configure({
876
876
  element: i,
@@ -893,7 +893,7 @@ var L = (e) => {
893
893
  >
894
894
  ${v(e.label)}
895
895
  </button>`, z = (e) => e.isActive("table");
896
- x("edaha-richtext", class extends e {
896
+ S("edaha-richtext", class extends e {
897
897
  static properties = {
898
898
  value: { attribute: !1 },
899
899
  uploadImage: { attribute: !1 },
@@ -1112,12 +1112,12 @@ x("edaha-richtext", class extends e {
1112
1112
  let e = this.querySelector(".richtext-content");
1113
1113
  this.editor = bt(e, this.value, (e) => {
1114
1114
  this.value = e, this.dispatchEvent(new Event("richtext-change", { bubbles: !0 })), this.requestUpdate();
1115
- }, () => this.embedTools, this.formatMenu, (e) => this.fileAddress?.(e) ?? e), e.addEventListener(st, () => {
1115
+ }, () => this.embedTools, this.formatMenu, (e) => this.fileAddress?.(e) ?? e), e.addEventListener(at, () => {
1116
1116
  this.editor && this.editEmbed(this.editor);
1117
1117
  }), this.editor.on("selectionUpdate", () => this.requestUpdate()), this.requestUpdate();
1118
1118
  }
1119
1119
  updated(e) {
1120
- if (r(this.formatActions.map((e) => xt(e, this.editor)), this.formatMenu), e.has("value") && this.editor && this.editor.getHTML() !== this.value && this.editor.commands.setContent(this.value, { emitUpdate: !1 }), e.has("embedTools")) for (let e of this.querySelectorAll(".embed-block")) e.dispatchEvent(new Event(ct));
1120
+ if (r(this.formatActions.map((e) => xt(e, this.editor)), this.formatMenu), e.has("value") && this.editor && this.editor.getHTML() !== this.value && this.editor.commands.setContent(this.value, { emitUpdate: !1 }), e.has("embedTools")) for (let e of this.querySelectorAll(".embed-block")) e.dispatchEvent(new Event(ot));
1121
1121
  }
1122
1122
  disconnectedCallback() {
1123
1123
  super.disconnectedCallback(), this.editor?.destroy(), this.editor = void 0;
@@ -1240,7 +1240,7 @@ var B = (e, t) => e.sort === t ? e.order === "asc" ? {
1240
1240
  let t = Math.min(Math.max(Math.floor(Math.log(e) / Math.log(1024)), 0), Dt.length - 1), n = e / 1024 ** t;
1241
1241
  return `${t && n < 10 ? Math.round(n * 10) / 10 : Math.round(n)} ${Dt[t]}`;
1242
1242
  }, V = (e) => `${e} ${e === 1 ? "article" : "articles"}`;
1243
- x("edaha-file-browser", class extends e {
1243
+ S("edaha-file-browser", class extends e {
1244
1244
  static properties = {
1245
1245
  api: { attribute: !1 },
1246
1246
  types: { attribute: !1 },
@@ -1562,7 +1562,7 @@ x("edaha-file-browser", class extends e {
1562
1562
  });
1563
1563
  // src/client/components/edaha-article-data-field/index.ts
1564
1564
  var kt = /\.(png|jpe?g|gif|webp|svg)$/i;
1565
- x("edaha-article-data-field", class extends e {
1565
+ S("edaha-article-data-field", class extends e {
1566
1566
  static properties = {
1567
1567
  name: {},
1568
1568
  type: {},
@@ -1714,7 +1714,7 @@ x("edaha-article-data-field", class extends e {
1714
1714
  });
1715
1715
  // src/client/components/edaha-article-data-group/style.css?inline
1716
1716
  var At = ":host{display:block}";
1717
- x("edaha-article-data-group", class extends e {
1717
+ S("edaha-article-data-group", class extends e {
1718
1718
  static properties = {
1719
1719
  name: {},
1720
1720
  label: {},
@@ -1768,7 +1768,7 @@ var H = "edaha-toast", U = (e, t) => {
1768
1768
  bubbles: !0
1769
1769
  }));
1770
1770
  };
1771
- x("edaha-toasts", class extends e {
1771
+ S("edaha-toasts", class extends e {
1772
1772
  static properties = { toasts: { state: !0 } };
1773
1773
  duration = 4e3;
1774
1774
  nextId = 0;
@@ -1853,8 +1853,7 @@ var jt = (e, t) => t.$edahaField?.title ?? t.title ?? e, Mt = (e) => e.$edahaFie
1853
1853
  }, Bt = /^#?([0-9a-f]{6})$/i, Vt = (e) => {
1854
1854
  let t = Bt.exec(String(e ?? ""));
1855
1855
  return t ? `#${t[1].toLowerCase()}` : "";
1856
- }, Ht = (e, t) => typeof t == "string" && /^[0-9a-f]{6}$/i.test(t) ? e.replace(/^#/, "") : e, K = (e, t) => e.filter((e) => e.path === t), q = (e) => t`<span class="visually-hidden">${e}</span>`, Ut = (e) => `meta-${e.replace(/[^\w-]/g, "-")}`;
1857
- x("edaha-metadata-field", class extends e {
1856
+ }, Ht = (e, t) => typeof t == "string" && /^[0-9a-f]{6}$/i.test(t) ? e.replace(/^#/, "") : e, K = (e, t) => e.filter((e) => e.path === t), q = (e) => t`<span class="visually-hidden">${e}</span>`, Ut = (e) => `meta-${e.replace(/[^\w-]/g, "-")}`, Wt = class extends e {
1858
1857
  static properties = {
1859
1858
  path: {},
1860
1859
  label: {},
@@ -1959,11 +1958,11 @@ x("edaha-metadata-field", class extends e {
1959
1958
  </fieldset>`;
1960
1959
  }
1961
1960
  renderSelect(e, r) {
1962
- let i = g(this.schema.$edahaField), a = Pt(this.schema), o = i.multiple === !0, s = o ? (this.value ?? []).map(String) : [String(this.value ?? "")];
1961
+ let i = g(this.schema.$edahaField), a = Pt(this.schema), o = i.multiple === !0, s = !o && !a.some((e) => e.value === ""), c = o ? (this.value ?? []).map(String) : [String(this.value ?? "")];
1963
1962
  return t`<select
1964
1963
  id=${e}
1965
1964
  ?multiple=${o}
1966
- size=${i.list === !0 ? a.length + +!o : n}
1965
+ size=${i.list === !0 ? a.length + +!!s : n}
1967
1966
  ?required=${this.required}
1968
1967
  aria-invalid=${K(this.problems, this.path).length ? "true" : "false"}
1969
1968
  aria-describedby=${this.describedBy(e) || n}
@@ -1972,11 +1971,11 @@ x("edaha-metadata-field", class extends e {
1972
1971
  this.change(this.path, o ? t : t[0] ?? Rt(r, ""));
1973
1972
  }}
1974
1973
  >
1975
- ${o ? n : t`<option value="">—</option>`}
1974
+ ${s ? t`<option value="">—</option>` : n}
1976
1975
  ${a.map((e, n) => t`<option
1977
1976
  data-index=${n}
1978
1977
  value=${String(e.value)}
1979
- ?selected=${s.includes(String(e.value))}
1978
+ ?selected=${c.includes(String(e.value))}
1980
1979
  >
1981
1980
  ${e.title ?? String(e.value)}
1982
1981
  </option>`)}
@@ -2115,9 +2114,10 @@ x("edaha-metadata-field", class extends e {
2115
2114
  ${o} ${this.renderNotes(e)} ${this.renderInput(e, r)}
2116
2115
  </div>`;
2117
2116
  }
2118
- });
2119
- var Wt = "embed-options";
2120
- x("edaha-embed-dialog", class extends e {
2117
+ };
2118
+ S("edaha-metadata-field", Wt);
2119
+ var Gt = "embed-options";
2120
+ S("edaha-embed-dialog", class extends e {
2121
2121
  static properties = {
2122
2122
  embed: { state: !0 },
2123
2123
  content: { state: !0 },
@@ -2192,14 +2192,14 @@ x("edaha-embed-dialog", class extends e {
2192
2192
  let { values: r, hidden: i } = this.resolvedOptions();
2193
2193
  return t`<edaha-metadata-field
2194
2194
  class="embed-dialog-options"
2195
- path=${Wt}
2195
+ path=${Gt}
2196
2196
  .schema=${{
2197
2197
  title: "Options",
2198
2198
  type: "object",
2199
2199
  properties: e
2200
2200
  }}
2201
2201
  .value=${r}
2202
- .hiddenFields=${new Set([...i].map((e) => `${Wt}.${e}`))}
2202
+ .hiddenFields=${new Set([...i].map((e) => `${Gt}.${e}`))}
2203
2203
  @metadata-change=${this.onOptionChange}
2204
2204
  @metadata-blur=${(e) => e.stopPropagation()}
2205
2205
  ></edaha-metadata-field>`;
@@ -2273,7 +2273,7 @@ x("edaha-embed-dialog", class extends e {
2273
2273
  }
2274
2274
  });
2275
2275
  // src/client/components/edaha-article/index.ts
2276
- var Gt = [
2276
+ var Kt = [
2277
2277
  {
2278
2278
  value: "published",
2279
2279
  label: "Published"
@@ -2286,7 +2286,7 @@ var Gt = [
2286
2286
  value: "unlisted",
2287
2287
  label: "Unlisted"
2288
2288
  }
2289
- ], Kt = [
2289
+ ], qt = [
2290
2290
  {
2291
2291
  mode: "wysiwyg",
2292
2292
  label: "WYSIWYG"
@@ -2299,7 +2299,7 @@ var Gt = [
2299
2299
  mode: "preview",
2300
2300
  label: "Preview"
2301
2301
  }
2302
- ], qt = [
2302
+ ], Jt = [
2303
2303
  {
2304
2304
  value: "full",
2305
2305
  label: "Full",
@@ -2320,7 +2320,7 @@ var Gt = [
2320
2320
  label: "320px",
2321
2321
  width: "320px"
2322
2322
  }
2323
- ], Jt = (e) => `body-tab-${e}`, Yt = (e, t, n) => {
2323
+ ], Yt = (e) => `body-tab-${e}`, Xt = (e, t, n) => {
2324
2324
  switch (e) {
2325
2325
  case "ArrowRight": return (t + 1) % n;
2326
2326
  case "ArrowLeft": return (t - 1 + n) % n;
@@ -2328,7 +2328,7 @@ var Gt = [
2328
2328
  case "End": return n - 1;
2329
2329
  default: return;
2330
2330
  }
2331
- }, Xt = (e = /* @__PURE__ */ new Date()) => ({
2331
+ }, Zt = (e = /* @__PURE__ */ new Date()) => ({
2332
2332
  type: "article",
2333
2333
  slug: "",
2334
2334
  status: "draft",
@@ -2340,7 +2340,7 @@ var Gt = [
2340
2340
  tags: [],
2341
2341
  attachments: [],
2342
2342
  bodyHtml: ""
2343
- }), Zt = (e, t, n) => {
2343
+ }), Qt = (e, t, n) => {
2344
2344
  let r = /^author\[(name|email|url)\]$/.exec(t);
2345
2345
  if (r) {
2346
2346
  let t = {
@@ -2381,7 +2381,7 @@ var Gt = [
2381
2381
  switch (t) {
2382
2382
  case "date": return {
2383
2383
  ...e,
2384
- date: Fe(n) || e.date
2384
+ date: Pe(n) || e.date
2385
2385
  };
2386
2386
  case "body": return {
2387
2387
  ...e,
@@ -2405,13 +2405,13 @@ var Gt = [
2405
2405
  };
2406
2406
  default: return e;
2407
2407
  }
2408
- }, Qt = (e) => ({
2408
+ }, $t = (e) => ({
2409
2409
  ...e,
2410
2410
  slug: e.slug.trim() || u(e.title),
2411
2411
  title: e.title.trim(),
2412
2412
  tags: e.tags.map((e) => e.trim()).filter(Boolean),
2413
2413
  attachments: e.attachments.filter((e) => e.url.trim())
2414
- }), $t = [
2414
+ }), en = [
2415
2415
  "title",
2416
2416
  "type",
2417
2417
  "template",
@@ -2424,7 +2424,7 @@ var Gt = [
2424
2424
  "tags",
2425
2425
  "attachments",
2426
2426
  "meta"
2427
- ], J = (e) => Array.isArray(e) ? e.map(J) : e && typeof e == "object" ? Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => [e, J(t)])) : e, Y = (e, t) => new Set($t.filter((n) => JSON.stringify(J(e[n])) !== JSON.stringify(J(t[n])))), en = [
2427
+ ], J = (e) => Array.isArray(e) ? e.map(J) : e && typeof e == "object" ? Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => [e, J(t)])) : e, Y = (e, t) => new Set(en.filter((n) => JSON.stringify(J(e[n])) !== JSON.stringify(J(t[n])))), tn = [
2428
2428
  "type",
2429
2429
  "status",
2430
2430
  "slug",
@@ -2436,8 +2436,8 @@ var Gt = [
2436
2436
  "thumbnail",
2437
2437
  "attachments",
2438
2438
  "uploaded"
2439
- ], X = (e) => en.includes(e), tn = (e) => t`<span class="visually-hidden">${e}</span>`, nn = (e) => new Set(e.filter((e) => e.openedByDefault).map((e) => e.key)), rn = "Some values aren't valid. Fix the fields marked ⚠️ in the settings.";
2440
- x("edaha-article", class extends e {
2439
+ ], X = (e) => tn.includes(e), nn = (e) => t`<span class="visually-hidden">${e}</span>`, rn = (e) => new Set(e.filter((e) => e.openedByDefault).map((e) => e.key)), an = "Some values aren't valid. Fix the fields marked ⚠️ in the settings.";
2440
+ S("edaha-article", class extends e {
2441
2441
  static properties = {
2442
2442
  api: { attribute: !1 },
2443
2443
  article: { attribute: !1 },
@@ -2476,7 +2476,7 @@ x("edaha-article", class extends e {
2476
2476
  templatesType = "";
2477
2477
  confirm = (e) => window.confirm(e);
2478
2478
  constructor() {
2479
- super(), this.typeOptions = [], this.data = Xt(), this.files = [], this.busy = !1, this.message = "", this.error = "", this.templates = [], this.mode = "wysiwyg", this.bodyMarkdown = "", this.previewUrl = "", this.previewWidth = "full", this.metadataOpen = !1, this.savedData = structuredClone(this.data), this.bodyChanged = !1, this.metaProblems = [], this.openGroups = nn(Te), this.compact = !1, this.focusMode = !1;
2479
+ super(), this.typeOptions = [], this.data = Zt(), this.files = [], this.busy = !1, this.message = "", this.error = "", this.templates = [], this.mode = "wysiwyg", this.bodyMarkdown = "", this.previewUrl = "", this.previewWidth = "full", this.metadataOpen = !1, this.savedData = structuredClone(this.data), this.bodyChanged = !1, this.metaProblems = [], this.openGroups = rn(Te), this.compact = !1, this.focusMode = !1;
2480
2480
  }
2481
2481
  createRenderRoot() {
2482
2482
  return this;
@@ -2497,13 +2497,13 @@ x("edaha-article", class extends e {
2497
2497
  await e?.updateComplete, e?.querySelector("input")?.focus();
2498
2498
  }
2499
2499
  willUpdate(e) {
2500
- if (e.get("compact") && !this.compact && (this.metadataOpen = !1), e.has("metadata") && this.metadata && !this.groupsOpened && (this.groupsOpened = !0, this.openGroups = nn(this.metadata.groups)), e.has("metaProblems")) {
2500
+ if (e.get("compact") && !this.compact && (this.metadataOpen = !1), e.has("metadata") && this.metadata && !this.groupsOpened && (this.groupsOpened = !0, this.openGroups = rn(this.metadata.groups)), e.has("metaProblems")) {
2501
2501
  let e = this.groupsWithErrors();
2502
2502
  [...e].some((e) => !this.openGroups.has(e)) && (this.openGroups = /* @__PURE__ */ new Set([...this.openGroups, ...e]));
2503
2503
  }
2504
2504
  if (e.has("article")) {
2505
2505
  let { files: e, problems: t = [], ...n } = this.article ?? {
2506
- ...Xt(),
2506
+ ...Zt(),
2507
2507
  files: []
2508
2508
  };
2509
2509
  this.savedProblems = t.filter(({ level: e }) => e === "error"), this.metaProblems = this.savedProblems, this.data = n, this.files = e, this.location = this.article ? {
@@ -2605,7 +2605,7 @@ x("edaha-article", class extends e {
2605
2605
  }
2606
2606
  onFieldChange(e) {
2607
2607
  let { name: t, value: n } = e.detail;
2608
- t === "bodyMarkdown" ? this.bodyMarkdown = n : this.data = Zt(this.data, t, n), (t === "body" || t === "bodyMarkdown") && this.scheduleBodyCheck();
2608
+ t === "bodyMarkdown" ? this.bodyMarkdown = n : this.data = Qt(this.data, t, n), (t === "body" || t === "bodyMarkdown") && this.scheduleBodyCheck();
2609
2609
  }
2610
2610
  async currentBodyMarkdown() {
2611
2611
  return this.mode === "markdown" ? this.bodyMarkdown : this.api.toMarkdown(this.data.bodyHtml, this.location);
@@ -2633,7 +2633,7 @@ x("edaha-article", class extends e {
2633
2633
  }
2634
2634
  async onFieldFile(e) {
2635
2635
  let t = e.target.name, n = await this.upload(e.detail);
2636
- n && (this.data = Zt(this.data, t, n));
2636
+ n && (this.data = Qt(this.data, t, n));
2637
2637
  }
2638
2638
  async syncBody() {
2639
2639
  if (this.mode !== "markdown") return !0;
@@ -2650,7 +2650,7 @@ x("edaha-article", class extends e {
2650
2650
  if (e === void 0) return;
2651
2651
  this.bodyMarkdown = e;
2652
2652
  } else if (e === "preview") {
2653
- let e = await this.run(() => this.api.preview(Qt(this.data), this.location));
2653
+ let e = await this.run(() => this.api.preview($t(this.data), this.location));
2654
2654
  if (e === void 0) return;
2655
2655
  this.previewUrl = e;
2656
2656
  }
@@ -2661,10 +2661,10 @@ x("edaha-article", class extends e {
2661
2661
  let { values: e } = this.resolvedMeta(), t = this.metadataKeys().flatMap((t) => this.checkMetadata(t, e));
2662
2662
  if (t.length) return this.metaProblems = t, U(this, {
2663
2663
  kind: "error",
2664
- message: rn
2664
+ message: an
2665
2665
  }), !1;
2666
2666
  if (!await this.syncBody()) return !1;
2667
- let n = this.metadataKeys(), r = Qt({
2667
+ let n = this.metadataKeys(), r = $t({
2668
2668
  ...this.data,
2669
2669
  meta: {
2670
2670
  ...Object.fromEntries(Object.entries(this.data.meta ?? {}).filter(([e]) => !n.includes(e))),
@@ -2721,7 +2721,7 @@ x("edaha-article", class extends e {
2721
2721
  let t = e.detail.split("/")[0], n = (e) => e.path.split("/")[0] === t, r = this.metaProblems.some(n), i = this.checkMetadata(t);
2722
2722
  this.metaProblems = [...this.metaProblems.filter((e) => !n(e)), ...i], i.length && !r && U(this, {
2723
2723
  kind: "error",
2724
- message: rn
2724
+ message: an
2725
2725
  });
2726
2726
  }
2727
2727
  removeSetting(e) {
@@ -2892,7 +2892,7 @@ x("edaha-article", class extends e {
2892
2892
  id="preview-width"
2893
2893
  @change=${(e) => this.previewWidth = e.target.value}
2894
2894
  >
2895
- ${qt.map(({ value: e, label: n }) => t`<option
2895
+ ${Jt.map(({ value: e, label: n }) => t`<option
2896
2896
  value=${e}
2897
2897
  ?selected=${this.previewWidth === e}
2898
2898
  >
@@ -2905,7 +2905,7 @@ x("edaha-article", class extends e {
2905
2905
  class="preview"
2906
2906
  title="Preview"
2907
2907
  src=${this.api.previewUrl(this.previewUrl)}
2908
- style=${c({ width: qt.find(({ value: e }) => e === this.previewWidth)?.width })}
2908
+ style=${c({ width: Jt.find(({ value: e }) => e === this.previewWidth)?.width })}
2909
2909
  ></iframe>
2910
2910
  </div>` : t`<edaha-article-data-field
2911
2911
  name="body"
@@ -2923,10 +2923,10 @@ x("edaha-article", class extends e {
2923
2923
  aria-label="Body"
2924
2924
  @keydown=${this.onTabKey}
2925
2925
  >
2926
- ${Kt.map(({ mode: e, label: n }) => t`<button
2926
+ ${qt.map(({ mode: e, label: n }) => t`<button
2927
2927
  type="button"
2928
2928
  role="tab"
2929
- id=${Jt(e)}
2929
+ id=${Yt(e)}
2930
2930
  data-mode=${e}
2931
2931
  aria-selected=${this.mode === e ? "true" : "false"}
2932
2932
  aria-controls="body-panel"
@@ -2941,13 +2941,13 @@ x("edaha-article", class extends e {
2941
2941
  class="body-panel body-panel-${this.mode}"
2942
2942
  id="body-panel"
2943
2943
  role="tabpanel"
2944
- aria-labelledby=${Jt(this.mode)}
2944
+ aria-labelledby=${Yt(this.mode)}
2945
2945
  >
2946
2946
  ${e}
2947
2947
  </div>`;
2948
2948
  }
2949
2949
  onTabKey(e) {
2950
- let t = [...e.currentTarget.querySelectorAll("[role=\"tab\"]")], n = t.indexOf(e.target), r = Yt(e.key, n, t.length);
2950
+ let t = [...e.currentTarget.querySelectorAll("[role=\"tab\"]")], n = t.indexOf(e.target), r = Xt(e.key, n, t.length);
2951
2951
  r !== void 0 && (e.preventDefault(), t[r]?.focus());
2952
2952
  }
2953
2953
  groups() {
@@ -2976,7 +2976,7 @@ x("edaha-article", class extends e {
2976
2976
  ?changed=${n.has("status")}
2977
2977
  type="select"
2978
2978
  label="Status"
2979
- .options=${Gt}
2979
+ .options=${Kt}
2980
2980
  .value=${i.status}
2981
2981
  ></edaha-article-data-field>`;
2982
2982
  case "slug": return t`<edaha-article-data-field
@@ -2991,7 +2991,7 @@ x("edaha-article", class extends e {
2991
2991
  ?changed=${n.has("date")}
2992
2992
  type="datetime-local"
2993
2993
  label="Publication date"
2994
- .value=${Pe(i.date)}
2994
+ .value=${Ne(i.date)}
2995
2995
  ></edaha-article-data-field>`;
2996
2996
  case "author": return this.renderAuthor();
2997
2997
  case "tags": return this.renderTags();
@@ -3098,7 +3098,7 @@ x("edaha-article", class extends e {
3098
3098
  class="btn btn-xs"
3099
3099
  @click=${() => this.removeSetting(e)}
3100
3100
  >
3101
- Remove${tn(` "${e}"`)}
3101
+ Remove${nn(` "${e}"`)}
3102
3102
  </button>
3103
3103
  </li>`)}
3104
3104
  </ul>` : n}
@@ -3207,7 +3207,7 @@ x("edaha-article", class extends e {
3207
3207
  }
3208
3208
  });
3209
3209
  // src/client/components/edaha-article-browser/index.ts
3210
- var an = [
3210
+ var on = [
3211
3211
  {
3212
3212
  value: "errors",
3213
3213
  label: "With errors"
@@ -3220,13 +3220,13 @@ var an = [
3220
3220
  value: "any",
3221
3221
  label: "With errors or warnings"
3222
3222
  }
3223
- ], Z = (e = []) => {
3223
+ ], sn = (e = []) => {
3224
3224
  let t = (t) => {
3225
3225
  let n = e.filter((e) => e.level === t).length;
3226
3226
  return n ? `${n} ${t}${n === 1 ? "" : "s"}` : "";
3227
3227
  };
3228
3228
  return [t("error"), t("warning")].filter(Boolean).join(", ");
3229
- }, on = [
3229
+ }, cn = [
3230
3230
  {
3231
3231
  value: "published",
3232
3232
  label: "Published"
@@ -3239,7 +3239,7 @@ var an = [
3239
3239
  value: "unlisted",
3240
3240
  label: "Unlisted"
3241
3241
  }
3242
- ], sn = [
3242
+ ], ln = [
3243
3243
  {
3244
3244
  sort: "title",
3245
3245
  label: "Title"
@@ -3260,8 +3260,8 @@ var an = [
3260
3260
  sort: "updated",
3261
3261
  label: "Changed"
3262
3262
  }
3263
- ], cn = "article-choose", Q = (e, t) => e[t]?.labelSingle ?? t;
3264
- x("edaha-article-browser", class extends e {
3263
+ ], un = "article-choose", Z = (e, t) => e[t]?.labelSingle ?? t;
3264
+ S("edaha-article-browser", class extends e {
3265
3265
  static properties = {
3266
3266
  api: { attribute: !1 },
3267
3267
  types: { attribute: !1 },
@@ -3349,7 +3349,7 @@ x("edaha-article-browser", class extends e {
3349
3349
  this.page = e, await this.load(), this.querySelector(".article-browser-results")?.scrollTo?.(0, 0);
3350
3350
  }
3351
3351
  chooseArticle(e) {
3352
- this.close(), this.dispatchEvent(new CustomEvent(cn, {
3352
+ this.close(), this.dispatchEvent(new CustomEvent(un, {
3353
3353
  detail: {
3354
3354
  type: e.type,
3355
3355
  slug: e.slug
@@ -3379,11 +3379,11 @@ x("edaha-article-browser", class extends e {
3379
3379
  let e = this.result;
3380
3380
  if (!e) return n;
3381
3381
  if (!e.articles.length) return t`<p class="article-browser-empty">No articles found.</p>`;
3382
- let r = Object.fromEntries(on.map(({ value: e, label: t }) => [e, t]));
3382
+ let r = Object.fromEntries(cn.map(({ value: e, label: t }) => [e, t]));
3383
3383
  return t`<table class="article-browser-table">
3384
3384
  <thead>
3385
3385
  <tr>
3386
- ${sn.map(({ sort: e, label: t }) => St(e, t, {
3386
+ ${ln.map(({ sort: e, label: t }) => St(e, t, {
3387
3387
  sort: this.sort,
3388
3388
  order: this.order
3389
3389
  }, (e) => this.sortBy(e)))}
@@ -3401,10 +3401,10 @@ x("edaha-article-browser", class extends e {
3401
3401
  >
3402
3402
  ${e.error ? t`<small class="error">${e.error}</small>` : n}
3403
3403
  ${e.problems ? t`<small class="problems"
3404
- >⚠️ ${Z(e.problems)}</small
3404
+ >⚠️ ${sn(e.problems)}</small
3405
3405
  >` : n}
3406
3406
  </td>
3407
- <td>${Q(this.types, e.type)}</td>
3407
+ <td>${Z(this.types, e.type)}</td>
3408
3408
  <td>${r[e.status]}</td>
3409
3409
  <td>${e.date.slice(0, 10)}</td>
3410
3410
  <td>${e.updated.slice(0, 10)}</td>
@@ -3446,7 +3446,7 @@ x("edaha-article-browser", class extends e {
3446
3446
  label: e
3447
3447
  })), n = [.../* @__PURE__ */ new Set([...Object.keys(this.types), ...this.filters.types])].map((e) => ({
3448
3448
  value: e,
3449
- label: Q(this.types, e)
3449
+ label: Z(this.types, e)
3450
3450
  }));
3451
3451
  return t`<dialog
3452
3452
  class="article-browser"
@@ -3477,8 +3477,8 @@ x("edaha-article-browser", class extends e {
3477
3477
  ${this.renderSelect("type", "Type", "All types", n)}
3478
3478
  ${this.renderSelect("author", "Author", "Any author", e(this.filters.authors))}
3479
3479
  ${this.renderSelect("tag", "Tag", "Any tag", e(this.filters.tags))}
3480
- ${this.renderSelect("status", "Status", "Any status", on)}
3481
- ${this.renderSelect("problems", "Problems", "Any article", an)}
3480
+ ${this.renderSelect("status", "Status", "Any status", cn)}
3481
+ ${this.renderSelect("problems", "Problems", "Any article", on)}
3482
3482
  </div>
3483
3483
  <p
3484
3484
  class="article-browser-status ${this.error ? "error" : ""}"
@@ -3493,24 +3493,24 @@ x("edaha-article-browser", class extends e {
3493
3493
  }
3494
3494
  });
3495
3495
  // src/client/theme/index.ts
3496
- var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function" ? window.matchMedia("(prefers-color-scheme: dark)") : void 0, dn = () => {
3496
+ var dn = "edaha-editor-theme", fn = () => typeof window.matchMedia == "function" ? window.matchMedia("(prefers-color-scheme: dark)") : void 0, pn = () => {
3497
3497
  let e = document.documentElement.dataset.theme;
3498
- return e === "light" || e === "dark" ? e : un()?.matches ? "dark" : "light";
3499
- }, fn = (e) => {
3498
+ return e === "light" || e === "dark" ? e : fn()?.matches ? "dark" : "light";
3499
+ }, mn = (e) => {
3500
3500
  document.documentElement.dataset.theme = e;
3501
3501
  try {
3502
- localStorage.setItem(ln, e);
3502
+ localStorage.setItem(dn, e);
3503
3503
  } catch {}
3504
- }, pn = () => {
3505
- let e = dn() === "dark" ? "light" : "dark";
3506
- return fn(e), e;
3507
- }, mn = () => `Switch to the ${dn() === "dark" ? "light" : "dark"} theme`, hn = (e) => {
3508
- let t = un();
3504
+ }, hn = () => {
3505
+ let e = pn() === "dark" ? "light" : "dark";
3506
+ return mn(e), e;
3507
+ }, Q = () => `Switch to the ${pn() === "dark" ? "light" : "dark"} theme`, gn = (e) => {
3508
+ let t = fn();
3509
3509
  return t?.addEventListener("change", e), () => t?.removeEventListener("change", e);
3510
- }, gn = "(max-width: 899.98px)", _n = () => typeof window.matchMedia == "function" ? window.matchMedia(gn) : void 0, vn = () => _n()?.matches ?? !1, yn = (e) => {
3511
- let t = _n();
3510
+ }, _n = "(max-width: 899.98px)", vn = () => typeof window.matchMedia == "function" ? window.matchMedia(_n) : void 0, yn = () => vn()?.matches ?? !1, bn = (e) => {
3511
+ let t = vn();
3512
3512
  return t?.addEventListener("change", e), () => t?.removeEventListener("change", e);
3513
- }, bn = (e) => [
3513
+ }, xn = (e) => [
3514
3514
  e.slug,
3515
3515
  e.status,
3516
3516
  e.date.slice(0, 10)
@@ -3531,13 +3531,13 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
3531
3531
  label: "Cancel"
3532
3532
  }
3533
3533
  ]
3534
- }, xn = (e, t) => {
3534
+ }, Sn = (e, t) => {
3535
3535
  let n = Object.keys(t), r = (e) => n.includes(e) ? n.indexOf(e) : n.length;
3536
3536
  return e.map((e) => ({
3537
3537
  ...e,
3538
3538
  label: t[e.type]?.labelPlural ?? e.type
3539
3539
  })).sort((e, t) => r(e.type) - r(t.type) || e.type.localeCompare(t.type));
3540
- }, Sn = class extends e {
3540
+ }, Cn = class extends e {
3541
3541
  static properties = {
3542
3542
  api: { attribute: !1 },
3543
3543
  hideTitle: {
@@ -3577,7 +3577,7 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
3577
3577
  searches = 0;
3578
3578
  onToast = (e) => this.toast(e.detail);
3579
3579
  constructor() {
3580
- super(), this.api = new Ne(), this.hideTitle = !1, this.hideThemeSwitcher = !1, this.recent = [], this.types = {}, this.editing = !1, this.formKey = 0, this.error = "", this.searchText = "", this.navOpen = !1, this.narrow = !1, this.focusMode = !1;
3580
+ super(), this.api = new x(), this.hideTitle = !1, this.hideThemeSwitcher = !1, this.recent = [], this.types = {}, this.editing = !1, this.formKey = 0, this.error = "", this.searchText = "", this.navOpen = !1, this.narrow = !1, this.focusMode = !1;
3581
3581
  }
3582
3582
  get compact() {
3583
3583
  return this.narrow || this.focusMode;
@@ -3586,7 +3586,7 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
3586
3586
  return this;
3587
3587
  }
3588
3588
  connectedCallback() {
3589
- super.connectedCallback(), window.addEventListener("beforeunload", this.onBeforeUnload), this.addEventListener(H, this.onToast), this.stopWatchingTheme = hn(() => this.requestUpdate()), this.hideThemeSwitcher && delete document.documentElement.dataset.theme, this.narrow = vn(), this.stopWatchingNarrow = yn(() => this.narrow = vn()), this.refresh().then(() => this.openFromAddress());
3589
+ super.connectedCallback(), window.addEventListener("beforeunload", this.onBeforeUnload), this.addEventListener(H, this.onToast), this.stopWatchingTheme = gn(() => this.requestUpdate()), this.hideThemeSwitcher && delete document.documentElement.dataset.theme, this.narrow = yn(), this.stopWatchingNarrow = bn(() => this.narrow = yn()), this.refresh().then(() => this.openFromAddress());
3590
3590
  }
3591
3591
  async openFromAddress() {
3592
3592
  let [, e, t] = /^#([a-z0-9-]+)\/([a-z0-9-]+)$/.exec(window.location.hash) ?? [];
@@ -3781,7 +3781,7 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
3781
3781
  >${e.title}</a
3782
3782
  >
3783
3783
  <small class="welcome-prompt-meta"
3784
- >${Q(this.types, e.type)} · changed
3784
+ >${Z(this.types, e.type)} · changed
3785
3785
  ${e.updated.slice(0, 10)}</small
3786
3786
  >
3787
3787
  </li>`)}
@@ -3817,7 +3817,7 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
3817
3817
  >
3818
3818
  <small class="welcome-prompt-meta"
3819
3819
  >⚠️
3820
- ${Z(e.problems)}${r ? t`: "${r.path}" ${r.message}` : n}</small
3820
+ ${sn(e.problems)}${r ? t`: "${r.path}" ${r.message}` : n}</small
3821
3821
  >
3822
3822
  </li>`;
3823
3823
  })}
@@ -3852,7 +3852,7 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
3852
3852
  </div>`;
3853
3853
  }
3854
3854
  renderGroups(e) {
3855
- return xn(this.recent, this.types).map((r) => t`<div class="edaha-editor-article-group" data-type=${r.type}>
3855
+ return Sn(this.recent, this.types).map((r) => t`<div class="edaha-editor-article-group" data-type=${r.type}>
3856
3856
  <h2 class="edaha-editor-article-group-title">${r.label}</h2>
3857
3857
  <ul class="edaha-editor-article-group-list">
3858
3858
  ${r.articles.map(e)}
@@ -3881,7 +3881,7 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
3881
3881
  >${r.title}</a
3882
3882
  >
3883
3883
  <small class="edaha-editor-article-group-item-meta"
3884
- >${bn(r)}</small
3884
+ >${xn(r)}</small
3885
3885
  >
3886
3886
  ${r.error ? t`<small class="error">${r.error}</small>` : n}
3887
3887
  </li>`;
@@ -3922,12 +3922,12 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
3922
3922
  ${this.hideThemeSwitcher ? n : t`<button
3923
3923
  type="button"
3924
3924
  class="theme-switcher"
3925
- title=${mn()}
3925
+ title=${Q()}
3926
3926
  @click=${() => {
3927
- pn(), this.requestUpdate();
3927
+ hn(), this.requestUpdate();
3928
3928
  }}
3929
3929
  >
3930
- <span class="visually-hidden">${mn()}</span>
3930
+ <span class="visually-hidden">${Q()}</span>
3931
3931
  </button>`}
3932
3932
  ${this.hideTitle ? t`<h1 class="visually-hidden">
3933
3933
  ${this.site?.name ?? "Articles"}
@@ -4033,5 +4033,5 @@ var ln = "edaha-editor-theme", un = () => typeof window.matchMedia == "function"
4033
4033
  `;
4034
4034
  }
4035
4035
  };
4036
- x("edaha-editor", Sn);
4037
- export { y as ApiError, Sn as EdahaEditor, Ne as EditorApi };
4036
+ S("edaha-editor", Cn);
4037
+ export { y as ApiError, Cn as EdahaEditor, Wt as EdahaMetadataField, x as EditorApi };
@@ -1,2 +1,3 @@
1
1
  export { EdahaEditor } from "./components/edaha-editor/index.ts";
2
+ export { EdahaMetadataField, type MetadataChange, } from "./components/edaha-metadata-field/index.ts";
2
3
  export { ApiError, EditorApi, type ArticleLocation, type EditorApiOptions, } from "./editorApi/index.ts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvl99dotcom/edaha-editor",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Local WYSIWYG article editor for edaha.md sites.",
5
5
  "keywords": [
6
6
  "blog",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@hono/node-server": "^2.1.5",
47
- "@lvl99dotcom/edaha.md": "^0.4.0",
47
+ "@lvl99dotcom/edaha.md": "^0.4.2",
48
48
  "@tiptap/core": "^3.32.0",
49
49
  "@tiptap/extension-bubble-menu": "^3.34.0",
50
50
  "@tiptap/extension-details": "3.32.0",