@damiro/stylo 0.7.0 → 0.9.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 (146) hide show
  1. package/README.md +24 -10
  2. package/dist/{InPlaceView-CS1qy-Ba.js → InPlaceView-Bu91_3Ig.js} +1199 -855
  3. package/dist/InPlaceView-Bu91_3Ig.js.map +1 -0
  4. package/dist/Preview-AaGGwLQP.js +170 -0
  5. package/dist/Preview-AaGGwLQP.js.map +1 -0
  6. package/dist/SplitView.d.ts +4 -2
  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 -2
  10. package/dist/editor/SourceView.d.ts.map +1 -1
  11. package/dist/editor/extensions.d.ts +2 -2
  12. package/dist/editor/extensions.d.ts.map +1 -1
  13. package/dist/editor/useCodeMirror.d.ts +4 -2
  14. package/dist/editor/useCodeMirror.d.ts.map +1 -1
  15. package/dist/editor/wikilink-complete.d.ts +5 -3
  16. package/dist/editor/wikilink-complete.d.ts.map +1 -1
  17. package/dist/embed-B2Dfkpd_.js +124 -0
  18. package/dist/embed-B2Dfkpd_.js.map +1 -0
  19. package/dist/embed.d.ts +14 -0
  20. package/dist/embed.d.ts.map +1 -0
  21. package/dist/frontmatter-DGUkb9z-.js +39 -0
  22. package/dist/frontmatter-DGUkb9z-.js.map +1 -0
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/inplace/InPlaceView.d.ts +11 -2
  26. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  27. package/dist/inplace/config.d.ts +8 -0
  28. package/dist/inplace/config.d.ts.map +1 -1
  29. package/dist/inplace/context-menu-actions.d.ts +5 -14
  30. package/dist/inplace/context-menu-actions.d.ts.map +1 -1
  31. package/dist/inplace/context-menu-helpers.d.ts +30 -0
  32. package/dist/inplace/context-menu-helpers.d.ts.map +1 -0
  33. package/dist/inplace/context-menu-shell.d.ts +23 -0
  34. package/dist/inplace/context-menu-shell.d.ts.map +1 -0
  35. package/dist/inplace/context-menu-types.d.ts +46 -0
  36. package/dist/inplace/context-menu-types.d.ts.map +1 -0
  37. package/dist/inplace/context-menu.d.ts +2 -42
  38. package/dist/inplace/context-menu.d.ts.map +1 -1
  39. package/dist/inplace/decorate.d.ts.map +1 -1
  40. package/dist/inplace/edit-boundaries.d.ts +1 -25
  41. package/dist/inplace/edit-boundaries.d.ts.map +1 -1
  42. package/dist/inplace/edit-divider.d.ts +27 -0
  43. package/dist/inplace/edit-divider.d.ts.map +1 -0
  44. package/dist/inplace/embed-registry.d.ts +39 -0
  45. package/dist/inplace/embed-registry.d.ts.map +1 -0
  46. package/dist/inplace/embed.d.ts +8 -0
  47. package/dist/inplace/embed.d.ts.map +1 -0
  48. package/dist/inplace/extension.d.ts +6 -0
  49. package/dist/inplace/extension.d.ts.map +1 -1
  50. package/dist/inplace/inline-md.d.ts +6 -1
  51. package/dist/inplace/inline-md.d.ts.map +1 -1
  52. package/dist/inplace/link-row.d.ts +21 -0
  53. package/dist/inplace/link-row.d.ts.map +1 -0
  54. package/dist/inplace/math-edit.d.ts +36 -0
  55. package/dist/inplace/math-edit.d.ts.map +1 -0
  56. package/dist/inplace/math.d.ts +12 -0
  57. package/dist/inplace/math.d.ts.map +1 -1
  58. package/dist/inplace/menu-plugin.d.ts.map +1 -1
  59. package/dist/inplace/nodes-blocks.d.ts +14 -0
  60. package/dist/inplace/nodes-blocks.d.ts.map +1 -0
  61. package/dist/inplace/nodes-inline.d.ts +16 -0
  62. package/dist/inplace/nodes-inline.d.ts.map +1 -0
  63. package/dist/inplace/nodes.d.ts +3 -2
  64. package/dist/inplace/nodes.d.ts.map +1 -1
  65. package/dist/inplace/scan.d.ts +6 -0
  66. package/dist/inplace/scan.d.ts.map +1 -1
  67. package/dist/inplace/selection-bar-position.d.ts +31 -0
  68. package/dist/inplace/selection-bar-position.d.ts.map +1 -0
  69. package/dist/inplace/selection-bar.d.ts +0 -2
  70. package/dist/inplace/selection-bar.d.ts.map +1 -1
  71. package/dist/inplace/table-widget-caret.d.ts +11 -0
  72. package/dist/inplace/table-widget-caret.d.ts.map +1 -0
  73. package/dist/inplace/table-widget-render.d.ts +18 -0
  74. package/dist/inplace/table-widget-render.d.ts.map +1 -0
  75. package/dist/inplace/table-widget.d.ts +5 -2
  76. package/dist/inplace/table-widget.d.ts.map +1 -1
  77. package/dist/inplace/tables.d.ts.map +1 -1
  78. package/dist/inplace/theme-callout.d.ts +50 -0
  79. package/dist/inplace/theme-callout.d.ts.map +1 -0
  80. package/dist/inplace/theme-canvas.d.ts +166 -0
  81. package/dist/inplace/theme-canvas.d.ts.map +1 -0
  82. package/dist/inplace/theme-fonts.d.ts +4 -0
  83. package/dist/inplace/theme-fonts.d.ts.map +1 -0
  84. package/dist/inplace/theme-menu.d.ts +87 -0
  85. package/dist/inplace/theme-menu.d.ts.map +1 -0
  86. package/dist/inplace/theme-popups.d.ts +94 -0
  87. package/dist/inplace/theme-popups.d.ts.map +1 -0
  88. package/dist/inplace/theme-table-gizmos.d.ts +57 -0
  89. package/dist/inplace/theme-table-gizmos.d.ts.map +1 -0
  90. package/dist/inplace/theme-table.d.ts +30 -0
  91. package/dist/inplace/theme-table.d.ts.map +1 -0
  92. package/dist/inplace/theme.d.ts +5 -0
  93. package/dist/inplace/theme.d.ts.map +1 -1
  94. package/dist/inplace/wikilinks.d.ts.map +1 -1
  95. package/dist/inplace/wrap-at.d.ts +32 -0
  96. package/dist/inplace/wrap-at.d.ts.map +1 -0
  97. package/dist/{markdown-N3lRmU2n.js → markdown-BYXs9Tj8.js} +2 -2
  98. package/dist/{markdown-N3lRmU2n.js.map → markdown-BYXs9Tj8.js.map} +1 -1
  99. package/dist/render/Embed.d.ts +24 -0
  100. package/dist/render/Embed.d.ts.map +1 -0
  101. package/dist/render/Preview.d.ts +6 -2
  102. package/dist/render/Preview.d.ts.map +1 -1
  103. package/dist/render/embed-cache.d.ts +10 -0
  104. package/dist/render/embed-cache.d.ts.map +1 -0
  105. package/dist/render/remark-embed.d.ts +19 -0
  106. package/dist/render/remark-embed.d.ts.map +1 -0
  107. package/dist/styles.css +1 -1
  108. package/dist/stylo.js +70 -54
  109. package/dist/stylo.js.map +1 -1
  110. package/dist/toolbar/block.d.ts +0 -26
  111. package/dist/toolbar/block.d.ts.map +1 -1
  112. package/dist/toolbar/command-helpers.d.ts +57 -0
  113. package/dist/toolbar/command-helpers.d.ts.map +1 -0
  114. package/dist/toolbar/commands.d.ts +1 -21
  115. package/dist/toolbar/commands.d.ts.map +1 -1
  116. package/dist/toolbar/frontmatter-toggle.d.ts +13 -0
  117. package/dist/toolbar/frontmatter-toggle.d.ts.map +1 -0
  118. package/dist/toolbar/heading.d.ts +10 -0
  119. package/dist/toolbar/heading.d.ts.map +1 -0
  120. package/dist/toolbar/inline-ops.d.ts +3 -53
  121. package/dist/toolbar/inline-ops.d.ts.map +1 -1
  122. package/dist/toolbar/link-ops.d.ts +22 -0
  123. package/dist/toolbar/link-ops.d.ts.map +1 -0
  124. package/dist/toolbar/rule.d.ts +11 -0
  125. package/dist/toolbar/rule.d.ts.map +1 -0
  126. package/dist/toolbar/table-position.d.ts +32 -0
  127. package/dist/toolbar/table-position.d.ts.map +1 -0
  128. package/dist/toolbar/table.d.ts +1 -16
  129. package/dist/toolbar/table.d.ts.map +1 -1
  130. package/dist/toolbar/underline-ops.d.ts +15 -0
  131. package/dist/toolbar/underline-ops.d.ts.map +1 -0
  132. package/dist/toolbar/wikilink-ops.d.ts +22 -0
  133. package/dist/toolbar/wikilink-ops.d.ts.map +1 -0
  134. package/dist/types.d.ts +48 -0
  135. package/dist/types.d.ts.map +1 -1
  136. package/dist/{useCodeMirror-GPSkaYW6.js → useCodeMirror-DtwupFgc.js} +559 -531
  137. package/dist/useCodeMirror-DtwupFgc.js.map +1 -0
  138. package/package.json +2 -1
  139. package/dist/InPlaceView-CS1qy-Ba.js.map +0 -1
  140. package/dist/Preview-Bw0k3Mev.js +0 -93
  141. package/dist/Preview-Bw0k3Mev.js.map +0 -1
  142. package/dist/callout-oLE630ZP.js +0 -37
  143. package/dist/callout-oLE630ZP.js.map +0 -1
  144. package/dist/useCodeMirror-GPSkaYW6.js.map +0 -1
  145. package/dist/wikilink-CTR8IFKc.js +0 -42
  146. package/dist/wikilink-CTR8IFKc.js.map +0 -1
@@ -1,169 +1,135 @@
1
- import { n as e, t } from "./wikilink-CTR8IFKc.js";
1
+ import { r as e, t } from "./frontmatter-DGUkb9z-.js";
2
2
  import { useEffect as n, useRef as r } from "react";
3
3
  import { EditorView as i, keymap as a, placeholder as o } from "@codemirror/view";
4
4
  import { Annotation as s, ChangeSet as c, Compartment as l, EditorSelection as u, EditorState as d, Facet as f, Prec as p } from "@codemirror/state";
5
5
  import { defaultKeymap as ee, history as te, historyKeymap as m, redo as h, undo as g } from "@codemirror/commands";
6
6
  import { markdown as _, markdownLanguage as v } from "@codemirror/lang-markdown";
7
- import { openSearchPanel as y, search as b, searchKeymap as x } from "@codemirror/search";
8
- import { HighlightStyle as ne, syntaxHighlighting as re, syntaxTree as ie } from "@codemirror/language";
9
- import { tags as S } from "@lezer/highlight";
10
- import { autocompletion as ae } from "@codemirror/autocomplete";
11
- //#region src/editor/save.ts
12
- var C = f.define({ combine: (e) => e[0] ?? null });
13
- function oe(e) {
14
- let t = e.state.facet(C);
15
- return t ? (t(e.state.doc.toString()), !0) : !1;
16
- }
17
- //#endregion
18
- //#region src/toolbar/block.ts
19
- function w(e) {
20
- let { from: t, to: n } = e.selection.main;
21
- return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
22
- }
23
- function se(e, t) {
24
- let n = "#".repeat(t) + " ", r = e.state, [i, a] = w(r), o = [];
25
- for (let e = i; e <= a; e++) {
26
- let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
27
- a && a[1].length === t ? o.push({
28
- from: i.from,
29
- to: i.from + a[0].length
30
- }) : a ? o.push({
31
- from: i.from,
32
- to: i.from + a[0].length,
33
- insert: n
34
- }) : o.push({
35
- from: i.from,
36
- insert: n
37
- });
38
- }
39
- return e.dispatch({
40
- changes: o,
41
- scrollIntoView: !0
42
- }), e.focus(), !0;
43
- }
44
- function ce(e) {
45
- let t = e.state, [n, r] = w(t), i = [];
46
- for (let e = n; e <= r; e++) {
47
- let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
48
- r && i.push({
49
- from: n.from,
50
- to: n.from + r[0].length
51
- });
7
+ import { openSearchPanel as y, search as b, searchKeymap as ne } from "@codemirror/search";
8
+ import { HighlightStyle as x, syntaxHighlighting as S, syntaxTree as C } from "@codemirror/language";
9
+ import { tags as w } from "@lezer/highlight";
10
+ import { autocompletion as re } from "@codemirror/autocomplete";
11
+ //#region src/toolbar/link-ops.ts
12
+ function T(e, t) {
13
+ let n = /\[([^\]]*)\]\([^)]*\)/g;
14
+ for (let r; r = n.exec(e);) {
15
+ let e = r.index, n = e + r[0].length;
16
+ if (t >= e && t <= n) return {
17
+ from: e,
18
+ to: n,
19
+ label: r[1] ?? ""
20
+ };
52
21
  }
53
- return i.length ? (e.dispatch({
54
- changes: i,
55
- scrollIntoView: !0
56
- }), e.focus(), !0) : !1;
22
+ return null;
57
23
  }
58
- function le(e, t) {
59
- let n = e.state, [r, i] = w(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
60
- for (let e = r; e <= i && o; e++) {
61
- let r = n.doc.line(e).text;
62
- r.trim() && !t.match.test(r) && (o = !1);
63
- }
64
- let s = [], c = 0;
65
- for (let e = r; e <= i; e++) {
66
- let r = n.doc.line(e);
67
- if (!r.text.trim() && !a) continue;
68
- let i = t.match.exec(r.text);
69
- if (o) {
70
- i && s.push({
71
- from: r.from,
72
- to: r.from + i[0].length
73
- });
74
- continue;
75
- }
76
- if (i) continue;
77
- let l = typeof t.insert == "function" ? t.insert(c++) : t.insert, u = t.siblings?.exec(r.text);
78
- if (u) s.push({
79
- from: r.from + (u[1] ?? "").length,
80
- to: r.from + u[0].length,
81
- insert: l
82
- });
83
- else {
84
- let e = /^\s*/.exec(r.text)[0].length;
85
- s.push({
86
- from: r.from + e,
87
- insert: l
88
- });
24
+ function ie(e, t) {
25
+ let n = /\[([^\]]*)\]\(([^)]*)\)/g;
26
+ for (let r; r = n.exec(e);) {
27
+ let e = r.index, n = e + r[0].length;
28
+ if (t >= e && t <= n) {
29
+ let t = r[1] ?? "", i = r[2] ?? "", a = e + 1 + t.length + 2;
30
+ return {
31
+ from: e,
32
+ to: n,
33
+ label: t,
34
+ url: i,
35
+ urlFrom: a,
36
+ urlTo: a + i.length
37
+ };
89
38
  }
90
39
  }
91
- return s.length ? (e.dispatch({
92
- changes: s,
93
- scrollIntoView: !0
94
- }), e.focus(), !0) : !1;
40
+ return null;
95
41
  }
96
- function ue(e, t) {
97
- return t.test(e.doc.lineAt(e.selection.main.head).text);
42
+ function ae(e, t, n) {
43
+ let r = T(e, t);
44
+ if (r) return {
45
+ text: e.slice(0, r.from) + r.label + e.slice(r.to),
46
+ from: r.from,
47
+ to: r.from + r.label.length
48
+ };
49
+ let i = e.slice(t, n) || "text", a = t + i.length + 3;
50
+ return {
51
+ text: e.slice(0, t) + `[${i}](url)` + e.slice(n),
52
+ from: a,
53
+ to: a + 3
54
+ };
98
55
  }
99
- var de = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
100
- function fe(e) {
101
- let t = e.state, n = t.doc.lineAt(t.selection.main.head);
102
- return de.test(n.text) ? e.dispatch({
103
- changes: {
104
- from: n.from,
105
- to: Math.min(n.to + 1, t.doc.length)
106
- },
107
- scrollIntoView: !0
108
- }) : n.text.trim() === "" ? e.dispatch({
109
- changes: {
110
- from: n.from,
111
- to: n.to,
112
- insert: "---"
113
- },
114
- selection: u.cursor(n.from + 3),
115
- scrollIntoView: !0
116
- }) : e.dispatch({
117
- changes: {
118
- from: n.to,
119
- insert: "\n\n---\n"
120
- },
121
- selection: u.cursor(n.to + 6),
122
- scrollIntoView: !0
123
- }), e.focus(), !0;
56
+ //#endregion
57
+ //#region src/toolbar/wikilink-ops.ts
58
+ function E(t, n) {
59
+ for (let r of t.matchAll(e)) {
60
+ let e = r.index ?? 0, t = e + r[0].length;
61
+ if (n >= e && n <= t) return {
62
+ from: e,
63
+ to: t,
64
+ label: r[2] || r[1] || ""
65
+ };
66
+ }
67
+ return null;
124
68
  }
125
- function pe(e) {
126
- return de.test(e.doc.lineAt(e.selection.main.head).text);
69
+ function oe(t, n) {
70
+ for (let r of t.matchAll(e)) {
71
+ let e = r.index ?? 0, t = e + r[0].length;
72
+ if (n < e || n > t) continue;
73
+ let i = r[1] ?? "", a = e + 2;
74
+ return {
75
+ from: e,
76
+ to: t,
77
+ target: i,
78
+ label: r[2] ?? "",
79
+ targetFrom: a,
80
+ targetTo: a + i.length
81
+ };
82
+ }
83
+ return null;
127
84
  }
128
- function me(t) {
129
- let n = t.state, r = e(n.doc);
130
- if (r) {
131
- let e = n.doc.lineAt(r.from), i = n.doc.lineAt(r.to);
132
- t.dispatch({
133
- changes: [{
134
- from: e.from,
135
- to: Math.min(e.to + 1, n.doc.length)
136
- }, {
137
- from: i.from,
138
- to: Math.min(i.to + 1, n.doc.length)
139
- }],
140
- scrollIntoView: !0
141
- });
142
- } else {
143
- let e = n.doc.lineAt(n.selection.main.to).number;
144
- t.dispatch({
145
- changes: [{
146
- from: 0,
147
- insert: "---\n"
148
- }, {
149
- from: n.doc.line(e).to,
150
- insert: "\n---"
151
- }],
152
- selection: u.cursor(4),
153
- scrollIntoView: !0
154
- });
85
+ function se(e, t, n) {
86
+ let r = E(e, t);
87
+ if (r) return {
88
+ text: e.slice(0, r.from) + r.label + e.slice(r.to),
89
+ from: r.from,
90
+ to: r.from + r.label.length
91
+ };
92
+ let i = e.slice(t, n) || "target";
93
+ return {
94
+ text: e.slice(0, t) + `[[${i}]]` + e.slice(n),
95
+ from: t + 2,
96
+ to: t + 2 + i.length
97
+ };
98
+ }
99
+ //#endregion
100
+ //#region src/toolbar/underline-ops.ts
101
+ function ce(e, t) {
102
+ let n = /<u>([\s\S]*?)<\/u>/gi;
103
+ for (let r; r = n.exec(e);) {
104
+ let e = r.index, n = e + r[0].length;
105
+ if (t >= e && t <= n) return {
106
+ from: e,
107
+ to: n,
108
+ inner: r[1] ?? ""
109
+ };
155
110
  }
156
- return t.focus(), !0;
111
+ return null;
157
112
  }
158
- function he(t) {
159
- return e(t.doc) !== null;
113
+ function le(e, t, n) {
114
+ let r = ce(e, t);
115
+ if (r) return {
116
+ text: e.slice(0, r.from) + r.inner + e.slice(r.to),
117
+ from: r.from,
118
+ to: r.from + r.inner.length
119
+ };
120
+ let i = e.slice(t, n) || "text";
121
+ return {
122
+ text: e.slice(0, t) + `<u>${i}</u>` + e.slice(n),
123
+ from: t + 3,
124
+ to: t + 3 + i.length
125
+ };
160
126
  }
161
127
  //#endregion
162
128
  //#region src/toolbar/inline-ops.ts
163
- function T(e) {
129
+ function D(e) {
164
130
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
165
131
  }
166
- function ge(e, t, n) {
132
+ function ue(e, t, n) {
167
133
  let r = t, i = t;
168
134
  if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
169
135
  else for (; i < e.length && "*~`$".includes(e[i]);) i++;
@@ -172,7 +138,7 @@ function ge(e, t, n) {
172
138
  from: r
173
139
  };
174
140
  }
175
- function _e(e, t) {
141
+ function de(e, t) {
176
142
  let n = [];
177
143
  for (let r = 0; r < e.length;) {
178
144
  if (e[r] !== t) {
@@ -188,15 +154,15 @@ function _e(e, t) {
188
154
  }
189
155
  return n;
190
156
  }
191
- function ve(e, t, n) {
157
+ function fe(e, t, n) {
192
158
  return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
193
159
  }
194
- function ye(e, t, n, r) {
160
+ function pe(e, t, n, r) {
195
161
  let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
196
162
  for (; o[s] === a;) s++;
197
163
  let c = 0;
198
164
  for (; o[o.length - 1 - c] === a;) c++;
199
- if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && ve(s, c, i)) return {
165
+ if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && fe(s, c, i)) return {
200
166
  changes: [{
201
167
  from: t,
202
168
  to: t + i,
@@ -209,10 +175,10 @@ function ye(e, t, n, r) {
209
175
  from: t,
210
176
  to: n - 2 * i
211
177
  };
212
- let l = ge(e, t, -1), u = ge(e, n, 1), d = _e(l.text, a), f = _e(u.text, a).reverse();
178
+ let l = ue(e, t, -1), u = ue(e, n, 1), d = de(l.text, a), f = de(u.text, a).reverse();
213
179
  for (let e = 0; e < Math.min(d.length, f.length); e++) {
214
180
  let r = d[e], a = f[e];
215
- if (!ve(r.len, a.len, i)) continue;
181
+ if (!fe(r.len, a.len, i)) continue;
216
182
  let o = l.from + r.start + r.len, s = n + a.start;
217
183
  return {
218
184
  changes: [{
@@ -242,26 +208,26 @@ function ye(e, t, n, r) {
242
208
  to: n + i
243
209
  };
244
210
  }
245
- function be(e, t) {
211
+ function me(e, t) {
246
212
  let n = e;
247
213
  for (let e of [...t].sort((e, t) => t.from - e.from)) n = n.slice(0, e.from) + e.insert + n.slice(e.to);
248
214
  return n;
249
215
  }
250
- function E(e, t, n, r) {
251
- let i = ye(e, t, n, r);
216
+ function O(e, t, n, r) {
217
+ let i = pe(e, t, n, r);
252
218
  return {
253
- text: be(e, i.changes),
219
+ text: me(e, i.changes),
254
220
  from: i.from,
255
221
  to: i.to
256
222
  };
257
223
  }
258
- function xe(e, t) {
259
- let n = D(e, t);
224
+ function he(e, t) {
225
+ let n = T(e, t);
260
226
  if (n) return {
261
227
  from: n.from,
262
228
  to: n.to
263
229
  };
264
- let r = A(e, t);
230
+ let r = oe(e, t);
265
231
  if (r) return {
266
232
  from: r.from,
267
233
  to: r.to
@@ -273,7 +239,7 @@ function xe(e, t) {
273
239
  "*",
274
240
  "`"
275
241
  ]) {
276
- let r = RegExp(T(n) + "(?!\\s)(?:[^]*?\\S)??" + T(n), "g");
242
+ let r = RegExp(D(n) + "(?!\\s)(?:[^]*?\\S)??" + D(n), "g");
277
243
  for (let a; a = r.exec(e);) {
278
244
  if (a[0].length <= 2 * n.length) continue;
279
245
  let e = a.index + n.length, r = a.index + a[0].length - n.length;
@@ -285,121 +251,10 @@ function xe(e, t) {
285
251
  }
286
252
  return i;
287
253
  }
288
- function D(e, t) {
289
- let n = /\[([^\]]*)\]\([^)]*\)/g;
290
- for (let r; r = n.exec(e);) {
291
- let e = r.index, n = e + r[0].length;
292
- if (t >= e && t <= n) return {
293
- from: e,
294
- to: n,
295
- label: r[1] ?? ""
296
- };
297
- }
298
- return null;
299
- }
300
- function Se(e, t) {
301
- let n = /\[([^\]]*)\]\(([^)]*)\)/g;
302
- for (let r; r = n.exec(e);) {
303
- let e = r.index, n = e + r[0].length;
304
- if (t >= e && t <= n) {
305
- let t = r[1] ?? "", i = r[2] ?? "", a = e + 1 + t.length + 2;
306
- return {
307
- from: e,
308
- to: n,
309
- label: t,
310
- url: i,
311
- urlFrom: a,
312
- urlTo: a + i.length
313
- };
314
- }
315
- }
316
- return null;
317
- }
318
- function Ce(e, t, n) {
319
- let r = D(e, t);
320
- if (r) return {
321
- text: e.slice(0, r.from) + r.label + e.slice(r.to),
322
- from: r.from,
323
- to: r.from + r.label.length
324
- };
325
- let i = e.slice(t, n) || "text", a = t + i.length + 3;
326
- return {
327
- text: e.slice(0, t) + `[${i}](url)` + e.slice(n),
328
- from: a,
329
- to: a + 3
330
- };
331
- }
332
- function we(e, t) {
333
- let n = /<u>([\s\S]*?)<\/u>/gi;
334
- for (let r; r = n.exec(e);) {
335
- let e = r.index, n = e + r[0].length;
336
- if (t >= e && t <= n) return {
337
- from: e,
338
- to: n,
339
- inner: r[1] ?? ""
340
- };
341
- }
342
- return null;
343
- }
344
- function O(e, t, n) {
345
- let r = we(e, t);
346
- if (r) return {
347
- text: e.slice(0, r.from) + r.inner + e.slice(r.to),
348
- from: r.from,
349
- to: r.from + r.inner.length
350
- };
351
- let i = e.slice(t, n) || "text";
352
- return {
353
- text: e.slice(0, t) + `<u>${i}</u>` + e.slice(n),
354
- from: t + 3,
355
- to: t + 3 + i.length
356
- };
357
- }
358
- function k(e, n) {
359
- for (let r of e.matchAll(t)) {
360
- let e = r.index ?? 0, t = e + r[0].length;
361
- if (n >= e && n <= t) return {
362
- from: e,
363
- to: t,
364
- label: r[2] || r[1] || ""
365
- };
366
- }
367
- return null;
368
- }
369
- function A(e, n) {
370
- for (let r of e.matchAll(t)) {
371
- let e = r.index ?? 0, t = e + r[0].length;
372
- if (n < e || n > t) continue;
373
- let i = r[1] ?? "", a = e + 2;
374
- return {
375
- from: e,
376
- to: t,
377
- target: i,
378
- label: r[2] ?? "",
379
- targetFrom: a,
380
- targetTo: a + i.length
381
- };
382
- }
383
- return null;
384
- }
385
- function Te(e, t, n) {
386
- let r = k(e, t);
387
- if (r) return {
388
- text: e.slice(0, r.from) + r.label + e.slice(r.to),
389
- from: r.from,
390
- to: r.from + r.label.length
391
- };
392
- let i = e.slice(t, n) || "target";
393
- return {
394
- text: e.slice(0, t) + `[[${i}]]` + e.slice(n),
395
- from: t + 2,
396
- to: t + 2 + i.length
397
- };
398
- }
399
254
  //#endregion
400
255
  //#region src/inplace/table-cell-dom.ts
401
- var Ee = (e) => [e.head, ...e.body].map((e) => [...e]), De = (e) => e.map((e) => e.map((e) => e.trim())), Oe = (e) => e.replace(/\\\|/g, "|");
402
- function j(e, t) {
256
+ var ge = (e) => [e.head, ...e.body].map((e) => [...e]), _e = (e) => e.map((e) => e.map((e) => e.trim())), ve = (e) => e.replace(/\\\|/g, "|");
257
+ function k(e, t) {
403
258
  let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
404
259
  for (let e = n.nextNode(); e; e = n.nextNode()) {
405
260
  if (e === t) return r;
@@ -407,12 +262,12 @@ function j(e, t) {
407
262
  }
408
263
  return r;
409
264
  }
410
- function ke(e) {
265
+ function ye(e) {
411
266
  let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
412
- return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? j(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
267
+ return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? k(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
413
268
  }
414
- function Ae(e) {
415
- let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? j(e, t) + r : r > 0 ? n : 0;
269
+ function be(e) {
270
+ let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? k(e, t) + r : r > 0 ? n : 0;
416
271
  if (!t || t.rangeCount === 0) return {
417
272
  from: n,
418
273
  to: n
@@ -423,7 +278,7 @@ function Ae(e) {
423
278
  to: Math.max(i, a)
424
279
  };
425
280
  }
426
- function je(e, t, n) {
281
+ function xe(e, t, n) {
427
282
  let r = e.ownerDocument, i = null, a = 0;
428
283
  if (r.caretPositionFromPoint) {
429
284
  let e = r.caretPositionFromPoint(t, n);
@@ -432,18 +287,18 @@ function je(e, t, n) {
432
287
  let e = r.caretRangeFromPoint(t, n);
433
288
  e && ([i, a] = [e.startContainer, e.startOffset]);
434
289
  }
435
- return !i || !e.contains(i) ? 0 : j(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
290
+ return !i || !e.contains(i) ? 0 : k(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
436
291
  }
437
- var Me = /[\p{L}\p{N}_]/u;
438
- function Ne(e, t, n) {
439
- let r = e.textContent ?? "", i = je(e, t, n), a = xe(r, i);
440
- if (a) return M(e, a.from, a.to), !0;
292
+ var Se = /[\p{L}\p{N}_]/u;
293
+ function Ce(e, t, n) {
294
+ let r = e.textContent ?? "", i = xe(e, t, n), a = he(r, i);
295
+ if (a) return A(e, a.from, a.to), !0;
441
296
  let o = i, s = i;
442
- for (; o > 0 && Me.test(r[o - 1]);) o--;
443
- for (; s < r.length && Me.test(r[s]);) s++;
444
- return s <= o ? !1 : (M(e, o, s), !0);
297
+ for (; o > 0 && Se.test(r[o - 1]);) o--;
298
+ for (; s < r.length && Se.test(r[s]);) s++;
299
+ return s <= o ? !1 : (A(e, o, s), !0);
445
300
  }
446
- function M(e, t, n = t) {
301
+ function A(e, t, n = t) {
447
302
  e.focus();
448
303
  let r = e.ownerDocument, i = r.createRange(), a = e.firstChild;
449
304
  if (a && a.nodeType === Node.TEXT_NODE) {
@@ -456,34 +311,81 @@ function M(e, t, n = t) {
456
311
  }
457
312
  //#endregion
458
313
  //#region src/toolbar/cell-inline.ts
459
- function Pe(e) {
314
+ function we(e) {
460
315
  let t = e.dom.ownerDocument.activeElement;
461
316
  return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
462
317
  }
463
- function N(e, t) {
464
- let { from: n, to: r } = Ae(e), i = t(e.textContent ?? "", n, r);
465
- e.textContent = i.text, M(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
466
- }
467
- function P(e, t) {
468
- let n = Pe(e);
469
- return n ? (N(n, t), !0) : !1;
470
- }
471
- var Fe = {
472
- b: (e, t, n) => E(e, t, n, "**"),
473
- i: (e, t, n) => E(e, t, n, "*"),
474
- u: O,
475
- k: Ce,
476
- K: Te
318
+ function Te(e, t) {
319
+ let { from: n, to: r } = be(e), i = t(e.textContent ?? "", n, r);
320
+ e.textContent = i.text, A(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
321
+ }
322
+ function j(e, t) {
323
+ let n = we(e);
324
+ return n ? (Te(n, t), !0) : !1;
325
+ }
326
+ var Ee = {
327
+ b: (e, t, n) => O(e, t, n, "**"),
328
+ i: (e, t, n) => O(e, t, n, "*"),
329
+ u: le,
330
+ k: ae,
331
+ K: se
477
332
  };
478
- function Ie(e, t) {
333
+ function De(e, t) {
479
334
  if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
480
- let n = Fe[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
481
- return n ? (e.preventDefault(), N(t, n), !0) : !1;
335
+ let n = Ee[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
336
+ return n ? (e.preventDefault(), Te(t, n), !0) : !1;
337
+ }
338
+ //#endregion
339
+ //#region src/toolbar/block.ts
340
+ function M(e) {
341
+ let { from: t, to: n } = e.selection.main;
342
+ return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
343
+ }
344
+ function Oe(e, t) {
345
+ let n = e.state, [r, i] = M(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
346
+ for (let e = r; e <= i && o; e++) {
347
+ let r = n.doc.line(e).text;
348
+ r.trim() && !t.match.test(r) && (o = !1);
349
+ }
350
+ let s = [], c = 0;
351
+ for (let e = r; e <= i; e++) {
352
+ let r = n.doc.line(e);
353
+ if (!r.text.trim() && !a) continue;
354
+ let i = t.match.exec(r.text);
355
+ if (o) {
356
+ i && s.push({
357
+ from: r.from,
358
+ to: r.from + i[0].length
359
+ });
360
+ continue;
361
+ }
362
+ if (i) continue;
363
+ let l = typeof t.insert == "function" ? t.insert(c++) : t.insert, u = t.siblings?.exec(r.text);
364
+ if (u) s.push({
365
+ from: r.from + (u[1] ?? "").length,
366
+ to: r.from + u[0].length,
367
+ insert: l
368
+ });
369
+ else {
370
+ let e = /^\s*/.exec(r.text)[0].length;
371
+ s.push({
372
+ from: r.from + e,
373
+ insert: l
374
+ });
375
+ }
376
+ }
377
+ return s.length ? (e.dispatch({
378
+ changes: s,
379
+ scrollIntoView: !0
380
+ }), e.focus(), !0) : !1;
381
+ }
382
+ function ke(e, t) {
383
+ return t.test(e.doc.lineAt(e.selection.main.head).text);
482
384
  }
483
385
  //#endregion
484
386
  //#region src/toolbar/fence.ts
485
- function F(e, t) {
486
- for (let n = ie(e).resolveInner(t, 0); n; n = n.parent) {
387
+ function N(e, t) {
388
+ for (let n = C(e).resolveInner(t, 0); n; n = n.parent) {
487
389
  if (n.name === "FencedCode") return {
488
390
  from: n.from,
489
391
  to: n.to
@@ -492,8 +394,8 @@ function F(e, t) {
492
394
  }
493
395
  return null;
494
396
  }
495
- function Le(e) {
496
- let t = e.state, n = F(t, t.selection.main.head);
397
+ function Ae(e) {
398
+ let t = e.state, n = N(t, t.selection.main.head);
497
399
  if (n) {
498
400
  let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
499
401
  from: r.from,
@@ -507,7 +409,7 @@ function Le(e) {
507
409
  scrollIntoView: !0
508
410
  });
509
411
  } else {
510
- let [n, r] = w(t);
412
+ let [n, r] = M(t);
511
413
  e.dispatch({
512
414
  changes: [{
513
415
  from: t.doc.line(n).from,
@@ -522,11 +424,11 @@ function Le(e) {
522
424
  }
523
425
  return e.focus(), !0;
524
426
  }
525
- function I(e) {
526
- return F(e, e.selection.main.head) !== null;
427
+ function P(e) {
428
+ return N(e, e.selection.main.head) !== null;
527
429
  }
528
- function Re(e) {
529
- let t = F(e, e.selection.main.head);
430
+ function je(e) {
431
+ let t = N(e, e.selection.main.head);
530
432
  if (!t) return null;
531
433
  let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
532
434
  if (!r) return null;
@@ -537,18 +439,18 @@ function Re(e) {
537
439
  lang: r[2]
538
440
  };
539
441
  }
540
- var ze = /^\s*\$\$\s*$/;
541
- function Be(e, t) {
442
+ var Me = /^\s*\$\$\s*$/;
443
+ function Ne(e, t) {
542
444
  let n = 0, r = 0;
543
- for (let i = 1; i <= e.doc.lines; i++) if (ze.test(e.doc.line(i).text)) {
445
+ for (let i = 1; i <= e.doc.lines; i++) if (Me.test(e.doc.line(i).text)) {
544
446
  if (r++, r % 2 == 1) {
545
447
  if (n = i, i > t) return null;
546
448
  } else if (i >= t) return [n, i];
547
449
  }
548
450
  return null;
549
451
  }
550
- function Ve(e) {
551
- let t = e.state, [n, r] = w(t), i = Be(t, t.doc.lineAt(t.selection.main.head).number);
452
+ function Pe(e) {
453
+ let t = e.state, [n, r] = M(t), i = Ne(t, t.doc.lineAt(t.selection.main.head).number);
552
454
  if (i) {
553
455
  let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
554
456
  e.dispatch({
@@ -574,16 +476,53 @@ function Ve(e) {
574
476
  });
575
477
  return e.focus(), !0;
576
478
  }
577
- function L(e) {
578
- return Be(e, e.doc.lineAt(e.selection.main.head).number) !== null;
479
+ function F(e) {
480
+ return Ne(e, e.doc.lineAt(e.selection.main.head).number) !== null;
481
+ }
482
+ //#endregion
483
+ //#region src/toolbar/heading.ts
484
+ function Fe(e, t) {
485
+ let n = "#".repeat(t) + " ", r = e.state, [i, a] = M(r), o = [];
486
+ for (let e = i; e <= a; e++) {
487
+ let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
488
+ a && a[1].length === t ? o.push({
489
+ from: i.from,
490
+ to: i.from + a[0].length
491
+ }) : a ? o.push({
492
+ from: i.from,
493
+ to: i.from + a[0].length,
494
+ insert: n
495
+ }) : o.push({
496
+ from: i.from,
497
+ insert: n
498
+ });
499
+ }
500
+ return e.dispatch({
501
+ changes: o,
502
+ scrollIntoView: !0
503
+ }), e.focus(), !0;
504
+ }
505
+ function Ie(e) {
506
+ let t = e.state, [n, r] = M(t), i = [];
507
+ for (let e = n; e <= r; e++) {
508
+ let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
509
+ r && i.push({
510
+ from: n.from,
511
+ to: n.from + r[0].length
512
+ });
513
+ }
514
+ return i.length ? (e.dispatch({
515
+ changes: i,
516
+ scrollIntoView: !0
517
+ }), e.focus(), !0) : !1;
579
518
  }
580
519
  //#endregion
581
520
  //#region src/toolbar/inline.ts
582
- function R(e, t) {
521
+ function I(e, t) {
583
522
  let n = e.state.doc.toString();
584
523
  return e.dispatch({
585
524
  ...e.state.changeByRange((e) => {
586
- let r = ye(n, e.from, e.to, t);
525
+ let r = pe(n, e.from, e.to, t);
587
526
  return {
588
527
  changes: r.changes,
589
528
  range: r.from === r.to ? u.cursor(r.from) : u.range(r.from, r.to)
@@ -592,8 +531,8 @@ function R(e, t) {
592
531
  scrollIntoView: !0
593
532
  }), e.focus(), !0;
594
533
  }
595
- function z(e, t) {
596
- let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(T(t) + "(?!\\s)(?:[^]*?\\S)??" + T(t), "g");
534
+ function L(e, t) {
535
+ let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(D(t) + "(?!\\s)(?:[^]*?\\S)??" + D(t), "g");
597
536
  for (let e; e = i.exec(r.text);) {
598
537
  if (e[0].length <= 2 * t.length || t === "$" && (r.text[e.index - 1] === "$" || r.text[e.index + e[0].length] === "$")) continue;
599
538
  let i = r.from + e.index;
@@ -601,16 +540,16 @@ function z(e, t) {
601
540
  }
602
541
  return !1;
603
542
  }
604
- function He(e) {
605
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = D(n.text, t - n.from);
543
+ function Le(e) {
544
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = T(n.text, t - n.from);
606
545
  return r ? {
607
546
  from: n.from + r.from,
608
547
  to: n.from + r.to,
609
548
  text: r.label
610
549
  } : null;
611
550
  }
612
- function Ue(e) {
613
- let t = He(e.state);
551
+ function Re(e) {
552
+ let t = Le(e.state);
614
553
  if (t) return e.dispatch({
615
554
  changes: {
616
555
  from: t.from,
@@ -631,19 +570,19 @@ function Ue(e) {
631
570
  scrollIntoView: !0
632
571
  }), e.focus(), !0;
633
572
  }
634
- function We(e) {
635
- return He(e) !== null;
573
+ function ze(e) {
574
+ return Le(e) !== null;
636
575
  }
637
- function Ge(e) {
638
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = k(n.text, t - n.from);
576
+ function Be(e) {
577
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(n.text, t - n.from);
639
578
  return r ? {
640
579
  from: n.from + r.from,
641
580
  to: n.from + r.to,
642
581
  text: r.label
643
582
  } : null;
644
583
  }
645
- function Ke(e) {
646
- let t = Ge(e.state);
584
+ function Ve(e) {
585
+ let t = Be(e.state);
647
586
  if (t) return e.dispatch({
648
587
  changes: {
649
588
  from: t.from,
@@ -664,19 +603,19 @@ function Ke(e) {
664
603
  scrollIntoView: !0
665
604
  }), e.focus(), !0;
666
605
  }
667
- function qe(e) {
668
- return Ge(e) !== null;
606
+ function He(e) {
607
+ return Be(e) !== null;
669
608
  }
670
- function Je(e) {
671
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = we(n.text, t - n.from);
609
+ function Ue(e) {
610
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ce(n.text, t - n.from);
672
611
  return r ? {
673
612
  from: n.from + r.from,
674
613
  to: n.from + r.to,
675
614
  inner: r.inner
676
615
  } : null;
677
616
  }
678
- function Ye(e) {
679
- let t = Je(e.state);
617
+ function We(e) {
618
+ let t = Ue(e.state);
680
619
  if (t) return e.dispatch({
681
620
  changes: {
682
621
  from: t.from,
@@ -697,29 +636,29 @@ function Ye(e) {
697
636
  scrollIntoView: !0
698
637
  }), e.focus(), !0;
699
638
  }
700
- function Xe(e) {
701
- return Je(e) !== null;
639
+ function Ge(e) {
640
+ return Ue(e) !== null;
702
641
  }
703
642
  //#endregion
704
643
  //#region src/toolbar/table-grid.ts
705
- function Ze(e) {
644
+ function Ke(e) {
706
645
  let t = e.trim();
707
646
  return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
708
647
  }
709
- function Qe(e) {
648
+ function qe(e) {
710
649
  let t = e.trim();
711
650
  t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
712
651
  let n = [], r = "";
713
652
  for (let e = 0; e < t.length; e++) t[e] === "\\" && t[e + 1] === "|" ? (r += "\\|", e++) : t[e] === "|" ? (n.push(r.trim()), r = "") : r += t[e];
714
653
  return n.push(r.trim()), n;
715
654
  }
716
- function $e(e) {
655
+ function Je(e) {
717
656
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
718
657
  return n && r ? "center" : r ? "right" : n ? "left" : "";
719
658
  }
720
- function B(e) {
721
- if (e.length < 2 || !Ze(e[1])) return null;
722
- let t = Qe(e[1]).map($e), n = e.filter((e, t) => t !== 1).map(Qe), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
659
+ function R(e) {
660
+ if (e.length < 2 || !Ke(e[1])) return null;
661
+ let t = qe(e[1]).map(Je), n = e.filter((e, t) => t !== 1).map(qe), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
723
662
  let t = e.slice(0, r);
724
663
  for (; t.length < r;) t.push("");
725
664
  return t;
@@ -730,11 +669,11 @@ function B(e) {
730
669
  aligns: a
731
670
  };
732
671
  }
733
- function et(e) {
672
+ function Ye(e) {
734
673
  return e.replace(/\\\|/g, "|").length;
735
674
  }
736
- function tt(e, t, n) {
737
- let r = t - et(e);
675
+ function Xe(e, t, n) {
676
+ let r = t - Ye(e);
738
677
  if (r <= 0) return e;
739
678
  if (n === "right") return " ".repeat(r) + e;
740
679
  if (n === "center") {
@@ -743,23 +682,23 @@ function tt(e, t, n) {
743
682
  }
744
683
  return e + " ".repeat(r);
745
684
  }
746
- function nt(e, t) {
685
+ function Ze(e, t) {
747
686
  let n = Math.max(3, e);
748
687
  return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
749
688
  }
750
- function V(e) {
689
+ function z(e) {
751
690
  let t = e.aligns.length, n = [];
752
691
  for (let r = 0; r < t; r++) {
753
692
  let t = 3;
754
- for (let n of e.rows) t = Math.max(t, et(n[r] ?? ""));
693
+ for (let n of e.rows) t = Math.max(t, Ye(n[r] ?? ""));
755
694
  n.push(t);
756
695
  }
757
- let r = (t) => "| " + t.map((t, r) => tt(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
758
- i.push("| " + e.aligns.map((e, t) => nt(n[t], e)).join(" | ") + " |");
696
+ let r = (t) => "| " + t.map((t, r) => Xe(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
697
+ i.push("| " + e.aligns.map((e, t) => Ze(n[t], e)).join(" | ") + " |");
759
698
  for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
760
699
  return i.join("\n");
761
700
  }
762
- function rt(e) {
701
+ function Qe(e) {
763
702
  let t = [];
764
703
  for (let n = 0; n < e.length; n++) {
765
704
  if (e[n] === "\\") {
@@ -781,8 +720,8 @@ function rt(e) {
781
720
  return n;
782
721
  }
783
722
  //#endregion
784
- //#region src/toolbar/table.ts
785
- function H(e, t) {
723
+ //#region src/toolbar/table-position.ts
724
+ function B(e, t) {
786
725
  let n = e.lineAt(t);
787
726
  if (!n.text.includes("|")) return null;
788
727
  let r = n.number;
@@ -800,13 +739,13 @@ function H(e, t) {
800
739
  if (i - r < 1) return null;
801
740
  let a = [];
802
741
  for (let t = r; t <= i; t++) a.push(e.line(t).text);
803
- return B(a) ? {
742
+ return R(a) ? {
804
743
  from: e.line(r).from,
805
744
  to: e.line(i).to,
806
745
  lines: a
807
746
  } : null;
808
747
  }
809
- function it(e, t, n) {
748
+ function $e(e, t, n) {
810
749
  let r = t;
811
750
  for (let t = 0; t < e.length; t++) {
812
751
  let i = e[t];
@@ -822,7 +761,7 @@ function it(e, t, n) {
822
761
  onDelimiter: !0
823
762
  };
824
763
  }
825
- let a = rt(i), o = 0;
764
+ let a = Qe(i), o = 0;
826
765
  for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
827
766
  let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
828
767
  return {
@@ -836,22 +775,24 @@ function it(e, t, n) {
836
775
  }
837
776
  return null;
838
777
  }
839
- function U(e, t, n) {
778
+ function V(e, t, n) {
840
779
  let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
841
780
  for (let e = 0; e < i; e++) a += r[e].length + 1;
842
- let o = rt(r[i]), s = o[Math.min(n.col, o.length - 1)];
781
+ let o = Qe(r[i]), s = o[Math.min(n.col, o.length - 1)];
843
782
  return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
844
783
  }
845
- function at(e, t, n, r) {
846
- let i = H(e, t);
847
- return i ? U(i.lines.join("\n"), i.from, {
784
+ function et(e, t, n, r) {
785
+ let i = B(e, t);
786
+ return i ? V(i.lines.join("\n"), i.from, {
848
787
  row: n,
849
788
  col: r,
850
789
  offset: 0,
851
790
  onDelimiter: !1
852
791
  }) : null;
853
792
  }
854
- function ot(e, t) {
793
+ //#endregion
794
+ //#region src/toolbar/table.ts
795
+ function tt(e, t) {
855
796
  requestAnimationFrame(() => {
856
797
  let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
857
798
  if (n.length === 0) return;
@@ -871,7 +812,7 @@ function ot(e, t) {
871
812
  s?.removeAllRanges(), s?.addRange(o), a.focus();
872
813
  });
873
814
  }
874
- function st(e) {
815
+ function nt(e) {
875
816
  let { from: t, to: n } = e.state.selection.main, r = e.state.doc.lineAt(t), i = r.text.slice(0, t - r.from).trim() ? "\n\n" : "", a = t + i.length + 2;
876
817
  return e.dispatch({
877
818
  changes: {
@@ -881,30 +822,30 @@ function st(e) {
881
822
  },
882
823
  selection: u.range(a, a + 8),
883
824
  scrollIntoView: !0
884
- }), e.focus(), ot(e, a), !0;
825
+ }), e.focus(), tt(e, a), !0;
885
826
  }
886
- function W(e) {
887
- return H(e.doc, e.selection.main.head) !== null;
827
+ function H(e) {
828
+ return B(e.doc, e.selection.main.head) !== null;
888
829
  }
889
- function G(e, t) {
890
- let n = H(e.state.doc, e.state.selection.main.head);
830
+ function U(e, t) {
831
+ let n = B(e.state.doc, e.state.selection.main.head);
891
832
  if (!n) return !1;
892
- let r = B(n.lines), i = it(n.lines, n.from, e.state.selection.main.head);
833
+ let r = R(n.lines), i = $e(n.lines, n.from, e.state.selection.main.head);
893
834
  if (!r || !i) return !1;
894
835
  let a = t(r, i);
895
836
  if (!a) return !1;
896
- let o = V(r);
837
+ let o = z(r);
897
838
  return e.dispatch({
898
839
  changes: {
899
840
  from: n.from,
900
841
  to: n.to,
901
842
  insert: o
902
843
  },
903
- selection: u.cursor(U(o, n.from, a)),
844
+ selection: u.cursor(V(o, n.from, a)),
904
845
  scrollIntoView: !0
905
846
  }), e.focus(), !0;
906
847
  }
907
- function ct(e, t, n) {
848
+ function rt(e, t, n) {
908
849
  let r = e.aligns.length, { row: i, col: a } = t;
909
850
  return a += n, a >= r ? (i++, a = 0) : a < 0 && (i--, a = r - 1), i < 0 ? null : (i >= e.rows.length && e.rows.push(Array(r).fill("")), {
910
851
  row: i,
@@ -913,7 +854,7 @@ function ct(e, t, n) {
913
854
  onDelimiter: !1
914
855
  });
915
856
  }
916
- function lt(e, t) {
857
+ function it(e, t) {
917
858
  let n = t.row + 1;
918
859
  return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
919
860
  row: n,
@@ -922,58 +863,58 @@ function lt(e, t) {
922
863
  onDelimiter: !1
923
864
  };
924
865
  }
925
- var ut = a.of([
866
+ var at = a.of([
926
867
  {
927
868
  key: "Tab",
928
- run: (e) => G(e, (e, t) => ct(e, t, 1))
869
+ run: (e) => U(e, (e, t) => rt(e, t, 1))
929
870
  },
930
871
  {
931
872
  key: "Shift-Tab",
932
- run: (e) => G(e, (e, t) => ct(e, t, -1))
873
+ run: (e) => U(e, (e, t) => rt(e, t, -1))
933
874
  },
934
875
  {
935
876
  key: "Enter",
936
- run: (e) => G(e, lt)
877
+ run: (e) => U(e, it)
937
878
  }
938
- ]), dt = d.transactionFilter.of((e) => {
879
+ ]), ot = d.transactionFilter.of((e) => {
939
880
  if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
940
- let t = e.newSelection.main.head, n = H(e.newDoc, t);
881
+ let t = e.newSelection.main.head, n = B(e.newDoc, t);
941
882
  if (!n) return e;
942
- let r = B(n.lines);
883
+ let r = R(n.lines);
943
884
  if (!r) return e;
944
- let i = V(r);
885
+ let i = z(r);
945
886
  if (i === n.lines.join("\n")) return e;
946
- let a = it(n.lines, n.from, t), o = c.of([{
887
+ let a = $e(n.lines, n.from, t), o = c.of([{
947
888
  from: n.from,
948
889
  to: n.to,
949
890
  insert: i
950
891
  }], e.newDoc.length);
951
892
  return {
952
893
  changes: e.changes.compose(o),
953
- selection: a ? u.cursor(U(i, n.from, a)) : e.newSelection,
894
+ selection: a ? u.cursor(V(i, n.from, a)) : e.newSelection,
954
895
  effects: e.effects,
955
896
  scrollIntoView: e.scrollIntoView
956
897
  };
957
- }), K = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), q = (t) => {
958
- let n = e(t.doc);
959
- return n !== null && t.selection.main.head <= n.to;
960
- }, J = (e) => q(e) || I(e) || L(e), ft = (e) => (t) => e !== "`" && z(t, "`") || e !== "$" && z(t, "$"), pt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), Y = (...e) => (t) => e.some((e) => e(t)), X = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, mt = {
898
+ }), W = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), G = (e) => {
899
+ let n = t(e.doc);
900
+ return n !== null && e.selection.main.head <= n.to;
901
+ }, K = (e) => G(e) || P(e) || F(e), st = (e) => (t) => e !== "`" && L(t, "`") || e !== "$" && L(t, "$"), ct = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), q = (...e) => (t) => e.some((e) => e(t)), J = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, lt = {
961
902
  match: /^ {0,3}> ?/,
962
903
  insert: "> "
963
- }, ht = {
904
+ }, ut = {
964
905
  match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
965
906
  insert: "- ",
966
- siblings: X
967
- }, gt = {
907
+ siblings: J
908
+ }, dt = {
968
909
  match: /^(\s*)\d+\. +/,
969
910
  insert: (e) => `${e + 1}. `,
970
- siblings: X
971
- }, _t = {
911
+ siblings: J
912
+ }, ft = {
972
913
  match: /^(\s*)[-*+] \[[ xX]\] +/,
973
914
  insert: "- [ ] ",
974
- siblings: X
915
+ siblings: J
975
916
  };
976
- function vt(e, t, n) {
917
+ function pt(e, t, n) {
977
918
  return {
978
919
  id: e,
979
920
  title: t,
@@ -983,47 +924,122 @@ function vt(e, t, n) {
983
924
  }
984
925
  };
985
926
  }
986
- function Z(e, t, n, r) {
927
+ function Y(e, t, n, r) {
987
928
  return {
988
929
  id: e,
989
930
  title: t,
990
- run: (e) => P(e, (e, t, r) => E(e, t, r, n)) || R(e, n),
991
- isActive: (e) => z(e, n),
992
- disabled: Y(J, ft(n), pt),
931
+ run: (e) => j(e, (e, t, r) => O(e, t, r, n)) || I(e, n),
932
+ isActive: (e) => L(e, n),
933
+ disabled: q(K, st(n), ct),
993
934
  keys: r
994
935
  };
995
936
  }
996
- function Q(e) {
937
+ function X(e) {
997
938
  let t = RegExp(`^#{${e}} `);
998
939
  return {
999
940
  id: `h${e}`,
1000
941
  title: `Heading ${e}`,
1001
- run: (t) => se(t, e),
942
+ run: (t) => Fe(t, e),
1002
943
  isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
1003
- disabled: Y(W, J),
944
+ disabled: q(H, K),
1004
945
  keys: [`Mod-Alt-${e}`]
1005
946
  };
1006
947
  }
1007
- function $(e, t, n, ...r) {
948
+ function Z(e, t, n, ...r) {
1008
949
  return {
1009
950
  id: e,
1010
951
  title: t,
1011
- run: (e) => le(e, n),
1012
- isActive: (e) => ue(e, n.match),
1013
- disabled: Y(W, J, ...r)
952
+ run: (e) => Oe(e, n),
953
+ isActive: (e) => ke(e, n.match),
954
+ disabled: q(H, K, ...r)
1014
955
  };
1015
956
  }
1016
- var yt = [
1017
- vt("undo", "Undo", g),
1018
- vt("redo", "Redo", h),
957
+ //#endregion
958
+ //#region src/toolbar/frontmatter-toggle.ts
959
+ function mt(e) {
960
+ let n = e.state, r = t(n.doc);
961
+ if (r) {
962
+ let t = n.doc.lineAt(r.from), i = n.doc.lineAt(r.to);
963
+ e.dispatch({
964
+ changes: [{
965
+ from: t.from,
966
+ to: Math.min(t.to + 1, n.doc.length)
967
+ }, {
968
+ from: i.from,
969
+ to: Math.min(i.to + 1, n.doc.length)
970
+ }],
971
+ scrollIntoView: !0
972
+ });
973
+ } else {
974
+ let t = n.doc.lineAt(n.selection.main.to).number;
975
+ e.dispatch({
976
+ changes: [{
977
+ from: 0,
978
+ insert: "---\n"
979
+ }, {
980
+ from: n.doc.line(t).to,
981
+ insert: "\n---"
982
+ }],
983
+ selection: u.cursor(4),
984
+ scrollIntoView: !0
985
+ });
986
+ }
987
+ return e.focus(), !0;
988
+ }
989
+ function ht(e) {
990
+ return t(e.doc) !== null;
991
+ }
992
+ //#endregion
993
+ //#region src/toolbar/rule.ts
994
+ var gt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
995
+ function _t(e) {
996
+ let t = e.state, n = t.doc.lineAt(t.selection.main.head);
997
+ return gt.test(n.text) ? e.dispatch({
998
+ changes: {
999
+ from: n.from,
1000
+ to: Math.min(n.to + 1, t.doc.length)
1001
+ },
1002
+ scrollIntoView: !0
1003
+ }) : n.text.trim() === "" ? e.dispatch({
1004
+ changes: {
1005
+ from: n.from,
1006
+ to: n.to,
1007
+ insert: "---"
1008
+ },
1009
+ selection: u.cursor(n.from + 3),
1010
+ scrollIntoView: !0
1011
+ }) : e.dispatch({
1012
+ changes: {
1013
+ from: n.to,
1014
+ insert: "\n\n---\n"
1015
+ },
1016
+ selection: u.cursor(n.to + 6),
1017
+ scrollIntoView: !0
1018
+ }), e.focus(), !0;
1019
+ }
1020
+ function vt(e) {
1021
+ return gt.test(e.doc.lineAt(e.selection.main.head).text);
1022
+ }
1023
+ //#endregion
1024
+ //#region src/editor/save.ts
1025
+ var Q = f.define({ combine: (e) => e[0] ?? null });
1026
+ function yt(e) {
1027
+ let t = e.state.facet(Q);
1028
+ return t ? (t(e.state.doc.toString()), !0) : !1;
1029
+ }
1030
+ //#endregion
1031
+ //#region src/toolbar/commands.ts
1032
+ var $ = [
1033
+ pt("undo", "Undo", g),
1034
+ pt("redo", "Redo", h),
1019
1035
  {
1020
1036
  id: "save",
1021
1037
  title: "Save",
1022
1038
  run: (e) => {
1023
- let t = oe(e);
1039
+ let t = yt(e);
1024
1040
  return e.focus(), t;
1025
1041
  },
1026
- disabled: (e) => e.facet(C) == null
1042
+ disabled: (e) => e.facet(Q) == null
1027
1043
  },
1028
1044
  {
1029
1045
  id: "search",
@@ -1031,173 +1047,173 @@ var yt = [
1031
1047
  run: (e) => y(e),
1032
1048
  keys: ["Mod-f"]
1033
1049
  },
1034
- Q(1),
1035
- Q(2),
1036
- Q(3),
1050
+ X(1),
1051
+ X(2),
1052
+ X(3),
1037
1053
  {
1038
1054
  id: "body",
1039
1055
  title: "Body",
1040
- run: (e) => (ce(e) || e.focus(), !0),
1056
+ run: (e) => (Ie(e) || e.focus(), !0),
1041
1057
  isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
1042
- disabled: Y(W, J)
1058
+ disabled: q(H, K)
1043
1059
  },
1044
- Z("bold", "Bold", "**", ["Mod-b"]),
1045
- Z("italic", "Italic", "*", ["Mod-i"]),
1046
- Z("strike", "Strikethrough", "~~"),
1060
+ Y("bold", "Bold", "**", ["Mod-b"]),
1061
+ Y("italic", "Italic", "*", ["Mod-i"]),
1062
+ Y("strike", "Strikethrough", "~~"),
1047
1063
  {
1048
1064
  id: "underline",
1049
1065
  title: "Underline",
1050
- run: (e) => P(e, O) || Ye(e),
1051
- isActive: Xe,
1052
- disabled: Y(J, ft("u"), pt),
1066
+ run: (e) => j(e, le) || We(e),
1067
+ isActive: Ge,
1068
+ disabled: q(K, st("u"), ct),
1053
1069
  keys: ["Mod-u"]
1054
1070
  },
1055
- Z("code", "Inline code", "`"),
1071
+ Y("code", "Inline code", "`"),
1056
1072
  {
1057
1073
  id: "codeBlock",
1058
1074
  title: "Code block",
1059
- run: (e) => P(e, (e, t, n) => E(e, t, n, "`")) || (W(e.state) ? R(e, "`") : Le(e)),
1060
- isActive: (e) => W(e) ? z(e, "`") : I(e),
1061
- disabled: Y(q, L, K)
1075
+ run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (H(e.state) ? I(e, "`") : Ae(e)),
1076
+ isActive: (e) => H(e) ? L(e, "`") : P(e),
1077
+ disabled: q(G, F, W)
1062
1078
  },
1063
1079
  {
1064
1080
  id: "link",
1065
1081
  title: "Link",
1066
- run: (e) => P(e, Ce) || Ue(e),
1067
- isActive: We,
1068
- disabled: J,
1082
+ run: (e) => j(e, ae) || Re(e),
1083
+ isActive: ze,
1084
+ disabled: K,
1069
1085
  keys: ["Mod-k"]
1070
1086
  },
1071
1087
  {
1072
1088
  id: "wikilink",
1073
1089
  title: "Wikilink",
1074
- run: (e) => P(e, Te) || Ke(e),
1075
- isActive: qe,
1076
- disabled: J,
1090
+ run: (e) => j(e, se) || Ve(e),
1091
+ isActive: He,
1092
+ disabled: K,
1077
1093
  keys: ["Mod-Shift-k"]
1078
1094
  },
1079
- $("quote", "Blockquote", mt),
1080
- $("bulletList", "Bulleted list", ht, K),
1081
- $("orderedList", "Numbered list", gt, K),
1082
- $("task", "Task list", _t, K),
1095
+ Z("quote", "Blockquote", lt),
1096
+ Z("bulletList", "Bulleted list", ut, W),
1097
+ Z("orderedList", "Numbered list", dt, W),
1098
+ Z("task", "Task list", ft, W),
1083
1099
  {
1084
1100
  id: "hr",
1085
1101
  title: "Divider",
1086
- run: fe,
1087
- isActive: pe,
1088
- disabled: Y(W, J)
1102
+ run: _t,
1103
+ isActive: vt,
1104
+ disabled: q(H, K)
1089
1105
  },
1090
1106
  {
1091
1107
  id: "frontmatter",
1092
1108
  title: "Frontmatter",
1093
- run: me,
1094
- isActive: he,
1095
- disabled: Y(W, I, L, K)
1109
+ run: mt,
1110
+ isActive: ht,
1111
+ disabled: q(H, P, F, W)
1096
1112
  },
1097
1113
  {
1098
1114
  id: "table",
1099
1115
  title: "Table",
1100
- run: st,
1101
- isActive: W,
1102
- disabled: Y(W, q, I, L, K)
1116
+ run: nt,
1117
+ isActive: H,
1118
+ disabled: q(H, G, P, F, W)
1103
1119
  },
1104
- Z("math", "Inline math", "$"),
1120
+ Y("math", "Inline math", "$"),
1105
1121
  {
1106
1122
  id: "mathBlock",
1107
1123
  title: "Block math",
1108
- run: (e) => P(e, (e, t, n) => E(e, t, n, "$")) || (W(e.state) ? R(e, "$") : Ve(e)),
1109
- isActive: (e) => W(e) ? z(e, "$") : L(e),
1110
- disabled: Y(q, I, K)
1124
+ run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (H(e.state) ? I(e, "$") : Pe(e)),
1125
+ isActive: (e) => H(e) ? L(e, "$") : F(e),
1126
+ disabled: q(G, P, W)
1111
1127
  }
1112
- ], bt = Object.fromEntries(yt.map((e) => [e.id, e])), xt = p.high(a.of(yt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1128
+ ], bt = Object.fromEntries($.map((e) => [e.id, e])), xt = p.high(a.of($.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1113
1129
  key: t,
1114
1130
  preventDefault: !0,
1115
1131
  run: ((t) => !e.disabled?.(t.state) && e.run(t))
1116
- }))))), St = ne.define([
1132
+ }))))), St = x.define([
1117
1133
  {
1118
1134
  tag: [
1119
- S.keyword,
1120
- S.modifier,
1121
- S.controlKeyword,
1122
- S.operatorKeyword,
1123
- S.definitionKeyword,
1124
- S.moduleKeyword
1135
+ w.keyword,
1136
+ w.modifier,
1137
+ w.controlKeyword,
1138
+ w.operatorKeyword,
1139
+ w.definitionKeyword,
1140
+ w.moduleKeyword
1125
1141
  ],
1126
1142
  color: "var(--stylo-syntax-keyword)"
1127
1143
  },
1128
1144
  {
1129
1145
  tag: [
1130
- S.string,
1131
- S.special(S.string),
1132
- S.regexp,
1133
- S.attributeValue
1146
+ w.string,
1147
+ w.special(w.string),
1148
+ w.regexp,
1149
+ w.attributeValue
1134
1150
  ],
1135
1151
  color: "var(--stylo-syntax-string)"
1136
1152
  },
1137
1153
  {
1138
- tag: [S.escape, S.character],
1154
+ tag: [w.escape, w.character],
1139
1155
  color: "var(--stylo-syntax-escape)"
1140
1156
  },
1141
1157
  {
1142
1158
  tag: [
1143
- S.comment,
1144
- S.lineComment,
1145
- S.blockComment,
1146
- S.docComment
1159
+ w.comment,
1160
+ w.lineComment,
1161
+ w.blockComment,
1162
+ w.docComment
1147
1163
  ],
1148
1164
  color: "var(--stylo-syntax-comment)",
1149
1165
  fontStyle: "italic"
1150
1166
  },
1151
1167
  {
1152
1168
  tag: [
1153
- S.number,
1154
- S.integer,
1155
- S.float
1169
+ w.number,
1170
+ w.integer,
1171
+ w.float
1156
1172
  ],
1157
1173
  color: "var(--stylo-syntax-number)"
1158
1174
  },
1159
1175
  {
1160
1176
  tag: [
1161
- S.bool,
1162
- S.null,
1163
- S.atom,
1164
- S.constant(S.name)
1177
+ w.bool,
1178
+ w.null,
1179
+ w.atom,
1180
+ w.constant(w.name)
1165
1181
  ],
1166
1182
  color: "var(--stylo-syntax-constant)"
1167
1183
  },
1168
1184
  {
1169
1185
  tag: [
1170
- S.function(S.variableName),
1171
- S.function(S.propertyName),
1172
- S.macroName
1186
+ w.function(w.variableName),
1187
+ w.function(w.propertyName),
1188
+ w.macroName
1173
1189
  ],
1174
1190
  color: "var(--stylo-syntax-function)"
1175
1191
  },
1176
1192
  {
1177
1193
  tag: [
1178
- S.typeName,
1179
- S.className,
1180
- S.namespace
1194
+ w.typeName,
1195
+ w.className,
1196
+ w.namespace
1181
1197
  ],
1182
1198
  color: "var(--stylo-syntax-type)"
1183
1199
  },
1184
1200
  {
1185
- tag: [S.propertyName, S.attributeName],
1201
+ tag: [w.propertyName, w.attributeName],
1186
1202
  color: "var(--stylo-syntax-property)"
1187
1203
  },
1188
1204
  {
1189
- tag: [S.tagName],
1205
+ tag: [w.tagName],
1190
1206
  color: "var(--stylo-syntax-tag)"
1191
1207
  },
1192
1208
  {
1193
- tag: [S.meta, S.annotation],
1209
+ tag: [w.meta, w.annotation],
1194
1210
  color: "var(--stylo-syntax-comment)"
1195
1211
  },
1196
1212
  {
1197
- tag: [S.invalid],
1213
+ tag: [w.invalid],
1198
1214
  color: "var(--stylo-syntax-invalid)"
1199
1215
  }
1200
- ]), Ct = re(St), wt = i.theme({
1216
+ ]), Ct = S(St), wt = i.theme({
1201
1217
  "&": {
1202
1218
  color: "var(--stylo-text)",
1203
1219
  backgroundColor: "var(--stylo-bg)",
@@ -1282,39 +1298,47 @@ function Et(e) {
1282
1298
  }
1283
1299
  };
1284
1300
  }
1285
- function Dt(e) {
1286
- return async (t) => {
1287
- let n = t.matchBefore(Tt);
1288
- if (!n || n.from + 2 === t.pos && !t.explicit) return null;
1289
- let r = (await e(n.text.slice(2))).map(Et);
1290
- return r.length ? {
1291
- from: n.from + 2,
1292
- to: t.pos,
1293
- options: r,
1301
+ function Dt(e, t) {
1302
+ return async (n) => {
1303
+ let r = n.matchBefore(Tt);
1304
+ if (!r || r.from + 2 === n.pos && !n.explicit) return null;
1305
+ let i = r.text.slice(2), a;
1306
+ try {
1307
+ a = (await e(i)).map(Et);
1308
+ } catch (e) {
1309
+ return t?.(e, {
1310
+ source: "wikiLinkSource",
1311
+ input: i
1312
+ }), null;
1313
+ }
1314
+ return a.length ? {
1315
+ from: r.from + 2,
1316
+ to: n.pos,
1317
+ options: a,
1294
1318
  filter: !1
1295
1319
  } : null;
1296
1320
  };
1297
1321
  }
1298
- function Ot(e) {
1299
- return e ? [ae(), v.data.of({ autocomplete: Dt(e) })] : [];
1322
+ function Ot(e, t) {
1323
+ return e ? [re(), v.data.of({ autocomplete: Dt(e, t) })] : [];
1300
1324
  }
1301
1325
  //#endregion
1302
1326
  //#region src/editor/extensions.ts
1303
- function kt(e, t) {
1327
+ function kt(e, t, n) {
1304
1328
  return [
1305
1329
  te(),
1306
1330
  a.of([...ee, ...m]),
1307
- p.high(ut),
1331
+ p.high(at),
1308
1332
  xt,
1309
- dt,
1333
+ ot,
1310
1334
  b({ top: !0 }),
1311
- a.of(x),
1335
+ a.of(ne),
1312
1336
  _({
1313
1337
  base: v,
1314
1338
  codeLanguages: e
1315
1339
  }),
1316
1340
  Ct,
1317
- Ot(t),
1341
+ Ot(t, n),
1318
1342
  i.lineWrapping,
1319
1343
  wt
1320
1344
  ];
@@ -1324,50 +1348,54 @@ function At(e) {
1324
1348
  d.readOnly.of(e.readOnly),
1325
1349
  i.editable.of(!e.readOnly),
1326
1350
  e.placeholder ? o(e.placeholder) : [],
1327
- e.save ? C.of(e.save) : []
1351
+ e.save ? Q.of(e.save) : []
1328
1352
  ];
1329
1353
  }
1330
1354
  //#endregion
1331
1355
  //#region src/editor/useCodeMirror.ts
1332
1356
  var jt = s.define();
1333
- function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: u, extensions: f, codeLanguages: ee, wikiLinkSource: te }) {
1334
- let m = r(null), h = r(null), g = r(t);
1335
- g.current = t;
1336
- let _ = r(c);
1337
- _.current = c;
1338
- let v = r((e) => _.current?.(e)).current, y = c != null, b = r(u);
1339
- b.current = u;
1340
- let x = r(new l());
1357
+ function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: u, extensions: f, codeLanguages: ee, wikiLinkSource: te, onResolveError: m }) {
1358
+ let h = r(null), g = r(null), _ = r(t);
1359
+ _.current = t;
1360
+ let v = r(c);
1361
+ v.current = c;
1362
+ let y = r((e) => v.current?.(e)).current, b = r(m);
1363
+ b.current = m;
1364
+ let ne = r((e, t) => {
1365
+ b.current?.(e, t);
1366
+ }).current, x = c != null, S = r(u);
1367
+ S.current = u;
1368
+ let C = r(new l());
1341
1369
  return n(() => {
1342
- let t = m.current;
1370
+ let t = h.current;
1343
1371
  if (!t) return;
1344
1372
  let n = new i({
1345
1373
  parent: t,
1346
1374
  state: d.create({
1347
1375
  doc: e,
1348
1376
  extensions: [
1349
- kt(ee, te),
1350
- x.current.of(At({
1377
+ kt(ee, te, ne),
1378
+ C.current.of(At({
1351
1379
  readOnly: o,
1352
1380
  placeholder: s,
1353
- save: y ? v : void 0
1381
+ save: x ? y : void 0
1354
1382
  })),
1355
1383
  p.high(a.of([{
1356
1384
  key: "Mod-s",
1357
- run: oe
1385
+ run: yt
1358
1386
  }])),
1359
1387
  ...f ?? [],
1360
1388
  i.updateListener.of((e) => {
1361
- e.docChanged && (e.transactions.some((e) => !!e.annotation(jt)) || g.current(e.state.doc.toString()));
1389
+ e.docChanged && (e.transactions.some((e) => !!e.annotation(jt)) || _.current(e.state.doc.toString()));
1362
1390
  })
1363
1391
  ]
1364
1392
  })
1365
1393
  });
1366
- return h.current = n, b.current?.(n), () => {
1367
- b.current?.(null), n.destroy(), h.current = null;
1394
+ return g.current = n, S.current?.(n), () => {
1395
+ S.current?.(null), n.destroy(), g.current = null;
1368
1396
  };
1369
1397
  }, []), n(() => {
1370
- let t = h.current;
1398
+ let t = g.current;
1371
1399
  if (!t) return;
1372
1400
  let n = t.state.doc.toString();
1373
1401
  n !== e && t.dispatch({
@@ -1379,19 +1407,19 @@ function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1379
1407
  annotations: jt.of(!0)
1380
1408
  });
1381
1409
  }, [e]), n(() => {
1382
- h.current?.dispatch({ effects: x.current.reconfigure(At({
1410
+ g.current?.dispatch({ effects: C.current.reconfigure(At({
1383
1411
  readOnly: o,
1384
1412
  placeholder: s,
1385
- save: y ? v : void 0
1413
+ save: x ? y : void 0
1386
1414
  })) });
1387
1415
  }, [
1388
1416
  o,
1389
1417
  s,
1390
- y,
1391
- v
1392
- ]), m;
1418
+ x,
1419
+ y
1420
+ ]), h;
1393
1421
  }
1394
1422
  //#endregion
1395
- export { Oe as _, V as a, A as b, Pe as c, je as d, M as f, De as g, Ae as h, B as i, Ie as l, Ne as m, bt as n, Re as o, ke as p, at as r, I as s, Mt as t, Ee as u, Se as v, k as y };
1423
+ export { _e as _, R as a, oe as b, P as c, ge as d, xe as f, be as g, Ce as h, et as i, we as l, ye as m, bt as n, z as o, A as p, _t as r, je as s, Mt as t, De as u, ve as v, ie as x, E as y };
1396
1424
 
1397
- //# sourceMappingURL=useCodeMirror-GPSkaYW6.js.map
1425
+ //# sourceMappingURL=useCodeMirror-DtwupFgc.js.map