@damiro/stylo 0.7.0 → 0.9.1
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 +41 -14
- package/dist/{InPlaceView-CS1qy-Ba.js → InPlaceView-Bu91_3Ig.js} +1199 -855
- package/dist/InPlaceView-Bu91_3Ig.js.map +1 -0
- package/dist/Preview-AaGGwLQP.js +170 -0
- package/dist/Preview-AaGGwLQP.js.map +1 -0
- package/dist/SplitView.d.ts +4 -2
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +4 -2
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/extensions.d.ts +2 -2
- package/dist/editor/extensions.d.ts.map +1 -1
- package/dist/editor/useCodeMirror.d.ts +4 -2
- package/dist/editor/useCodeMirror.d.ts.map +1 -1
- package/dist/editor/wikilink-complete.d.ts +5 -3
- package/dist/editor/wikilink-complete.d.ts.map +1 -1
- package/dist/embed-B2Dfkpd_.js +124 -0
- package/dist/embed-B2Dfkpd_.js.map +1 -0
- package/dist/embed.d.ts +14 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/frontmatter-DGUkb9z-.js +39 -0
- package/dist/frontmatter-DGUkb9z-.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/inplace/InPlaceView.d.ts +11 -2
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/config.d.ts +8 -0
- package/dist/inplace/config.d.ts.map +1 -1
- package/dist/inplace/context-menu-actions.d.ts +5 -14
- package/dist/inplace/context-menu-actions.d.ts.map +1 -1
- package/dist/inplace/context-menu-helpers.d.ts +30 -0
- package/dist/inplace/context-menu-helpers.d.ts.map +1 -0
- package/dist/inplace/context-menu-shell.d.ts +23 -0
- package/dist/inplace/context-menu-shell.d.ts.map +1 -0
- package/dist/inplace/context-menu-types.d.ts +46 -0
- package/dist/inplace/context-menu-types.d.ts.map +1 -0
- package/dist/inplace/context-menu.d.ts +2 -42
- package/dist/inplace/context-menu.d.ts.map +1 -1
- package/dist/inplace/decorate.d.ts.map +1 -1
- package/dist/inplace/edit-boundaries.d.ts +1 -25
- package/dist/inplace/edit-boundaries.d.ts.map +1 -1
- package/dist/inplace/edit-divider.d.ts +27 -0
- package/dist/inplace/edit-divider.d.ts.map +1 -0
- package/dist/inplace/embed-registry.d.ts +39 -0
- package/dist/inplace/embed-registry.d.ts.map +1 -0
- package/dist/inplace/embed.d.ts +8 -0
- package/dist/inplace/embed.d.ts.map +1 -0
- package/dist/inplace/extension.d.ts +6 -0
- package/dist/inplace/extension.d.ts.map +1 -1
- package/dist/inplace/inline-md.d.ts +6 -1
- package/dist/inplace/inline-md.d.ts.map +1 -1
- package/dist/inplace/link-row.d.ts +21 -0
- package/dist/inplace/link-row.d.ts.map +1 -0
- package/dist/inplace/math-edit.d.ts +36 -0
- package/dist/inplace/math-edit.d.ts.map +1 -0
- package/dist/inplace/math.d.ts +12 -0
- package/dist/inplace/math.d.ts.map +1 -1
- package/dist/inplace/menu-plugin.d.ts.map +1 -1
- package/dist/inplace/nodes-blocks.d.ts +14 -0
- package/dist/inplace/nodes-blocks.d.ts.map +1 -0
- package/dist/inplace/nodes-inline.d.ts +16 -0
- package/dist/inplace/nodes-inline.d.ts.map +1 -0
- package/dist/inplace/nodes.d.ts +3 -2
- package/dist/inplace/nodes.d.ts.map +1 -1
- package/dist/inplace/scan.d.ts +6 -0
- package/dist/inplace/scan.d.ts.map +1 -1
- package/dist/inplace/selection-bar-position.d.ts +31 -0
- package/dist/inplace/selection-bar-position.d.ts.map +1 -0
- package/dist/inplace/selection-bar.d.ts +0 -2
- package/dist/inplace/selection-bar.d.ts.map +1 -1
- package/dist/inplace/table-widget-caret.d.ts +11 -0
- package/dist/inplace/table-widget-caret.d.ts.map +1 -0
- package/dist/inplace/table-widget-render.d.ts +18 -0
- package/dist/inplace/table-widget-render.d.ts.map +1 -0
- package/dist/inplace/table-widget.d.ts +5 -2
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/inplace/tables.d.ts.map +1 -1
- package/dist/inplace/theme-callout.d.ts +50 -0
- package/dist/inplace/theme-callout.d.ts.map +1 -0
- package/dist/inplace/theme-canvas.d.ts +166 -0
- package/dist/inplace/theme-canvas.d.ts.map +1 -0
- package/dist/inplace/theme-fonts.d.ts +4 -0
- package/dist/inplace/theme-fonts.d.ts.map +1 -0
- package/dist/inplace/theme-menu.d.ts +87 -0
- package/dist/inplace/theme-menu.d.ts.map +1 -0
- package/dist/inplace/theme-popups.d.ts +94 -0
- package/dist/inplace/theme-popups.d.ts.map +1 -0
- package/dist/inplace/theme-table-gizmos.d.ts +57 -0
- package/dist/inplace/theme-table-gizmos.d.ts.map +1 -0
- package/dist/inplace/theme-table.d.ts +30 -0
- package/dist/inplace/theme-table.d.ts.map +1 -0
- package/dist/inplace/theme.d.ts +5 -0
- package/dist/inplace/theme.d.ts.map +1 -1
- package/dist/inplace/wikilinks.d.ts.map +1 -1
- package/dist/inplace/wrap-at.d.ts +32 -0
- package/dist/inplace/wrap-at.d.ts.map +1 -0
- package/dist/{markdown-N3lRmU2n.js → markdown-BYXs9Tj8.js} +2 -2
- package/dist/{markdown-N3lRmU2n.js.map → markdown-BYXs9Tj8.js.map} +1 -1
- package/dist/render/Embed.d.ts +24 -0
- package/dist/render/Embed.d.ts.map +1 -0
- package/dist/render/Preview.d.ts +6 -2
- package/dist/render/Preview.d.ts.map +1 -1
- package/dist/render/embed-cache.d.ts +10 -0
- package/dist/render/embed-cache.d.ts.map +1 -0
- package/dist/render/remark-embed.d.ts +19 -0
- package/dist/render/remark-embed.d.ts.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/stylo.js +70 -54
- package/dist/stylo.js.map +1 -1
- package/dist/toolbar/block.d.ts +0 -26
- package/dist/toolbar/block.d.ts.map +1 -1
- package/dist/toolbar/command-helpers.d.ts +57 -0
- package/dist/toolbar/command-helpers.d.ts.map +1 -0
- package/dist/toolbar/commands.d.ts +1 -21
- package/dist/toolbar/commands.d.ts.map +1 -1
- package/dist/toolbar/frontmatter-toggle.d.ts +13 -0
- package/dist/toolbar/frontmatter-toggle.d.ts.map +1 -0
- package/dist/toolbar/heading.d.ts +10 -0
- package/dist/toolbar/heading.d.ts.map +1 -0
- package/dist/toolbar/inline-ops.d.ts +3 -53
- package/dist/toolbar/inline-ops.d.ts.map +1 -1
- package/dist/toolbar/link-ops.d.ts +22 -0
- package/dist/toolbar/link-ops.d.ts.map +1 -0
- package/dist/toolbar/rule.d.ts +11 -0
- package/dist/toolbar/rule.d.ts.map +1 -0
- package/dist/toolbar/table-position.d.ts +32 -0
- package/dist/toolbar/table-position.d.ts.map +1 -0
- package/dist/toolbar/table.d.ts +1 -16
- package/dist/toolbar/table.d.ts.map +1 -1
- package/dist/toolbar/underline-ops.d.ts +15 -0
- package/dist/toolbar/underline-ops.d.ts.map +1 -0
- package/dist/toolbar/wikilink-ops.d.ts +22 -0
- package/dist/toolbar/wikilink-ops.d.ts.map +1 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-GPSkaYW6.js → useCodeMirror-DtwupFgc.js} +559 -531
- package/dist/useCodeMirror-DtwupFgc.js.map +1 -0
- package/package.json +2 -1
- package/dist/InPlaceView-CS1qy-Ba.js.map +0 -1
- package/dist/Preview-Bw0k3Mev.js +0 -93
- package/dist/Preview-Bw0k3Mev.js.map +0 -1
- package/dist/callout-oLE630ZP.js +0 -37
- package/dist/callout-oLE630ZP.js.map +0 -1
- package/dist/useCodeMirror-GPSkaYW6.js.map +0 -1
- package/dist/wikilink-CTR8IFKc.js +0 -42
- package/dist/wikilink-CTR8IFKc.js.map +0 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./markdown-BYXs9Tj8.js";
|
|
2
|
+
import { i as s, n as c, r as l } from "./frontmatter-DGUkb9z-.js";
|
|
3
|
+
import { a as u, i as d, n as f, o as p, t as m } from "./embed-B2Dfkpd_.js";
|
|
4
|
+
import { useMemo as h } from "react";
|
|
5
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
6
|
+
//#region src/render/remark-callout.ts
|
|
7
|
+
function v() {
|
|
8
|
+
return (e) => {
|
|
9
|
+
r(e, "blockquote", (e) => {
|
|
10
|
+
let t = e.children[0];
|
|
11
|
+
if (t?.type !== "paragraph") return;
|
|
12
|
+
let n = t.children[0];
|
|
13
|
+
if (n?.type !== "text") return;
|
|
14
|
+
let r = d.exec(n.value);
|
|
15
|
+
if (!r) return;
|
|
16
|
+
n.value = n.value.slice(r[0].length);
|
|
17
|
+
let i = r[1].toLowerCase();
|
|
18
|
+
e.data ??= {};
|
|
19
|
+
let a = e.data.hProperties ??= {};
|
|
20
|
+
a.className = ["stylo-callout", `stylo-callout-${u(i)}`], a["data-callout"] = i;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/render/remark-embed.ts
|
|
26
|
+
function y() {
|
|
27
|
+
return (e) => {
|
|
28
|
+
r(e, "paragraph", (e) => {
|
|
29
|
+
let t = e.children.length === 1 ? e.children[0] : void 0;
|
|
30
|
+
if (t?.type !== "text" || !f(t.value)) return;
|
|
31
|
+
m.lastIndex = 0;
|
|
32
|
+
let n = (m.exec(t.value.trim())?.[1] ?? "").trim();
|
|
33
|
+
n && (e.children = [], e.data ??= {}, e.data.hName = "div", e.data.hProperties = {
|
|
34
|
+
className: ["stylo-embed"],
|
|
35
|
+
"data-stylo-embed": n
|
|
36
|
+
});
|
|
37
|
+
}), r(e, "text", (e, t, n) => {
|
|
38
|
+
if (t == null || n == null || !e.value.includes("![[")) return;
|
|
39
|
+
let r = [], i = 0;
|
|
40
|
+
m.lastIndex = 0;
|
|
41
|
+
for (let t of e.value.matchAll(m)) {
|
|
42
|
+
let n = (t[1] ?? "").trim();
|
|
43
|
+
if (!n) continue;
|
|
44
|
+
let a = t.index ?? 0;
|
|
45
|
+
a > i && r.push({
|
|
46
|
+
type: "text",
|
|
47
|
+
value: e.value.slice(i, a)
|
|
48
|
+
}), r.push({
|
|
49
|
+
type: "text",
|
|
50
|
+
value: "",
|
|
51
|
+
data: {
|
|
52
|
+
hName: "span",
|
|
53
|
+
hProperties: {
|
|
54
|
+
className: ["stylo-embed"],
|
|
55
|
+
"data-stylo-embed-inline": n
|
|
56
|
+
},
|
|
57
|
+
hChildren: []
|
|
58
|
+
}
|
|
59
|
+
}), i = a + t[0].length;
|
|
60
|
+
}
|
|
61
|
+
if (r.length) return i < e.value.length && r.push({
|
|
62
|
+
type: "text",
|
|
63
|
+
value: e.value.slice(i)
|
|
64
|
+
}), n.children.splice(t, 1, ...r), [a, t + r.length];
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/render/remark-wikilink.ts
|
|
70
|
+
function b() {
|
|
71
|
+
return (e) => {
|
|
72
|
+
r(e, "text", (e, t, n) => {
|
|
73
|
+
if (n == null || t == null || !e.value.includes("[[")) return;
|
|
74
|
+
let r = [], i = 0;
|
|
75
|
+
for (let t of e.value.matchAll(l)) {
|
|
76
|
+
let [n = "", a = "", o] = t, s = t.index ?? 0;
|
|
77
|
+
s > i && r.push({
|
|
78
|
+
type: "text",
|
|
79
|
+
value: e.value.slice(i, s)
|
|
80
|
+
}), r.push({
|
|
81
|
+
type: "link",
|
|
82
|
+
url: "#",
|
|
83
|
+
data: { hProperties: { "data-wikilink": a.trim() } },
|
|
84
|
+
children: [{
|
|
85
|
+
type: "text",
|
|
86
|
+
value: (o ?? a).trim()
|
|
87
|
+
}]
|
|
88
|
+
}), i = s + n.length;
|
|
89
|
+
}
|
|
90
|
+
if (i !== 0) return i < e.value.length && r.push({
|
|
91
|
+
type: "text",
|
|
92
|
+
value: e.value.slice(i)
|
|
93
|
+
}), n.children.splice(t, 1, ...r), t + r.length;
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/render/Preview.tsx
|
|
99
|
+
var x = [t];
|
|
100
|
+
function S({ value: t, onWikiLinkClick: r, embedSource: a, onResolveError: l, frontmatter: u = "hidden" }) {
|
|
101
|
+
let d = u === "code" ? c(t) : null, f = h(() => [
|
|
102
|
+
i,
|
|
103
|
+
n,
|
|
104
|
+
o,
|
|
105
|
+
...a ? [y] : [],
|
|
106
|
+
b,
|
|
107
|
+
v
|
|
108
|
+
], [a]);
|
|
109
|
+
return /* @__PURE__ */ _("div", {
|
|
110
|
+
className: s.preview,
|
|
111
|
+
children: [d && /* @__PURE__ */ g("div", {
|
|
112
|
+
className: "stylo-frontmatter",
|
|
113
|
+
children: d.frontmatter
|
|
114
|
+
}), /* @__PURE__ */ g(e, {
|
|
115
|
+
remarkPlugins: f,
|
|
116
|
+
rehypePlugins: x,
|
|
117
|
+
components: {
|
|
118
|
+
a({ node: e, children: t, ...n }) {
|
|
119
|
+
let i = n["data-wikilink"];
|
|
120
|
+
return typeof i == "string" ? /* @__PURE__ */ g("a", {
|
|
121
|
+
...n,
|
|
122
|
+
href: "#",
|
|
123
|
+
onClick: (e) => {
|
|
124
|
+
e.preventDefault(), r?.(i);
|
|
125
|
+
},
|
|
126
|
+
children: t
|
|
127
|
+
}) : /* @__PURE__ */ g("a", {
|
|
128
|
+
...n,
|
|
129
|
+
rel: "noreferrer",
|
|
130
|
+
children: t
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
div({ node: e, children: t, ...n }) {
|
|
134
|
+
let r = n["data-stylo-embed"];
|
|
135
|
+
return typeof r == "string" && a ? /* @__PURE__ */ g("div", {
|
|
136
|
+
...n,
|
|
137
|
+
children: /* @__PURE__ */ g(p, {
|
|
138
|
+
reference: r,
|
|
139
|
+
source: a,
|
|
140
|
+
onError: l
|
|
141
|
+
})
|
|
142
|
+
}) : /* @__PURE__ */ g("div", {
|
|
143
|
+
...n,
|
|
144
|
+
children: t
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
span({ node: e, children: t, ...n }) {
|
|
148
|
+
let r = n["data-stylo-embed-inline"];
|
|
149
|
+
return typeof r == "string" && a ? /* @__PURE__ */ g("span", {
|
|
150
|
+
...n,
|
|
151
|
+
children: /* @__PURE__ */ g(p, {
|
|
152
|
+
reference: r,
|
|
153
|
+
source: a,
|
|
154
|
+
onError: l,
|
|
155
|
+
inline: !0
|
|
156
|
+
})
|
|
157
|
+
}) : /* @__PURE__ */ g("span", {
|
|
158
|
+
...n,
|
|
159
|
+
children: t
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
children: t
|
|
164
|
+
})]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
export { S as Preview };
|
|
169
|
+
|
|
170
|
+
//# sourceMappingURL=Preview-AaGGwLQP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Preview-AaGGwLQP.js","names":[],"sources":["../src/render/remark-callout.ts","../src/render/remark-embed.ts","../src/render/remark-wikilink.ts","../src/render/Preview.tsx"],"sourcesContent":["import type { Blockquote, Root } from \"mdast\"\nimport { visit } from \"unist-util-visit\"\nimport { CALLOUT_TOKEN, calloutBucket } from \"../callout\"\n\n/**\n * Turns an Obsidian callout blockquote (`> [!note] Title`) into a\n * `<blockquote class=\"stylo-callout stylo-callout-<bucket>\" data-callout=\"note\">`.\n * The `[!type]` token is stripped from the first line; a `::before` label keyed\n * off `data-callout` stands in for it (matching the in-place canvas). The\n * `-` / `+` fold marker is accepted and ignored — the box always renders open.\n */\nexport function remarkCallout() {\n return (tree: Root) => {\n visit(tree, \"blockquote\", (node: Blockquote) => {\n const para = node.children[0]\n if (para?.type !== \"paragraph\") return\n const first = para.children[0]\n if (first?.type !== \"text\") return\n\n const m = CALLOUT_TOKEN.exec(first.value)\n if (!m) return\n\n first.value = first.value.slice(m[0].length)\n const type = m[1]!.toLowerCase()\n node.data ??= {}\n const props = (node.data.hProperties ??= {}) as Record<string, unknown>\n props.className = [\"stylo-callout\", `stylo-callout-${calloutBucket(type)}`]\n props[\"data-callout\"] = type\n })\n }\n}\n","import type { Paragraph, PhrasingContent, Root, Text } from \"mdast\"\nimport { SKIP, visit } from \"unist-util-visit\"\nimport { EMBED_PATTERN, isLoneEmbed } from \"../embed\"\n\n/**\n * Turns `![[ref]]` transclusion syntax into empty carrier elements the `Embed`\n * component (wired in `Preview`) fills from the host's `embedSource`.\n *\n * - A **lone** `![[ref]]` — the whole paragraph, trimmed — becomes a block\n * `<div class=\"stylo-embed\" data-stylo-embed=\"ref\">`.\n * - A `![[ref]]` **inside other text** becomes an inline\n * `<span class=\"stylo-embed\" data-stylo-embed-inline=\"ref\">`, and the\n * surrounding text is preserved around it. The host node should be phrasing\n * content in this case.\n *\n * `![[…]]` inside inline or fenced code is left literal (it is not a `text`\n * node). Must run before `remarkWikilink`, or the inner `[[ref]]` is rewritten\n * to a link first. Off unless the consumer passes `embedSource` — `Preview` only\n * adds this plugin then.\n */\nexport function remarkEmbed() {\n return (tree: Root) => {\n visit(tree, \"paragraph\", (node: Paragraph) => {\n const only = node.children.length === 1 ? node.children[0] : undefined\n if (only?.type !== \"text\" || !isLoneEmbed(only.value)) return\n\n EMBED_PATTERN.lastIndex = 0\n const ref = (EMBED_PATTERN.exec(only.value.trim())?.[1] ?? \"\").trim()\n if (!ref) return\n\n node.children = []\n node.data ??= {}\n node.data.hName = \"div\"\n node.data.hProperties = { className: [\"stylo-embed\"], \"data-stylo-embed\": ref }\n })\n\n visit(tree, \"text\", (node: Text, index, parent) => {\n if (index == null || parent == null || !node.value.includes(\"![[\")) return\n\n const parts: PhrasingContent[] = []\n let cursor = 0\n // `matchAll` seeds its internal copy from the shared regex's `lastIndex`;\n // reset it so the scan starts at 0 (the lone-paragraph pass above left it\n // mid-string).\n EMBED_PATTERN.lastIndex = 0\n for (const match of node.value.matchAll(EMBED_PATTERN)) {\n const ref = (match[1] ?? \"\").trim()\n if (!ref) continue\n const start = match.index ?? 0\n if (start > cursor) parts.push({ type: \"text\", value: node.value.slice(cursor, start) })\n parts.push({\n type: \"text\",\n value: \"\",\n data: {\n hName: \"span\",\n hProperties: { className: [\"stylo-embed\"], \"data-stylo-embed-inline\": ref },\n hChildren: [],\n },\n })\n cursor = start + match[0].length\n }\n\n if (!parts.length) return\n if (cursor < node.value.length) parts.push({ type: \"text\", value: node.value.slice(cursor) })\n parent.children.splice(index, 1, ...parts)\n return [SKIP, index + parts.length]\n })\n }\n}\n","import type { Link, Root, Text } from \"mdast\"\nimport { visit } from \"unist-util-visit\"\nimport { WIKILINK_PATTERN } from \"../wikilink\"\n\n/**\n * Rewrites `[[target]]` and `[[target|label]]` inside text into link nodes that\n * carry a `data-wikilink` attribute holding the target. The rendered href is\n * inert (`#`); navigation is the host's job via `onWikiLinkClick`.\n */\nexport function remarkWikilink() {\n return (tree: Root) => {\n visit(tree, \"text\", (node: Text, index, parent) => {\n if (parent == null || index == null || !node.value.includes(\"[[\")) return\n\n const out: Array<Text | Link> = []\n let cursor = 0\n\n for (const match of node.value.matchAll(WIKILINK_PATTERN)) {\n const [raw = \"\", rawTarget = \"\", rawLabel] = match\n const start = match.index ?? 0\n if (start > cursor) {\n out.push({ type: \"text\", value: node.value.slice(cursor, start) })\n }\n out.push({\n type: \"link\",\n url: \"#\",\n data: { hProperties: { \"data-wikilink\": rawTarget.trim() } },\n children: [{ type: \"text\", value: (rawLabel ?? rawTarget).trim() }],\n })\n cursor = start + raw.length\n }\n\n if (cursor === 0) return\n if (cursor < node.value.length) {\n out.push({ type: \"text\", value: node.value.slice(cursor) })\n }\n\n parent.children.splice(index, 1, ...out)\n return index + out.length\n })\n }\n}\n","import { useMemo } from \"react\"\nimport Markdown, { type Components } from \"react-markdown\"\nimport rehypeKatex from \"rehype-katex\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkGfm from \"remark-gfm\"\nimport remarkMath from \"remark-math\"\nimport { splitFrontmatter } from \"../frontmatter\"\nimport styles from \"../styles/stylo.module.css\"\nimport type { EmbedSource, FrontmatterDisplay, ResolveErrorInfo } from \"../types\"\nimport { Embed } from \"./Embed\"\nimport { remarkCallout } from \"./remark-callout\"\nimport { remarkEmbed } from \"./remark-embed\"\nimport { remarkWikilink } from \"./remark-wikilink\"\n\nconst REHYPE_PLUGINS = [rehypeKatex]\n\nexport interface PreviewProps {\n value: string\n onWikiLinkClick?: (target: string) => void\n /** Resolves `![[ref]]` embeds. Omit and `![[…]]` stays literal. */\n embedSource?: EmbedSource\n /** Notified when `embedSource` rejects; the literal fallback still renders. */\n onResolveError?: (error: unknown, info: ResolveErrorInfo) => void\n /** `\"code\"` renders the `---` block as a styled `<pre>`; `\"hidden\"` (default) drops it. */\n frontmatter?: FrontmatterDisplay\n}\n\n/** Rendered Markdown + KaTeX view. A pure function of the string. */\nexport function Preview({\n value,\n onWikiLinkClick,\n embedSource,\n onResolveError,\n frontmatter = \"hidden\",\n}: PreviewProps) {\n const fm = frontmatter === \"code\" ? splitFrontmatter(value) : null\n\n // `remarkEmbed` must precede `remarkWikilink` (it consumes the `![[…]]` before\n // the inner `[[…]]` is rewritten) and is only in the pipeline when the host\n // opts in, so a bare `![[x]]` renders unchanged otherwise.\n const remarkPlugins = useMemo(\n () => [\n remarkFrontmatter,\n remarkGfm,\n remarkMath,\n ...(embedSource ? [remarkEmbed] : []),\n remarkWikilink,\n remarkCallout,\n ],\n [embedSource],\n )\n\n const components: Components = {\n a({ node: _node, children, ...rest }) {\n const target = (rest as Record<string, unknown>)[\"data-wikilink\"]\n if (typeof target === \"string\") {\n return (\n <a\n {...rest}\n href=\"#\"\n onClick={(event) => {\n event.preventDefault()\n onWikiLinkClick?.(target)\n }}\n >\n {children}\n </a>\n )\n }\n return (\n <a {...rest} rel=\"noreferrer\">\n {children}\n </a>\n )\n },\n div({ node: _node, children, ...rest }) {\n const reference = (rest as Record<string, unknown>)[\"data-stylo-embed\"]\n if (typeof reference === \"string\" && embedSource) {\n return (\n <div {...rest}>\n <Embed reference={reference} source={embedSource} onError={onResolveError} />\n </div>\n )\n }\n return <div {...rest}>{children}</div>\n },\n span({ node: _node, children, ...rest }) {\n const reference = (rest as Record<string, unknown>)[\"data-stylo-embed-inline\"]\n if (typeof reference === \"string\" && embedSource) {\n return (\n <span {...rest}>\n <Embed reference={reference} source={embedSource} onError={onResolveError} inline />\n </span>\n )\n }\n return <span {...rest}>{children}</span>\n },\n }\n\n return (\n <div className={styles.preview}>\n {fm && <div className=\"stylo-frontmatter\">{fm.frontmatter}</div>}\n <Markdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={REHYPE_PLUGINS}\n components={components}\n >\n {value}\n </Markdown>\n </div>\n )\n}\n"],"mappings":"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"}
|
package/dist/SplitView.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EditorView } from "@codemirror/view";
|
|
2
|
-
import type { CodeLanguages, FrontmatterDisplay, WikiLinkSource } from "./types";
|
|
2
|
+
import type { CodeLanguages, EmbedSource, FrontmatterDisplay, ResolveErrorInfo, WikiLinkSource } from "./types";
|
|
3
3
|
export interface SplitViewProps {
|
|
4
4
|
value: string;
|
|
5
5
|
onChange: (next: string) => void;
|
|
@@ -8,6 +8,8 @@ export interface SplitViewProps {
|
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
codeLanguages?: CodeLanguages;
|
|
10
10
|
wikiLinkSource?: WikiLinkSource;
|
|
11
|
+
embedSource?: EmbedSource;
|
|
12
|
+
onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
|
|
11
13
|
frontmatter?: FrontmatterDisplay;
|
|
12
14
|
/** Called with the doc string on `Mod-s`. */
|
|
13
15
|
onSave?: (value: string) => void;
|
|
@@ -20,5 +22,5 @@ export interface SplitViewProps {
|
|
|
20
22
|
* Stylo root to have a bounded height — otherwise both panes grow and the page
|
|
21
23
|
* scrolls instead.
|
|
22
24
|
*/
|
|
23
|
-
export declare function SplitView({ value, onChange, onWikiLinkClick, readOnly, placeholder, codeLanguages, wikiLinkSource, frontmatter, onSave, onViewChange, }: SplitViewProps): import("react").JSX.Element;
|
|
25
|
+
export declare function SplitView({ value, onChange, onWikiLinkClick, readOnly, placeholder, codeLanguages, wikiLinkSource, embedSource, onResolveError, frontmatter, onSave, onViewChange, }: SplitViewProps): import("react").JSX.Element;
|
|
24
26
|
//# sourceMappingURL=SplitView.d.ts.map
|
package/dist/SplitView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitView.d.ts","sourceRoot":"","sources":["../src/SplitView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"SplitView.d.ts","sourceRoot":"","sources":["../src/SplitView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAA;IACjE,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,6CAA6C;IAC7C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,uEAAuE;IACvE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAA;CACjD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,WAAW,EACX,cAAc,EACd,WAAW,EACX,MAAM,EACN,YAAY,GACb,EAAE,cAAc,+BAgEhB"}
|
package/dist/Stylo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stylo.d.ts","sourceRoot":"","sources":["../src/Stylo.tsx"],"names":[],"mappings":"AAUA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Stylo.d.ts","sourceRoot":"","sources":["../src/Stylo.tsx"],"names":[],"mappings":"AAUA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAoB,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAExE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,oGAiLhB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EditorView } from "@codemirror/view";
|
|
2
|
-
import type { CodeLanguages, WikiLinkSource } from "../types";
|
|
2
|
+
import type { CodeLanguages, ResolveErrorInfo, WikiLinkSource } from "../types";
|
|
3
3
|
export interface SourceViewProps {
|
|
4
4
|
value: string;
|
|
5
5
|
onChange: (next: string) => void;
|
|
@@ -9,11 +9,13 @@ export interface SourceViewProps {
|
|
|
9
9
|
codeLanguages?: CodeLanguages;
|
|
10
10
|
/** `[[wikilink]]` autocomplete source. Read once. */
|
|
11
11
|
wikiLinkSource?: WikiLinkSource;
|
|
12
|
+
/** Notified when `wikiLinkSource` rejects. */
|
|
13
|
+
onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
|
|
12
14
|
/** Called with the doc string on `Mod-s`. */
|
|
13
15
|
onSave?: (value: string) => void;
|
|
14
16
|
/** Called with the `EditorView` once created, and with `null` on teardown. */
|
|
15
17
|
onViewChange?: (view: EditorView | null) => void;
|
|
16
18
|
}
|
|
17
19
|
/** Raw CodeMirror 6 Markdown surface bound to the canonical string. */
|
|
18
|
-
export declare function SourceView({ value, onChange, readOnly, placeholder, codeLanguages, wikiLinkSource, onSave, onViewChange, }: SourceViewProps): import("react").JSX.Element;
|
|
20
|
+
export declare function SourceView({ value, onChange, readOnly, placeholder, codeLanguages, wikiLinkSource, onResolveError, onSave, onViewChange, }: SourceViewProps): import("react").JSX.Element;
|
|
19
21
|
//# sourceMappingURL=SourceView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceView.d.ts","sourceRoot":"","sources":["../../src/editor/SourceView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"SourceView.d.ts","sourceRoot":"","sources":["../../src/editor/SourceView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG/E,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,qDAAqD;IACrD,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAA;IACjE,6CAA6C;IAC7C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,8EAA8E;IAC9E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAA;CACjD;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,cAAc,EACd,MAAM,EACN,YAAY,GACb,EAAE,eAAe,+BAajB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Extension } from "@codemirror/state";
|
|
2
|
-
import type { CodeLanguages, WikiLinkSource } from "../types";
|
|
2
|
+
import type { CodeLanguages, ResolveErrorInfo, WikiLinkSource } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* Static extensions — created once with the view.
|
|
5
5
|
*
|
|
@@ -10,7 +10,7 @@ import type { CodeLanguages, WikiLinkSource } from "../types";
|
|
|
10
10
|
* consumer opts in with exactly the set they want. See the 2026-09-01 journal
|
|
11
11
|
* note and the ADR-001 amendment.
|
|
12
12
|
*/
|
|
13
|
-
export declare function baseExtensions(codeLanguages?: CodeLanguages, wikiLinkSource?: WikiLinkSource): Extension;
|
|
13
|
+
export declare function baseExtensions(codeLanguages?: CodeLanguages, wikiLinkSource?: WikiLinkSource, onResolveError?: (error: unknown, info: ResolveErrorInfo) => void): Extension;
|
|
14
14
|
/** Extensions that depend on props and are swapped via a compartment on change. */
|
|
15
15
|
export declare function dynamicConfig(opts: {
|
|
16
16
|
readOnly: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/editor/extensions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,SAAS,EAAQ,MAAM,mBAAmB,CAAA;AAIrE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/editor/extensions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,SAAS,EAAQ,MAAM,mBAAmB,CAAA;AAIrE,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAM/E;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,aAAa,CAAC,EAAE,aAAa,EAC7B,cAAc,CAAC,EAAE,cAAc,EAC/B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAChE,SAAS,CAqBX;AAED,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,GAAG,SAAS,CAOZ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Extension } from "@codemirror/state";
|
|
2
2
|
import { EditorView } from "@codemirror/view";
|
|
3
|
-
import type { CodeLanguages, WikiLinkSource } from "../types";
|
|
3
|
+
import type { CodeLanguages, ResolveErrorInfo, WikiLinkSource } from "../types";
|
|
4
4
|
export interface UseCodeMirrorOptions {
|
|
5
5
|
value: string;
|
|
6
6
|
onChange: (next: string) => void;
|
|
@@ -19,10 +19,12 @@ export interface UseCodeMirrorOptions {
|
|
|
19
19
|
codeLanguages?: CodeLanguages;
|
|
20
20
|
/** `[[wikilink]]` autocomplete source. Read once. */
|
|
21
21
|
wikiLinkSource?: WikiLinkSource;
|
|
22
|
+
/** Notified when `wikiLinkSource` rejects. Reached through a stable wrapper. */
|
|
23
|
+
onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Owns a CodeMirror `EditorView` for the lifetime of the host element and keeps
|
|
25
27
|
* it in sync with a controlled Markdown string. Returns a ref for the container.
|
|
26
28
|
*/
|
|
27
|
-
export declare function useCodeMirror({ value, onChange, readOnly, placeholder, onSave, onViewChange, extensions, codeLanguages, wikiLinkSource, }: UseCodeMirrorOptions): import("react").RefObject<HTMLDivElement | null>;
|
|
29
|
+
export declare function useCodeMirror({ value, onChange, readOnly, placeholder, onSave, onViewChange, extensions, codeLanguages, wikiLinkSource, onResolveError, }: UseCodeMirrorOptions): import("react").RefObject<HTMLDivElement | null>;
|
|
28
30
|
//# sourceMappingURL=useCodeMirror.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCodeMirror.d.ts","sourceRoot":"","sources":["../../src/editor/useCodeMirror.ts"],"names":[],"mappings":"AACA,OAAO,EAAwC,KAAK,SAAS,EAAQ,MAAM,mBAAmB,CAAA;AAC9F,OAAO,EAAE,UAAU,EAAU,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"useCodeMirror.d.ts","sourceRoot":"","sources":["../../src/editor/useCodeMirror.ts"],"names":[],"mappings":"AACA,OAAO,EAAwC,KAAK,SAAS,EAAQ,MAAM,mBAAmB,CAAA;AAC9F,OAAO,EAAE,UAAU,EAAU,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAO/E,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qFAAqF;IACrF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,oFAAoF;IACpF,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAA;IAChD;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,EAAE,CAAA;IACxB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,qDAAqD;IACrD,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,gFAAgF;IAChF,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAA;CAClE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,WAAW,EACX,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,cAAc,GACf,EAAE,oBAAoB,oDA8EtB"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { type CompletionContext, type CompletionResult } from "@codemirror/autocomplete";
|
|
2
2
|
import type { Extension } from "@codemirror/state";
|
|
3
|
-
import type { WikiLinkSource } from "../types";
|
|
3
|
+
import type { ResolveErrorInfo, WikiLinkSource } from "../types";
|
|
4
|
+
type OnResolveError = (error: unknown, info: ResolveErrorInfo) => void;
|
|
4
5
|
/**
|
|
5
6
|
* The completion source. Exposed for unit tests; consumers use
|
|
6
7
|
* `wikilinkCompletion`.
|
|
7
8
|
*/
|
|
8
|
-
export declare function wikilinkCompletionSource(source: WikiLinkSource): (ctx: CompletionContext) => Promise<CompletionResult | null>;
|
|
9
|
+
export declare function wikilinkCompletionSource(source: WikiLinkSource, onError?: OnResolveError): (ctx: CompletionContext) => Promise<CompletionResult | null>;
|
|
9
10
|
/**
|
|
10
11
|
* `[[wikilink]]` autocomplete. Off unless the host passes `wikiLinkSource`.
|
|
11
12
|
* Registered through the Markdown language data, so it is inert inside a fenced
|
|
12
13
|
* code block and leaves any embedded-language completions intact.
|
|
13
14
|
*/
|
|
14
|
-
export declare function wikilinkCompletion(source?: WikiLinkSource): Extension;
|
|
15
|
+
export declare function wikilinkCompletion(source?: WikiLinkSource, onError?: OnResolveError): Extension;
|
|
16
|
+
export {};
|
|
15
17
|
//# sourceMappingURL=wikilink-complete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wikilink-complete.d.ts","sourceRoot":"","sources":["../../src/editor/wikilink-complete.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"wikilink-complete.d.ts","sourceRoot":"","sources":["../../src/editor/wikilink-complete.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAsB,cAAc,EAAE,MAAM,UAAU,CAAA;AAEpF,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAA;AAyBtE;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc,SACpE,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA0BxE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAM/F"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
2
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
+
//#region src/render/embed-cache.ts
|
|
4
|
+
var r = 64, i = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function a(e) {
|
|
6
|
+
let t = i.get(e);
|
|
7
|
+
return t || (t = /* @__PURE__ */ new Map(), i.set(e, t)), t;
|
|
8
|
+
}
|
|
9
|
+
function o(e, t) {
|
|
10
|
+
let n = a(e).get(t);
|
|
11
|
+
return n?.settled ? { node: n.node } : void 0;
|
|
12
|
+
}
|
|
13
|
+
function s(e, t) {
|
|
14
|
+
let n = a(e), i = n.get(t);
|
|
15
|
+
if (i) return i.promise;
|
|
16
|
+
let o = Promise.resolve(e(t)).then((e) => {
|
|
17
|
+
let r = n.get(t);
|
|
18
|
+
return r && (r.node = e, r.settled = !0), e;
|
|
19
|
+
}, (e) => {
|
|
20
|
+
throw n.delete(t), e;
|
|
21
|
+
});
|
|
22
|
+
if (n.set(t, {
|
|
23
|
+
promise: o,
|
|
24
|
+
settled: !1
|
|
25
|
+
}), n.size > r) {
|
|
26
|
+
let e = n.keys().next().value;
|
|
27
|
+
e !== void 0 && e !== t && n.delete(e);
|
|
28
|
+
}
|
|
29
|
+
return o;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/render/Embed.tsx
|
|
33
|
+
function c({ reference: r, source: i, onError: a, inline: c }) {
|
|
34
|
+
let [l, u] = t(() => {
|
|
35
|
+
let e = o(i, r);
|
|
36
|
+
return e ? {
|
|
37
|
+
status: "ready",
|
|
38
|
+
node: e.node
|
|
39
|
+
} : { status: "loading" };
|
|
40
|
+
});
|
|
41
|
+
e(() => {
|
|
42
|
+
let e = !0, t = o(i, r);
|
|
43
|
+
if (t) {
|
|
44
|
+
u({
|
|
45
|
+
status: "ready",
|
|
46
|
+
node: t.node
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
return u({ status: "loading" }), s(i, r).then((t) => e && u({
|
|
51
|
+
status: "ready",
|
|
52
|
+
node: t
|
|
53
|
+
}), (t) => {
|
|
54
|
+
a?.(t, {
|
|
55
|
+
source: "embedSource",
|
|
56
|
+
input: r
|
|
57
|
+
}), e && u({ status: "error" });
|
|
58
|
+
}), () => {
|
|
59
|
+
e = !1;
|
|
60
|
+
};
|
|
61
|
+
}, [
|
|
62
|
+
r,
|
|
63
|
+
i,
|
|
64
|
+
a
|
|
65
|
+
]);
|
|
66
|
+
let d = `![[${r}]]`;
|
|
67
|
+
return l.status === "loading" ? /* @__PURE__ */ n("span", {
|
|
68
|
+
"aria-busy": "true",
|
|
69
|
+
children: d
|
|
70
|
+
}) : l.status === "ready" && l.node != null ? c ? /* @__PURE__ */ n("span", {
|
|
71
|
+
className: "stylo-embed-content stylo-embed-inline",
|
|
72
|
+
children: l.node
|
|
73
|
+
}) : /* @__PURE__ */ n("div", {
|
|
74
|
+
className: "stylo-embed-content",
|
|
75
|
+
children: l.node
|
|
76
|
+
}) : /* @__PURE__ */ n("span", { children: d });
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/callout.ts
|
|
80
|
+
var l = /^\[!(\w+)\][+-]?[ \t]*/, u = /^([\s>]*)(\[!(\w+)\][+-]?[ \t]*)/, d = {
|
|
81
|
+
note: "note",
|
|
82
|
+
info: "note",
|
|
83
|
+
abstract: "note",
|
|
84
|
+
summary: "note",
|
|
85
|
+
tldr: "note",
|
|
86
|
+
tip: "tip",
|
|
87
|
+
hint: "tip",
|
|
88
|
+
important: "tip",
|
|
89
|
+
success: "tip",
|
|
90
|
+
check: "tip",
|
|
91
|
+
done: "tip",
|
|
92
|
+
question: "warn",
|
|
93
|
+
help: "warn",
|
|
94
|
+
faq: "warn",
|
|
95
|
+
warning: "warn",
|
|
96
|
+
caution: "warn",
|
|
97
|
+
attention: "warn",
|
|
98
|
+
todo: "warn",
|
|
99
|
+
failure: "danger",
|
|
100
|
+
fail: "danger",
|
|
101
|
+
missing: "danger",
|
|
102
|
+
danger: "danger",
|
|
103
|
+
error: "danger",
|
|
104
|
+
bug: "danger",
|
|
105
|
+
example: "example",
|
|
106
|
+
quote: "example",
|
|
107
|
+
cite: "example"
|
|
108
|
+
};
|
|
109
|
+
function f(e) {
|
|
110
|
+
return d[e.toLowerCase()] ?? "note";
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/embed.ts
|
|
114
|
+
var p = /!\[\[([^\]\n]+?)\]\]/g;
|
|
115
|
+
function m(e) {
|
|
116
|
+
let t = e.trim();
|
|
117
|
+
p.lastIndex = 0;
|
|
118
|
+
let n = p.exec(t);
|
|
119
|
+
return n != null && n[0].length === t.length;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { f as a, l as i, m as n, c as o, u as r, p as t };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=embed-B2Dfkpd_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-B2Dfkpd_.js","names":[],"sources":["../src/render/embed-cache.ts","../src/render/Embed.tsx","../src/callout.ts","../src/embed.ts"],"sourcesContent":["import type { ReactNode } from \"react\"\nimport type { EmbedSource } from \"../types\"\n\n/**\n * A process-wide resolution cache for `![[ref]]` embeds, shared by `preview` and\n * the in-place canvas (both render through `Embed`). Without it, an embed\n * scrolled out of the canvas viewport and back — or a `preview` re-render that\n * remounts the subtree — re-invokes `embedSource`, which for a network-backed\n * source is a refetch each time.\n *\n * Keyed first by the `embedSource` identity (a `WeakMap`, so two editors with\n * different resolvers never collide and a changed `embedSource` drops its cache\n * for free — the type doc already asks consumers to keep the reference stable),\n * then by the raw `ref` string.\n *\n * In-flight promises are shared, so two embeds of the same `ref` mounting\n * together call `embedSource` once. A rejection is **not** cached — the next\n * mount retries. `null` (the host chose to keep the reference literal) is a\n * valid cached value; `settled` tells it apart from an absent entry.\n */\n\ninterface Entry {\n promise: Promise<ReactNode>\n node?: ReactNode\n settled: boolean\n}\n\n/** Distinct `ref`s kept per resolver. Eviction only costs a re-resolve. */\nconst MAX_ENTRIES = 64\n\nconst caches = new WeakMap<EmbedSource, Map<string, Entry>>()\n\nfunction bucket(source: EmbedSource): Map<string, Entry> {\n let m = caches.get(source)\n if (!m) {\n m = new Map()\n caches.set(source, m)\n }\n return m\n}\n\n/** A settled result for `ref`, or `undefined` while it is unresolved or absent. */\nexport function peekEmbed(source: EmbedSource, ref: string): { node: ReactNode } | undefined {\n const entry = bucket(source).get(ref)\n return entry?.settled ? { node: entry.node } : undefined\n}\n\n/** Resolve `ref` through the cache — reusing an in-flight or settled entry, or\n * calling `source` on a miss. */\nexport function resolveEmbed(source: EmbedSource, ref: string): Promise<ReactNode> {\n const m = bucket(source)\n const existing = m.get(ref)\n if (existing) return existing.promise\n\n const promise = Promise.resolve(source(ref)).then(\n (node) => {\n const entry = m.get(ref)\n if (entry) {\n entry.node = node\n entry.settled = true\n }\n return node\n },\n (err) => {\n m.delete(ref) // never cache a failure\n throw err\n },\n )\n m.set(ref, { promise, settled: false })\n\n // Insertion-order cap: drop the oldest distinct ref once over the limit.\n if (m.size > MAX_ENTRIES) {\n const oldest = m.keys().next().value\n if (oldest !== undefined && oldest !== ref) m.delete(oldest)\n }\n return promise\n}\n","import { type ReactNode, useEffect, useState } from \"react\"\nimport type { EmbedSource, ResolveErrorInfo } from \"../types\"\nimport { peekEmbed, resolveEmbed } from \"./embed-cache\"\n\ninterface EmbedProps {\n /** The raw `![[ref]]` reference, trimmed. */\n reference: string\n source: EmbedSource\n /** Notified if `source` rejects; the literal fallback still renders. */\n onError?: (error: unknown, info: ResolveErrorInfo) => void\n /**\n * Render as phrasing content in a `<span>` (a `![[…]]` mid-sentence) rather\n * than the default block `<div>`. The host node should be inline in this mode.\n */\n inline?: boolean\n}\n\ntype State = { status: \"loading\" | \"error\" } | { status: \"ready\"; node: ReactNode }\n\n/**\n * Renders one `![[ref]]` embed. Resolves the reference through `embedSource` —\n * via a shared cache (`embed-cache.ts`), so an embed re-mounted by a scroll or a\n * `preview` re-render is not re-fetched — and drops the result into\n * `<div class=\"stylo-embed-content\">`, or a `<span>` when `inline`. While it\n * resolves — and if it rejects, or resolves to `null` — the literal `![[ref]]`\n * text stands in, so a reference is never silently lost.\n */\nexport function Embed({ reference, source, onError, inline }: EmbedProps) {\n const [state, setState] = useState<State>(() => {\n const hit = peekEmbed(source, reference)\n return hit ? { status: \"ready\", node: hit.node } : { status: \"loading\" }\n })\n\n useEffect(() => {\n let live = true\n const hit = peekEmbed(source, reference)\n if (hit) {\n setState({ status: \"ready\", node: hit.node })\n return\n }\n setState({ status: \"loading\" })\n resolveEmbed(source, reference).then(\n (node) => live && setState({ status: \"ready\", node }),\n (error) => {\n onError?.(error, { source: \"embedSource\", input: reference })\n if (live) setState({ status: \"error\" })\n },\n )\n return () => {\n live = false\n }\n }, [reference, source, onError])\n\n const literal = `![[${reference}]]`\n if (state.status === \"loading\") return <span aria-busy=\"true\">{literal}</span>\n if (state.status === \"ready\" && state.node != null) {\n return inline ? (\n <span className=\"stylo-embed-content stylo-embed-inline\">{state.node}</span>\n ) : (\n <div className=\"stylo-embed-content\">{state.node}</div>\n )\n }\n return <span>{literal}</span>\n}\n","/**\n * Obsidian-style callouts: a blockquote whose first line is `> [!type]`,\n * optionally `> [!type] Title` or `> [!type]- Title` (the `-` / `+` fold marker\n * is parsed but Stylo always renders expanded).\n *\n * Single source of truth for the in-place decoration scanner (`nodes.ts`) and\n * the preview remark plugin (`remark-callout.ts`), so the two never drift. The\n * many Obsidian type names collapse to five colour buckets; the raw type is kept\n * on a `data-callout` attribute for a `::before` label and consumer styling.\n */\n\n/** `[!type]` with an optional fold marker, anchored after any `>` prefix. */\nexport const CALLOUT_TOKEN = /^\\[!(\\w+)\\][+-]?[ \\t]*/\n\n/** A blockquote head line in the in-place canvas: `> ` prefix, then the token. */\nexport const CALLOUT_HEAD_LINE = /^([\\s>]*)(\\[!(\\w+)\\][+-]?[ \\t]*)/\n\nexport type CalloutBucket = \"note\" | \"tip\" | \"warn\" | \"danger\" | \"example\"\n\nconst BUCKET: Record<string, CalloutBucket> = {\n note: \"note\",\n info: \"note\",\n abstract: \"note\",\n summary: \"note\",\n tldr: \"note\",\n tip: \"tip\",\n hint: \"tip\",\n important: \"tip\",\n success: \"tip\",\n check: \"tip\",\n done: \"tip\",\n question: \"warn\",\n help: \"warn\",\n faq: \"warn\",\n warning: \"warn\",\n caution: \"warn\",\n attention: \"warn\",\n todo: \"warn\",\n failure: \"danger\",\n fail: \"danger\",\n missing: \"danger\",\n danger: \"danger\",\n error: \"danger\",\n bug: \"danger\",\n example: \"example\",\n quote: \"example\",\n cite: \"example\",\n}\n\n/** The colour bucket for a callout type; unknown types read as `note`. */\nexport function calloutBucket(type: string): CalloutBucket {\n return BUCKET[type.toLowerCase()] ?? \"note\"\n}\n","/**\n * `![[ref]]` transclusion. Capture group 1 is the raw reference — everything\n * between `![[` and `]]`, passed to the host verbatim (any `#heading`,\n * `#^blockid`, or `|size` suffix included). The `g` flag is set for\n * `matchAll` / `exec` loops.\n *\n * Deliberately not built on `WIKILINK_PATTERN`: in an embed the `|` is a size\n * hint (`![[image.png|300]]`), not a display label, so Stylo does not split on\n * it — the whole reference goes to `embedSource`.\n */\nexport const EMBED_PATTERN = /!\\[\\[([^\\]\\n]+?)\\]\\]/g\n\n/** True when `text` (trimmed) is exactly one `![[ref]]` and nothing else. */\nexport function isLoneEmbed(text: string): boolean {\n const trimmed = text.trim()\n EMBED_PATTERN.lastIndex = 0\n const m = EMBED_PATTERN.exec(trimmed)\n return m != null && m[0].length === trimmed.length\n}\n"],"mappings":"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"}
|
package/dist/embed.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `![[ref]]` transclusion. Capture group 1 is the raw reference — everything
|
|
3
|
+
* between `![[` and `]]`, passed to the host verbatim (any `#heading`,
|
|
4
|
+
* `#^blockid`, or `|size` suffix included). The `g` flag is set for
|
|
5
|
+
* `matchAll` / `exec` loops.
|
|
6
|
+
*
|
|
7
|
+
* Deliberately not built on `WIKILINK_PATTERN`: in an embed the `|` is a size
|
|
8
|
+
* hint (`![[image.png|300]]`), not a display label, so Stylo does not split on
|
|
9
|
+
* it — the whole reference goes to `embedSource`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const EMBED_PATTERN: RegExp;
|
|
12
|
+
/** True when `text` (trimmed) is exactly one `![[ref]]` and nothing else. */
|
|
13
|
+
export declare function isLoneEmbed(text: string): boolean;
|
|
14
|
+
//# sourceMappingURL=embed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,QAA0B,CAAA;AAEpD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKjD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var e = {
|
|
2
|
+
root: "_root_1y1lh_1",
|
|
3
|
+
source: "_source_1y1lh_42",
|
|
4
|
+
inplace: "_inplace_1y1lh_57",
|
|
5
|
+
toolbar: "_toolbar_1y1lh_63",
|
|
6
|
+
toolbarButton: "_toolbarButton_1y1lh_73",
|
|
7
|
+
toolbarSep: "_toolbarSep_1y1lh_132",
|
|
8
|
+
toolbarSticky: "_toolbarSticky_1y1lh_142",
|
|
9
|
+
toolbarStickyBottom: "_toolbarStickyBottom_1y1lh_142",
|
|
10
|
+
toolbarStickyTop: "_toolbarStickyTop_1y1lh_142",
|
|
11
|
+
toolbarStickyHidden: "_toolbarStickyHidden_1y1lh_211",
|
|
12
|
+
stickyToolbarRootBottom: "_stickyToolbarRootBottom_1y1lh_222",
|
|
13
|
+
stickyToolbarRootTop: "_stickyToolbarRootTop_1y1lh_227",
|
|
14
|
+
split: "_split_1y1lh_241",
|
|
15
|
+
splitPane: "_splitPane_1y1lh_248",
|
|
16
|
+
preview: "_preview_1y1lh_268"
|
|
17
|
+
}, t = /\[\[([^\]|\n]+?)(?:\|([^\]\n]+?))?\]\]/g;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/frontmatter.ts
|
|
20
|
+
function n(e) {
|
|
21
|
+
if (e.lines < 2 || e.line(1).text.trim() !== "---") return null;
|
|
22
|
+
for (let t = 2; t <= e.lines; t++) if (e.line(t).text.trim() === "---") return {
|
|
23
|
+
from: 0,
|
|
24
|
+
to: e.line(t).to
|
|
25
|
+
};
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
var r = /^---\r?\n(?:([\s\S]*?)\r?\n)?---[ \t]*(?:\r?\n|$)/;
|
|
29
|
+
function i(e) {
|
|
30
|
+
let t = r.exec(e);
|
|
31
|
+
return t ? {
|
|
32
|
+
frontmatter: t[1] ?? "",
|
|
33
|
+
body: e.slice(t[0].length)
|
|
34
|
+
} : null;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { e as i, i as n, t as r, n as t };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=frontmatter-DGUkb9z-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-DGUkb9z-.js","names":[],"sources":["../src/styles/stylo.module.css","../src/wikilink.ts","../src/frontmatter.ts"],"sourcesContent":[".root {\n display: flex;\n flex-direction: column;\n min-height: 0;\n color: var(--stylo-text);\n background: var(--stylo-bg);\n border: 1px solid var(--stylo-border);\n border-radius: var(--stylo-radius);\n overflow: hidden;\n}\n\n/* The editing surface's own scroll container (source, in-place, and the source\n pane of split all resolve to `.cm-scroller`). Thin, token-tinted bars so the\n editor doesn't fall back to a heavier native scrollbar than the app chrome\n around it. A host's own `.cm-scroller` rules load after and win. */\n.root :global(.cm-scroller) {\n scrollbar-width: thin;\n scrollbar-color: color-mix(in srgb, var(--stylo-border) 90%, transparent) transparent;\n}\n\n.root :global(.cm-scroller)::-webkit-scrollbar {\n width: 10px;\n height: 10px;\n}\n\n.root :global(.cm-scroller)::-webkit-scrollbar-thumb {\n border: 3px solid transparent;\n border-radius: 6px;\n background: color-mix(in srgb, var(--stylo-border) 90%, transparent);\n background-clip: padding-box;\n}\n\n.root :global(.cm-scroller)::-webkit-scrollbar-thumb:hover {\n background: color-mix(in srgb, var(--stylo-text-muted) 55%, transparent);\n background-clip: padding-box;\n}\n\n.root :global(.cm-scroller)::-webkit-scrollbar-corner {\n background: transparent;\n}\n\n.source {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n}\n\n.source :global(.cm-editor) {\n height: 100%;\n}\n\n.source :global(.cm-editor.cm-focused) {\n outline: 2px solid var(--stylo-ring);\n outline-offset: -2px;\n}\n\n.inplace {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n}\n\n.toolbar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 2px;\n padding: 4px 6px;\n background: var(--stylo-bg);\n border-bottom: 1px solid var(--stylo-border);\n}\n\n.toolbarButton {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-width: 28px;\n height: 28px;\n padding: 0 5px;\n border: 0;\n border-radius: calc(var(--stylo-radius) - 3px);\n background: none;\n color: var(--stylo-text-muted);\n font: inherit;\n font-size: 0.75rem;\n font-weight: 600;\n line-height: 1;\n cursor: pointer;\n}\n\n.toolbarButton:hover:not(:disabled) {\n background: color-mix(in srgb, var(--stylo-border) 45%, transparent);\n color: var(--stylo-text);\n}\n\n.toolbarButton[data-active] {\n background: color-mix(in srgb, var(--stylo-accent) 12%, transparent);\n color: var(--stylo-text);\n}\n\n.toolbarButton:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.toolbarButton:focus-visible {\n outline: 2px solid var(--stylo-ring);\n outline-offset: -2px;\n}\n\n.toolbarButton svg {\n display: block;\n width: 16px;\n height: 16px;\n}\n\n/* Text glyphs that stand in for an icon (e.g. `fm`) — monospace to read as syntax. */\n.toolbarButton code {\n font-family: var(\n --stylo-font-family-mono,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace\n );\n font-size: 0.8125rem;\n font-weight: 500;\n}\n\n.toolbarSep {\n align-self: stretch;\n width: 1px;\n margin: 4px 3px;\n background: var(--stylo-border);\n}\n\n/* `toolbar={{ sticky: \"top\" | \"bottom\" | true }}` — pins the bar to an edge\n instead of wherever `<Stylo>` sits on the page. One row, no wrapping: it\n scrolls horizontally instead, and its buttons grow to a comfortable touch\n size. Shared by both edges; `.toolbarStickyTop` / `.toolbarStickyBottom`\n below pick the positioning mechanism and the edge itself. */\n.toolbarSticky {\n z-index: 50;\n flex-wrap: nowrap;\n overflow-x: auto;\n -webkit-overflow-scrolling: touch;\n scrollbar-width: none;\n transition: opacity 0.15s ease;\n /* The base `.toolbar` deliberately leaves font-family to inherit from\n wherever the host mounts `<Stylo>`. Both sticky edges are\n `position: fixed` against the window, so neither can safely lean on\n that — the prose-font token (or its default stack) instead of the\n browser's serif default. */\n font-family: var(\n --stylo-font-family,\n -apple-system,\n BlinkMacSystemFont,\n \"Segoe UI\",\n Roboto,\n Helvetica,\n Arial,\n sans-serif\n );\n}\n\n.toolbarSticky::-webkit-scrollbar {\n display: none;\n}\n\n.toolbarSticky .toolbarButton {\n min-width: 40px;\n height: 40px;\n flex: 0 0 auto;\n}\n\n/* `\"bottom\"` (or `true`) — has to be `position: fixed`: nothing about a\n mobile keyboard opening is a \"scroll\", so `position: sticky` has nothing to\n react to. Toolbar.tsx nudges it up from `bottom: 0` with\n `transform: translateY()`, tracking `useKeyboardInset`. */\n.toolbarStickyBottom {\n position: fixed;\n left: 0;\n right: 0;\n bottom: 0;\n border-bottom: none;\n border-top: 1px solid var(--stylo-border);\n box-shadow: 0 -2px 8px color-mix(in srgb, var(--stylo-text) 10%, transparent);\n}\n\n/* `\"top\"` — `position: fixed`, always pinned rather than waiting for a scroll\n threshold like `\"bottom\"`. Nothing ever eats into the top of the screen, so\n there's no keyboard to react to and no accessory bar to collide with — the\n two problems `\"bottom\"` has. `Toolbar.tsx`'s `useFloatingWatchdog` (a\n `requestAnimationFrame` loop, not CSS) is what actually keeps it visible on\n iOS Safari: earlier rounds tried a static `translateZ(0)`, then real\n `position: sticky`, and the disappear-on-scroll bug outlived both — a value\n that's set once and never re-touched gives the browser's compositor nothing\n to recompute if it drifts, so the watchdog re-asserts a `transform` every\n frame instead of trusting a one-time fix to hold. */\n.toolbarStickyTop {\n position: fixed;\n left: 0;\n right: 0;\n top: 0;\n box-shadow: 0 2px 8px color-mix(in srgb, var(--stylo-text) 10%, transparent);\n}\n\n/* `stickyVisibility: \"dynamic\"` — faded out while nothing is focused. */\n.toolbarStickyHidden {\n opacity: 0;\n pointer-events: none;\n}\n\n/* `\"bottom\"` is `position: fixed`, out of flow entirely — reserve its resting\n height so it doesn't sit over the document's last line. Static, not\n keyboard-aware: while the keyboard is open the bar rides up to meet it (see\n `useKeyboardInset`), but the browser's own scroll-into-view around the\n caret is what keeps typing visible above both — this padding only covers\n the keyboard-closed resting state. */\n.stickyToolbarRootBottom .source,\n.stickyToolbarRootBottom .inplace {\n padding-bottom: 52px;\n}\n\n.stickyToolbarRootTop .source,\n.stickyToolbarRootTop .inplace {\n padding-top: 52px;\n}\n\n.inplace :global(.cm-editor) {\n height: 100%;\n}\n\n.inplace :global(.cm-editor.cm-focused) {\n outline: 2px solid var(--stylo-ring);\n outline-offset: -2px;\n}\n\n.split {\n display: grid;\n grid-template-columns: 1fr 1fr;\n flex: 1;\n min-height: 0;\n}\n\n.splitPane {\n display: flex;\n flex-direction: column;\n min-height: 0;\n overflow: auto;\n box-sizing: border-box;\n}\n\n.splitPane + .splitPane {\n border-left: 1px solid var(--stylo-border);\n}\n\n.splitPane > .source {\n flex: 1;\n min-height: 0;\n}\n\n/* Vertical rhythm follows Tailwind's `prose` (@tailwindcss/typography) as a\n visual reference — the em-based scale only, no plugin bundled. Consumer CSS\n wins: `.stylo p`, `.stylo h2`, … load after and match our specificity. */\n.preview {\n padding: 0.75rem 1rem;\n font-size: 0.9375rem;\n line-height: 1.75;\n overflow-wrap: break-word;\n}\n\n.preview > :first-child {\n margin-top: 0;\n}\n\n.preview > :last-child {\n margin-bottom: 0;\n}\n\n.preview :is(h1, h2, h3, h4, h5, h6) {\n font-weight: 600;\n}\n\n.preview h1 {\n margin: 0 0 0.8888889em;\n font-size: 2.25em;\n line-height: 1.1111111;\n}\n\n.preview h2 {\n margin: 2em 0 1em;\n font-size: 1.5em;\n line-height: 1.3333333;\n}\n\n.preview h3 {\n margin: 1.6em 0 0.6em;\n font-size: 1.25em;\n line-height: 1.6;\n}\n\n.preview :is(h4, h5, h6) {\n margin: 1.5em 0 0.5em;\n line-height: 1.5;\n}\n\n.preview p {\n margin: 1.25em 0;\n}\n\n.preview :is(ul, ol) {\n margin: 1.25em 0;\n padding-left: 1.625em;\n}\n\n.preview li {\n margin: 0.5em 0;\n}\n\n.preview li > :is(ul, ol) {\n margin: 0.75em 0;\n}\n\n.preview a {\n color: var(--stylo-link);\n text-decoration: none;\n}\n\n.preview code {\n font-family: var(\n --stylo-font-family-mono,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace\n );\n font-size: 0.9em;\n padding: 0.1em 0.35em;\n border-radius: calc(var(--stylo-radius) - 3px);\n background: color-mix(in srgb, var(--stylo-border) 45%, transparent);\n}\n\n.preview pre {\n margin: 1.7142857em 0;\n padding: 0.75rem 0.9rem;\n border-radius: var(--stylo-radius);\n background: color-mix(in srgb, var(--stylo-border) 35%, transparent);\n overflow-x: auto;\n}\n\n.preview pre code {\n padding: 0;\n font-size: 0.85em;\n background: none;\n}\n\n/* frontmatter=\"code\": the raw `---` block, recessed. `.stylo-frontmatter` is a\n plain (unscoped) class so a consumer's own CSS overrides it at equal\n specificity — restyle the block, or rename / remove the label:\n .stylo-frontmatter::before { content: \"Meta\" }\n .stylo-frontmatter::before { content: none } */\n:global(.stylo-frontmatter) {\n margin: 0 0 1.2em;\n padding: 0.7rem 0.9rem;\n border-left: 3px solid var(--stylo-border);\n border-radius: calc(var(--stylo-radius) - 3px);\n background: color-mix(in srgb, var(--stylo-border) 22%, transparent);\n color: var(--stylo-text-muted);\n font-family: var(\n --stylo-font-family-mono,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace\n );\n font-size: 0.8125rem;\n line-height: 1.5;\n white-space: pre-wrap;\n overflow-x: auto;\n}\n\n:global(.stylo-frontmatter)::before {\n content: \"Frontmatter\";\n display: block;\n margin-bottom: 0.5em;\n font-family: var(\n --stylo-font-family,\n -apple-system,\n BlinkMacSystemFont,\n \"Segoe UI\",\n Roboto,\n Helvetica,\n Arial,\n sans-serif\n );\n font-size: 0.7rem;\n font-weight: 600;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n}\n\n.preview blockquote {\n margin: 1.6em 0;\n padding-left: 1em;\n border-left: 0.25rem solid var(--stylo-border);\n color: var(--stylo-text-muted);\n}\n\n/* Obsidian callouts (`> [!note]`) — mirrors the in-place canvas. `remark-callout`\n adds `stylo-callout stylo-callout-<bucket>` + `data-callout`. Override\n `--stylo-callout-<bucket>` (or `--stylo-callout-accent` per type) to reskin. */\n.preview :global(.stylo-callout) {\n margin: 1.6em 0;\n padding: 0.6em 1em;\n border-left: 0.25rem solid var(--stylo-callout-accent, var(--stylo-border));\n border-radius: var(--stylo-radius);\n background: color-mix(in srgb, var(--stylo-callout-accent, var(--stylo-border)) 10%, transparent);\n color: var(--stylo-text);\n}\n.preview :global(.stylo-callout)::before {\n content: attr(data-callout);\n display: block;\n margin-bottom: 0.2em;\n font-size: 0.8em;\n font-weight: 700;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n color: var(--stylo-callout-accent, var(--stylo-text-muted));\n}\n.preview :global(.stylo-callout-note) {\n --stylo-callout-accent: var(--stylo-callout-note, #3b82f6);\n}\n.preview :global(.stylo-callout-tip) {\n --stylo-callout-accent: var(--stylo-callout-tip, #22c55e);\n}\n.preview :global(.stylo-callout-warn) {\n --stylo-callout-accent: var(--stylo-callout-warn, #f59e0b);\n}\n.preview :global(.stylo-callout-danger) {\n --stylo-callout-accent: var(--stylo-callout-danger, #ef4444);\n}\n.preview :global(.stylo-callout-example) {\n --stylo-callout-accent: var(--stylo-callout-example, #a855f7);\n}\n\n/* `![[embed]]` transclusion. `remark-embed` swaps a lone-`![[ref]]` paragraph\n for `<div class=\"stylo-embed\">`, and `Embed` nests the host-rendered content\n in `.stylo-embed-content`. Both classes are stable override points; set\n `--stylo-embed-accent` to reskin the rail, or zero the padding / border to\n opt out of the frame entirely. */\n.preview :global(.stylo-embed) {\n margin: 1.6em 0;\n padding-left: 1em;\n border-left: 0.25rem solid var(--stylo-embed-accent, var(--stylo-border));\n}\n.preview :global(.stylo-embed-content) > :first-child {\n margin-top: 0;\n}\n.preview :global(.stylo-embed-content) > :last-child {\n margin-bottom: 0;\n}\n\n.preview table {\n display: block;\n margin: 2em 0;\n border-collapse: collapse;\n overflow-x: auto;\n}\n\n.preview :is(th, td) {\n padding: 0.35em 0.6em;\n border: 1px solid var(--stylo-table-border);\n text-align: left;\n}\n\n.preview thead th {\n background: var(--stylo-table-header-bg);\n font-weight: 600;\n}\n\n/* Opt-in zebra striping — no-op until the host sets `--stylo-table-stripe-bg`. */\n.preview tbody tr:nth-child(even) td {\n background: var(--stylo-table-stripe-bg);\n}\n\n/* prose sets `hr { margin: 3em 0 }`, which reads as a page break, not a rule.\n GitHub / VS Code render it tight; `1em` each side matches that. */\n.preview hr {\n margin: 1em 0;\n border: none;\n border-top: 1px solid var(--stylo-border);\n}\n\n.preview :global(.katex-display) {\n padding: 0.25em 0;\n overflow-x: auto;\n overflow-y: hidden;\n}\n","/**\n * `[[target]]` or `[[target|label]]`. Capture group 1 is the target, group 2 the\n * optional display label. The `g` flag is set for `matchAll` / `exec` loops;\n * callers that keep the regex across calls must reset `lastIndex` (or use\n * `matchAll`, which is stateless).\n *\n * Single source of truth for both the render-side plugin (`remark-wikilink`) and\n * the in-place decoration scanner, so the two never drift.\n */\nexport const WIKILINK_PATTERN = /\\[\\[([^\\]|\\n]+?)(?:\\|([^\\]\\n]+?))?\\]\\]/g\n","import type { Text } from \"@codemirror/state\"\n\n/**\n * The leading `---` … `---` YAML block, if present. The CodeMirror Markdown\n * grammar has no frontmatter node — it parses the fences as two thematic breaks\n * — so the region is located by hand. Shared by the in-place decoration layer\n * and the toolbar's frontmatter command.\n */\nexport function frontmatterRange(doc: Text): { from: number; to: number } | null {\n if (doc.lines < 2 || doc.line(1).text.trim() !== \"---\") return null\n for (let n = 2; n <= doc.lines; n++) {\n if (doc.line(n).text.trim() === \"---\") return { from: 0, to: doc.line(n).to }\n }\n return null\n}\n\nconst FRONTMATTER_BLOCK = /^---\\r?\\n(?:([\\s\\S]*?)\\r?\\n)?---[ \\t]*(?:\\r?\\n|$)/\n\n/**\n * Split a leading `---` … `---` block off a Markdown string. `frontmatter` is\n * the inner text (`\"\"` for an empty block); `body` is everything after the\n * closing fence. Used by `preview` to render the block instead of dropping it.\n */\nexport function splitFrontmatter(md: string): { frontmatter: string; body: string } | null {\n const m = FRONTMATTER_BLOCK.exec(md)\n return m ? { frontmatter: m[1] ?? \"\", body: md.slice(m[0].length) } : null\n}\n"],"mappings":";;;;;;;;;;;;;;;;GCSa,IAAmB;;;ACDhC,SAAgB,EAAiB,GAAgD;CAC/E,IAAI,EAAI,QAAQ,KAAK,EAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,OAAO,OAAO;CAC/D,KAAK,IAAI,IAAI,GAAG,KAAK,EAAI,OAAO,KAC9B,IAAI,EAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,OAAO,OAAO;EAAE,MAAM;EAAG,IAAI,EAAI,KAAK,CAAC,CAAC,CAAC;CAAG;CAE9E,OAAO;AACT;AAEA,IAAM,IAAoB;AAO1B,SAAgB,EAAiB,GAA0D;CACzF,IAAM,IAAI,EAAkB,KAAK,CAAE;CACnC,OAAO,IAAI;EAAE,aAAa,EAAE,MAAM;EAAI,MAAM,EAAG,MAAM,EAAE,EAAE,CAAC,MAAM;CAAE,IAAI;AACxE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Stylo } from "./Stylo";
|
|
2
2
|
export { splitFrontmatter } from "./frontmatter";
|
|
3
|
-
export type { CodeLanguages, FrontmatterDisplay, InPlaceConfig, InPlaceDecorationToggles, RevealMode, SelectionUI, StyloHandle, StyloMode, StyloProps, TableEditing, ToolbarCommandId, ToolbarConfig, ToolbarCustomItem, ToolbarItem, WikiLinkCompletion, WikiLinkSource, } from "./types";
|
|
3
|
+
export type { CodeLanguages, EmbedSource, FrontmatterDisplay, InPlaceConfig, InPlaceDecorationToggles, ResolveErrorInfo, RevealMode, SelectionUI, StyloHandle, StyloMode, StyloProps, TableEditing, ToolbarCommandId, ToolbarConfig, ToolbarCustomItem, ToolbarItem, WikiLinkCompletion, WikiLinkSource, } from "./types";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAA"}
|