@damiro/stylo 0.16.0 → 0.18.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 (42) hide show
  1. package/README.md +6 -4
  2. package/dist/{InPlaceView-CC5hZCcI.js → InPlaceView-Z8c9cqW8.js} +461 -460
  3. package/dist/{InPlaceView-CC5hZCcI.js.map → InPlaceView-Z8c9cqW8.js.map} +1 -1
  4. package/dist/{Preview-5lm2uUVj.js → Preview-BRA_R_Gp.js} +3 -3
  5. package/dist/{Preview-5lm2uUVj.js.map → Preview-BRA_R_Gp.js.map} +1 -1
  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 → embed-DJAydn-v.js} +2 -2
  15. package/dist/{embed-DKKeCE1Y.js.map → embed-DJAydn-v.js.map} +1 -1
  16. package/dist/{embed-cache-CcBfVrc9.js → embed-cache-BU9Smn-h.js} +24 -17
  17. package/dist/embed-cache-BU9Smn-h.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/styles.css +1 -1
  21. package/dist/stylo.js +384 -154
  22. package/dist/stylo.js.map +1 -1
  23. package/dist/toolbar/OverflowBar.d.ts +19 -0
  24. package/dist/toolbar/OverflowBar.d.ts.map +1 -0
  25. package/dist/toolbar/OverflowMenu.d.ts +24 -0
  26. package/dist/toolbar/OverflowMenu.d.ts.map +1 -0
  27. package/dist/toolbar/Toolbar.d.ts +5 -1
  28. package/dist/toolbar/Toolbar.d.ts.map +1 -1
  29. package/dist/toolbar/overflow-fit.d.ts +27 -0
  30. package/dist/toolbar/overflow-fit.d.ts.map +1 -0
  31. package/dist/toolbar/toolbar-model.d.ts +31 -0
  32. package/dist/toolbar/toolbar-model.d.ts.map +1 -0
  33. package/dist/toolbar/use-toolbar-overflow.d.ts +17 -0
  34. package/dist/toolbar/use-toolbar-overflow.d.ts.map +1 -0
  35. package/dist/types/core.d.ts +9 -0
  36. package/dist/types/core.d.ts.map +1 -1
  37. package/dist/types/toolbar.d.ts +16 -0
  38. package/dist/types/toolbar.d.ts.map +1 -1
  39. package/dist/{useCodeMirror-TAWSJQiZ.js → useCodeMirror-Fn6qEfMx.js} +262 -254
  40. package/dist/{useCodeMirror-TAWSJQiZ.js.map → useCodeMirror-Fn6qEfMx.js.map} +1 -1
  41. package/package.json +4 -4
  42. package/dist/embed-cache-CcBfVrc9.js.map +0 -1
package/dist/stylo.js CHANGED
@@ -1,20 +1,20 @@
1
- import { c as e, t, u as n } from "./embed-cache-CcBfVrc9.js";
2
- import { g as r, k as i, l as a, n as o, t as s } from "./useCodeMirror-TAWSJQiZ.js";
1
+ import { c as e, t, u as n } from "./embed-cache-BU9Smn-h.js";
2
+ import { g as r, k as i, l as a, n as o, t as s } from "./useCodeMirror-Fn6qEfMx.js";
3
3
  import { n as c, r as l } from "./config-DTBxVhtH.js";
4
- import { Suspense as u, forwardRef as d, lazy as f, useEffect as p, useImperativeHandle as m, useReducer as h, useRef as g, useState as _, useSyncExternalStore as v } from "react";
5
- import { EditorView as y, showPanel as b } from "@codemirror/view";
6
- import { createPortal as x } from "react-dom";
7
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
4
+ import { Suspense as u, forwardRef as d, lazy as f, useCallback as p, useEffect as m, useImperativeHandle as h, useLayoutEffect as g, useReducer as _, useRef as v, useState as y, useSyncExternalStore as b } from "react";
5
+ import { EditorView as x, showPanel as S } from "@codemirror/view";
6
+ import { createPortal as C } from "react-dom";
7
+ import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
8
8
  //#region src/editor/SourceView.tsx
9
- var w = () => () => {}, T = () => null;
10
- function E({ value: e, onChange: t, readOnly: r, placeholder: a, codeLanguages: o, wikiLinkSource: c, tagSource: l, onResolveError: u, onSave: d, onViewChange: f, canvasHeader: p }) {
11
- let [m, h] = _(null), y = g(f);
12
- y.current = f;
13
- let C = g((e) => {
14
- h(e), y.current?.(e);
15
- }).current, E = g(p);
16
- E.current = p;
17
- let [D] = _(() => p ? new i() : null), O = v(D?.subscribe ?? w, D?.getSnapshot ?? T), [k] = _(() => D ? [b.of(D.panel)] : []), A = s({
9
+ var D = () => () => {}, O = () => null;
10
+ function k({ value: e, onChange: t, readOnly: r, placeholder: a, codeLanguages: o, wikiLinkSource: c, tagSource: l, onResolveError: u, onSave: d, onViewChange: f, canvasHeader: p, hostExtensions: m }) {
11
+ let [h, g] = y(null), _ = v(f);
12
+ _.current = f;
13
+ let x = v((e) => {
14
+ g(e), _.current?.(e);
15
+ }).current, w = v(p);
16
+ w.current = p;
17
+ let [E] = y(() => p ? new i() : null), k = b(E?.subscribe ?? D, E?.getSnapshot ?? O), [A] = y(() => E ? [S.of(E.panel)] : []), j = s({
18
18
  value: e,
19
19
  onChange: t,
20
20
  readOnly: r,
@@ -24,24 +24,25 @@ function E({ value: e, onChange: t, readOnly: r, placeholder: a, codeLanguages:
24
24
  tagSource: l,
25
25
  onResolveError: u,
26
26
  onSave: d,
27
- onViewChange: C,
28
- extensions: k
27
+ onViewChange: x,
28
+ hostExtensions: m,
29
+ extensions: A
29
30
  });
30
- return /* @__PURE__ */ S("div", {
31
+ return /* @__PURE__ */ T("div", {
31
32
  className: n.source,
32
- ref: A,
33
- children: O && E.current && x(E.current({ view: m }), O)
33
+ ref: j,
34
+ children: k && w.current && C(w.current({ view: h }), k)
34
35
  });
35
36
  }
36
37
  //#endregion
37
38
  //#region src/inplace/lazyInPlace.ts
38
- var D = f(async () => ({ default: (await import("./InPlaceView-CC5hZCcI.js")).InPlaceView })), O = f(async () => ({ default: (await import("./Preview-5lm2uUVj.js")).Preview }));
39
+ var A = f(async () => ({ default: (await import("./InPlaceView-Z8c9cqW8.js")).InPlaceView })), j = f(async () => ({ default: (await import("./Preview-BRA_R_Gp.js")).Preview }));
39
40
  //#endregion
40
41
  //#region src/SplitView.tsx
41
- function k({ value: e, onChange: t, onWikiLinkClick: r, readOnly: i, placeholder: a, codeLanguages: o, wikiLinkSource: s, tagSource: c, embedSource: l, onResolveError: d, frontmatter: f, softBreaks: m, onTaskToggle: h, onSave: v, onViewChange: y, canvasHeader: b }) {
42
- let [x, w] = _(null), T = g(null), D = g(!1);
43
- return p(() => {
44
- let e = x?.scrollDOM, t = T.current;
42
+ function M({ value: e, onChange: t, onWikiLinkClick: r, readOnly: i, placeholder: a, codeLanguages: o, wikiLinkSource: s, tagSource: c, embedSource: l, onResolveError: d, frontmatter: f, softBreaks: p, onTaskToggle: h, onSave: g, onViewChange: _, canvasHeader: b, hostExtensions: x }) {
43
+ let [S, C] = y(null), w = v(null), D = v(!1);
44
+ return m(() => {
45
+ let e = S?.scrollDOM, t = w.current;
45
46
  if (!e || !t) return;
46
47
  let n = (e, t) => {
47
48
  if (D.current) return;
@@ -53,11 +54,11 @@ function k({ value: e, onChange: t, onWikiLinkClick: r, readOnly: i, placeholder
53
54
  return e.addEventListener("scroll", r, { passive: !0 }), t.addEventListener("scroll", i, { passive: !0 }), () => {
54
55
  e.removeEventListener("scroll", r), t.removeEventListener("scroll", i);
55
56
  };
56
- }, [x]), /* @__PURE__ */ C("div", {
57
+ }, [S]), /* @__PURE__ */ E("div", {
57
58
  className: n.split,
58
- children: [/* @__PURE__ */ S("div", {
59
+ children: [/* @__PURE__ */ T("div", {
59
60
  className: n.splitPane,
60
- children: /* @__PURE__ */ S(E, {
61
+ children: /* @__PURE__ */ T(k, {
61
62
  value: e,
62
63
  onChange: t,
63
64
  readOnly: i,
@@ -66,28 +67,29 @@ function k({ value: e, onChange: t, onWikiLinkClick: r, readOnly: i, placeholder
66
67
  wikiLinkSource: s,
67
68
  tagSource: c,
68
69
  onResolveError: d,
69
- onSave: v,
70
+ onSave: g,
70
71
  onViewChange: (e) => {
71
- w(e), y?.(e);
72
+ C(e), _?.(e);
72
73
  },
73
- canvasHeader: b
74
+ canvasHeader: b,
75
+ hostExtensions: x
74
76
  })
75
- }), /* @__PURE__ */ S("div", {
77
+ }), /* @__PURE__ */ T("div", {
76
78
  className: n.splitPane,
77
- ref: T,
78
- children: /* @__PURE__ */ S(u, {
79
- fallback: /* @__PURE__ */ S("div", {
79
+ ref: w,
80
+ children: /* @__PURE__ */ T(u, {
81
+ fallback: /* @__PURE__ */ T("div", {
80
82
  className: n.preview,
81
83
  "aria-busy": "true"
82
84
  }),
83
- children: /* @__PURE__ */ S(O, {
85
+ children: /* @__PURE__ */ T(j, {
84
86
  value: e,
85
87
  onWikiLinkClick: r,
86
88
  embedSource: l,
87
89
  onResolveError: d,
88
90
  frontmatter: f,
89
91
  codeLanguages: o,
90
- softBreaks: m,
92
+ softBreaks: p,
91
93
  onTaskToggle: h
92
94
  })
93
95
  })
@@ -96,8 +98,8 @@ function k({ value: e, onChange: t, onWikiLinkClick: r, readOnly: i, placeholder
96
98
  }
97
99
  //#endregion
98
100
  //#region src/toolbar/floating-watchdog.ts
99
- function A(e, t) {
100
- p(() => {
101
+ function N(e, t) {
102
+ m(() => {
101
103
  if (!t) return;
102
104
  let n = 0, r = !1, i = () => {
103
105
  let t = e.current;
@@ -108,9 +110,9 @@ function A(e, t) {
108
110
  }
109
111
  //#endregion
110
112
  //#region src/toolbar/keyboard-inset.ts
111
- function j(e) {
112
- let [t, n] = _(0);
113
- return p(() => {
113
+ function P(e) {
114
+ let [t, n] = y(0);
115
+ return m(() => {
114
116
  let t = typeof window > "u" ? null : window.visualViewport;
115
117
  if (!e || !t) {
116
118
  n(0);
@@ -123,8 +125,130 @@ function j(e) {
123
125
  }, [e]), t;
124
126
  }
125
127
  //#endregion
126
- //#region src/toolbar/Toolbar.tsx
127
- function M(e) {
128
+ //#region src/toolbar/OverflowMenu.tsx
129
+ var F = /* @__PURE__ */ E("svg", {
130
+ viewBox: "0 0 24 24",
131
+ fill: "currentColor",
132
+ stroke: "none",
133
+ children: [
134
+ /* @__PURE__ */ T("circle", {
135
+ cx: "5",
136
+ cy: "12",
137
+ r: "1.8"
138
+ }),
139
+ /* @__PURE__ */ T("circle", {
140
+ cx: "12",
141
+ cy: "12",
142
+ r: "1.8"
143
+ }),
144
+ /* @__PURE__ */ T("circle", {
145
+ cx: "19",
146
+ cy: "12",
147
+ r: "1.8"
148
+ })
149
+ ]
150
+ }), I = (e) => e ?? F;
151
+ function L({ entries: e, icon: t }) {
152
+ let [r, i] = y(!1), a = v(null), o = v(null);
153
+ m(() => {
154
+ if (!r) return;
155
+ let e = (e) => {
156
+ a.current?.contains(e.target) || i(!1);
157
+ }, t = (e) => {
158
+ if (e.key !== "Escape") return;
159
+ let t = a.current?.contains(document.activeElement);
160
+ i(!1), t && o.current?.focus();
161
+ };
162
+ return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
163
+ document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
164
+ };
165
+ }, [r]);
166
+ let s = () => Array.from(a.current?.querySelectorAll("[role^=menuitem]:enabled") ?? []);
167
+ return /* @__PURE__ */ E("div", {
168
+ ref: a,
169
+ className: n.toolbarMore,
170
+ "data-stylo-overflow": "",
171
+ onKeyDown: (e) => {
172
+ if ((e.key === "ArrowDown" || e.key === "ArrowUp") && r) {
173
+ e.preventDefault();
174
+ let t = s(), n = t.indexOf(document.activeElement), r = e.key === "ArrowDown";
175
+ t[n < 0 ? r ? 0 : t.length - 1 : (n + (r ? 1 : -1) + t.length) % t.length]?.focus();
176
+ }
177
+ },
178
+ onBlur: (e) => {
179
+ r && !a.current?.contains(e.relatedTarget) && i(!1);
180
+ },
181
+ children: [/* @__PURE__ */ T("button", {
182
+ ref: o,
183
+ type: "button",
184
+ className: n.toolbarButton,
185
+ title: "More",
186
+ "aria-label": "More",
187
+ "aria-haspopup": "menu",
188
+ "aria-expanded": r,
189
+ onMouseDown: (e) => e.preventDefault(),
190
+ onClick: (e) => {
191
+ let t = !r;
192
+ i(t), t && e.detail === 0 && requestAnimationFrame(() => s()[0]?.focus());
193
+ },
194
+ children: I(t)
195
+ }), r && /* @__PURE__ */ T("div", {
196
+ className: n.toolbarMenu,
197
+ role: "menu",
198
+ "data-stylo-overflow-menu": "",
199
+ children: e.map((e, t) => e === "|" ? /* @__PURE__ */ T("div", {
200
+ className: n.toolbarMenuDivider,
201
+ role: "separator"
202
+ }, `d-${t}`) : /* @__PURE__ */ E("button", {
203
+ type: "button",
204
+ role: e.active === void 0 ? "menuitem" : "menuitemcheckbox",
205
+ "aria-checked": e.active,
206
+ "data-active": e.active ? "" : void 0,
207
+ className: n.toolbarMenuItem,
208
+ "data-command": e.key,
209
+ disabled: e.disabled,
210
+ onMouseDown: (e) => e.preventDefault(),
211
+ onClick: () => {
212
+ a.current?.contains(document.activeElement) && o.current?.focus(), i(!1), e.run();
213
+ },
214
+ children: [e.icon, /* @__PURE__ */ T("span", { children: e.title })]
215
+ }, e.key))
216
+ })]
217
+ });
218
+ }
219
+ //#endregion
220
+ //#region src/toolbar/overflow-fit.ts
221
+ function R(e) {
222
+ let t = [];
223
+ for (let n of e) n.sep && (t.length === 0 || t[t.length - 1].sep) || t.push(n);
224
+ for (; t.length && t[t.length - 1].sep;) t.pop();
225
+ return t;
226
+ }
227
+ function z(e) {
228
+ let t = e.findIndex((e) => e.folded), n = e.map((e) => e.folded).lastIndexOf(!0);
229
+ return R(e.filter((e, r) => e.folded || e.sep && r > t && r < n));
230
+ }
231
+ function B(e, t, n, r = 0) {
232
+ let i = e.map(() => !1), a = () => {
233
+ let a = R(e.filter((e, t) => !i[t]));
234
+ return a.reduce((e, t) => e + t.width, 0) + r * Math.max(0, a.length - 1) + (i.some(Boolean) ? n + (a.length ? r : 0) : 0) <= t;
235
+ }, o = (t) => {
236
+ for (let n = e.length - 1; n >= 0; n--) {
237
+ let r = e[n];
238
+ if (!i[n] && !r.sep && r.pinned === t) return n;
239
+ }
240
+ return -1;
241
+ };
242
+ for (; !a();) {
243
+ let e = o(!1) >= 0 ? o(!1) : o(!0);
244
+ if (e < 0) break;
245
+ i[e] = !0;
246
+ }
247
+ return i;
248
+ }
249
+ //#endregion
250
+ //#region src/toolbar/toolbar-model.ts
251
+ function V(e) {
128
252
  let t = [], n = [];
129
253
  for (let r of e) {
130
254
  if (r !== "|") {
@@ -135,7 +259,7 @@ function M(e) {
135
259
  }
136
260
  return n.length && t.push(n), t;
137
261
  }
138
- function N(e, t) {
262
+ function H(e, t) {
139
263
  if (typeof e != "string") {
140
264
  let { id: t, icon: n, title: r, run: i, isActive: a, disabled: o } = e;
141
265
  return {
@@ -157,91 +281,192 @@ function N(e, t) {
157
281
  disabled: n.disabled
158
282
  } : null;
159
283
  }
160
- function P({ view: e, items: t, icons: i, disabled: s, sticky: c, stickyVisibility: l }) {
161
- let [, u] = h((e) => e + 1, 0), [d, f] = _(!1), m = j(c === "bottom"), v = g(null);
162
- A(v, c === "top"), p(() => {
284
+ //#endregion
285
+ //#region src/toolbar/use-toolbar-overflow.ts
286
+ var U = (e) => parseFloat(e) || 0;
287
+ function W(e) {
288
+ let t = getComputedStyle(e);
289
+ return e.getBoundingClientRect().width + U(t.marginLeft) + U(t.marginRight);
290
+ }
291
+ function G(e, t) {
292
+ let [n, r] = y([]), i = t.map((e) => `${e.key}${e.sep ? "|" : ""}${e.pinned ? "!" : ""}`).join("\0"), a = p(() => {
293
+ let n = e.current, i = n?.closest("[role=toolbar]");
294
+ if (!i || !n) return;
295
+ let a = Array.from(n.children), o = a.pop();
296
+ if (!o || a.length !== t.length) return;
297
+ let s = getComputedStyle(i), c = i.clientWidth - U(s.paddingLeft) - U(s.paddingRight), l = B(t.map((e, t) => ({
298
+ sep: e.sep,
299
+ pinned: e.pinned,
300
+ width: W(a[t])
301
+ })), c, W(o), U(getComputedStyle(n).columnGap));
302
+ r((e) => e.length === l.length && e.every((e, t) => e === l[t]) ? e : l);
303
+ }, [e, i]);
304
+ return g(() => {
305
+ let t = e.current, n = t?.closest("[role=toolbar]");
306
+ if (!n || !t || (a(), typeof ResizeObserver > "u")) return;
307
+ let r = new ResizeObserver(a);
308
+ return r.observe(n), r.observe(t), () => r.disconnect();
309
+ }, [e, a]), n;
310
+ }
311
+ //#endregion
312
+ //#region src/toolbar/OverflowBar.tsx
313
+ var K = () => /* @__PURE__ */ T("span", {
314
+ className: n.toolbarSep,
315
+ "aria-hidden": "true"
316
+ });
317
+ function q({ items: e, icons: t, overflowIcon: r, resolve: i, run: a, renderItem: o }) {
318
+ let s = v(null), c = e.filter((e) => e === "|" || H(e, t) !== null), l = G(s, c.map((e, t) => ({
319
+ key: e === "|" ? `sep-${t}` : typeof e == "string" ? e : e.id,
320
+ sep: e === "|",
321
+ pinned: typeof e == "object" && !!e.pinned
322
+ }))), u = c.map((e, t) => ({
323
+ it: e,
324
+ sep: e === "|",
325
+ folded: !!l[t]
326
+ })), d = R(u.filter((e) => !e.folded)), f = z(u), p = f.map((e) => {
327
+ let t = e.it === "|" ? null : i(e.it);
328
+ if (!t) return "|";
329
+ let { btn: n, off: r, active: o } = t;
330
+ return {
331
+ key: n.key,
332
+ title: n.title,
333
+ icon: n.icon,
334
+ disabled: r,
335
+ active: n.isActive ? o : void 0,
336
+ run: () => a(n)
337
+ };
338
+ });
339
+ return /* @__PURE__ */ E(w, { children: [
340
+ d.map((e, t) => e.it === "|" ? /* @__PURE__ */ T(K, {}, `sep-${t}`) : o(e.it)),
341
+ f.length > 0 && /* @__PURE__ */ T(L, {
342
+ entries: p,
343
+ icon: r
344
+ }),
345
+ /* @__PURE__ */ T("div", {
346
+ className: n.toolbarMeasureClip,
347
+ "aria-hidden": "true",
348
+ children: /* @__PURE__ */ E("div", {
349
+ ref: s,
350
+ className: n.toolbarMeasure,
351
+ children: [c.map((e, r) => e === "|" ? /* @__PURE__ */ T(K, {}, r) : /* @__PURE__ */ T("button", {
352
+ type: "button",
353
+ tabIndex: -1,
354
+ className: n.toolbarButton,
355
+ children: H(e, t).icon
356
+ }, r)), /* @__PURE__ */ T("button", {
357
+ type: "button",
358
+ tabIndex: -1,
359
+ className: n.toolbarButton,
360
+ children: I(r)
361
+ })]
362
+ })
363
+ })
364
+ ] });
365
+ }
366
+ //#endregion
367
+ //#region src/toolbar/Toolbar.tsx
368
+ function J({ view: e, items: t, icons: i, disabled: s, sticky: c, stickyVisibility: l, overflow: u, overflowIcon: d }) {
369
+ let [, f] = _((e) => e + 1, 0), [p, h] = y(!1), g = P(c === "bottom"), b = v(null);
370
+ N(b, c === "top"), m(() => {
163
371
  if (!e) return;
164
372
  let t = e.contentDOM;
165
- f(e.hasFocus);
373
+ h(e.hasFocus);
166
374
  let n = () => {
167
- f(!0), u();
375
+ h(!0), f();
168
376
  }, r = () => {
169
- f(!1), u();
377
+ h(!1), f();
170
378
  }, i = [
171
379
  "keyup",
172
380
  "mouseup",
173
381
  "input"
174
382
  ];
175
- for (let e of i) t.addEventListener(e, u);
383
+ for (let e of i) t.addEventListener(e, f);
176
384
  return t.addEventListener("focus", n), t.addEventListener("blur", r), () => {
177
- for (let e of i) t.removeEventListener(e, u);
385
+ for (let e of i) t.removeEventListener(e, f);
178
386
  t.removeEventListener("focus", n), t.removeEventListener("blur", r);
179
387
  };
180
388
  }, [e]);
181
- let y = !!c && l === "dynamic" && !d, b = e ? !!r(e) : !1, x = [
389
+ let x = !!c && l === "dynamic" && !p, S = e ? !!r(e) : !1, C = u === "menu", w = [
182
390
  n.toolbar,
183
391
  c && n.toolbarSticky,
184
392
  c === "top" && n.toolbarStickyTop,
185
393
  c === "bottom" && n.toolbarStickyBottom,
186
- y && n.toolbarStickyHidden
187
- ].filter(Boolean).join(" "), C = c === "bottom" ? { transform: `translateY(-${m}px)` } : void 0;
188
- return /* @__PURE__ */ S("div", {
189
- ref: v,
190
- className: x,
394
+ x && n.toolbarStickyHidden,
395
+ C && n.toolbarOverflow
396
+ ].filter(Boolean).join(" "), E = c === "bottom" ? { transform: `translateY(-${g}px)` } : void 0, D = (t) => {
397
+ let n = H(t, i);
398
+ if (!n) return null;
399
+ let r = typeof t == "string" ? o[t] : void 0, c = e ? r ? a(e.state, r, S) : {
400
+ disabled: !!n.disabled?.(e.state),
401
+ active: !!n.isActive?.(e.state)
402
+ } : {
403
+ disabled: !0,
404
+ active: !1
405
+ }, l = !!(s || !e || c.disabled);
406
+ return {
407
+ btn: n,
408
+ off: l,
409
+ active: !l && c.active
410
+ };
411
+ }, O = (t) => {
412
+ e && (t.run(e), f());
413
+ }, k = (e) => {
414
+ let t = D(e);
415
+ if (!t) return null;
416
+ let { btn: r, off: i, active: a } = t;
417
+ return /* @__PURE__ */ T("button", {
418
+ type: "button",
419
+ className: n.toolbarButton,
420
+ "data-command": r.key,
421
+ title: r.title,
422
+ "aria-label": r.title,
423
+ "aria-pressed": r.isActive ? a : void 0,
424
+ "data-active": a ? "" : void 0,
425
+ disabled: i,
426
+ onMouseDown: (e) => e.preventDefault(),
427
+ onClick: () => O(r),
428
+ children: r.icon
429
+ }, r.key);
430
+ }, A = C ? /* @__PURE__ */ T(q, {
431
+ items: t,
432
+ icons: i,
433
+ overflowIcon: d,
434
+ resolve: D,
435
+ run: O,
436
+ renderItem: k
437
+ }) : V(t).map((e, t) => e === "|" ? /* @__PURE__ */ T("span", {
438
+ className: n.toolbarSep,
439
+ "aria-hidden": "true"
440
+ }, `sep-${t}`) : /* @__PURE__ */ T("div", {
441
+ className: n.toolbarGroup,
442
+ children: e.map(k)
443
+ }, `group-${t}`));
444
+ return /* @__PURE__ */ T("div", {
445
+ ref: b,
446
+ className: w,
191
447
  role: "toolbar",
192
448
  "aria-label": "Formatting",
193
- "aria-hidden": y || void 0,
194
- style: C,
195
- children: M(t).map((t, r) => t === "|" ? /* @__PURE__ */ S("span", {
196
- className: n.toolbarSep,
197
- "aria-hidden": "true"
198
- }, `sep-${r}`) : /* @__PURE__ */ S("div", {
199
- className: n.toolbarGroup,
200
- children: t.map((t) => {
201
- let r = N(t, i);
202
- if (!r) return null;
203
- let c = typeof t == "string" ? o[t] : void 0, l = e ? c ? a(e.state, c, b) : {
204
- disabled: !!r.disabled?.(e.state),
205
- active: !!r.isActive?.(e.state)
206
- } : {
207
- disabled: !0,
208
- active: !1
209
- }, d = s || !e || l.disabled, f = !d && l.active;
210
- return /* @__PURE__ */ S("button", {
211
- type: "button",
212
- className: n.toolbarButton,
213
- "data-command": r.key,
214
- title: r.title,
215
- "aria-label": r.title,
216
- "aria-pressed": r.isActive ? f : void 0,
217
- "data-active": f ? "" : void 0,
218
- disabled: d,
219
- onMouseDown: (e) => e.preventDefault(),
220
- onClick: () => {
221
- e && (r.run(e), u());
222
- },
223
- children: r.icon
224
- }, r.key);
225
- })
226
- }, `group-${r}`))
449
+ "aria-hidden": x || void 0,
450
+ style: E,
451
+ children: A
227
452
  });
228
453
  }
229
454
  //#endregion
230
455
  //#region src/Stylo.tsx
231
- var F = d(function({ value: r, onChange: i, mode: a = "in-place", onSave: o, onFrontmatter: s, onWikiLinkClick: l, onLinkClick: d, readOnly: f, placeholder: h, className: v, inPlace: b, codeLanguages: x, wikiLinkSource: w, tagSource: T, embedSource: A, onResolveError: j, toolbar: M, icons: N, frontmatter: F, softBreaks: I, onTaskToggle: L, canvasHeader: R }, z) {
232
- let B = a === "preview" || a === "split" || a === "in-place" ? a : "source", [V, H] = _(null), U = B === "preview" ? null : c(M), W = M && typeof M == "object" ? M : void 0, G = W?.render, K = W?.sticky === "top" ? "top" : W?.sticky ? "bottom" : !1, q = W?.stickyVisibility, J = g(s);
233
- J.current = s;
234
- let Y = g(j);
235
- Y.current = j;
236
- let X = g((e, t) => {
237
- Y.current?.(e, t);
238
- }).current, Z = g(A);
239
- Z.current = A;
240
- let Q = g(void 0);
241
- p(() => {
456
+ var Y = d(function({ value: r, onChange: i, mode: a = "in-place", onSave: o, onFrontmatter: s, onWikiLinkClick: l, onLinkClick: d, readOnly: f, placeholder: p, className: g, inPlace: _, codeLanguages: b, wikiLinkSource: S, tagSource: C, embedSource: w, onResolveError: D, toolbar: O, icons: N, frontmatter: P, softBreaks: F, onTaskToggle: I, canvasHeader: L, extensions: R }, z) {
457
+ let B = a === "preview" || a === "split" || a === "in-place" ? a : "source", [V, H] = y(null), U = B === "preview" ? null : c(O), W = O && typeof O == "object" ? O : void 0, G = W?.render, K = W?.sticky === "top" ? "top" : W?.sticky ? "bottom" : !1, q = W?.stickyVisibility, Y = v(s);
458
+ Y.current = s;
459
+ let X = v(D);
460
+ X.current = D;
461
+ let Z = v((e, t) => {
462
+ X.current?.(e, t);
463
+ }).current, Q = v(w);
464
+ Q.current = w;
465
+ let $ = v(void 0);
466
+ m(() => {
242
467
  let t = e(r)?.frontmatter ?? null;
243
- t !== Q.current && (Q.current = t, J.current?.(t));
244
- }, [r]), m(z, () => ({
468
+ t !== $.current && ($.current = t, Y.current?.(t));
469
+ }, [r]), h(z, () => ({
245
470
  focus: () => V?.focus(),
246
471
  getView: () => V,
247
472
  insertAtCursor: (e) => {
@@ -254,113 +479,118 @@ var F = d(function({ value: r, onChange: i, mode: a = "in-place", onSave: o, onF
254
479
  let r = n.line(e), i = /^ {0,3}#{1,6}[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/.exec(r.text);
255
480
  if (!(!i || i[1] === void 0) && i[1].trim().toLowerCase() === t) return V.dispatch({
256
481
  selection: { anchor: r.from },
257
- effects: y.scrollIntoView(r.from, { y: "start" })
482
+ effects: x.scrollIntoView(r.from, { y: "start" })
258
483
  }), V.focus(), !0;
259
484
  }
260
485
  return !1;
261
486
  },
262
487
  invalidateEmbed: (e) => {
263
- let n = Z.current;
488
+ let n = Q.current;
264
489
  n && t(n, e);
265
490
  }
266
491
  }), [V]);
267
- let $ = [
492
+ let ee = [
268
493
  n.root,
269
494
  K === "bottom" && n.stickyToolbarRootBottom,
270
495
  K === "top" && n.stickyToolbarRootTop,
271
496
  "stylo",
272
- v
497
+ g
273
498
  ].filter(Boolean).join(" ");
274
- return /* @__PURE__ */ C("div", {
275
- className: $,
499
+ return /* @__PURE__ */ E("div", {
500
+ className: ee,
276
501
  "data-stylo-mode": B,
277
502
  children: [
278
503
  U && (() => {
279
- let e = /* @__PURE__ */ S(P, {
504
+ let e = /* @__PURE__ */ T(J, {
280
505
  view: V,
281
506
  items: U,
282
507
  icons: N,
283
508
  disabled: f,
284
509
  sticky: K,
285
- stickyVisibility: q
510
+ stickyVisibility: q,
511
+ overflow: W?.overflow,
512
+ overflowIcon: W?.overflowIcon
286
513
  });
287
514
  return G ? G(e, { view: V }) : e;
288
515
  })(),
289
- B === "source" && /* @__PURE__ */ S(E, {
516
+ B === "source" && /* @__PURE__ */ T(k, {
290
517
  value: r,
291
518
  onChange: i,
292
519
  readOnly: f,
293
- placeholder: h,
294
- codeLanguages: x,
295
- wikiLinkSource: w,
296
- tagSource: T,
297
- onResolveError: X,
520
+ placeholder: p,
521
+ codeLanguages: b,
522
+ wikiLinkSource: S,
523
+ tagSource: C,
524
+ onResolveError: Z,
298
525
  onSave: o,
299
526
  onViewChange: H,
300
- canvasHeader: R
527
+ canvasHeader: L,
528
+ hostExtensions: R
301
529
  }),
302
- B === "preview" && /* @__PURE__ */ S(u, {
303
- fallback: /* @__PURE__ */ S("div", {
530
+ B === "preview" && /* @__PURE__ */ T(u, {
531
+ fallback: /* @__PURE__ */ T("div", {
304
532
  className: n.preview,
305
533
  "aria-busy": "true"
306
534
  }),
307
- children: /* @__PURE__ */ S(O, {
535
+ children: /* @__PURE__ */ T(j, {
308
536
  value: r,
309
537
  onWikiLinkClick: l,
310
- embedSource: A,
311
- onResolveError: X,
312
- frontmatter: F,
313
- codeLanguages: x,
314
- softBreaks: I,
315
- onTaskToggle: L
538
+ embedSource: w,
539
+ onResolveError: Z,
540
+ frontmatter: P,
541
+ codeLanguages: b,
542
+ softBreaks: F,
543
+ onTaskToggle: I
316
544
  })
317
545
  }),
318
- B === "split" && /* @__PURE__ */ S(k, {
546
+ B === "split" && /* @__PURE__ */ T(M, {
319
547
  value: r,
320
548
  onChange: i,
321
549
  onWikiLinkClick: l,
322
550
  readOnly: f,
323
- placeholder: h,
324
- codeLanguages: x,
325
- wikiLinkSource: w,
326
- tagSource: T,
327
- embedSource: A,
328
- onResolveError: X,
329
- frontmatter: F,
330
- softBreaks: I,
331
- onTaskToggle: L,
551
+ placeholder: p,
552
+ codeLanguages: b,
553
+ wikiLinkSource: S,
554
+ tagSource: C,
555
+ embedSource: w,
556
+ onResolveError: Z,
557
+ frontmatter: P,
558
+ softBreaks: F,
559
+ onTaskToggle: I,
332
560
  onSave: o,
333
561
  onViewChange: H,
334
- canvasHeader: R
562
+ canvasHeader: L,
563
+ hostExtensions: R
335
564
  }),
336
- B === "in-place" && /* @__PURE__ */ S(u, {
337
- fallback: /* @__PURE__ */ S("div", {
565
+ B === "in-place" && /* @__PURE__ */ T(u, {
566
+ fallback: /* @__PURE__ */ T("div", {
338
567
  className: n.inplace,
339
568
  "aria-busy": "true"
340
569
  }),
341
- children: /* @__PURE__ */ S(D, {
570
+ children: /* @__PURE__ */ T(A, {
342
571
  value: r,
343
572
  onChange: i,
344
573
  readOnly: f,
345
- placeholder: h,
574
+ placeholder: p,
346
575
  onWikiLinkClick: l,
347
576
  onLinkClick: d,
348
- inPlace: b,
349
- codeLanguages: x,
350
- wikiLinkSource: w,
351
- tagSource: T,
352
- embedSource: A,
353
- onResolveError: X,
577
+ inPlace: _,
578
+ codeLanguages: b,
579
+ wikiLinkSource: S,
580
+ tagSource: C,
581
+ embedSource: w,
582
+ onResolveError: Z,
354
583
  onSave: o,
355
584
  onViewChange: H,
356
- canvasHeader: R
585
+ canvasHeader: L,
586
+ hostExtensions: R
357
587
  })
358
588
  })
359
589
  ]
360
590
  });
361
591
  });
362
- F.displayName = "Stylo";
592
+ Y.displayName = "Stylo";
363
593
  //#endregion
364
- export { F as Stylo, e as splitFrontmatter };
594
+ export { Y as Stylo, e as splitFrontmatter };
365
595
 
366
596
  //# sourceMappingURL=stylo.js.map