@damiro/stylo 0.12.0 → 0.13.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.
- package/README.md +7 -4
- package/dist/{InPlaceView-BWc06Jso.js → InPlaceView-BGVCST5f.js} +40 -40
- package/dist/{InPlaceView-BWc06Jso.js.map → InPlaceView-BGVCST5f.js.map} +1 -1
- package/dist/Preview-C5Oi_jpI.js +238 -0
- package/dist/Preview-C5Oi_jpI.js.map +1 -0
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/highlight.d.ts +20 -0
- package/dist/editor/highlight.d.ts.map +1 -1
- package/dist/highlight-DNGJlCDY.js +133 -0
- package/dist/highlight-DNGJlCDY.js.map +1 -0
- package/dist/render/CodeBlock.d.ts +18 -0
- package/dist/render/CodeBlock.d.ts.map +1 -0
- package/dist/render/Preview.d.ts +9 -2
- package/dist/render/Preview.d.ts.map +1 -1
- package/dist/render/highlightCode.d.ts +10 -0
- package/dist/render/highlightCode.d.ts.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/stylo.js +44 -42
- package/dist/stylo.js.map +1 -1
- package/dist/types.d.ts +9 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-BI1kEPRE.js → useCodeMirror-COmcRrUo.js} +343 -428
- package/dist/useCodeMirror-COmcRrUo.js.map +1 -0
- package/package.json +1 -1
- package/dist/Preview-DIsFdBFA.js +0 -170
- package/dist/Preview-DIsFdBFA.js.map +0 -1
- package/dist/frontmatter-DTCC0gaa.js +0 -40
- package/dist/frontmatter-DTCC0gaa.js.map +0 -1
- package/dist/useCodeMirror-BI1kEPRE.js.map +0 -1
package/README.md
CHANGED
|
@@ -180,7 +180,9 @@ whole canvas. See [Canvas header](./docs/wiki/reference/props.md#canvas-header).
|
|
|
180
180
|
|
|
181
181
|
`inPlace`, `codeLanguages`, `wikiLinkSource`, and `tagSource` are read once,
|
|
182
182
|
when the editing surface mounts — give `<Stylo>` a `key` derived from the
|
|
183
|
-
config to apply a change.
|
|
183
|
+
config to apply a change. (`codeLanguages` is the exception in `preview`,
|
|
184
|
+
which is a pure function of its props and picks up a change immediately, no
|
|
185
|
+
`key` needed.) Every other prop is fully reactive. See
|
|
184
186
|
[props · applied at mount](./docs/wiki/reference/props.md#config-applied-at-mount).
|
|
185
187
|
|
|
186
188
|
Pass `wikiLinkSource` — `(query) => { target, label? }[]`, sync or async — to
|
|
@@ -208,9 +210,10 @@ full grammar set is ~110 lazy chunks). See
|
|
|
208
210
|
Every colour is a `--stylo-*` custom property; override any of them on `.stylo`
|
|
209
211
|
or an ancestor. A dark palette ships built in and activates under a `.dark` or
|
|
210
212
|
`[data-theme="dark"]` ancestor — the `next-themes` / shadcn convention.
|
|
211
|
-
`--stylo-font-size` (default `0.9375rem`) sets the base
|
|
212
|
-
everything inside scales from it;
|
|
213
|
-
`--stylo-font-family-mono` set the prose and code
|
|
213
|
+
`--stylo-font-size` (default `0.9375rem`) sets the base size for the in-place
|
|
214
|
+
canvas, `source`, and `preview` alike — everything inside each scales from it;
|
|
215
|
+
`--stylo-font-family` and `--stylo-font-family-mono` set the prose and code
|
|
216
|
+
fonts.
|
|
214
217
|
|
|
215
218
|
---
|
|
216
219
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
1
|
+
import { a as e, o as t, r as n } from "./highlight-DNGJlCDY.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-COmcRrUo.js";
|
|
3
3
|
import { a as ie, i as x } from "./config-DTBxVhtH.js";
|
|
4
4
|
import { a as S, n as ae, o as oe, r as C, t as w } from "./embed-Dsu6b-MV.js";
|
|
5
5
|
import { t as se } from "./katex-BfiLlqfN.js";
|
|
@@ -468,18 +468,18 @@ function ct(e, t) {
|
|
|
468
468
|
}
|
|
469
469
|
//#endregion
|
|
470
470
|
//#region src/inplace/wikilinks.ts
|
|
471
|
-
function lt(
|
|
472
|
-
let s =
|
|
471
|
+
function lt(t, n, r, i, a, o) {
|
|
472
|
+
let s = t.state.doc.sliceString(n, r);
|
|
473
473
|
if (!s.includes("[[")) return;
|
|
474
|
-
let c =
|
|
475
|
-
for (let r of s.matchAll(
|
|
476
|
-
let [
|
|
477
|
-
if (!u || V(a, d + 1) || c && d > 0 &&
|
|
478
|
-
let f = d +
|
|
474
|
+
let c = t.state.facet(L) != null;
|
|
475
|
+
for (let r of s.matchAll(e)) {
|
|
476
|
+
let [e = "", s = "", l] = r, u = s.trim(), d = n + (r.index ?? 0);
|
|
477
|
+
if (!u || V(a, d + 1) || c && d > 0 && t.state.doc.sliceString(d - 1, d) === "!") continue;
|
|
478
|
+
let f = d + e.length, p = l == null ? d + 2 : d + 2 + s.length + 1, m = f - 2;
|
|
479
479
|
o.push(D.mark({
|
|
480
480
|
class: "cm-inplace-link cm-inplace-wikilink",
|
|
481
481
|
attributes: { "data-stylo-wikilink": u }
|
|
482
|
-
}).range(p, m)), i.has(
|
|
482
|
+
}).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)));
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
//#endregion
|
|
@@ -559,15 +559,15 @@ var ht = {
|
|
|
559
559
|
function H(e, t) {
|
|
560
560
|
return e.facet(R) === "never" || !B(e).has(t);
|
|
561
561
|
}
|
|
562
|
-
function U(
|
|
563
|
-
let a =
|
|
564
|
-
if (!i && !H(
|
|
565
|
-
let o =
|
|
566
|
-
for (let
|
|
567
|
-
let
|
|
568
|
-
if (
|
|
569
|
-
if (!o[
|
|
570
|
-
let
|
|
562
|
+
function U(t, n, r = !1, i = !1) {
|
|
563
|
+
let a = t.doc.lineAt(n);
|
|
564
|
+
if (!i && !H(t, a.number)) return null;
|
|
565
|
+
let o = t.facet(I), s = F(t);
|
|
566
|
+
for (let e of [-1, 1]) for (let i = s.resolveInner(n, e); i; i = i.parent) {
|
|
567
|
+
let e = ht[i.name];
|
|
568
|
+
if (e) {
|
|
569
|
+
if (!o[e.toggle]) break;
|
|
570
|
+
let t = i.getChildren(e.markType), n = t[0], r = t[t.length - 1];
|
|
571
571
|
if (!n || !r || n === r) break;
|
|
572
572
|
return {
|
|
573
573
|
from: i.from,
|
|
@@ -578,26 +578,26 @@ function U(e, n, r = !1, i = !1) {
|
|
|
578
578
|
};
|
|
579
579
|
}
|
|
580
580
|
if (i.name === "Link") {
|
|
581
|
-
if (r ||
|
|
582
|
-
let
|
|
583
|
-
if (
|
|
581
|
+
if (r || t.doc.sliceString(Math.max(0, i.from - 1), i.from) === "[" || !o.links) break;
|
|
582
|
+
let e = i.getChildren("LinkMark");
|
|
583
|
+
if (e.length < 2) break;
|
|
584
584
|
return {
|
|
585
585
|
from: i.from,
|
|
586
586
|
to: i.to,
|
|
587
|
-
contentFrom:
|
|
588
|
-
contentTo:
|
|
587
|
+
contentFrom: e[0].to,
|
|
588
|
+
contentTo: e[1].from,
|
|
589
589
|
kind: "link"
|
|
590
590
|
};
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
|
-
if (o.wikilinks && !r) for (let
|
|
594
|
-
let
|
|
595
|
-
if (n <
|
|
596
|
-
let i =
|
|
593
|
+
if (o.wikilinks && !r) for (let t of a.text.matchAll(e)) {
|
|
594
|
+
let e = a.from + (t.index ?? 0), r = e + t[0].length;
|
|
595
|
+
if (n < e || n > r) continue;
|
|
596
|
+
let i = t[1] ?? "", o = t[2] != null;
|
|
597
597
|
return {
|
|
598
|
-
from:
|
|
598
|
+
from: e,
|
|
599
599
|
to: r,
|
|
600
|
-
contentFrom:
|
|
600
|
+
contentFrom: e + 2 + (o ? i.length + 1 : 0),
|
|
601
601
|
contentTo: r - 2,
|
|
602
602
|
kind: "link"
|
|
603
603
|
};
|
|
@@ -1331,7 +1331,7 @@ var ln = /!\[\[[^\]\n]+?\]\]/, un = [
|
|
|
1331
1331
|
}
|
|
1332
1332
|
},
|
|
1333
1333
|
{
|
|
1334
|
-
re: new RegExp(
|
|
1334
|
+
re: new RegExp(e.source),
|
|
1335
1335
|
build: (e) => {
|
|
1336
1336
|
let t = Z("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
|
|
1337
1337
|
return t.dataset.styloWikilink = e[1] ?? "", t;
|
|
@@ -1924,11 +1924,11 @@ function zn(e, t) {
|
|
|
1924
1924
|
}
|
|
1925
1925
|
return null;
|
|
1926
1926
|
}
|
|
1927
|
-
function Bn(
|
|
1928
|
-
let r =
|
|
1929
|
-
for (let
|
|
1930
|
-
let
|
|
1931
|
-
if (!(n <
|
|
1927
|
+
function Bn(t, n) {
|
|
1928
|
+
let r = t.state.doc.lineAt(n);
|
|
1929
|
+
for (let t of r.text.matchAll(e)) {
|
|
1930
|
+
let e = r.from + (t.index ?? 0), i = e + t[0].length;
|
|
1931
|
+
if (!(n < e || n > i)) return Rn(e, i, (t[1] ?? "").trim());
|
|
1932
1932
|
}
|
|
1933
1933
|
return null;
|
|
1934
1934
|
}
|
|
@@ -2661,7 +2661,7 @@ function mr(e = {}) {
|
|
|
2661
2661
|
//#endregion
|
|
2662
2662
|
//#region src/inplace/InPlaceView.tsx
|
|
2663
2663
|
var hr = () => () => {}, gr = () => null;
|
|
2664
|
-
function _r({ value:
|
|
2664
|
+
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 }) {
|
|
2665
2665
|
let _ = T(o);
|
|
2666
2666
|
_.current = o;
|
|
2667
2667
|
let ee = T(s);
|
|
@@ -2678,7 +2678,7 @@ function _r({ value: t, onChange: n, readOnly: i, placeholder: a, onWikiLinkClic
|
|
|
2678
2678
|
inPlace: c,
|
|
2679
2679
|
embedRegistry: f ? v : void 0
|
|
2680
2680
|
}), ...S ? [ue.of(S.panel)] : []]), w = te({
|
|
2681
|
-
value:
|
|
2681
|
+
value: e,
|
|
2682
2682
|
onChange: n,
|
|
2683
2683
|
readOnly: i,
|
|
2684
2684
|
placeholder: a,
|
|
@@ -2691,7 +2691,7 @@ function _r({ value: t, onChange: n, readOnly: i, placeholder: a, onWikiLinkClic
|
|
|
2691
2691
|
onViewChange: ie
|
|
2692
2692
|
});
|
|
2693
2693
|
return /* @__PURE__ */ _e("div", {
|
|
2694
|
-
className:
|
|
2694
|
+
className: t.inplace,
|
|
2695
2695
|
ref: w,
|
|
2696
2696
|
children: [f && ne.map((e) => de(/* @__PURE__ */ ge(oe, {
|
|
2697
2697
|
reference: e.ref,
|
|
@@ -2704,4 +2704,4 @@ function _r({ value: t, onChange: n, readOnly: i, placeholder: a, onWikiLinkClic
|
|
|
2704
2704
|
//#endregion
|
|
2705
2705
|
export { _r as InPlaceView };
|
|
2706
2706
|
|
|
2707
|
-
//# sourceMappingURL=InPlaceView-
|
|
2707
|
+
//# sourceMappingURL=InPlaceView-BGVCST5f.js.map
|