@damiro/stylo 0.15.2 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/dist/{InPlaceView-DVX9qV68.js → InPlaceView-CRb5AkfX.js} +781 -743
  3. package/dist/InPlaceView-CRb5AkfX.js.map +1 -0
  4. package/dist/Preview-5lm2uUVj.js +319 -0
  5. package/dist/Preview-5lm2uUVj.js.map +1 -0
  6. package/dist/SplitView.d.ts +4 -1
  7. package/dist/SplitView.d.ts.map +1 -1
  8. package/dist/Stylo.d.ts.map +1 -1
  9. package/dist/editor/SourceView.d.ts +4 -1
  10. package/dist/editor/SourceView.d.ts.map +1 -1
  11. package/dist/editor/theme.d.ts.map +1 -1
  12. package/dist/editor/useCodeMirror.d.ts +7 -1
  13. package/dist/editor/useCodeMirror.d.ts.map +1 -1
  14. package/dist/embed-DKKeCE1Y.js +109 -0
  15. package/dist/embed-DKKeCE1Y.js.map +1 -0
  16. package/dist/{highlight-BLdNzTxQ.js → embed-cache-CcBfVrc9.js} +47 -4
  17. package/dist/embed-cache-CcBfVrc9.js.map +1 -0
  18. package/dist/inplace/InPlaceView.d.ts +4 -1
  19. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  20. package/dist/inplace/context-menu-helpers.d.ts +3 -4
  21. package/dist/inplace/context-menu-helpers.d.ts.map +1 -1
  22. package/dist/inplace/decorate.d.ts.map +1 -1
  23. package/dist/inplace/edit-line-prefix.d.ts.map +1 -1
  24. package/dist/inplace/embed.d.ts.map +1 -1
  25. package/dist/inplace/extension.d.ts.map +1 -1
  26. package/dist/inplace/inline-md.d.ts.map +1 -1
  27. package/dist/inplace/link-row.d.ts +14 -13
  28. package/dist/inplace/link-row.d.ts.map +1 -1
  29. package/dist/inplace/list-guides.d.ts.map +1 -1
  30. package/dist/inplace/math.d.ts +18 -3
  31. package/dist/inplace/math.d.ts.map +1 -1
  32. package/dist/inplace/table-widget-keys.d.ts +46 -0
  33. package/dist/inplace/table-widget-keys.d.ts.map +1 -0
  34. package/dist/inplace/table-widget.d.ts +1 -2
  35. package/dist/inplace/table-widget.d.ts.map +1 -1
  36. package/dist/inplace/tables.d.ts.map +1 -1
  37. package/dist/inplace/wikilinks.d.ts +1 -1
  38. package/dist/inplace/wikilinks.d.ts.map +1 -1
  39. package/dist/render/Embed.d.ts.map +1 -1
  40. package/dist/render/Preview.d.ts.map +1 -1
  41. package/dist/render/embed-cache.d.ts +13 -0
  42. package/dist/render/embed-cache.d.ts.map +1 -1
  43. package/dist/render/preview-components.d.ts +22 -0
  44. package/dist/render/preview-components.d.ts.map +1 -0
  45. package/dist/render/remark-wikilink.d.ts.map +1 -1
  46. package/dist/render/taskCheckbox.d.ts +30 -0
  47. package/dist/render/taskCheckbox.d.ts.map +1 -1
  48. package/dist/stylo.js +213 -196
  49. package/dist/stylo.js.map +1 -1
  50. package/dist/toolbar/Toolbar.d.ts.map +1 -1
  51. package/dist/toolbar/command-helpers.d.ts +27 -0
  52. package/dist/toolbar/command-helpers.d.ts.map +1 -1
  53. package/dist/toolbar/heading.d.ts +3 -0
  54. package/dist/toolbar/heading.d.ts.map +1 -1
  55. package/dist/toolbar/inline-ops.d.ts +6 -0
  56. package/dist/toolbar/inline-ops.d.ts.map +1 -1
  57. package/dist/toolbar/table.d.ts.map +1 -1
  58. package/dist/types/core.d.ts +209 -0
  59. package/dist/types/core.d.ts.map +1 -0
  60. package/dist/types/inplace.d.ts +91 -0
  61. package/dist/types/inplace.d.ts.map +1 -0
  62. package/dist/types/sources.d.ts +66 -0
  63. package/dist/types/sources.d.ts.map +1 -0
  64. package/dist/types/toolbar.d.ts +72 -0
  65. package/dist/types/toolbar.d.ts.map +1 -0
  66. package/dist/types.d.ts +11 -406
  67. package/dist/types.d.ts.map +1 -1
  68. package/dist/{useCodeMirror-CXtuBlLf.js → useCodeMirror-B07wRexo.js} +317 -268
  69. package/dist/useCodeMirror-B07wRexo.js.map +1 -0
  70. package/package.json +4 -4
  71. package/dist/InPlaceView-DVX9qV68.js.map +0 -1
  72. package/dist/Preview-BcdSr09-.js +0 -304
  73. package/dist/Preview-BcdSr09-.js.map +0 -1
  74. package/dist/embed-Dsu6b-MV.js +0 -131
  75. package/dist/embed-Dsu6b-MV.js.map +0 -1
  76. package/dist/highlight-BLdNzTxQ.js.map +0 -1
  77. package/dist/inplace/table-widget-caret.d.ts +0 -11
  78. package/dist/inplace/table-widget-caret.d.ts.map +0 -1
  79. package/dist/useCodeMirror-CXtuBlLf.js.map +0 -1
@@ -1,16 +1,16 @@
1
- import { a as e, o as t, r as n } from "./highlight-BLdNzTxQ.js";
2
- import { S as r, _ as i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as ee, s as v, t as te, u as ne, v as re, x as y, y as b } from "./useCodeMirror-CXtuBlLf.js";
3
- import { a as ie, i as x } from "./config-DTBxVhtH.js";
4
- import { a as S, n as ae, o as oe, r as C, t as w } from "./embed-Dsu6b-MV.js";
5
- import { t as se } from "./katex-BfiLlqfN.js";
6
- import { useRef as T, useState as E, useSyncExternalStore as ce } from "react";
7
- import { Decoration as D, EditorView as O, ViewPlugin as k, WidgetType as A, hoverTooltip as le, keymap as j, showPanel as ue } from "@codemirror/view";
8
- import { createPortal as de } from "react-dom";
9
- import { Annotation as fe, EditorSelection as pe, EditorState as me, Facet as M, Prec as N, StateEffect as he, StateField as P } from "@codemirror/state";
10
- import { syntaxTree as F } from "@codemirror/language";
11
- import { jsx as ge, jsxs as _e } from "react/jsx-runtime";
1
+ import { l as e, s as t, u as n } from "./embed-cache-CcBfVrc9.js";
2
+ import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as re, m as g, n as _, o as ie, p as ae, r as oe, s as se, t as ce, u as v, v as y, w as b, x as le, y as ue } from "./useCodeMirror-B07wRexo.js";
3
+ import { a as de, i as x } from "./config-DTBxVhtH.js";
4
+ import { a as fe, n as pe, o as me, r as he, t as S } from "./embed-DKKeCE1Y.js";
5
+ import { t as ge } from "./katex-BfiLlqfN.js";
6
+ import { useRef as C, useState as w, useSyncExternalStore as _e } from "react";
7
+ import { Decoration as T, EditorView as E, ViewPlugin as D, WidgetType as O, hoverTooltip as ve, keymap as k, showPanel as ye } from "@codemirror/view";
8
+ import { createPortal as be } from "react-dom";
9
+ import { Annotation as xe, EditorSelection as Se, EditorState as Ce, Facet as A, Prec as j, StateEffect as we, StateField as M } from "@codemirror/state";
10
+ import { syntaxTree as N } from "@codemirror/language";
11
+ import { jsx as Te, jsxs as Ee } from "react/jsx-runtime";
12
12
  //#region src/inplace/embed-registry.ts
13
- var ve = class {
13
+ var De = class {
14
14
  slots = /* @__PURE__ */ new Map();
15
15
  listeners = /* @__PURE__ */ new Set();
16
16
  snapshot = [];
@@ -33,7 +33,7 @@ var ve = class {
33
33
  for (let e of this.listeners) e();
34
34
  }));
35
35
  }
36
- }, ye = {
36
+ }, Oe = {
37
37
  headings: !0,
38
38
  emphasis: !0,
39
39
  links: !0,
@@ -48,19 +48,19 @@ var ve = class {
48
48
  tables: !0,
49
49
  embeds: !0
50
50
  };
51
- function be(e) {
51
+ function ke(e) {
52
52
  return {
53
- ...ye,
53
+ ...Oe,
54
54
  ...e?.decorations
55
55
  };
56
56
  }
57
- var I = M.define({ combine: (e) => e[0] ?? ye }), L = M.define({ combine: (e) => e[0] ?? null }), xe = M.define({ combine: (e) => e[0] ?? "source" }), R = M.define({ combine: (e) => e[0] ?? "caret" }), Se = M.define({ combine: (e) => e[0] ?? null }), Ce = M.define({ combine: (e) => e[0] ?? !0 }), we = [
57
+ var P = A.define({ combine: (e) => e[0] ?? Oe }), F = A.define({ combine: (e) => e[0] ?? null }), I = A.define({ combine: (e) => e[0] ?? "source" }), L = A.define({ combine: (e) => e[0] ?? "caret" }), Ae = A.define({ combine: (e) => e[0] ?? null }), je = A.define({ combine: (e) => e[0] ?? !0 }), Me = [
58
58
  "link",
59
59
  "format",
60
60
  "paragraph",
61
61
  "insert",
62
62
  "clipboard"
63
- ], z = [
63
+ ], R = [
64
64
  "bold",
65
65
  "italic",
66
66
  "strike",
@@ -69,54 +69,54 @@ var I = M.define({ combine: (e) => e[0] ?? ye }), L = M.define({ combine: (e) =>
69
69
  "wikilink",
70
70
  "math"
71
71
  ];
72
- function Te(e) {
72
+ function Ne(e) {
73
73
  return e === !1 ? {
74
74
  enabled: !1,
75
75
  groups: []
76
76
  } : e == null || e === !0 ? {
77
77
  enabled: !0,
78
- groups: we
78
+ groups: Me
79
79
  } : {
80
80
  enabled: !0,
81
- groups: e.groups?.length ? e.groups : we
81
+ groups: e.groups?.length ? e.groups : Me
82
82
  };
83
83
  }
84
- var Ee = M.define({ combine: (e) => e[0] ?? we });
85
- function De(e) {
86
- if (!e?.length) return z;
87
- let t = e.filter((e) => z.includes(e));
88
- return t.length ? t : z;
84
+ var Pe = A.define({ combine: (e) => e[0] ?? Me });
85
+ function Fe(e) {
86
+ if (!e?.length) return R;
87
+ let t = e.filter((e) => R.includes(e));
88
+ return t.length ? t : R;
89
89
  }
90
- var Oe = M.define({ combine: (e) => e[0] ?? z }), ke = M.define({ combine: (e) => e[0] ?? "menu" });
90
+ var Ie = A.define({ combine: (e) => e[0] ?? R }), Le = A.define({ combine: (e) => e[0] ?? "menu" });
91
91
  //#endregion
92
92
  //#region src/inplace/frontmatter.ts
93
- function Ae(e) {
94
- if (!e.facet(I).frontmatter) return D.none;
95
- let t = n(e.doc);
96
- if (!t) return D.none;
97
- let r = e.doc.lineAt(t.from).number, i = e.doc.lineAt(t.to).number, a = e.selection.ranges.some((t) => {
93
+ function Re(e) {
94
+ if (!e.facet(P).frontmatter) return T.none;
95
+ let n = t(e.doc);
96
+ if (!n) return T.none;
97
+ let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number, a = e.selection.ranges.some((t) => {
98
98
  let n = e.doc.lineAt(t.from).number;
99
99
  return n >= r && n <= i;
100
100
  }), o = [];
101
101
  for (let t = r; t <= i; t++) {
102
102
  let n = e.doc.line(t), s = t === r ? "cm-inplace-fm cm-inplace-fm-first" : "cm-inplace-fm";
103
- o.push(D.line({ class: s }).range(n.from)), (t === r || t === i) && !a && n.to > n.from && o.push(D.replace({}).range(n.from, n.to));
103
+ o.push(T.line({ class: s }).range(n.from)), (t === r || t === i) && !a && n.to > n.from && o.push(T.replace({}).range(n.from, n.to));
104
104
  }
105
- return D.set(o, !0);
105
+ return T.set(o, !0);
106
106
  }
107
- var je = P.define({
108
- create: Ae,
109
- update: (e, t) => t.docChanged || t.selection ? Ae(t.state) : e,
110
- provide: (e) => O.decorations.from(e)
107
+ var ze = M.define({
108
+ create: Re,
109
+ update: (e, t) => t.docChanged || t.selection ? Re(t.state) : e,
110
+ provide: (e) => E.decorations.from(e)
111
111
  });
112
112
  //#endregion
113
113
  //#region src/inplace/list-guides.ts
114
- function Me(e) {
114
+ function Be(e) {
115
115
  let t = 1;
116
116
  for (let n = e.node.parent; n; n = n.parent) n.name === "ListItem" && t++;
117
117
  return t;
118
118
  }
119
- function Ne(e, t, n, r, i, a) {
119
+ function Ve(e, t, n, r, i, a) {
120
120
  if (!i.lists) return;
121
121
  let o = /* @__PURE__ */ new Set();
122
122
  n.iterate({
@@ -124,17 +124,17 @@ function Ne(e, t, n, r, i, a) {
124
124
  to: t,
125
125
  enter: (e) => {
126
126
  if (e.name !== "ListItem") return;
127
- let t = Me(e), n = t - 1, i = r.lineAt(e.from).number, s = e.node.getChild("BulletList") ?? e.node.getChild("OrderedList"), c = r.lineAt(s ? s.from - 1 : Math.min(e.to, r.length)).number, l = e.node.prevSibling ? "cm-inplace-item-gap" : t > 1 ? "cm-inplace-item-gap-nested" : null;
128
- for (let e = i; e <= c; e++) n >= 1 && !o.has(e) && (o.add(e), a.push(D.line({
127
+ let t = Be(e), n = t - 1, i = r.lineAt(e.from).number, s = r.lineAt(Math.min(e.to, r.length)).number, c = e.node.getChild("BulletList") ?? e.node.getChild("OrderedList"), l = c ? r.lineAt(c.from).number : -1, u = c ? r.lineAt(Math.max(c.from, c.to - 1)).number : -1, d = e.node.prevSibling ? "cm-inplace-item-gap" : t > 1 ? "cm-inplace-item-gap-nested" : null;
128
+ for (let e = i; e <= s; e++) c && e >= l && e <= u || (n >= 1 && !o.has(e) && (o.add(e), a.push(T.line({
129
129
  class: "cm-inplace-li",
130
130
  attributes: { style: `--sl-li-depth:${n}` }
131
- }).range(r.line(e).from))), e === i && l && a.push(D.line({ class: l }).range(r.line(e).from));
131
+ }).range(r.line(e).from))), e === i && d && a.push(T.line({ class: d }).range(r.line(e).from)));
132
132
  }
133
133
  });
134
134
  }
135
135
  //#endregion
136
136
  //#region src/inplace/reveal.ts
137
- function B(e) {
137
+ function z(e) {
138
138
  let t = /* @__PURE__ */ new Set();
139
139
  for (let n of e.selection.ranges) {
140
140
  let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number;
@@ -144,22 +144,22 @@ function B(e) {
144
144
  }
145
145
  //#endregion
146
146
  //#region src/inplace/scan.ts
147
- var Pe = /* @__PURE__ */ new Set([
147
+ var He = /* @__PURE__ */ new Set([
148
148
  "InlineCode",
149
149
  "FencedCode",
150
150
  "CodeBlock",
151
151
  "CodeText"
152
152
  ]);
153
- function V(e, t) {
153
+ function B(e, t) {
154
154
  let n = e.resolveInner(t, 1);
155
155
  for (;;) {
156
- if (Pe.has(n.name)) return !0;
156
+ if (He.has(n.name)) return !0;
157
157
  let e = n.parent;
158
158
  if (!e) return !1;
159
159
  n = e;
160
160
  }
161
161
  }
162
- function Fe(e, t) {
162
+ function Ue(e, t) {
163
163
  let n = e.resolveInner(t, 1);
164
164
  for (;;) {
165
165
  if (n.name === "Table") return !0;
@@ -168,16 +168,16 @@ function Fe(e, t) {
168
168
  n = e;
169
169
  }
170
170
  }
171
- function Ie(e, t, n, r) {
171
+ function We(e, t, n, r) {
172
172
  let i = t.lineAt(n).number, a = t.lineAt(r).number;
173
173
  for (let t = i; t <= a; t++) if (e.has(t)) return !0;
174
174
  return !1;
175
175
  }
176
176
  //#endregion
177
177
  //#region src/inplace/math.ts
178
- var Le = /(?<![\w$])\$(?!\s)([^\n$]+?)(?<!\s)\$(?![\w$])/g, Re = /(?<![\w$])\$\$([^\n$]+?)\$\$(?![\w$])/g, ze = /(?<![\w$])\$\$([^]+?)\$\$/g;
179
- function Be(e, t) {
180
- for (let n of e.matchAll(Re)) {
178
+ var Ge = /(?<![\w$])\$(?!\s)([^\n$]+?)(?<!\s)\$(?![\w$])/g, Ke = /(?<![\w$])\$\$([^\n$]+?)\$\$(?![\w$])/g, qe = /(?<![\w$])\$\$([^]+?)\$\$/g;
179
+ function Je(e, t) {
180
+ for (let n of e.matchAll(Ke)) {
181
181
  let e = n.index ?? 0, r = e + (n[0] ?? "").length;
182
182
  if (t >= e && t <= r) return {
183
183
  from: e,
@@ -186,7 +186,7 @@ function Be(e, t) {
186
186
  block: !0
187
187
  };
188
188
  }
189
- for (let n of e.matchAll(Le)) {
189
+ for (let n of e.matchAll(Ge)) {
190
190
  let e = n.index ?? 0, r = e + (n[0] ?? "").length;
191
191
  if (t >= e && t <= r) return {
192
192
  from: e,
@@ -197,7 +197,7 @@ function Be(e, t) {
197
197
  }
198
198
  return null;
199
199
  }
200
- var Ve = class extends A {
200
+ var Ye = class extends O {
201
201
  src;
202
202
  block;
203
203
  constructor(e, t) {
@@ -210,7 +210,7 @@ var Ve = class extends A {
210
210
  let e = document.createElement(this.block ? "div" : "span");
211
211
  e.className = this.block ? "cm-inplace-math cm-inplace-math-block" : "cm-inplace-math";
212
212
  try {
213
- se.render(this.src, e, {
213
+ ge.render(this.src, e, {
214
214
  displayMode: this.block,
215
215
  throwOnError: !1
216
216
  });
@@ -223,45 +223,67 @@ var Ve = class extends A {
223
223
  return !1;
224
224
  }
225
225
  };
226
- function He(e, t, n, r, i, a) {
227
- let o = e.state.doc.sliceString(t, n);
228
- if (!o.includes("$")) return;
226
+ function Xe(e, t, n, r, i, a, o) {
227
+ if (!r.includes("$")) return;
229
228
  let { doc: s } = e.state, c = [];
230
- for (let e of o.matchAll(Re)) {
231
- let n = (e[1] ?? "").trim(), o = t + (e.index ?? 0), l = o + (e[0] ?? "").length;
232
- !n || V(i, o + 2) || (c.push([o, l]), !Ie(r, s, o, l) && a.push(D.replace({ widget: new Ve(n, !0) }).range(o, l)));
229
+ for (let e of r.matchAll(Ke)) {
230
+ let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
231
+ !n || B(a, r + 2) || (c.push([r, l]), !We(i, s, r, l) && o.push(T.replace({ widget: new Ye(n, !0) }).range(r, l)));
233
232
  }
234
- for (let e of o.matchAll(Le)) {
235
- let n = (e[1] ?? "").trim(), o = t + (e.index ?? 0), l = o + (e[0] ?? "").length;
236
- !n || V(i, o + 1) || c.some(([e, t]) => o >= e && l <= t) || Ie(r, s, o, l) || a.push(D.replace({ widget: new Ve(n, !1) }).range(o, l));
233
+ for (let e of r.matchAll(Ge)) {
234
+ let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
235
+ !n || B(a, r + 1) || c.some(([e, t]) => r >= e && l <= t) || We(i, s, r, l) || o.push(T.replace({ widget: new Ye(n, !1) }).range(r, l));
237
236
  }
238
237
  }
239
- var Ue = P.define({
240
- create: We,
238
+ function Ze(e, t, n) {
239
+ let r = n.map((t) => ({
240
+ first: e.doc.lineAt(t.from).number,
241
+ last: e.doc.lineAt(t.to).number
242
+ }));
243
+ for (let n of t.ranges) {
244
+ let t = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number;
245
+ for (let e = t; e <= i; e++) if (r.some((t) => t.first <= e && e <= t.last)) return !0;
246
+ }
247
+ return !1;
248
+ }
249
+ var Qe = M.define({
250
+ create: $e,
241
251
  update(e, t) {
242
- return t.docChanged || t.selection ? We(t.state) : e;
252
+ return t.docChanged || t.selection && (Ze(t.state, t.startState.selection, e.ranges) || Ze(t.state, t.state.selection, e.ranges)) ? $e(t.state) : e;
243
253
  },
244
- provide: (e) => [O.decorations.from(e), O.atomicRanges.of((t) => t.state.field(e))]
254
+ provide: (e) => [E.decorations.from(e, (e) => e.decorations), E.atomicRanges.of((t) => t.state.field(e).decorations)]
245
255
  });
246
- function We(e) {
247
- if (!e.facet(I).math) return D.none;
256
+ function $e(e) {
257
+ if (!e.facet(P).math) return {
258
+ decorations: T.none,
259
+ ranges: []
260
+ };
248
261
  let t = e.doc.toString();
249
- if (!t.includes("$$")) return D.none;
250
- let n = [], r = B(e), i = F(e);
251
- for (let a of t.matchAll(ze)) {
252
- let t = a[0] ?? "", o = (a[1] ?? "").trim();
253
- if (!o || !t.includes("\n")) continue;
254
- let s = a.index ?? 0, c = s + t.length, l = e.doc.lineAt(s), u = e.doc.lineAt(c), d = e.doc.sliceString(l.from, s).trim(), f = e.doc.sliceString(c, u.to).trim();
255
- d === "" && f === "" && (V(i, s + 2) || Ie(r, e.doc, s, c) || n.push(D.replace({
256
- widget: new Ve(o, !0),
262
+ if (!t.includes("$$")) return {
263
+ decorations: T.none,
264
+ ranges: []
265
+ };
266
+ let n = [], r = [], i = z(e), a = N(e);
267
+ for (let o of t.matchAll(qe)) {
268
+ let t = o[0] ?? "", s = (o[1] ?? "").trim();
269
+ if (!s || !t.includes("\n")) continue;
270
+ let c = o.index ?? 0, l = c + t.length, u = e.doc.lineAt(c), d = e.doc.lineAt(l), f = e.doc.sliceString(u.from, c).trim(), p = e.doc.sliceString(l, d.to).trim();
271
+ f === "" && p === "" && (B(a, c + 2) || (r.push({
272
+ from: c,
273
+ to: l
274
+ }), !We(i, e.doc, c, l) && n.push(T.replace({
275
+ widget: new Ye(s, !0),
257
276
  block: !0
258
- }).range(s, c)));
277
+ }).range(c, l))));
259
278
  }
260
- return D.set(n, !0);
279
+ return {
280
+ decorations: T.set(n, !0),
281
+ ranges: r
282
+ };
261
283
  }
262
284
  //#endregion
263
285
  //#region src/inplace/nodes-inline.ts
264
- var Ge = {
286
+ var et = {
265
287
  StrongEmphasis: {
266
288
  mark: "EmphasisMark",
267
289
  className: "cm-inplace-strong",
@@ -283,26 +305,26 @@ var Ge = {
283
305
  toggle: "code"
284
306
  }
285
307
  };
286
- function Ke(e, t, n) {
308
+ function tt(e, t, n) {
287
309
  let { doc: r, revealed: i, out: a, toggles: o } = t;
288
310
  if (!o[n.toggle]) return;
289
311
  let s = e.node.getChildren(n.mark), c = s[0], l = s[s.length - 1], u = c && l && c !== l, d = u ? c.to : e.from, f = u ? l.from : e.to;
290
- f > d && a.push(D.mark({ class: n.className }).range(d, f)), u && !i.has(r.lineAt(e.from).number) && (a.push(D.replace({}).range(c.from, c.to)), a.push(D.replace({}).range(l.from, l.to)));
312
+ f > d && a.push(T.mark({ class: n.className }).range(d, f)), u && !i.has(r.lineAt(e.from).number) && (a.push(T.replace({}).range(c.from, c.to)), a.push(T.replace({}).range(l.from, l.to)));
291
313
  }
292
- function qe(e, t) {
314
+ function nt(e, t) {
293
315
  let { doc: n, revealed: r, out: i, toggles: a } = t, o = n.sliceString(Math.max(0, e.from - 1), e.from), s = n.sliceString(e.to, e.to + 1);
294
316
  if (o === "[" && s === "]" || !a.links) return !1;
295
- let c = n.lineAt(e.from), l = C.exec(c.text);
317
+ let c = n.lineAt(e.from), l = he.exec(c.text);
296
318
  if (l && e.from - c.from < l[1].length + l[2].length) return !1;
297
319
  let u = e.node.getChildren("LinkMark");
298
320
  if (u.length >= 2) {
299
321
  let t = u[0], a = u[1];
300
- a.from > t.to && i.push(D.mark({ class: "cm-inplace-link" }).range(t.to, a.from)), r.has(n.lineAt(e.from).number) || (i.push(D.replace({}).range(e.from, t.to)), i.push(D.replace({}).range(a.from, e.to)));
322
+ a.from > t.to && i.push(T.mark({ class: "cm-inplace-link" }).range(t.to, a.from)), r.has(n.lineAt(e.from).number) || (i.push(T.replace({}).range(e.from, t.to)), i.push(T.replace({}).range(a.from, e.to)));
301
323
  }
302
324
  }
303
325
  //#endregion
304
326
  //#region src/inplace/widgets.ts
305
- var Je = class extends A {
327
+ var rt = class extends O {
306
328
  eq() {
307
329
  return !0;
308
330
  }
@@ -313,7 +335,7 @@ var Je = class extends A {
313
335
  ignoreEvent() {
314
336
  return !1;
315
337
  }
316
- }, Ye = class extends A {
338
+ }, it = class extends O {
317
339
  eq() {
318
340
  return !0;
319
341
  }
@@ -324,7 +346,7 @@ var Je = class extends A {
324
346
  ignoreEvent() {
325
347
  return !1;
326
348
  }
327
- }, Xe = class extends A {
349
+ }, at = class extends O {
328
350
  checked;
329
351
  constructor(e) {
330
352
  super(), this.checked = e;
@@ -346,58 +368,58 @@ var Je = class extends A {
346
368
  ignoreEvent() {
347
369
  return !0;
348
370
  }
349
- }, Ze = /^[-*+]$/;
350
- function Qe(e, t) {
371
+ }, ot = /^[-*+]$/;
372
+ function st(e, t) {
351
373
  let { doc: n, revealed: r, out: i, toggles: a } = t;
352
374
  if (!a.horizontalRule) return !1;
353
375
  let o = n.lineAt(e.from);
354
- return r.has(o.number) || (i.push(D.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(D.replace({ widget: new Je() }).range(o.from, o.to))), !1;
376
+ return r.has(o.number) || (i.push(T.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(T.replace({ widget: new rt() }).range(o.from, o.to))), !1;
355
377
  }
356
- function $e(e, t) {
378
+ function ct(e, t) {
357
379
  let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o, quoteRevealed: s } = t;
358
380
  if (o.blockquote) {
359
- let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l = C.exec(c.text), u = l ? S(l[3]) : null, d = !1;
381
+ let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l = he.exec(c.text), u = l ? fe(l[3]) : null, d = !1;
360
382
  for (let e = t; e <= o; e++) i.has(e) && (d = !0);
361
383
  if (d) for (let e = t; e <= o; e++) s.add(e);
362
384
  for (let e = t; e <= o; e++) {
363
385
  let r = u ? `cm-inplace-callout cm-inplace-callout-${u}` : "cm-inplace-quote";
364
386
  u && e === t && (r += " cm-inplace-callout-head"), u && e === o && (r += " cm-inplace-callout-foot");
365
387
  let i = {};
366
- u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(D.line({
388
+ u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(T.line({
367
389
  class: r,
368
390
  attributes: i
369
391
  }).range(n.line(e).from));
370
392
  }
371
393
  if (u && !d && !r.has(t)) {
372
394
  let e = c.from + l[1].length;
373
- a.push(D.replace({}).range(e, e + l[2].length));
395
+ a.push(T.replace({}).range(e, e + l[2].length));
374
396
  }
375
397
  }
376
398
  }
377
- function et(e, t) {
399
+ function lt(e, t) {
378
400
  let { doc: n, revealed: r, out: i, toggles: a, quoteRevealed: o } = t;
379
401
  if (!a.blockquote) return !1;
380
402
  let s = n.lineAt(e.from);
381
403
  if (!r.has(s.number) && !o.has(s.number)) {
382
- let t = Math.min(e.to + 1, s.to), n = C.exec(s.text), r = n ? s.text.slice(n[1].length + n[2].length) : s.text.slice(t - s.from);
383
- i.push(D.replace({}).range(e.from, r.trim() === "" ? e.to : t));
404
+ let t = Math.min(e.to + 1, s.to), n = he.exec(s.text), r = n ? s.text.slice(n[1].length + n[2].length) : s.text.slice(t - s.from);
405
+ i.push(T.replace({}).range(e.from, r.trim() === "" ? e.to : t));
384
406
  }
385
407
  return !1;
386
408
  }
387
- function tt(e, t) {
409
+ function ut(e, t) {
388
410
  let { doc: n, revealed: r, out: i, toggles: a } = t, o = n.sliceString(e.from, e.to), s = n.lineAt(e.from), c = e.node.parent, l = !!(c?.getChild("Task") ?? c?.getChild("TaskMarker"));
389
- return r.has(s.number) || (l ? a.tasks && i.push(D.replace({}).range(e.from, Math.min(e.to + 1, s.to))) : a.lists && Ze.test(o) && i.push(D.replace({ widget: new Ye() }).range(e.from, e.to))), !1;
411
+ return r.has(s.number) || (l ? a.tasks && i.push(T.replace({}).range(e.from, Math.min(e.to + 1, s.to))) : a.lists && ot.test(o) && i.push(T.replace({ widget: new it() }).range(e.from, e.to))), !1;
390
412
  }
391
- function nt(e, t) {
413
+ function dt(e, t) {
392
414
  let { doc: n, revealed: r, out: i, toggles: a } = t;
393
415
  if (!a.tasks) return !1;
394
416
  if (!r.has(n.lineAt(e.from).number)) {
395
417
  let t = n.sliceString(e.from + 1, e.to - 1).toLowerCase() === "x";
396
- i.push(D.replace({ widget: new Xe(t) }).range(e.from, e.to));
418
+ i.push(T.replace({ widget: new at(t) }).range(e.from, e.to));
397
419
  }
398
420
  return !1;
399
421
  }
400
- function rt(e, t) {
422
+ function ft(e, t) {
401
423
  let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o } = t;
402
424
  if (!o.code) return !1;
403
425
  let s = e.name === "FencedCode", c = n.lineAt(e.from).number, l = n.lineAt(e.to > e.from ? e.to - 1 : e.to).number, u = l > c + 1, d = !1;
@@ -407,18 +429,18 @@ function rt(e, t) {
407
429
  let t = s && (e === c || e === l), r = "cm-inplace-mono";
408
430
  e === c && (r += " cm-inplace-code-top"), e === l && (r += " cm-inplace-code-bottom"), t && (r += f ? " cm-inplace-code-pad" : " cm-inplace-fence");
409
431
  let i = n.line(e);
410
- a.push(D.line({ class: r }).range(i.from)), t && f && i.to > i.from && a.push(D.replace({}).range(i.from, i.to));
432
+ a.push(T.line({ class: r }).range(i.from)), t && f && i.to > i.from && a.push(T.replace({}).range(i.from, i.to));
411
433
  }
412
434
  return !1;
413
435
  }
414
436
  //#endregion
415
437
  //#region src/inplace/nodes.ts
416
- var it = /^ATXHeading([1-6])$/, at = /^SetextHeading([12])$/;
417
- function ot(e, t, n) {
438
+ var pt = /^ATXHeading([1-6])$/, mt = /^SetextHeading([12])$/;
439
+ function ht(e, t, n) {
418
440
  let { doc: r, revealed: i, out: a, toggles: o } = t;
419
441
  if (o.headings) {
420
442
  let t = r.lineAt(e.from);
421
- if (a.push(D.line({
443
+ if (a.push(T.line({
422
444
  class: `cm-inplace-heading cm-inplace-h${n}`,
423
445
  attributes: {
424
446
  role: "heading",
@@ -426,15 +448,15 @@ function ot(e, t, n) {
426
448
  }
427
449
  }).range(t.from)), !i.has(t.number)) {
428
450
  let n = e.node.firstChild;
429
- n?.name === "HeaderMark" && a.push(D.replace({}).range(n.from, Math.min(n.to + 1, t.to)));
451
+ n?.name === "HeaderMark" && a.push(T.replace({}).range(n.from, Math.min(n.to + 1, t.to)));
430
452
  }
431
453
  }
432
454
  }
433
- function st(e, t, n) {
455
+ function gt(e, t, n) {
434
456
  let { doc: r, caretRevealed: i, out: a, toggles: o } = t;
435
457
  if (o.headings) {
436
458
  let t = r.lineAt(e.from);
437
- a.push(D.line({
459
+ a.push(T.line({
438
460
  class: `cm-inplace-heading cm-inplace-h${n}`,
439
461
  attributes: {
440
462
  role: "heading",
@@ -444,99 +466,102 @@ function st(e, t, n) {
444
466
  let o = e.node.getChild("HeaderMark");
445
467
  if (o) {
446
468
  let e = r.lineAt(o.from);
447
- !i.has(t.number) && !i.has(e.number) && (a.push(D.line({ class: "cm-inplace-setext-rule" }).range(e.from)), a.push(D.replace({}).range(o.from, o.to)));
469
+ !i.has(t.number) && !i.has(e.number) && (a.push(T.line({ class: "cm-inplace-setext-rule" }).range(e.from)), a.push(T.replace({}).range(o.from, o.to)));
448
470
  }
449
471
  }
450
472
  }
451
- function ct(e, t) {
473
+ function _t(e, t) {
452
474
  if (e.to <= t.fmEnd) return !1;
453
- let n = it.exec(e.name);
454
- if (n) return ot(e, t, n[1]);
455
- let r = at.exec(e.name);
456
- if (r) return st(e, t, r[1]);
457
- let i = Ge[e.name];
458
- if (i) return Ke(e, t, i);
459
- if (e.name === "Link") return qe(e, t);
460
- if (e.name === "HorizontalRule") return Qe(e, t);
461
- if (e.name === "Blockquote") return $e(e, t);
462
- if (e.name === "QuoteMark") return et(e, t);
463
- if (e.name === "ListMark") return tt(e, t);
464
- if (e.name === "TaskMarker") return nt(e, t);
465
- if (e.name === "FencedCode" || e.name === "CodeBlock") return rt(e, t);
475
+ let n = pt.exec(e.name);
476
+ if (n) return ht(e, t, n[1]);
477
+ let r = mt.exec(e.name);
478
+ if (r) return gt(e, t, r[1]);
479
+ let i = et[e.name];
480
+ if (i) return tt(e, t, i);
481
+ if (e.name === "Link") return nt(e, t);
482
+ if (e.name === "HorizontalRule") return st(e, t);
483
+ if (e.name === "Blockquote") return ct(e, t);
484
+ if (e.name === "QuoteMark") return lt(e, t);
485
+ if (e.name === "ListMark") return ut(e, t);
486
+ if (e.name === "TaskMarker") return dt(e, t);
487
+ if (e.name === "FencedCode" || e.name === "CodeBlock") return ft(e, t);
466
488
  }
467
489
  //#endregion
468
490
  //#region src/inplace/wikilinks.ts
469
- function lt(t, n, r, i, a, o) {
470
- let s = t.state.doc.sliceString(n, r);
471
- if (!s.includes("[[")) return;
472
- let c = t.state.facet(L) != null;
473
- for (let r of s.matchAll(e)) {
474
- let [e = "", s = "", l] = r, u = s.trim(), d = n + (r.index ?? 0);
475
- if (!u || V(a, d + 1) || c && d > 0 && t.state.doc.sliceString(d - 1, d) === "!") continue;
476
- let f = d + e.length, p = l == null ? d + 2 : d + 2 + s.length + 1, m = f - 2;
477
- o.push(D.mark({
491
+ function vt(t, n, r, i, a, o, s) {
492
+ if (!i.includes("[[")) return;
493
+ let c = t.state.facet(F) != null;
494
+ for (let r of i.matchAll(e)) {
495
+ let [e = "", i = "", l] = r, u = i.trim(), d = n + (r.index ?? 0);
496
+ if (!u || B(o, d + 1) || c && d > 0 && t.state.doc.sliceString(d - 1, d) === "!") continue;
497
+ let f = d + e.length, p = l == null ? d + 2 : d + 2 + i.length + 1, m = f - 2;
498
+ s.push(T.mark({
478
499
  class: "cm-inplace-link cm-inplace-wikilink",
479
500
  attributes: { "data-stylo-wikilink": u }
480
- }).range(p, m)), i.has(t.state.doc.lineAt(d).number) || (o.push(D.replace({}).range(d, p)), o.push(D.replace({}).range(m, f)));
501
+ }).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(T.replace({}).range(d, p)), s.push(T.replace({}).range(m, f)));
481
502
  }
482
503
  }
483
504
  //#endregion
484
505
  //#region src/inplace/decorate.ts
485
- var ut = /* @__PURE__ */ new Set(), dt = D.replace({});
486
- function ft(e) {
487
- let t = [], r = B(e.state), i = e.state.facet(R) === "never" ? ut : r, a = F(e.state), { doc: o } = e.state, s = e.state.facet(I), c = {
506
+ var yt = /* @__PURE__ */ new Set(), bt = T.replace({});
507
+ function xt(e) {
508
+ let n = [], r = z(e.state), i = e.state.facet(L) === "never" ? yt : r, a = N(e.state), { doc: o } = e.state, s = e.state.facet(P), c = {
488
509
  doc: o,
489
510
  revealed: i,
490
511
  caretRevealed: r,
491
- out: t,
512
+ out: n,
492
513
  toggles: s,
493
- fmEnd: n(o)?.to ?? -1,
514
+ fmEnd: t(o)?.to ?? -1,
494
515
  quoteRevealed: /* @__PURE__ */ new Set()
495
516
  };
496
- for (let n of e.visibleRanges) a.iterate({
497
- from: n.from,
498
- to: n.to,
499
- enter: (e) => ct(e, c)
500
- }), s.wikilinks && lt(e, n.from, n.to, i, a, t), s.math && He(e, n.from, n.to, i, a, t), Ne(n.from, n.to, a, o, s, t);
501
- let l = t.filter((e) => e.from < e.to && !e.value.spec.class).sort((e, t) => e.from - t.from || e.to - t.to), u = [];
517
+ for (let t of e.visibleRanges) {
518
+ a.iterate({
519
+ from: t.from,
520
+ to: t.to,
521
+ enter: (e) => _t(e, c)
522
+ });
523
+ let r = e.state.doc.sliceString(t.from, t.to);
524
+ s.wikilinks && vt(e, t.from, t.to, r, i, a, n), s.math && Xe(e, t.from, t.to, r, i, a, n), Ve(t.from, t.to, a, o, s, n);
525
+ }
526
+ let l = n.filter((e) => e.from < e.to && !e.value.spec.class).sort((e, t) => e.from - t.from || e.to - t.to), u = [];
502
527
  for (let e of l) {
503
528
  if (!e.value.spec.widget) {
504
529
  let t = o.lineAt(e.from);
505
530
  if (e.from === t.from && e.to === t.to) continue;
506
531
  }
507
532
  let t = u[u.length - 1];
508
- t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = dt.range(t.from, e.to)) : u.push(dt.range(e.from, e.to));
533
+ t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = bt.range(t.from, e.to)) : u.push(bt.range(e.from, e.to));
509
534
  }
510
535
  return {
511
- decorations: D.set(t, !0),
512
- atomic: D.set(u, !0)
536
+ decorations: T.set(n, !0),
537
+ atomic: T.set(u, !0)
513
538
  };
514
539
  }
515
540
  //#endregion
516
541
  //#region src/inplace/plugin.ts
517
- var pt = k.fromClass(class {
542
+ var St = D.fromClass(class {
518
543
  decorations;
519
544
  atomic;
520
545
  constructor(e) {
521
- let t = ft(e);
546
+ let t = xt(e);
522
547
  this.decorations = t.decorations, this.atomic = t.atomic;
523
548
  }
524
549
  update(e) {
525
550
  if (e.docChanged || e.viewportChanged || e.selectionSet) {
526
- let t = ft(e.view);
551
+ let t = xt(e.view);
527
552
  this.decorations = t.decorations, this.atomic = t.atomic;
528
553
  }
529
554
  }
530
555
  }, {
531
556
  decorations: (e) => e.decorations,
532
- provide: (e) => O.atomicRanges.of((t) => t.plugin(e)?.atomic ?? D.none)
557
+ provide: (e) => E.atomicRanges.of((t) => t.plugin(e)?.atomic ?? T.none)
533
558
  });
534
- function mt() {
535
- return pt;
559
+ function Ct() {
560
+ return St;
536
561
  }
537
562
  //#endregion
538
563
  //#region src/inplace/wrap-at.ts
539
- var ht = {
564
+ var wt = {
540
565
  StrongEmphasis: {
541
566
  markType: "EmphasisMark",
542
567
  toggle: "emphasis"
@@ -554,15 +579,15 @@ var ht = {
554
579
  toggle: "code"
555
580
  }
556
581
  };
557
- function H(e, t) {
558
- return e.facet(R) === "never" || !B(e).has(t);
582
+ function V(e, t) {
583
+ return e.facet(L) === "never" || !z(e).has(t);
559
584
  }
560
- function U(t, n, r = !1, i = !1) {
585
+ function H(t, n, r = !1, i = !1) {
561
586
  let a = t.doc.lineAt(n);
562
- if (!i && !H(t, a.number)) return null;
563
- let o = t.facet(I), s = F(t);
587
+ if (!i && !V(t, a.number)) return null;
588
+ let o = t.facet(P), s = N(t);
564
589
  for (let e of [-1, 1]) for (let i = s.resolveInner(n, e); i; i = i.parent) {
565
- let e = ht[i.name];
590
+ let e = wt[i.name];
566
591
  if (e) {
567
592
  if (!o[e.toggle]) break;
568
593
  let t = i.getChildren(e.markType), n = t[0], r = t[t.length - 1];
@@ -604,8 +629,8 @@ function U(t, n, r = !1, i = !1) {
604
629
  }
605
630
  //#endregion
606
631
  //#region src/inplace/edit-boundaries.ts
607
- function gt(e, t, n) {
608
- let r = e.plugin(pt)?.decorations;
632
+ function Tt(e, t, n) {
633
+ let r = e.plugin(St)?.decorations;
609
634
  if (!r) return t;
610
635
  let i = n < 0 ? 0 : e.state.doc.length, a = t;
611
636
  for (let e = !0; e;) e = !1, r.between(Math.min(a, i), Math.max(a, i), (t, r, i) => {
@@ -613,18 +638,18 @@ function gt(e, t, n) {
613
638
  });
614
639
  return a;
615
640
  }
616
- var _t = (e) => (t) => {
617
- if (p(t)) return !1;
641
+ var Et = (e) => (t) => {
642
+ if (h(t)) return !1;
618
643
  let n = t.state.selection.main;
619
644
  if (!n.empty) return !1;
620
645
  let { state: r } = t;
621
- if (!H(r, r.doc.lineAt(n.head).number)) return !1;
622
- let i = gt(t, n.head, e);
646
+ if (!V(r, r.doc.lineAt(n.head).number)) return !1;
647
+ let i = Tt(t, n.head, e);
623
648
  if (i === n.head) return !1;
624
649
  let a = r.doc;
625
650
  if (e < 0 ? i <= 0 : i >= a.length) return !0;
626
651
  let o = e < 0 ? i - 1 : i, s = e < 0 ? i : i + 1;
627
- for (let e = U(r, o); e && o <= e.contentFrom && s >= e.contentTo && e.contentTo > e.contentFrom && !(e.from >= o && e.to <= s); e = U(r, o)) o = Math.min(o, e.from), s = Math.max(s, e.to);
652
+ for (let e = H(r, o); e && o <= e.contentFrom && s >= e.contentTo && e.contentTo > e.contentFrom && !(e.from >= o && e.to <= s); e = H(r, o)) o = Math.min(o, e.from), s = Math.max(s, e.to);
628
653
  return t.dispatch({
629
654
  changes: {
630
655
  from: o,
@@ -635,87 +660,89 @@ var _t = (e) => (t) => {
635
660
  userEvent: e < 0 ? "delete.backward" : "delete.forward",
636
661
  scrollIntoView: !0
637
662
  }), !0;
638
- }, vt = _t(-1), yt = _t(1);
639
- function bt(e, t, n) {
663
+ }, Dt = Et(-1), Ot = Et(1);
664
+ function kt(e, t, n) {
640
665
  if (n <= t) return !1;
641
- let r = e.plugin(pt)?.decorations;
666
+ let r = e.plugin(St)?.decorations;
642
667
  if (!r) return !1;
643
668
  let i = t;
644
669
  return r.between(t, n, (e, t, n) => {
645
670
  n.spec.widget || n.spec.class || t <= e || e <= i && (i = Math.max(i, t));
646
671
  }), i >= n;
647
672
  }
648
- var W = (e, t) => (n) => {
649
- if (p(n)) return !1;
673
+ var U = (e, t) => (n) => {
674
+ if (h(n)) return !1;
650
675
  let r = n.state.selection.main;
651
- if (!t && !r.empty || !H(n.state, n.state.doc.lineAt(r.head).number)) return !1;
676
+ if (!t && !r.empty || !V(n.state, n.state.doc.lineAt(r.head).number)) return !1;
652
677
  let i = n.moveByChar(r, e);
653
- if (bt(n, Math.min(r.head, i.head), Math.max(r.head, i.head)) && (i = n.moveByChar(i, e)), i.head === r.head) return !1;
654
- let a = t ? pe.range(r.anchor, i.head) : pe.cursor(i.head);
678
+ if (kt(n, Math.min(r.head, i.head), Math.max(r.head, i.head)) && (i = n.moveByChar(i, e)), i.head === r.head) return !1;
679
+ let a = t ? Se.range(r.anchor, i.head) : Se.cursor(i.head);
655
680
  return n.dispatch({
656
681
  selection: a,
657
682
  userEvent: "select"
658
683
  }), !0;
659
- }, xt = W(!1, !1), St = W(!0, !1), Ct = W(!1, !0), wt = W(!0, !0), Tt = N.high(j.of([
684
+ }, At = U(!1, !1), jt = U(!0, !1), Mt = U(!1, !0), Nt = U(!0, !0), Pt = j.high(k.of([
660
685
  {
661
686
  key: "Backspace",
662
- run: vt
687
+ run: Dt
663
688
  },
664
689
  {
665
690
  key: "Delete",
666
- run: yt
691
+ run: Ot
667
692
  },
668
693
  {
669
694
  key: "ArrowLeft",
670
- run: xt
695
+ run: At
671
696
  },
672
697
  {
673
698
  key: "ArrowRight",
674
- run: St
699
+ run: jt
675
700
  },
676
701
  {
677
702
  key: "Shift-ArrowLeft",
678
- run: Ct
703
+ run: Mt
679
704
  },
680
705
  {
681
706
  key: "Shift-ArrowRight",
682
- run: wt
707
+ run: Nt
683
708
  }
684
- ])), Et = (e) => e === "h1" || e === "h2" || e === "h3" ? x.heading : x[e], Dt = [
709
+ ])), Ft = (e) => e === "h1" || e === "h2" || e === "h3" ? x.heading : x[e], It = [
685
710
  "bold",
686
711
  "italic",
687
712
  "strike"
688
- ], Ot = ["code", "math"], kt = [
713
+ ], Lt = ["code", "math"], Rt = [
689
714
  "bulletList",
690
715
  "orderedList",
691
716
  "task"
692
- ], At = [
717
+ ], zt = [
693
718
  "h1",
694
719
  "h2",
695
720
  "h3"
696
- ], jt = ["table", "hr"], Mt = [
721
+ ], Bt = ["table", "hr"], Vt = [
697
722
  "codeBlock",
698
723
  "mathBlock",
699
724
  "frontmatter"
700
- ], Nt = (e, t, n = !1) => {
701
- let r = h[t];
702
- return r ? {
725
+ ], Ht = (e, t, n = !1) => {
726
+ let r = _[t];
727
+ if (!r) return null;
728
+ let { disabled: i, active: a } = re(e.state, r, n);
729
+ return {
703
730
  label: r.title,
704
- icon: Et(t),
705
- active: !n && !!r.isActive?.(e.state),
706
- disabled: !n && !!r.disabled?.(e.state),
731
+ icon: Ft(t),
732
+ active: a,
733
+ disabled: i,
707
734
  onSelect: () => {
708
735
  r.run(e), e.focus();
709
736
  }
710
- } : null;
711
- }, G = (e, t, n = !1, r = !1) => {
737
+ };
738
+ }, W = (e, t, n = !1, r = !1) => {
712
739
  let i = [];
713
740
  for (let a of t) {
714
- let t = Nt(e, a, r);
741
+ let t = Ht(e, a, r);
715
742
  t && !(n && t.disabled) && i.push(t);
716
743
  }
717
744
  return i;
718
- }, K = (e) => {
745
+ }, G = (e) => {
719
746
  let t = e.contentDOM.ownerDocument, n = (n) => () => {
720
747
  e.focus();
721
748
  try {
@@ -737,9 +764,9 @@ var W = (e, t) => (n) => {
737
764
  label: "Paste",
738
765
  icon: x.paste,
739
766
  onSelect: () => {
740
- let n = p(e);
767
+ let n = h(e);
741
768
  n || e.focus(), r?.readText().then((r) => {
742
- r && (n ? t.execCommand("insertText", !1, r) : e.dispatch(e.state.replaceSelection(r)));
769
+ r && (n ? t.activeElement === n && t.execCommand("insertText", !1, r) : e.hasFocus && e.dispatch(e.state.replaceSelection(r)));
743
770
  }).catch(() => {});
744
771
  }
745
772
  } : {
@@ -750,200 +777,191 @@ var W = (e, t) => (n) => {
750
777
  onSelect: () => {}
751
778
  }
752
779
  ];
753
- }, q = (e, t, n, r = !1) => ({
780
+ }, K = (e, t, n, r = !1) => ({
754
781
  label: e,
755
782
  icon: t,
756
783
  rows: n,
757
784
  disabled: r
758
785
  });
759
- function J(e, t) {
786
+ function q(e, t) {
760
787
  t.length && (e.length && e.push("separator"), e.push(...t));
761
788
  }
762
789
  //#endregion
763
790
  //#region src/inplace/edit-divider.ts
764
- function Pt(e) {
791
+ function Ut(e) {
765
792
  let t = e.selection.main;
766
793
  if (!t.empty) return !1;
767
794
  let n = e.doc.lineAt(t.head);
768
- if (!H(e, n.number)) return !1;
769
- for (let t = F(e).resolveInner(n.from, 1); t; t = t.parent) {
795
+ if (!V(e, n.number)) return !1;
796
+ for (let t = N(e).resolveInner(n.from, 1); t; t = t.parent) {
770
797
  if (t.name === "HorizontalRule") return !0;
771
798
  if (!t.parent) break;
772
799
  }
773
800
  return !1;
774
801
  }
775
- var Ft = (e) => p(e) || !Pt(e.state) ? !1 : ee(e), It = N.high(j.of([{
802
+ var Wt = (e) => h(e) || !Ut(e.state) ? !1 : oe(e), Gt = j.high(k.of([{
776
803
  key: "Backspace",
777
- run: Ft
804
+ run: Wt
778
805
  }, {
779
806
  key: "Delete",
780
- run: Ft
807
+ run: Wt
781
808
  }]));
782
- function Lt(e) {
809
+ function Kt(e) {
783
810
  return {
784
811
  label: "Remove divider",
785
812
  icon: x.hr,
786
813
  onSelect: () => {
787
- h.hr?.run(e), e.focus();
814
+ _.hr?.run(e), e.focus();
788
815
  }
789
816
  };
790
817
  }
791
818
  //#endregion
792
819
  //#region src/inplace/link-row.ts
793
- var Rt = (e) => {
820
+ var qt = (e) => {
794
821
  let t = e.trim().replace(/^<([^]*)>$/, "$1");
795
822
  return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
796
- }, zt = (e) => e.replace(/^<([^]*)>$/, "$1");
797
- function Bt(e, t) {
823
+ }, Jt = (e) => e.replace(/^<([^]*)>$/, "$1");
824
+ function Yt(e, t) {
798
825
  let n = e.doc.lineAt(t.from);
799
826
  if (e.doc.lineAt(t.to).number !== n.number) return null;
800
- let r = t.from - n.from, i = t.to - n.from, a = y(n.text, r) ?? y(n.text, i);
801
- if (a) return {
802
- from: n.from + a.from,
803
- to: n.from + a.to,
804
- text: a.label
827
+ let r = t.from - n.from, i = t.to - n.from, s = o(n.text, r) ?? o(n.text, i);
828
+ if (s) return {
829
+ from: n.from + s.from,
830
+ to: n.from + s.to,
831
+ text: s.label
805
832
  };
806
- let o = b(n.text, r) ?? b(n.text, i);
807
- return o ? {
808
- from: n.from + o.from,
809
- to: n.from + o.to,
810
- text: o.label
833
+ let c = a(n.text, r) ?? a(n.text, i);
834
+ return c ? {
835
+ from: n.from + c.from,
836
+ to: n.from + c.to,
837
+ text: c.label
811
838
  } : null;
812
839
  }
813
- function Vt(e) {
814
- let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = y(r.text, n.head - r.from);
815
- if (i) {
816
- let n = r.from + i.from, a = r.from + i.to, o = r.from + i.urlFrom, s = r.from + i.urlTo, c = t.facet(Se), l = [];
817
- return c && i.url && l.push({
818
- label: "Open link",
819
- icon: x.link,
820
- onSelect: () => c(i.url)
821
- }), l.push({
840
+ function Xt(e, t) {
841
+ let { state: n } = e, r = n.selection.main, i = n.doc.lineAt(r.head), a = t.partsIn(i.text, r.head - i.from);
842
+ if (a) {
843
+ let n = i.from + a.from, r = i.from + a.to, o = t.editActions?.(e, a) ?? [];
844
+ return o.push({
822
845
  label: "Remove link",
823
846
  onSelect: () => {
824
847
  e.dispatch({
825
848
  changes: {
826
849
  from: n,
827
- to: a,
828
- insert: i.label
850
+ to: r,
851
+ insert: a.label
829
852
  },
830
853
  selection: {
831
854
  anchor: n,
832
- head: n + i.label.length
855
+ head: n + a.label.length
833
856
  }
834
857
  }), e.focus();
835
858
  }
836
859
  }), {
837
860
  field: !0,
838
- label: "Edit external link",
839
- icon: x.link,
840
- value: zt(i.url),
841
- placeholder: "https://…",
842
- onSubmit: (t) => {
843
- e.dispatch({ changes: {
844
- from: o,
845
- to: s,
846
- insert: Rt(t)
847
- } }), e.focus();
848
- },
849
- actions: l
861
+ label: t.editLabel,
862
+ icon: t.icon,
863
+ value: t.editValue(a),
864
+ placeholder: t.placeholder,
865
+ onSubmit: (n) => t.onEdit(e, a, n),
866
+ actions: o
850
867
  };
851
868
  }
852
- let a = Bt(t, n), o = a ? a.from : n.from, s = a ? a.to : n.to, c = (a ? a.text : t.sliceDoc(n.from, n.to)) || "link";
869
+ let o = Yt(n, r), s = o ? o.from : r.from, c = o ? o.to : r.to, l = o ? o.text : n.sliceDoc(r.from, r.to);
853
870
  return {
854
871
  field: !0,
855
- label: "Add external link",
856
- icon: x.link,
872
+ label: t.addLabel,
873
+ icon: t.icon,
857
874
  value: "",
858
- placeholder: "https://…",
859
- onSubmit: (t) => {
860
- e.dispatch({
861
- changes: {
862
- from: o,
863
- to: s,
864
- insert: `[${c}](${Rt(t)})`
865
- },
866
- selection: {
867
- anchor: o + 1,
868
- head: o + 1 + c.length
869
- }
870
- }), e.focus();
871
- }
875
+ placeholder: t.placeholder,
876
+ onSubmit: (n) => t.onAdd(e, s, c, l, n)
872
877
  };
873
878
  }
874
- function Ht(e) {
875
- let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = o(r.text, n.head - r.from);
876
- if (i) {
877
- let t = r.from + i.from, n = r.from + i.to, a = r.from + i.targetFrom, o = r.from + i.targetTo, s = i.label || i.target;
878
- return {
879
- field: !0,
880
- label: "Edit link",
881
- icon: x.wikilink,
882
- value: i.target,
883
- placeholder: "note or path",
884
- onSubmit: (t) => {
885
- t && e.dispatch({ changes: {
886
- from: a,
887
- to: o,
888
- insert: t
889
- } }), e.focus();
879
+ var Zt = {
880
+ icon: x.link,
881
+ placeholder: "https://…",
882
+ editLabel: "Edit external link",
883
+ addLabel: "Add external link",
884
+ partsIn: o,
885
+ editValue: (e) => Jt(e.url),
886
+ editActions: (e, t) => {
887
+ let n = e.state.facet(Ae);
888
+ return !n || !t.url ? [] : [{
889
+ label: "Open link",
890
+ icon: x.link,
891
+ onSelect: () => n(t.url)
892
+ }];
893
+ },
894
+ onEdit: (e, t, n) => {
895
+ e.dispatch({ changes: {
896
+ from: t.urlFrom,
897
+ to: t.urlTo,
898
+ insert: qt(n)
899
+ } }), e.focus();
900
+ },
901
+ onAdd: (e, t, n, r, i) => {
902
+ let a = r || "link";
903
+ e.dispatch({
904
+ changes: {
905
+ from: t,
906
+ to: n,
907
+ insert: `[${a}](${qt(i)})`
890
908
  },
891
- actions: [{
892
- label: "Remove link",
893
- onSelect: () => {
894
- e.dispatch({
895
- changes: {
896
- from: t,
897
- to: n,
898
- insert: s
899
- },
900
- selection: {
901
- anchor: t,
902
- head: t + s.length
903
- }
904
- }), e.focus();
905
- }
906
- }]
907
- };
909
+ selection: {
910
+ anchor: t + 1,
911
+ head: t + 1 + a.length
912
+ }
913
+ }), e.focus();
914
+ }
915
+ }, Qt = {
916
+ icon: x.wikilink,
917
+ placeholder: "note or path",
918
+ editLabel: "Edit link",
919
+ addLabel: "Add link",
920
+ partsIn: i,
921
+ editValue: (e) => e.target,
922
+ onEdit: (e, t, n) => {
923
+ n && e.dispatch({ changes: {
924
+ from: t.targetFrom,
925
+ to: t.targetTo,
926
+ insert: n
927
+ } }), e.focus();
928
+ },
929
+ onAdd: (e, t, n, r, i) => {
930
+ let a = i || r || "target", o = !i || i === r ? `[[${a}]]` : `[[${i}|${r}]]`;
931
+ e.dispatch({
932
+ changes: {
933
+ from: t,
934
+ to: n,
935
+ insert: o
936
+ },
937
+ selection: {
938
+ anchor: t + 2,
939
+ head: t + 2 + (i || a).length
940
+ }
941
+ }), e.focus();
908
942
  }
909
- let a = Bt(t, n), s = a ? a.from : n.from, c = a ? a.to : n.to, l = a ? a.text : t.sliceDoc(n.from, n.to);
910
- return {
911
- field: !0,
912
- label: "Add link",
913
- icon: x.wikilink,
914
- value: "",
915
- placeholder: "note or path",
916
- onSubmit: (t) => {
917
- let n = t || l || "target", r = !t || t === l ? `[[${n}]]` : `[[${t}|${l}]]`;
918
- e.dispatch({
919
- changes: {
920
- from: s,
921
- to: c,
922
- insert: r
923
- },
924
- selection: {
925
- anchor: s + 2,
926
- head: s + 2 + (t || n).length
927
- }
928
- }), e.focus();
929
- }
930
- };
943
+ };
944
+ function $t(e) {
945
+ return Xt(e, Zt);
946
+ }
947
+ function en(e) {
948
+ return Xt(e, Qt);
931
949
  }
932
950
  //#endregion
933
951
  //#region src/inplace/context-menu-shell.ts
934
- function Ut(e, t, n, r) {
952
+ function tn(e, t, n, r) {
935
953
  let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
936
954
  e.style.left = "0", e.style.top = "0";
937
955
  let { width: o, height: s } = e.getBoundingClientRect();
938
956
  e.style.left = `${Math.max(4, Math.min(t, i - o - 4))}px`, e.style.top = `${Math.max(4, Math.min(n, a - s - 4))}px`;
939
957
  }
940
- function Wt(e, t, n) {
958
+ function nn(e, t, n) {
941
959
  let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
942
960
  e.style.left = "0", e.style.top = "0";
943
961
  let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
944
962
  e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
945
963
  }
946
- function Gt(e, t, n, r = 350) {
964
+ function rn(e, t, n, r = 350) {
947
965
  let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
948
966
  a(e) && n();
949
967
  }, s = (e) => {
@@ -957,10 +975,10 @@ function Gt(e, t, n, r = 350) {
957
975
  }
958
976
  //#endregion
959
977
  //#region src/inplace/context-menu-types.ts
960
- var Kt = (e) => typeof e != "string" && "rows" in e, qt = (e) => typeof e != "string" && "field" in e;
978
+ var an = (e) => typeof e != "string" && "rows" in e, on = (e) => typeof e != "string" && "field" in e;
961
979
  //#endregion
962
980
  //#region src/inplace/context-menu.ts
963
- function Y(e, t = "cm-inplace-menu", n) {
981
+ function J(e, t = "cm-inplace-menu", n) {
964
982
  let r = e.defaultView, i = e.createElement("div");
965
983
  i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
966
984
  let a = null, o = null, s = () => {
@@ -970,7 +988,7 @@ function Y(e, t = "cm-inplace-menu", n) {
970
988
  }, l = (e) => e.addEventListener("mousedown", (e) => {
971
989
  e.preventDefault(), e.stopPropagation();
972
990
  }), u = (t, n, r) => {
973
- r && t.appendChild(ie(e, r));
991
+ r && t.appendChild(de(e, r));
974
992
  let i = e.createElement("span");
975
993
  i.textContent = n, t.appendChild(i);
976
994
  }, d = (n) => {
@@ -988,7 +1006,7 @@ function Y(e, t = "cm-inplace-menu", n) {
988
1006
  if (a?.dataset.for === n) return;
989
1007
  s();
990
1008
  let e = c();
991
- e.dataset.for = n, i.appendChild(e), Wt(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
1009
+ e.dataset.for = n, i.appendChild(e), nn(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
992
1010
  };
993
1011
  return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
994
1012
  e.stopPropagation(), p();
@@ -1011,7 +1029,7 @@ function Y(e, t = "cm-inplace-menu", n) {
1011
1029
  for (let i of n) if (i === "separator") {
1012
1030
  let n = e.createElement("div");
1013
1031
  n.className = `${t}-sep`, r.appendChild(n);
1014
- } else Kt(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : qt(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
1032
+ } else an(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : on(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
1015
1033
  return r;
1016
1034
  };
1017
1035
  return {
@@ -1022,12 +1040,12 @@ function Y(e, t = "cm-inplace-menu", n) {
1022
1040
  show: (t, a, s) => {
1023
1041
  c();
1024
1042
  let l = m(t);
1025
- i.appendChild(l), i.hidden = !1, Ut(l, a, s, r), o = Gt(e, i, c), n?.(!0);
1043
+ i.appendChild(l), i.hidden = !1, tn(l, a, s, r), o = rn(e, i, c), n?.(!0);
1026
1044
  },
1027
1045
  showField: (t, a, s) => {
1028
1046
  c();
1029
1047
  let l = p(t);
1030
- i.appendChild(l), i.hidden = !1, Ut(l, a, s, r), l.querySelector("input")?.focus({ preventScroll: !0 }), o = Gt(e, i, c), n?.(!0);
1048
+ i.appendChild(l), i.hidden = !1, tn(l, a, s, r), l.querySelector("input")?.focus({ preventScroll: !0 }), o = rn(e, i, c), n?.(!0);
1031
1049
  },
1032
1050
  hide: c,
1033
1051
  destroy: () => {
@@ -1037,8 +1055,8 @@ function Y(e, t = "cm-inplace-menu", n) {
1037
1055
  }
1038
1056
  //#endregion
1039
1057
  //#region src/inplace/math-edit.ts
1040
- function Jt(e) {
1041
- let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Be(r.text, n.head - r.from);
1058
+ function sn(e) {
1059
+ let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Je(r.text, n.head - r.from);
1042
1060
  if (i) {
1043
1061
  let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
1044
1062
  return {
@@ -1096,27 +1114,27 @@ function Jt(e) {
1096
1114
  }
1097
1115
  };
1098
1116
  }
1099
- var Yt = class {
1117
+ var cn = class {
1100
1118
  menu;
1101
1119
  contentDOM;
1102
1120
  onClick;
1103
1121
  constructor(e) {
1104
- this.menu = Y(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
1105
- if (!e.state.facet(I).math) return;
1122
+ this.menu = J(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
1123
+ if (!e.state.facet(P).math) return;
1106
1124
  let n = t.target?.closest(".cm-inplace-math");
1107
1125
  if (!n) return;
1108
1126
  let r = e.posAtDOM(n);
1109
1127
  if (r < 0) return;
1110
1128
  let i = e.state.doc.lineAt(r);
1111
- Be(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(Jt(e), t.clientX, t.clientY));
1129
+ Je(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(sn(e), t.clientX, t.clientY));
1112
1130
  }, this.contentDOM.addEventListener("click", this.onClick);
1113
1131
  }
1114
1132
  destroy() {
1115
1133
  this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
1116
1134
  }
1117
- }, Xt = k.fromClass(Yt), Zt = le((e, t) => {
1118
- if (!e.state.facet(I).math) return null;
1119
- let n = e.state.doc.lineAt(t), r = Be(n.text, t - n.from);
1135
+ }, ln = D.fromClass(cn), un = ve((e, t) => {
1136
+ if (!e.state.facet(P).math) return null;
1137
+ let n = e.state.doc.lineAt(t), r = Je(n.text, t - n.from);
1120
1138
  return r ? {
1121
1139
  pos: n.from + r.from,
1122
1140
  end: n.from + r.to,
@@ -1129,14 +1147,14 @@ var Yt = class {
1129
1147
  });
1130
1148
  //#endregion
1131
1149
  //#region src/inplace/context-menu-actions.ts
1132
- function X(e) {
1133
- let t = p(e);
1150
+ function Y(e) {
1151
+ let t = h(e);
1134
1152
  if (!t) return !1;
1135
- let { from: n, to: r } = u(t);
1136
- return r > n;
1153
+ let { from: n, to: i } = r(t);
1154
+ return i > n;
1137
1155
  }
1138
- function Qt(e) {
1139
- let t = v(e.state);
1156
+ function dn(e) {
1157
+ let t = g(e.state);
1140
1158
  return {
1141
1159
  field: !0,
1142
1160
  label: "Language",
@@ -1153,49 +1171,49 @@ function Qt(e) {
1153
1171
  actions: [{
1154
1172
  label: "Remove code block",
1155
1173
  onSelect: () => {
1156
- h.codeBlock?.run(e), e.focus();
1174
+ _.codeBlock?.run(e), e.focus();
1157
1175
  }
1158
1176
  }]
1159
1177
  };
1160
1178
  }
1161
- var $t = (e, t = !1) => [
1162
- ...G(e, Dt, !1, t),
1179
+ var fn = (e, t = !1) => [
1180
+ ...W(e, It, !1, t),
1163
1181
  "separator",
1164
- ...t ? G(e, Ot, !1, !0) : [Nt(e, "code", !1), Jt(e)]
1182
+ ...t ? W(e, Lt, !1, !0) : [Ht(e, "code", !1), sn(e)]
1165
1183
  ];
1166
- function en(e) {
1167
- let t = e.state.facet(Ee), n = [];
1168
- return t.includes("format") && J(n, [q("Format", x.format, $t(e, !0))]), t.includes("clipboard") && J(n, K(e)), n;
1184
+ function pn(e) {
1185
+ let t = e.state.facet(Pe), n = [];
1186
+ return t.includes("format") && q(n, [K("Format", x.format, fn(e, !0))]), t.includes("clipboard") && q(n, G(e)), n;
1169
1187
  }
1170
- var tn = (e) => [
1171
- ...G(e, kt),
1188
+ var mn = (e) => [
1189
+ ...W(e, Rt),
1172
1190
  "separator",
1173
- ...G(e, [...At, "body"]),
1191
+ ...W(e, [...zt, "body"]),
1174
1192
  "separator",
1175
- ...G(e, ["quote"])
1176
- ], nn = (e) => [
1177
- ...G(e, jt),
1193
+ ...W(e, ["quote"])
1194
+ ], hn = (e) => [
1195
+ ...W(e, Bt),
1178
1196
  "separator",
1179
- ...G(e, Mt)
1197
+ ...W(e, Vt)
1180
1198
  ];
1181
- function rn(e) {
1182
- let { state: t } = e, n = t.facet(Ee), r = (e) => n.includes(e);
1183
- if (X(e)) return en(e);
1184
- if (s(t)) {
1185
- let t = [Qt(e)];
1186
- return r("clipboard") && J(t, K(e)), t;
1199
+ function gn(e) {
1200
+ let { state: t } = e, n = t.facet(Pe), r = (e) => n.includes(e);
1201
+ if (Y(e)) return pn(e);
1202
+ if (ee(t)) {
1203
+ let t = [dn(e)];
1204
+ return r("clipboard") && q(t, G(e)), t;
1187
1205
  }
1188
- if (Pt(t)) {
1189
- let t = [Lt(e)];
1190
- return r("clipboard") && J(t, K(e)), t;
1206
+ if (Ut(t)) {
1207
+ let t = [Kt(e)];
1208
+ return r("clipboard") && q(t, G(e)), t;
1191
1209
  }
1192
- let i = t.selection.main, a = t.doc.lineAt(i.head).text.trim() === "", o = !i.empty || !!t.wordAt(i.head), c = t.facet(ke) === "menu", l = [];
1193
- for (let t of n) t === "link" && c ? J(l, [Ht(e), Vt(e)]) : t === "format" && c ? J(l, [q("Format", x.format, $t(e), !o)]) : t === "paragraph" ? J(l, [q("Paragraph", x.paragraph, tn(e))]) : t === "insert" ? J(l, [q("Insert", x.insert, nn(e), !a)]) : t === "clipboard" && J(l, K(e));
1194
- return l;
1210
+ let i = t.selection.main, a = t.doc.lineAt(i.head).text.trim() === "", o = !i.empty || !!t.wordAt(i.head), s = t.facet(Le) === "menu", c = [];
1211
+ for (let t of n) t === "link" && s ? q(c, [en(e), $t(e)]) : t === "format" && s ? q(c, [K("Format", x.format, fn(e), !o)]) : t === "paragraph" ? q(c, [K("Paragraph", x.paragraph, mn(e))]) : t === "insert" ? q(c, [K("Insert", x.insert, hn(e), !a)]) : t === "clipboard" && q(c, G(e));
1212
+ return c;
1195
1213
  }
1196
1214
  //#endregion
1197
1215
  //#region src/inplace/long-press.ts
1198
- function an(e, t) {
1216
+ function _n(e, t) {
1199
1217
  let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
1200
1218
  i != null && (clearTimeout(i), i = null);
1201
1219
  }, c = (e) => {
@@ -1217,10 +1235,10 @@ function an(e, t) {
1217
1235
  }
1218
1236
  //#endregion
1219
1237
  //#region src/inplace/table-gizmos.ts
1220
- function on(e, t) {
1238
+ function vn(e, t) {
1221
1239
  let n = e.createElement("div");
1222
1240
  n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
1223
- let r = Y(e), i = (t, n, r) => {
1241
+ let r = J(e), i = (t, n, r) => {
1224
1242
  let i = e.createElement("button");
1225
1243
  return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
1226
1244
  e.preventDefault(), e.stopPropagation();
@@ -1302,76 +1320,136 @@ function on(e, t) {
1302
1320
  };
1303
1321
  }
1304
1322
  //#endregion
1305
- //#region src/inplace/table-widget-caret.ts
1306
- function sn(e) {
1307
- let t = e.ownerDocument.getSelection(), n = e.firstChild, r = (e.textContent ?? "").length, i = t?.anchorNode === n ? t?.anchorOffset ?? 0 : r;
1308
- return {
1309
- offset: i,
1310
- head: t?.focusNode === n ? t?.focusOffset ?? i : i
1323
+ //#region src/inplace/table-widget-keys.ts
1324
+ function yn(e, t, n) {
1325
+ let r = e.target.closest("td, th");
1326
+ if (!r) return;
1327
+ if (l(e, r)) {
1328
+ e.stopPropagation();
1329
+ return;
1330
+ }
1331
+ let { r: i, c: a } = n.coords(r), o = n.rows(), s = n.cols(), c = o - 1;
1332
+ if (e.key === "Tab") {
1333
+ e.preventDefault(), e.stopPropagation();
1334
+ let r = i * s + a + (e.shiftKey ? -1 : 1);
1335
+ if (r < 0) return;
1336
+ if (r >= o * s) {
1337
+ if (e.shiftKey) return;
1338
+ n.appendRow(), n.cellAt(c + 1, 0)?.focus(), n.sync(t);
1339
+ return;
1340
+ }
1341
+ n.cellAt(Math.floor(r / s), r % s)?.focus();
1342
+ return;
1343
+ }
1344
+ if (e.key === "Enter") {
1345
+ if (e.preventDefault(), e.stopPropagation(), i < c) {
1346
+ n.cellAt(i + 1, a)?.focus();
1347
+ return;
1348
+ }
1349
+ n.appendRow(), n.cellAt(c + 1, a)?.focus(), n.sync(t);
1350
+ return;
1351
+ }
1352
+ let u = () => {
1353
+ let { to: e } = n.bounds(t);
1354
+ if (t.focus(), e >= t.state.doc.length) {
1355
+ t.dispatch({
1356
+ changes: {
1357
+ from: e,
1358
+ insert: "\n"
1359
+ },
1360
+ selection: { anchor: e + 1 }
1361
+ });
1362
+ return;
1363
+ }
1364
+ t.dispatch({ selection: { anchor: e + 1 } });
1365
+ }, d = () => {
1366
+ let { from: e } = n.bounds(t);
1367
+ t.focus(), t.dispatch({ selection: { anchor: Math.max(e - 1, 0) } });
1368
+ }, f = (e, t) => {
1369
+ let r = n.cellAt(Math.floor(e / s), e % s);
1370
+ r && n.enterCell(r, t);
1311
1371
  };
1372
+ if (e.key === "ArrowDown") {
1373
+ e.preventDefault(), e.stopPropagation(), i === c ? u() : f((i + 1) * s + a, n.readCaret()?.offset ?? 0);
1374
+ return;
1375
+ }
1376
+ if (e.key === "ArrowUp") {
1377
+ e.preventDefault(), e.stopPropagation(), i === 0 ? d() : f((i - 1) * s + a, n.readCaret()?.offset ?? 0);
1378
+ return;
1379
+ }
1380
+ if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
1381
+ let t = e.key === "ArrowLeft", c = n.readCaret();
1382
+ if (!c || c.offset !== c.head || (t ? c.offset > 0 : c.offset < (r.textContent ?? "").length)) return;
1383
+ e.preventDefault(), e.stopPropagation();
1384
+ let l = i * s + a + (t ? -1 : 1);
1385
+ if (l < 0) return d();
1386
+ if (l >= o * s) return u();
1387
+ f(l, t ? n.cellText(Math.floor(l / s), l % s).length : 0);
1388
+ return;
1389
+ }
1312
1390
  }
1313
1391
  //#endregion
1314
1392
  //#region src/inplace/inline-md.ts
1315
- function cn(e, t = !1) {
1393
+ function bn(e, t = !1) {
1316
1394
  let n = document.createDocumentFragment();
1317
- return dn(n, e, t), n;
1395
+ return Cn(n, e, t), n;
1318
1396
  }
1319
- var ln = /!\[\[[^\]\n]+?\]\]/, un = [
1397
+ var xn = /!\[\[[^\]\n]+?\]\]/, Sn = [
1320
1398
  {
1321
1399
  re: /`([^`\n]+)`/,
1322
- build: (e) => Z("code", "cm-inplace-code", document.createTextNode(e[1]))
1400
+ build: (e) => X("code", "cm-inplace-code", document.createTextNode(e[1]))
1323
1401
  },
1324
1402
  {
1325
- re: /(?<![\d$])\$(?!\s)([^$\n]+?)(?<!\s)\$(?![\d$])/,
1403
+ re: new RegExp(Ge.source),
1326
1404
  build: (e) => {
1327
- let t = Z("span", "cm-inplace-math");
1328
- return se.render(e[1], t, { throwOnError: !1 }), t;
1405
+ let t = X("span", "cm-inplace-math");
1406
+ return ge.render(e[1], t, { throwOnError: !1 }), t;
1329
1407
  }
1330
1408
  },
1331
1409
  {
1332
1410
  re: new RegExp(e.source),
1333
1411
  build: (e) => {
1334
- let t = Z("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
1412
+ let t = X("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
1335
1413
  return t.dataset.styloWikilink = e[1] ?? "", t;
1336
1414
  }
1337
1415
  },
1338
1416
  {
1339
1417
  re: /\[([^\]\n]*)\]\(([^)\n]*)\)/,
1340
1418
  build: (e, t) => {
1341
- let n = Z("a", "cm-inplace-link");
1342
- return n.href = e[2] ?? "", n.append(Q(e[1] ?? "", t)), n;
1419
+ let n = X("a", "cm-inplace-link");
1420
+ return n.href = e[2] ?? "", n.append(Z(e[1] ?? "", t)), n;
1343
1421
  }
1344
1422
  },
1345
1423
  {
1346
1424
  re: /\*\*\*([^*\n]+?)\*\*\*/,
1347
- build: (e, t) => Z("strong", "cm-inplace-strong", Z("em", "cm-inplace-em", Q(e[1], t)))
1425
+ build: (e, t) => X("strong", "cm-inplace-strong", X("em", "cm-inplace-em", Z(e[1], t)))
1348
1426
  },
1349
1427
  {
1350
1428
  re: /\*\*([^\n]+?)\*\*/,
1351
- build: (e, t) => Z("strong", "cm-inplace-strong", Q(e[1], t))
1429
+ build: (e, t) => X("strong", "cm-inplace-strong", Z(e[1], t))
1352
1430
  },
1353
1431
  {
1354
1432
  re: /~~([^\n]+?)~~/,
1355
- build: (e, t) => Z("span", "cm-inplace-strike", Q(e[1], t))
1433
+ build: (e, t) => X("span", "cm-inplace-strike", Z(e[1], t))
1356
1434
  },
1357
1435
  {
1358
1436
  re: /(?<!\*)\*(?!\*|\s)([^\n]+?)(?<!\s)\*(?!\*)/,
1359
- build: (e, t) => Z("em", "cm-inplace-em", Q(e[1], t))
1437
+ build: (e, t) => X("em", "cm-inplace-em", Z(e[1], t))
1360
1438
  }
1361
1439
  ];
1362
- function Z(e, t, ...n) {
1440
+ function X(e, t, ...n) {
1363
1441
  let r = document.createElement(e);
1364
1442
  return r.className = t, r.append(...n), r;
1365
1443
  }
1366
- function Q(e, t) {
1444
+ function Z(e, t) {
1367
1445
  let n = document.createDocumentFragment();
1368
- return dn(n, e, t), n;
1446
+ return Cn(n, e, t), n;
1369
1447
  }
1370
- function dn(e, t, n) {
1448
+ function Cn(e, t, n) {
1371
1449
  for (; t;) {
1372
- let r = -1, i = null, a = n ? ln.exec(t) : null;
1450
+ let r = -1, i = null, a = n ? xn.exec(t) : null;
1373
1451
  a && (r = a.index, i = { literal: a[0] });
1374
- for (let e of un) {
1452
+ for (let e of Sn) {
1375
1453
  let n = e.re.exec(t);
1376
1454
  n && (r < 0 || n.index < r) && (r = n.index, i = {
1377
1455
  rule: e,
@@ -1387,53 +1465,53 @@ function dn(e, t, n) {
1387
1465
  }
1388
1466
  //#endregion
1389
1467
  //#region src/inplace/table-widget-render.ts
1390
- function fn(e, t, n) {
1468
+ function wn(e, t, n) {
1391
1469
  let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
1392
- e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : cn(re(a), t.embeds));
1470
+ e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : bn(c(a), t.embeds));
1393
1471
  }
1394
- function pn(e, t, n, r) {
1472
+ function Tn(e, t, n, r) {
1395
1473
  let i = document.createElement(r ? "th" : "td");
1396
1474
  i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
1397
1475
  let a = e.aligns[n];
1398
- return a && (i.style.textAlign = a), fn(i, e, !1), i;
1476
+ return a && (i.style.textAlign = a), wn(i, e, !1), i;
1399
1477
  }
1400
- function mn(e, t) {
1478
+ function En(e, t) {
1401
1479
  e.replaceChildren();
1402
1480
  let n = t.aligns.length, r = e.createTHead().insertRow();
1403
- for (let e = 0; e < n; e++) r.appendChild(pn(t, 0, e, !0));
1481
+ for (let e = 0; e < n; e++) r.appendChild(Tn(t, 0, e, !0));
1404
1482
  let i = e.createTBody();
1405
1483
  for (let e = 1; e < t.rows.length; e++) {
1406
1484
  let r = i.insertRow();
1407
- for (let i = 0; i < n; i++) r.appendChild(pn(t, e, i, !1));
1485
+ for (let i = 0; i < n; i++) r.appendChild(Tn(t, e, i, !1));
1408
1486
  }
1409
1487
  }
1410
1488
  //#endregion
1411
1489
  //#region src/inplace/table-structure.ts
1412
- var $ = (e) => e.aligns.length;
1413
- function hn(e, t) {
1414
- let n = Math.max(0, Math.min(t, $(e)));
1490
+ var Q = (e) => e.aligns.length;
1491
+ function Dn(e, t) {
1492
+ let n = Math.max(0, Math.min(t, Q(e)));
1415
1493
  for (let t of e.rows) t.splice(n, 0, "");
1416
1494
  e.aligns.splice(n, 0, "");
1417
1495
  }
1418
- function gn(e, t) {
1419
- if (!($(e) <= 1 || t < 0 || t >= $(e))) {
1496
+ function On(e, t) {
1497
+ if (!(Q(e) <= 1 || t < 0 || t >= Q(e))) {
1420
1498
  for (let n of e.rows) n.splice(t, 1);
1421
1499
  e.aligns.splice(t, 1);
1422
1500
  }
1423
1501
  }
1424
- function _n(e, t) {
1502
+ function kn(e, t) {
1425
1503
  let n = Math.max(1, Math.min(t, e.rows.length));
1426
- e.rows.splice(n, 0, Array($(e)).fill(""));
1504
+ e.rows.splice(n, 0, Array(Q(e)).fill(""));
1427
1505
  }
1428
- function vn(e, t) {
1506
+ function An(e, t) {
1429
1507
  t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
1430
1508
  }
1431
- function yn(e, t, n) {
1432
- t >= 0 && t < $(e) && (e.aligns[t] = n);
1509
+ function jn(e, t, n) {
1510
+ t >= 0 && t < Q(e) && (e.aligns[t] = n);
1433
1511
  }
1434
1512
  //#endregion
1435
1513
  //#region src/inplace/tables.ts
1436
- var bn = class extends A {
1514
+ var Mn = class extends O {
1437
1515
  table;
1438
1516
  embeds;
1439
1517
  constructor(e, t) {
@@ -1445,17 +1523,17 @@ var bn = class extends A {
1445
1523
  toDOM() {
1446
1524
  let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
1447
1525
  r.className = "cm-inplace-table";
1448
- let i = (e) => cn(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
1526
+ let i = (e) => bn(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
1449
1527
  e.forEach((e, t) => {
1450
1528
  let r = document.createElement("th");
1451
- r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), xn(r, n[t]), a.appendChild(r);
1529
+ r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), Nn(r, n[t]), a.appendChild(r);
1452
1530
  });
1453
1531
  let o = r.createTBody();
1454
1532
  return t.forEach((t, r) => {
1455
1533
  let a = o.insertRow();
1456
1534
  for (let o = 0; o < e.length; o++) {
1457
1535
  let e = a.insertCell();
1458
- e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), xn(e, n[o]);
1536
+ e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), Nn(e, n[o]);
1459
1537
  }
1460
1538
  }), r;
1461
1539
  }
@@ -1463,49 +1541,57 @@ var bn = class extends A {
1463
1541
  return !1;
1464
1542
  }
1465
1543
  };
1466
- function xn(e, t) {
1544
+ function Nn(e, t) {
1467
1545
  t && (e.style.textAlign = t);
1468
1546
  }
1469
- function Sn(e, t) {
1547
+ function Pn(e, t) {
1470
1548
  let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
1471
1549
  for (let e = n; e <= r; e++) i.push(t.line(e).text);
1472
- let o = a(i);
1473
- return !o || o.rows.length === 0 ? null : {
1474
- head: o.rows[0],
1475
- body: o.rows.slice(1),
1476
- aligns: o.aligns
1550
+ let a = p(i);
1551
+ return !a || a.rows.length === 0 ? null : {
1552
+ head: a.rows[0],
1553
+ body: a.rows.slice(1),
1554
+ aligns: a.aligns
1477
1555
  };
1478
1556
  }
1479
- function Cn(e) {
1480
- if (!e.facet(I).tables) return D.none;
1481
- let t = e.facet(xe) === "cells" && !e.readOnly, r = e.facet(L) != null && e.facet(I).embeds, i = F(e), a = n(e.doc), o = t ? null : B(e), s = [];
1482
- return i.iterate({ enter: (n) => {
1483
- if (n.name !== "Table") return;
1484
- if (a && n.from < a.to) return !1;
1557
+ function Fn(e, t) {
1558
+ let n = N(e);
1559
+ for (let e of [-1, 1]) for (let r = n.resolveInner(t, e); r; r = r.parent) if (r.name === "Table") return !0;
1560
+ return !1;
1561
+ }
1562
+ function In(e, t) {
1563
+ return t.ranges.some((t) => Fn(e, t.from) || Fn(e, t.to));
1564
+ }
1565
+ function Ln(e) {
1566
+ if (!e.facet(P).tables) return T.none;
1567
+ let n = e.facet(I) === "cells" && !e.readOnly, r = e.facet(F) != null && e.facet(P).embeds, i = N(e), a = t(e.doc), o = n ? null : z(e), s = [];
1568
+ return i.iterate({ enter: (t) => {
1569
+ if (t.name !== "Table") return;
1570
+ if (a && t.from < a.to) return !1;
1485
1571
  if (o) {
1486
- let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
1487
- for (let e = t; e <= r; e++) if (o.has(e)) return !1;
1572
+ let n = e.doc.lineAt(t.from).number, r = e.doc.lineAt(t.to).number;
1573
+ for (let e = n; e <= r; e++) if (o.has(e)) return !1;
1488
1574
  }
1489
- let i = Sn(n.node, e.doc);
1575
+ let i = Pn(t.node, e.doc);
1490
1576
  if (i) {
1491
- let e = t ? new En(i, r) : new bn(i, r);
1492
- s.push(D.replace({
1577
+ let e = n ? new zn(i, r) : new Mn(i, r);
1578
+ s.push(T.replace({
1493
1579
  widget: e,
1494
1580
  block: !0
1495
- }).range(n.from, n.to));
1581
+ }).range(t.from, t.to));
1496
1582
  }
1497
1583
  return !1;
1498
- } }), D.set(s, !0);
1584
+ } }), T.set(s, !0);
1499
1585
  }
1500
- var wn = P.define({
1501
- create: Cn,
1586
+ var Rn = M.define({
1587
+ create: Ln,
1502
1588
  update: (e, t) => {
1503
- if (t.annotation(Tn)) return e.map(t.changes);
1589
+ if (t.annotation($)) return e.map(t.changes);
1504
1590
  let n = t.startState.readOnly !== t.state.readOnly;
1505
- return t.state.facet(xe) === "cells" ? t.docChanged || n ? Cn(t.state) : e.map(t.changes) : t.docChanged || t.selection || n ? Cn(t.state) : e;
1591
+ return t.state.facet(I) === "cells" ? t.docChanged || n ? Ln(t.state) : e.map(t.changes) : t.docChanged || n || t.selection && (In(t.state, t.startState.selection) || In(t.state, t.state.selection)) ? Ln(t.state) : e;
1506
1592
  },
1507
- provide: (e) => [O.decorations.from(e), O.atomicRanges.of((t) => t.state.field(e))]
1508
- }), Tn = fe.define(), En = class extends A {
1593
+ provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
1594
+ }), $ = xe.define(), zn = class extends O {
1509
1595
  data;
1510
1596
  embeds;
1511
1597
  table = null;
@@ -1513,15 +1599,14 @@ var wn = P.define({
1513
1599
  editing = null;
1514
1600
  syncing = !1;
1515
1601
  pendingOffset = null;
1516
- current;
1517
1602
  gizmos = null;
1518
1603
  longPress = null;
1519
1604
  longPressAt = 0;
1520
1605
  constructor(e, t = !1) {
1521
- super(), this.data = e, this.embeds = t, this.rows = c(e), this.current = i(this.rows);
1606
+ super(), this.data = e, this.embeds = t, this.rows = y(e);
1522
1607
  }
1523
1608
  eq(e) {
1524
- return !this.table && JSON.stringify(this.current) === JSON.stringify(e.current);
1609
+ return !this.table && JSON.stringify(b(this.rows)) === JSON.stringify(b(e.rows));
1525
1610
  }
1526
1611
  ignoreEvent() {
1527
1612
  return !0;
@@ -1531,7 +1616,7 @@ var wn = P.define({
1531
1616
  }
1532
1617
  bounds(e) {
1533
1618
  let t = e.posAtDOM(this.table), n = null;
1534
- return e.state.field(wn).between(t, t, (e, t) => (n = {
1619
+ return e.state.field(Rn).between(t, t, (e, t) => (n = {
1535
1620
  from: e,
1536
1621
  to: t
1537
1622
  }, !1)), n ?? e.state.doc.lineAt(t);
@@ -1546,21 +1631,21 @@ var wn = P.define({
1546
1631
  };
1547
1632
  }
1548
1633
  paint(e, t) {
1549
- fn(e, {
1634
+ wn(e, {
1550
1635
  rows: this.rows,
1551
1636
  aligns: this.data.aligns,
1552
1637
  embeds: this.embeds
1553
1638
  }, t);
1554
1639
  }
1555
1640
  renderCells() {
1556
- mn(this.table, {
1641
+ En(this.table, {
1557
1642
  rows: this.rows,
1558
1643
  aligns: this.data.aligns,
1559
1644
  embeds: this.embeds
1560
1645
  });
1561
1646
  }
1562
1647
  appendRow() {
1563
- _n(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
1648
+ kn(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
1564
1649
  }
1565
1650
  model() {
1566
1651
  return {
@@ -1571,7 +1656,7 @@ var wn = P.define({
1571
1656
  runOp(e, t) {
1572
1657
  if (!this.table) return;
1573
1658
  let n = this.model();
1574
- if (t.kind === "insertColumn" ? hn(n, t.at) : t.kind === "deleteColumn" ? gn(n, t.at) : t.kind === "insertRow" ? _n(n, t.at) : t.kind === "deleteRow" ? vn(n, t.at) : yn(n, t.at, n.aligns[t.at] === t.value ? "" : t.value), this.editing = null, this.sync(e), this.renderCells(), this.gizmos?.layout(this.table), t.kind !== "align") {
1659
+ if (t.kind === "insertColumn" ? Dn(n, t.at) : t.kind === "deleteColumn" ? On(n, t.at) : t.kind === "insertRow" ? kn(n, t.at) : t.kind === "deleteRow" ? An(n, t.at) : jn(n, t.at, n.aligns[t.at] === t.value ? "" : t.value), this.editing = null, this.sync(e), this.renderCells(), this.gizmos?.layout(this.table), t.kind !== "align") {
1575
1660
  let e = Math.max(0, Math.min(t.focus[0], this.rows.length - 1)), n = Math.max(0, Math.min(t.focus[1], this.cols() - 1));
1576
1661
  this.cellAt(e, n)?.focus();
1577
1662
  }
@@ -1583,8 +1668,8 @@ var wn = P.define({
1583
1668
  onFocusIn(e) {
1584
1669
  let t = e.target.closest("td, th");
1585
1670
  if (!t || t === this.editing) return;
1586
- let n = this.pendingOffset ?? m(t);
1587
- this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), _(t, n);
1671
+ let n = this.pendingOffset ?? le(t);
1672
+ this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), d(t, n);
1588
1673
  }
1589
1674
  onFocusOut(e) {
1590
1675
  if (this.syncing || !this.editing) return;
@@ -1593,100 +1678,51 @@ var wn = P.define({
1593
1678
  }
1594
1679
  readCaret() {
1595
1680
  if (!this.editing) return null;
1596
- let { r: e, c: t } = this.coords(this.editing);
1681
+ let { r: e, c: t } = this.coords(this.editing), { from: n, to: i } = r(this.editing);
1597
1682
  return {
1598
1683
  r: e,
1599
1684
  c: t,
1600
- ...sn(this.editing)
1685
+ offset: n,
1686
+ head: i
1601
1687
  };
1602
1688
  }
1603
1689
  writeCaret(e) {
1604
1690
  let t = this.cellAt(e.r, e.c);
1605
- t && _(t, e.offset, e.head);
1691
+ t && d(t, e.offset, e.head);
1606
1692
  }
1607
1693
  sync(e) {
1608
1694
  if (!this.table) return;
1609
- let t = this.readCaret(), n = g({
1695
+ let t = this.readCaret(), n = m({
1610
1696
  rows: this.rows,
1611
1697
  aligns: this.data.aligns
1612
- });
1613
- this.current = i(this.rows);
1614
- let { from: r, to: a } = this.bounds(e);
1615
- e.state.sliceDoc(r, a) !== n && (this.syncing = !0, e.dispatch({
1698
+ }), { from: r, to: i } = this.bounds(e);
1699
+ e.state.sliceDoc(r, i) !== n && (this.syncing = !0, e.dispatch({
1616
1700
  changes: {
1617
1701
  from: r,
1618
- to: a,
1702
+ to: i,
1619
1703
  insert: n
1620
1704
  },
1621
- annotations: Tn.of(!0),
1705
+ annotations: $.of(!0),
1622
1706
  userEvent: "input"
1623
1707
  }), this.syncing = !1, t && (this.writeCaret(t), requestAnimationFrame(() => {
1624
1708
  this.table && t && this.writeCaret(t);
1625
1709
  })));
1626
1710
  }
1627
1711
  onKey(e, t) {
1628
- let n = e.target.closest("td, th");
1629
- if (!n || !this.table) return;
1630
- if (ne(e, n)) {
1631
- e.stopPropagation();
1632
- return;
1633
- }
1634
- let { r, c: i } = this.coords(n), a = this.rows.length - 1;
1635
- if (e.key === "Tab") {
1636
- e.preventDefault(), e.stopPropagation();
1637
- let n = r * this.cols() + i + (e.shiftKey ? -1 : 1);
1638
- if (n < 0) return;
1639
- if (n >= this.rows.length * this.cols()) {
1640
- if (e.shiftKey) return;
1641
- this.appendRow(), this.cellAt(a + 1, 0)?.focus(), this.sync(t);
1642
- return;
1643
- }
1644
- this.cellAt(Math.floor(n / this.cols()), n % this.cols())?.focus();
1645
- return;
1646
- }
1647
- if (e.key === "Enter") {
1648
- if (e.preventDefault(), e.stopPropagation(), r < a) return this.cellAt(r + 1, i)?.focus();
1649
- this.appendRow(), this.cellAt(a + 1, i)?.focus(), this.sync(t);
1650
- return;
1651
- }
1652
- let o = this.cols(), s = () => {
1653
- let { to: e } = this.bounds(t);
1654
- if (t.focus(), e >= t.state.doc.length) {
1655
- t.dispatch({
1656
- changes: {
1657
- from: e,
1658
- insert: "\n"
1659
- },
1660
- selection: { anchor: e + 1 }
1661
- });
1662
- return;
1712
+ this.table && yn(e, t, {
1713
+ coords: (e) => this.coords(e),
1714
+ rows: () => this.rows.length,
1715
+ cols: () => this.cols(),
1716
+ cellAt: (e, t) => this.cellAt(e, t),
1717
+ cellText: (e, t) => this.rows[e]?.[t] ?? "",
1718
+ appendRow: () => this.appendRow(),
1719
+ sync: (e) => this.sync(e),
1720
+ bounds: (e) => this.bounds(e),
1721
+ readCaret: () => this.readCaret(),
1722
+ enterCell: (e, t) => {
1723
+ this.pendingOffset = t, e.focus();
1663
1724
  }
1664
- t.dispatch({ selection: { anchor: e + 1 } });
1665
- }, c = () => {
1666
- let { from: e } = this.bounds(t);
1667
- t.focus(), t.dispatch({ selection: { anchor: Math.max(e - 1, 0) } });
1668
- }, l = (e, t) => {
1669
- let n = this.cellAt(Math.floor(e / o), e % o);
1670
- n && (this.pendingOffset = t, n.focus());
1671
- };
1672
- if (e.key === "ArrowDown") {
1673
- e.preventDefault(), e.stopPropagation(), r === a ? s() : l((r + 1) * o + i, this.readCaret()?.offset ?? 0);
1674
- return;
1675
- }
1676
- if (e.key === "ArrowUp") {
1677
- e.preventDefault(), e.stopPropagation(), r === 0 ? c() : l((r - 1) * o + i, this.readCaret()?.offset ?? 0);
1678
- return;
1679
- }
1680
- if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
1681
- let t = e.key === "ArrowLeft", a = this.readCaret();
1682
- if (!a || a.offset !== a.head || (t ? a.offset > 0 : a.offset < (n.textContent ?? "").length)) return;
1683
- e.preventDefault(), e.stopPropagation();
1684
- let u = r * o + i + (t ? -1 : 1);
1685
- if (u < 0) return c();
1686
- if (u >= this.rows.length * o) return s();
1687
- l(u, t ? (this.rows[Math.floor(u / o)]?.[u % o] ?? "").length : 0);
1688
- return;
1689
- }
1725
+ });
1690
1726
  }
1691
1727
  focusEdge(e) {
1692
1728
  if (!this.table) return !1;
@@ -1696,8 +1732,8 @@ var wn = P.define({
1696
1732
  openCellMenuAt(e, t, n, r) {
1697
1733
  let i = r?.closest("td, th");
1698
1734
  if (!i) return;
1699
- this.editing === i && !X(e) && d(i, t, n);
1700
- let a = X(e) ? en(e) : void 0;
1735
+ this.editing === i && !Y(e) && s(i, t, n);
1736
+ let a = Y(e) ? pn(e) : void 0;
1701
1737
  this.gizmos?.openFor(i, t, n, a);
1702
1738
  }
1703
1739
  toDOM(e) {
@@ -1707,7 +1743,7 @@ var wn = P.define({
1707
1743
  this.table = n, this.editing = null, n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(), n.addEventListener("mousedown", (e) => {
1708
1744
  e.stopPropagation();
1709
1745
  let t = e.target.closest("td, th");
1710
- this.pendingOffset = t && t !== this.editing ? l(t, e.clientX, e.clientY) : null;
1746
+ this.pendingOffset = t && t !== this.editing ? ue(t, e.clientX, e.clientY) : null;
1711
1747
  }), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
1712
1748
  let r = (t) => {
1713
1749
  t && (this.editing = t, this.finish(t, !0), this.sync(e));
@@ -1720,9 +1756,9 @@ var wn = P.define({
1720
1756
  document.execCommand("insertText", !1, t);
1721
1757
  }), n.addEventListener("contextmenu", (t) => {
1722
1758
  t.target.closest("td, th") && (t.preventDefault(), t.stopPropagation(), this.longPress?.cancel(), !(Date.now() - this.longPressAt < 700) && this.openCellMenuAt(e, t.clientX, t.clientY, t.target));
1723
- }), this.longPress = an(n, { onLongPress: (t, n, r) => {
1759
+ }), this.longPress = _n(n, { onLongPress: (t, n, r) => {
1724
1760
  this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
1725
- } }), this.gizmos = on(document, {
1761
+ } }), this.gizmos = vn(document, {
1726
1762
  dims: () => ({
1727
1763
  cols: this.cols(),
1728
1764
  rows: this.rows.length,
@@ -1734,12 +1770,12 @@ var wn = P.define({
1734
1770
  destroy() {
1735
1771
  this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.editing = null;
1736
1772
  }
1737
- }, Dn = /* @__PURE__ */ new Set([
1773
+ }, Bn = /* @__PURE__ */ new Set([
1738
1774
  "-",
1739
1775
  "*",
1740
1776
  "_"
1741
- ]), On = me.transactionFilter.of((e) => {
1742
- if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(Tn) || !e.startState.selection.main.empty) return e;
1777
+ ]), Vn = Ce.transactionFilter.of((e) => {
1778
+ if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($) || !e.startState.selection.main.empty) return e;
1743
1779
  let t = e.startState.selection.main.head, n = "", r = 0;
1744
1780
  if (e.changes.iterChanges((e, i, a, o, s) => {
1745
1781
  r += 1, e === i && e === t && (n = s.toString());
@@ -1769,7 +1805,7 @@ var wn = P.define({
1769
1805
  },
1770
1806
  anchor: a + 1
1771
1807
  };
1772
- else if (Dn.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
1808
+ else if (Bn.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
1773
1809
  let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
1774
1810
  if (t || r) {
1775
1811
  let e = [];
@@ -1792,38 +1828,38 @@ var wn = P.define({
1792
1828
  scrollIntoView: !0,
1793
1829
  userEvent: "input.autoformat"
1794
1830
  }] : e;
1795
- }), kn = /* @__PURE__ */ new Set([
1831
+ }), Hn = /* @__PURE__ */ new Set([
1796
1832
  "EmphasisMark",
1797
1833
  "CodeMark",
1798
1834
  "StrikethroughMark"
1799
1835
  ]);
1800
- function An(e, t, n) {
1836
+ function Un(e, t, n) {
1801
1837
  let r = t;
1802
1838
  for (;;) {
1803
1839
  let t = e.resolveInner(r, n);
1804
- if (!kn.has(t.name) || t.from >= t.to) return r;
1840
+ if (!Hn.has(t.name) || t.from >= t.to) return r;
1805
1841
  let i = n < 0 ? t.from : t.to;
1806
1842
  if (i === r) return r;
1807
1843
  r = i;
1808
1844
  }
1809
1845
  }
1810
- function jn(e, t) {
1811
- let n = U(e, t, !0);
1846
+ function Wn(e, t) {
1847
+ let n = H(e, t, !0);
1812
1848
  if (!n) return t;
1813
- let r = F(e);
1814
- return t === n.contentTo ? An(r, t, 1) : t === n.contentFrom ? An(r, t, -1) : t;
1849
+ let r = N(e);
1850
+ return t === n.contentTo ? Un(r, t, 1) : t === n.contentFrom ? Un(r, t, -1) : t;
1815
1851
  }
1816
- var Mn = me.transactionFilter.of((e) => {
1817
- if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(Tn)) return e;
1852
+ var Gn = Ce.transactionFilter.of((e) => {
1853
+ if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($)) return e;
1818
1854
  let t = e.startState, n = t.selection.main;
1819
- if (!n.empty || !H(t, t.doc.lineAt(n.head).number)) return e;
1855
+ if (!n.empty || !V(t, t.doc.lineAt(n.head).number)) return e;
1820
1856
  let r = [], i = 0;
1821
1857
  e.changes.iterChanges((e, t, a, o, s) => {
1822
1858
  i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
1823
1859
  });
1824
1860
  let a = r[0];
1825
1861
  if (i !== 1 || a === void 0) return e;
1826
- let o = jn(t, n.head);
1862
+ let o = Wn(t, n.head);
1827
1863
  return o === n.head ? e : {
1828
1864
  changes: {
1829
1865
  from: o,
@@ -1833,54 +1869,61 @@ var Mn = me.transactionFilter.of((e) => {
1833
1869
  scrollIntoView: !0,
1834
1870
  userEvent: "input.type"
1835
1871
  };
1836
- });
1837
- //#endregion
1838
- //#region src/inplace/edit-line-prefix.ts
1839
- function Nn(e) {
1840
- let t = /^#{1,6} /.exec(e);
1841
- if (t) return {
1842
- prefixLen: t[0].length,
1843
- drop: [0, t[0].length]
1844
- };
1845
- let n = /^(?:> ?)+/.exec(e);
1846
- if (n) {
1847
- let t = /^> ?/.exec(e)[0].length;
1848
- return {
1849
- prefixLen: n[0].length,
1850
- drop: [0, t]
1851
- };
1872
+ }), Kn = RegExp(`^(?:${se.match.source.replace(/^\^/, "")})+`);
1873
+ function qn(e, t) {
1874
+ let n = e.doc.lineAt(t).number;
1875
+ for (let r = N(e).resolveInner(t, 1); r; r = r.parent) {
1876
+ if (r.name !== "ListItem" || e.doc.lineAt(r.from).number === n) continue;
1877
+ let t = u.exec(e.doc.lineAt(r.from).text);
1878
+ if (t) return t[0].length;
1852
1879
  }
1853
- let r = /^(\s*)[-*+] \[[ xX]\] /.exec(e);
1880
+ return null;
1881
+ }
1882
+ function Jn(e, t) {
1883
+ let n = t.text, r = ae.exec(n);
1854
1884
  if (r) return {
1855
1885
  prefixLen: r[0].length,
1856
1886
  drop: [0, r[0].length]
1857
1887
  };
1858
- let i = /^(\s*)([-*+] |\d+[.)] )/.exec(e);
1888
+ let i = Kn.exec(n);
1859
1889
  if (i) {
1860
- let e = i[1];
1861
- if (e) {
1862
- let t = e.startsWith(" ") ? 1 : Math.min(2, e.length);
1890
+ let e = se.match.exec(n)[0].length;
1891
+ return {
1892
+ prefixLen: i[0].length,
1893
+ drop: [0, e]
1894
+ };
1895
+ }
1896
+ let a = f.match.exec(n);
1897
+ if (a) return {
1898
+ prefixLen: a[0].length,
1899
+ drop: [0, a[0].length]
1900
+ };
1901
+ let o = te.match.exec(n) ?? ie.match.exec(n);
1902
+ if (o) {
1903
+ let n = o[1] ?? "", r = o[0].length - n.length;
1904
+ if (n) {
1905
+ let r = qn(e, t.from) ?? 2, i = n.startsWith(" ") ? 1 : Math.min(r, n.length);
1863
1906
  return {
1864
- prefixLen: i[0].length,
1865
- drop: [0, t]
1907
+ prefixLen: o[0].length,
1908
+ drop: [0, i]
1866
1909
  };
1867
1910
  }
1868
1911
  return {
1869
- prefixLen: i[2].length,
1870
- drop: [0, i[2].length]
1912
+ prefixLen: r,
1913
+ drop: [0, r]
1871
1914
  };
1872
1915
  }
1873
1916
  return null;
1874
1917
  }
1875
- var Pn = N.high(j.of([{
1918
+ var Yn = j.high(k.of([{
1876
1919
  key: "Backspace",
1877
1920
  run: (e) => {
1878
- if (p(e)) return !1;
1921
+ if (h(e)) return !1;
1879
1922
  let { state: t } = e, n = t.selection.main;
1880
1923
  if (!n.empty) return !1;
1881
1924
  let r = t.doc.lineAt(n.head);
1882
- if (!H(t, r.number)) return !1;
1883
- let i = Nn(r.text);
1925
+ if (!V(t, r.number)) return !1;
1926
+ let i = Jn(t, r);
1884
1927
  if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
1885
1928
  let [a, o] = i.drop;
1886
1929
  return e.dispatch({
@@ -1894,13 +1937,13 @@ var Pn = N.high(j.of([{
1894
1937
  scrollIntoView: !0
1895
1938
  }), !0;
1896
1939
  }
1897
- }])), Fn = class {
1940
+ }])), Xn = class {
1898
1941
  menu;
1899
1942
  contentDOM;
1900
1943
  onClick;
1901
1944
  constructor(e) {
1902
- this.menu = Y(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
1903
- if (e.state.facet(R) !== "never" || !e.state.facet(I).links) return;
1945
+ this.menu = J(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
1946
+ if (e.state.facet(L) !== "never" || !e.state.facet(P).links) return;
1904
1947
  let n = t.target?.closest(".cm-inplace-link");
1905
1948
  if (!n || n.classList.contains("cm-inplace-wikilink")) return;
1906
1949
  let r = e.posAtDOM(n);
@@ -1912,13 +1955,13 @@ var Pn = N.high(j.of([{
1912
1955
  if (n == null) return;
1913
1956
  r = n;
1914
1957
  }
1915
- e.dispatch({ selection: { anchor: r } }), this.menu.showField(Vt(e), t.clientX, t.clientY);
1958
+ e.dispatch({ selection: { anchor: r } }), this.menu.showField($t(e), t.clientX, t.clientY);
1916
1959
  }, this.contentDOM.addEventListener("click", this.onClick);
1917
1960
  }
1918
1961
  destroy() {
1919
1962
  this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
1920
1963
  }
1921
- }, In = k.fromClass(Fn), Ln = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), Rn = (e, t, n) => n ? {
1964
+ }, Zn = D.fromClass(Xn), Qn = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), $n = (e, t, n) => n ? {
1922
1965
  pos: e,
1923
1966
  end: t,
1924
1967
  above: !0,
@@ -1927,27 +1970,27 @@ var Pn = N.high(j.of([{
1927
1970
  return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
1928
1971
  }
1929
1972
  } : null;
1930
- function zn(e, t) {
1931
- for (let n = F(e.state).resolveInner(t, -1); n; n = n.parent) {
1973
+ function er(e, t) {
1974
+ for (let n = N(e.state).resolveInner(t, -1); n; n = n.parent) {
1932
1975
  if (n.name !== "Link") continue;
1933
1976
  if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
1934
1977
  let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
1935
- return Rn(n.from, n.to, Ln(r));
1978
+ return $n(n.from, n.to, Qn(r));
1936
1979
  }
1937
1980
  return null;
1938
1981
  }
1939
- function Bn(t, n) {
1982
+ function tr(t, n) {
1940
1983
  let r = t.state.doc.lineAt(n);
1941
1984
  for (let t of r.text.matchAll(e)) {
1942
1985
  let e = r.from + (t.index ?? 0), i = e + t[0].length;
1943
- if (!(n < e || n > i)) return Rn(e, i, (t[1] ?? "").trim());
1986
+ if (!(n < e || n > i)) return $n(e, i, (t[1] ?? "").trim());
1944
1987
  }
1945
1988
  return null;
1946
1989
  }
1947
- var Vn = le((e, t) => {
1948
- let n = e.state.facet(I);
1949
- return (n.links ? zn(e, t) : null) ?? (n.wikilinks ? Bn(e, t) : null);
1950
- }), Hn = class extends A {
1990
+ var nr = ve((e, t) => {
1991
+ let n = e.state.facet(P);
1992
+ return (n.links ? er(e, t) : null) ?? (n.wikilinks ? tr(e, t) : null);
1993
+ }), rr = class extends O {
1951
1994
  ref;
1952
1995
  inline;
1953
1996
  registry;
@@ -1974,45 +2017,52 @@ var Vn = le((e, t) => {
1974
2017
  return !1;
1975
2018
  }
1976
2019
  };
1977
- function Un(e) {
1978
- let t = e.facet(L);
1979
- if (!t || !e.facet(I).embeds || !e.doc.toString().includes("![[")) return D.none;
1980
- let n = B(e), r = F(e), i = [];
2020
+ function ir(e) {
2021
+ let t = e.facet(F);
2022
+ if (!t || !e.facet(P).embeds || !e.doc.toString().includes("![[")) return T.none;
2023
+ let n = z(e), r = N(e), i = [];
1981
2024
  for (let a = 1; a <= e.doc.lines; a++) {
1982
2025
  let o = e.doc.line(a);
1983
2026
  if (!(!o.text.includes("![[") || n.has(a))) {
1984
- if (ae(o.text)) {
1985
- w.lastIndex = 0;
1986
- let e = (w.exec(o.text.trim())?.[1] ?? "").trim();
1987
- if (!e || V(r, o.from + o.text.indexOf("!["))) continue;
1988
- i.push(D.replace({
1989
- widget: new Hn(e, !1, t),
2027
+ if (pe(o.text)) {
2028
+ S.lastIndex = 0;
2029
+ let e = (S.exec(o.text.trim())?.[1] ?? "").trim();
2030
+ if (!e || B(r, o.from + o.text.indexOf("!["))) continue;
2031
+ i.push(T.replace({
2032
+ widget: new rr(e, !1, t),
1990
2033
  block: !0
1991
2034
  }).range(o.from, o.to));
1992
2035
  continue;
1993
2036
  }
1994
- w.lastIndex = 0;
1995
- for (let e of o.text.matchAll(w)) {
2037
+ S.lastIndex = 0;
2038
+ for (let e of o.text.matchAll(S)) {
1996
2039
  let n = (e[1] ?? "").trim();
1997
2040
  if (!n) continue;
1998
2041
  let a = o.from + (e.index ?? 0);
1999
- V(r, a + 2) || Fe(r, a + 2) || i.push(D.replace({ widget: new Hn(n, !0, t) }).range(a, a + e[0].length));
2042
+ B(r, a + 2) || Ue(r, a + 2) || i.push(T.replace({ widget: new rr(n, !0, t) }).range(a, a + e[0].length));
2000
2043
  }
2001
2044
  }
2002
2045
  }
2003
- return D.set(i, !0);
2046
+ return T.set(i, !0);
2004
2047
  }
2005
- var Wn = P.define({
2006
- create: Un,
2007
- update: (e, t) => t.docChanged || t.selection ? Un(t.state) : e,
2008
- provide: (e) => [O.decorations.from(e), O.atomicRanges.of((t) => t.state.field(e))]
2009
- }), Gn = he.define(), Kn = P.define({
2048
+ function ar(e, t) {
2049
+ for (let n of t.ranges) {
2050
+ let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
2051
+ for (let n = t; n <= r; n++) if (e.doc.line(n).text.includes("![[")) return !0;
2052
+ }
2053
+ return !1;
2054
+ }
2055
+ var or = M.define({
2056
+ create: ir,
2057
+ update: (e, t) => t.docChanged || t.selection && (ar(t.state, t.startState.selection) || ar(t.state, t.state.selection)) ? ir(t.state) : e,
2058
+ provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
2059
+ }), sr = we.define(), cr = M.define({
2010
2060
  create: () => !1,
2011
2061
  update(e, t) {
2012
- for (let n of t.effects) n.is(Gn) && (e = n.value);
2062
+ for (let n of t.effects) n.is(sr) && (e = n.value);
2013
2063
  return e;
2014
2064
  }
2015
- }), qn = class {
2065
+ }), lr = class {
2016
2066
  view;
2017
2067
  menu;
2018
2068
  onContextMenu;
@@ -2023,8 +2073,8 @@ var Wn = P.define({
2023
2073
  longPressAt = 0;
2024
2074
  destroyed = !1;
2025
2075
  constructor(e) {
2026
- this.view = e, this.menu = Y(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
2027
- this.destroyed || e.dispatch({ effects: Gn.of(t) });
2076
+ this.view = e, this.menu = J(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
2077
+ this.destroyed || e.dispatch({ effects: sr.of(t) });
2028
2078
  }), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
2029
2079
  let t = e.state.selection.main;
2030
2080
  this.stashed = t.empty ? null : {
@@ -2033,18 +2083,18 @@ var Wn = P.define({
2033
2083
  };
2034
2084
  }, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (t) => {
2035
2085
  let n = t.target;
2036
- !e.state.facet(Ce) || e.state.readOnly || n?.closest(".cm-inplace-table-edit") || (t.preventDefault(), this.longPress.cancel(), !(Date.now() - this.longPressAt < 700) && this.openMenuAt(t.clientX, t.clientY, n));
2037
- }, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = an(this.contentDOM, { onLongPress: (e, t, n) => {
2086
+ !e.state.facet(je) || e.state.readOnly || n?.closest(".cm-inplace-table-edit") || (t.preventDefault(), this.longPress.cancel(), !(Date.now() - this.longPressAt < 700) && this.openMenuAt(t.clientX, t.clientY, n));
2087
+ }, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = _n(this.contentDOM, { onLongPress: (e, t, n) => {
2038
2088
  this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
2039
2089
  } });
2040
2090
  }
2041
2091
  openMenuAt(e, t, n) {
2042
2092
  let r = this.view;
2043
- if (!r.state.facet(Ce) || r.state.readOnly || n?.closest(".cm-inplace-table-edit")) return;
2093
+ if (!r.state.facet(je) || r.state.readOnly || n?.closest(".cm-inplace-table-edit")) return;
2044
2094
  let i = n?.closest(".cm-inplace-hr");
2045
2095
  if (i) {
2046
2096
  let n = r.posAtDOM(i);
2047
- n >= 0 && r.dispatch({ selection: { anchor: n } }), this.menu.show(rn(r), e, t);
2097
+ n >= 0 && r.dispatch({ selection: { anchor: n } }), this.menu.show(gn(r), e, t);
2048
2098
  return;
2049
2099
  }
2050
2100
  if (this.stashed && r.state.selection.main.empty) r.dispatch({ selection: this.stashed });
@@ -2054,7 +2104,7 @@ var Wn = P.define({
2054
2104
  y: t
2055
2105
  });
2056
2106
  if (n != null) {
2057
- let e = U(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
2107
+ let e = H(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
2058
2108
  e?.kind === "link" ? t = {
2059
2109
  anchor: e.from,
2060
2110
  head: e.to
@@ -2064,15 +2114,15 @@ var Wn = P.define({
2064
2114
  }), r.dispatch({ selection: t });
2065
2115
  }
2066
2116
  }
2067
- this.menu.show(rn(r), e, t);
2117
+ this.menu.show(gn(r), e, t);
2068
2118
  }
2069
2119
  destroy() {
2070
2120
  this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
2071
2121
  }
2072
- }, Jn = k.fromClass(qn);
2122
+ }, ur = D.fromClass(lr);
2073
2123
  //#endregion
2074
2124
  //#region src/inplace/selection-bar-position.ts
2075
- function Yn(e) {
2125
+ function dr(e) {
2076
2126
  let t = e.state.selection.main;
2077
2127
  if (!t.empty) {
2078
2128
  let n = e.coordsAtPos(t.from), r = e.coordsAtPos(t.to);
@@ -2086,7 +2136,7 @@ function Yn(e) {
2086
2136
  }
2087
2137
  };
2088
2138
  }
2089
- if (!X(e)) return null;
2139
+ if (!Y(e)) return null;
2090
2140
  let n = e.dom.ownerDocument.getSelection();
2091
2141
  if (!n || n.rangeCount === 0) return null;
2092
2142
  let r = n.getRangeAt(0).getBoundingClientRect();
@@ -2100,15 +2150,15 @@ function Yn(e) {
2100
2150
  }
2101
2151
  };
2102
2152
  }
2103
- function Xn(e, t, n) {
2104
- if (e.state.facet(ke) !== "bar" || e.state.readOnly || e.state.field(Kn, !1)) return null;
2105
- let r = Yn(e);
2153
+ function fr(e, t, n) {
2154
+ if (e.state.facet(Le) !== "bar" || e.state.readOnly || e.state.field(cr, !1)) return null;
2155
+ let r = dr(e);
2106
2156
  if (!r) return null;
2107
2157
  let { box: i, inCell: a } = r;
2108
2158
  if (!a && !e.hasFocus) return null;
2109
2159
  let o = t.getBoundingClientRect(), s = e.dom.ownerDocument.defaultView?.innerWidth ?? 0, c = (i.left + i.right) / 2, l = e.dom.getBoundingClientRect().top, u = i.top - o.height - 6, d = i.bottom + 6, f = {}, p = {};
2110
2160
  for (let t of n) {
2111
- let n = h[t], r = !a && !!n.disabled?.(e.state);
2161
+ let n = _[t], r = !a && !!n.disabled?.(e.state);
2112
2162
  f[t] = r, p[t] = !r && !a && !!n.isActive?.(e.state);
2113
2163
  }
2114
2164
  return n.every((e) => f[e]) ? null : {
@@ -2120,7 +2170,7 @@ function Xn(e, t, n) {
2120
2170
  }
2121
2171
  //#endregion
2122
2172
  //#region src/inplace/selection-bar.ts
2123
- var Zn = class {
2173
+ var pr = class {
2124
2174
  view;
2125
2175
  bar;
2126
2176
  ids;
@@ -2130,17 +2180,17 @@ var Zn = class {
2130
2180
  this.bar.hidden = !0;
2131
2181
  };
2132
2182
  onSelectionChange = () => {
2133
- p(this.view) && this.schedule();
2183
+ h(this.view) && this.schedule();
2134
2184
  };
2135
2185
  constructor(e) {
2136
2186
  this.view = e;
2137
2187
  let t = e.dom.ownerDocument;
2138
- this.ids = e.state.facet(Oe), this.linkMenu = Y(t), e.dom.appendChild(this.linkMenu.el), this.bar = t.createElement("div"), this.bar.className = "cm-inplace-selbar", this.bar.setAttribute("contenteditable", "false"), this.bar.hidden = !0;
2188
+ this.ids = e.state.facet(Ie), this.linkMenu = J(t), e.dom.appendChild(this.linkMenu.el), this.bar = t.createElement("div"), this.bar.className = "cm-inplace-selbar", this.bar.setAttribute("contenteditable", "false"), this.bar.hidden = !0;
2139
2189
  for (let n of this.ids) {
2140
- let r = h[n], i = t.createElement("button");
2141
- i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(ie(t, x[n] ?? "")), i.addEventListener("mousedown", (e) => e.preventDefault()), i.addEventListener("click", (t) => {
2190
+ let r = _[n], i = t.createElement("button");
2191
+ i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(de(t, x[n] ?? "")), i.addEventListener("mousedown", (e) => e.preventDefault()), i.addEventListener("click", (t) => {
2142
2192
  t.preventDefault();
2143
- let a = !!p(e), o = !a && n === "link" ? Vt(e) : !a && n === "wikilink" ? Ht(e) : null;
2193
+ let a = !!h(e), o = !a && n === "link" ? $t(e) : !a && n === "wikilink" ? en(e) : null;
2144
2194
  if (o) {
2145
2195
  let e = i.getBoundingClientRect();
2146
2196
  this.linkMenu.showField(o, e.left, e.bottom + 6);
@@ -2152,7 +2202,7 @@ var Zn = class {
2152
2202
  e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
2153
2203
  }
2154
2204
  update(e) {
2155
- let t = e.startState.field(Kn, !1) !== e.state.field(Kn, !1), n = e.startState.readOnly !== e.state.readOnly;
2205
+ let t = e.startState.field(cr, !1) !== e.state.field(cr, !1), n = e.startState.readOnly !== e.state.readOnly;
2156
2206
  (e.selectionSet || e.docChanged || e.focusChanged || t || n) && this.schedule();
2157
2207
  }
2158
2208
  schedule() {
@@ -2163,7 +2213,7 @@ var Zn = class {
2163
2213
  });
2164
2214
  }
2165
2215
  measure() {
2166
- return Xn(this.view, this.bar, this.ids);
2216
+ return fr(this.view, this.bar, this.ids);
2167
2217
  }
2168
2218
  apply(e) {
2169
2219
  if (!e) {
@@ -2177,30 +2227,30 @@ var Zn = class {
2177
2227
  let e = this.view.dom.ownerDocument;
2178
2228
  e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
2179
2229
  }
2180
- }, Qn = k.fromClass(Zn), $n = (e) => (t) => {
2181
- if (p(t)) return !1;
2230
+ }, mr = D.fromClass(pr), hr = (e) => (t) => {
2231
+ if (h(t)) return !1;
2182
2232
  let n = t.state.selection.main;
2183
2233
  if (!n.empty) return !1;
2184
2234
  let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
2185
2235
  if (a < 1 || a > r.lines) return !1;
2186
2236
  let o = r.line(a), s = -1, c = -1, l;
2187
- if (t.state.field(wn).between(o.from, o.to, (t, n, r) => {
2237
+ if (t.state.field(Rn).between(o.from, o.to, (t, n, r) => {
2188
2238
  if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
2189
2239
  }), s < 0) return !1;
2190
- if (t.state.facet(xe) === "cells") return l instanceof En && l.focusEdge(e ? "first" : "last");
2240
+ if (t.state.facet(I) === "cells") return l instanceof zn && l.focusEdge(e ? "first" : "last");
2191
2241
  let u = e ? r.lineAt(s).from : r.lineAt(c).to;
2192
2242
  return t.dispatch({
2193
2243
  selection: { anchor: u },
2194
2244
  userEvent: "select",
2195
2245
  scrollIntoView: !0
2196
2246
  }), !0;
2197
- }, er = $n(!0), tr = $n(!1), nr = N.high(j.of([{
2247
+ }, gr = hr(!0), _r = hr(!1), vr = j.high(k.of([{
2198
2248
  key: "ArrowDown",
2199
- run: er
2249
+ run: gr
2200
2250
  }, {
2201
2251
  key: "ArrowUp",
2202
- run: tr
2203
- }])), rr = {
2252
+ run: _r
2253
+ }])), yr = {
2204
2254
  ".cm-inplace-callout": {
2205
2255
  borderLeft: "0.25rem solid var(--stylo-callout-accent, var(--stylo-border))",
2206
2256
  padding: "0 var(--stylo-rhythm-callout-padding-x, 1rem)",
@@ -2234,9 +2284,9 @@ var Zn = class {
2234
2284
  content: "\"\"",
2235
2285
  display: "none"
2236
2286
  }
2237
- }, ir = "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)", ar = "var(--stylo-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif)", or = {
2287
+ }, br = "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)", xr = "var(--stylo-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif)", Sr = {
2238
2288
  "& .cm-content": {
2239
- fontFamily: ar,
2289
+ fontFamily: xr,
2240
2290
  lineHeight: "1.75",
2241
2291
  padding: "0.75rem",
2242
2292
  WebkitTouchCallout: "none"
@@ -2279,14 +2329,14 @@ var Zn = class {
2279
2329
  ".cm-inplace-em": { fontStyle: "italic" },
2280
2330
  ".cm-inplace-strike": { textDecoration: "line-through" },
2281
2331
  ".cm-inplace-code": {
2282
- fontFamily: ir,
2332
+ fontFamily: br,
2283
2333
  fontSize: "0.9em",
2284
2334
  padding: "0.1em 0.35em",
2285
2335
  borderRadius: "3px",
2286
2336
  background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
2287
2337
  },
2288
2338
  ".cm-inplace-mono": {
2289
- fontFamily: ir,
2339
+ fontFamily: br,
2290
2340
  fontSize: "0.9em",
2291
2341
  background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
2292
2342
  padding: "0 0.9rem"
@@ -2364,21 +2414,21 @@ var Zn = class {
2364
2414
  cursor: "pointer"
2365
2415
  },
2366
2416
  ".cm-inplace-fm": {
2367
- fontFamily: ir,
2417
+ fontFamily: br,
2368
2418
  fontSize: "0.85em",
2369
2419
  color: "var(--stylo-text-muted)"
2370
2420
  },
2371
2421
  ".cm-inplace-fm-first::before": {
2372
2422
  content: "\"Frontmatter\"",
2373
2423
  marginRight: "0.6em",
2374
- fontFamily: ar,
2424
+ fontFamily: xr,
2375
2425
  fontSize: "0.8rem",
2376
2426
  fontWeight: "600",
2377
2427
  textTransform: "uppercase",
2378
2428
  letterSpacing: "0.04em",
2379
2429
  color: "var(--stylo-text-muted)"
2380
2430
  }
2381
- }, sr = {
2431
+ }, Cr = {
2382
2432
  ".cm-inplace-menu": {
2383
2433
  position: "fixed",
2384
2434
  inset: "0",
@@ -2452,7 +2502,7 @@ var Zn = class {
2452
2502
  outline: "none"
2453
2503
  },
2454
2504
  ".cm-inplace-menu-input:focus": { borderColor: "var(--stylo-ring)" }
2455
- }, cr = {
2505
+ }, wr = {
2456
2506
  ".cm-inplace-selbar": {
2457
2507
  position: "fixed",
2458
2508
  zIndex: "20",
@@ -2537,7 +2587,7 @@ var Zn = class {
2537
2587
  lineHeight: "1.4",
2538
2588
  wordBreak: "break-all"
2539
2589
  }
2540
- }, lr = {
2590
+ }, Tr = {
2541
2591
  ".cm-inplace-table": {
2542
2592
  borderCollapse: "collapse",
2543
2593
  padding: "1em 0 1.4em",
@@ -2560,7 +2610,7 @@ var Zn = class {
2560
2610
  outline: "none"
2561
2611
  },
2562
2612
  ".cm-inplace-table-edit .cm-inplace-tcell:focus": { boxShadow: "inset 0 0 0 2px var(--stylo-ring)" }
2563
- }, ur = {
2613
+ }, Er = {
2564
2614
  ".cm-inplace-table-wrap": {
2565
2615
  position: "relative",
2566
2616
  display: "inline-block",
@@ -2602,70 +2652,57 @@ var Zn = class {
2602
2652
  },
2603
2653
  ".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
2604
2654
  "@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
2605
- }, dr = O.theme({
2606
- ...or,
2607
- ...rr,
2608
- ...lr,
2609
- ...ur,
2610
- ...sr,
2611
- ...cr
2612
- }), fr = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
2613
- function pr(e, t, n) {
2614
- let r = e.firstChild, i = e.textContent?.length ?? 0;
2615
- if (!r || r.nodeType !== Node.TEXT_NODE || i === 0) return 0;
2616
- let a = e.ownerDocument, o = null, s = 0;
2617
- if (a.caretPositionFromPoint) {
2618
- let e = a.caretPositionFromPoint(t, n);
2619
- e && ([o, s] = [e.offsetNode, e.offset]);
2620
- } else if (a.caretRangeFromPoint) {
2621
- let e = a.caretRangeFromPoint(t, n);
2622
- e && ([o, s] = [e.startContainer, e.startOffset]);
2623
- }
2624
- return o === r ? Math.min(s, i) : o === e && s > 0 ? i : 0;
2625
- }
2626
- function mr(e = {}) {
2627
- let t = Te(e.inPlace?.contextMenu);
2655
+ }, Dr = E.theme({
2656
+ ...Sr,
2657
+ ...yr,
2658
+ ...Tr,
2659
+ ...Er,
2660
+ ...Cr,
2661
+ ...wr
2662
+ }), Or = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
2663
+ function kr(e = {}) {
2664
+ let t = Ne(e.inPlace?.contextMenu);
2628
2665
  return [
2629
- I.of(be(e.inPlace)),
2630
- L.of(e.embedRegistry ?? null),
2631
- xe.of(e.inPlace?.table ?? "source"),
2632
- R.of(e.inPlace?.reveal ?? "caret"),
2633
- Se.of(e.onLinkClick ?? null),
2634
- Ce.of(t.enabled),
2635
- Ee.of(t.groups),
2636
- ke.of(e.inPlace?.selectionUI ?? "menu"),
2637
- Oe.of(De(e.inPlace?.selectionBarItems)),
2638
- mt(),
2639
- Pn,
2640
- It,
2641
- Tt,
2642
- nr,
2643
- Mn,
2644
- On,
2645
- Ue,
2646
- Wn,
2647
- je,
2648
- wn,
2649
- Kn,
2650
- Jn,
2651
- Qn,
2652
- In,
2666
+ P.of(ke(e.inPlace)),
2667
+ F.of(e.embedRegistry ?? null),
2668
+ I.of(e.inPlace?.table ?? "source"),
2669
+ L.of(e.inPlace?.reveal ?? "caret"),
2670
+ Ae.of(e.onLinkClick ?? null),
2671
+ je.of(t.enabled),
2672
+ Pe.of(t.groups),
2673
+ Le.of(e.inPlace?.selectionUI ?? "menu"),
2674
+ Ie.of(Fe(e.inPlace?.selectionBarItems)),
2675
+ Ct(),
2676
+ Yn,
2677
+ Gt,
2678
+ Pt,
2679
+ vr,
2680
+ Gn,
2653
2681
  Vn,
2654
- Xt,
2655
- Zt,
2656
- N.high(dr),
2657
- O.domEventHandlers({
2682
+ Qe,
2683
+ or,
2684
+ ze,
2685
+ Rn,
2686
+ cr,
2687
+ ur,
2688
+ mr,
2689
+ Zn,
2690
+ nr,
2691
+ ln,
2692
+ un,
2693
+ j.high(Dr),
2694
+ E.domEventHandlers({
2658
2695
  mousedown(e, t) {
2659
2696
  let n = e.target;
2660
2697
  if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
2661
- let r = n?.closest(fr);
2698
+ let r = n?.closest(Or);
2662
2699
  if (!r) return !1;
2663
2700
  let i = t.posAtDOM(r);
2664
2701
  if (i < 0) return !1;
2665
2702
  let a = n?.closest("[data-stylo-row]");
2666
2703
  if (a && r.contains(a)) {
2667
- let n = f(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
2668
- n != null && (i = n + pr(a, e.clientX, e.clientY));
2704
+ let n = v(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
2705
+ n != null && (i = n + ue(a, e.clientX, e.clientY));
2669
2706
  }
2670
2707
  return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
2671
2708
  },
@@ -2679,48 +2716,49 @@ function mr(e = {}) {
2679
2716
  }
2680
2717
  //#endregion
2681
2718
  //#region src/inplace/InPlaceView.tsx
2682
- var hr = () => () => {}, gr = () => null;
2683
- function _r({ value: e, onChange: n, readOnly: i, placeholder: a, onWikiLinkClick: o, onLinkClick: s, inPlace: c, codeLanguages: l, wikiLinkSource: u, tagSource: d, embedSource: f, onResolveError: p, onSave: m, onViewChange: h, canvasHeader: g }) {
2684
- let _ = T(o);
2685
- _.current = o;
2686
- let ee = T(s);
2687
- ee.current = s;
2688
- let [v] = E(() => new ve()), ne = ce(v.subscribe, v.getSnapshot, v.getSnapshot), [re, y] = E(null), b = T(h);
2689
- b.current = h;
2690
- let ie = T((e) => {
2691
- y(e), b.current?.(e);
2692
- }).current, x = T(g);
2693
- x.current = g;
2694
- let [S] = E(() => g ? new r() : null), ae = ce(S?.subscribe ?? hr, S?.getSnapshot ?? gr), [C] = E(() => [mr({
2695
- onWikiLinkClick: (e) => _.current?.(e),
2696
- onLinkClick: (e) => ee.current?.(e),
2697
- inPlace: c,
2698
- embedRegistry: f ? v : void 0
2699
- }), ...S ? [ue.of(S.panel)] : []]), w = te({
2719
+ var Ar = () => () => {}, jr = () => null;
2720
+ function Mr({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClick: a, onLinkClick: o, inPlace: s, codeLanguages: c, wikiLinkSource: l, tagSource: u, embedSource: d, onResolveError: f, onSave: p, onViewChange: m, canvasHeader: h, hostExtensions: ee }) {
2721
+ let te = C(a);
2722
+ te.current = a;
2723
+ let re = C(o);
2724
+ re.current = o;
2725
+ let [g] = w(() => new De()), _ = _e(g.subscribe, g.getSnapshot, g.getSnapshot), [ie, ae] = w(null), oe = C(m);
2726
+ oe.current = m;
2727
+ let se = C((e) => {
2728
+ ae(e), oe.current?.(e);
2729
+ }).current, v = C(h);
2730
+ v.current = h;
2731
+ let [y] = w(() => h ? new ne() : null), b = _e(y?.subscribe ?? Ar, y?.getSnapshot ?? jr), [le] = w(() => [kr({
2732
+ onWikiLinkClick: (e) => te.current?.(e),
2733
+ onLinkClick: (e) => re.current?.(e),
2734
+ inPlace: s,
2735
+ embedRegistry: d ? g : void 0
2736
+ }), ...y ? [ye.of(y.panel)] : []]), ue = ce({
2700
2737
  value: e,
2701
- onChange: n,
2702
- readOnly: i,
2703
- placeholder: a,
2704
- extensions: C,
2705
- codeLanguages: l,
2706
- wikiLinkSource: u,
2707
- tagSource: d,
2708
- onResolveError: p,
2709
- onSave: m,
2710
- onViewChange: ie
2738
+ onChange: t,
2739
+ readOnly: r,
2740
+ placeholder: i,
2741
+ extensions: le,
2742
+ codeLanguages: c,
2743
+ wikiLinkSource: l,
2744
+ tagSource: u,
2745
+ onResolveError: f,
2746
+ onSave: p,
2747
+ onViewChange: se,
2748
+ hostExtensions: ee
2711
2749
  });
2712
- return /* @__PURE__ */ _e("div", {
2713
- className: t.inplace,
2714
- ref: w,
2715
- children: [f && ne.map((e) => de(/* @__PURE__ */ ge(oe, {
2750
+ return /* @__PURE__ */ Ee("div", {
2751
+ className: n.inplace,
2752
+ ref: ue,
2753
+ children: [d && _.map((e) => be(/* @__PURE__ */ Te(me, {
2716
2754
  reference: e.ref,
2717
- source: f,
2718
- onError: p,
2755
+ source: d,
2756
+ onError: f,
2719
2757
  inline: e.inline
2720
- }), e.el, String(e.id))), ae && x.current && de(x.current({ view: re }), ae)]
2758
+ }), e.el, String(e.id))), b && v.current && be(v.current({ view: ie }), b)]
2721
2759
  });
2722
2760
  }
2723
2761
  //#endregion
2724
- export { _r as InPlaceView };
2762
+ export { Mr as InPlaceView };
2725
2763
 
2726
- //# sourceMappingURL=InPlaceView-DVX9qV68.js.map
2764
+ //# sourceMappingURL=InPlaceView-CRb5AkfX.js.map