@damiro/stylo 0.11.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 +16 -6
- package/dist/{InPlaceView-Dyf7I4XQ.js → InPlaceView-BGVCST5f.js} +449 -448
- package/dist/{InPlaceView-Dyf7I4XQ.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 +3 -2
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +5 -3
- 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/highlight.d.ts +20 -0
- package/dist/editor/highlight.d.ts.map +1 -1
- package/dist/editor/tag-complete.d.ts +16 -0
- package/dist/editor/tag-complete.d.ts.map +1 -0
- package/dist/editor/useCodeMirror.d.ts +8 -3
- package/dist/editor/useCodeMirror.d.ts.map +1 -1
- package/dist/highlight-DNGJlCDY.js +133 -0
- package/dist/highlight-DNGJlCDY.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 +5 -3
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- 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 +120 -113
- package/dist/stylo.js.map +1 -1
- package/dist/types.d.ts +35 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-CjG9CwpB.js → useCodeMirror-COmcRrUo.js} +348 -387
- 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-CjG9CwpB.js.map +0 -1
|
@@ -0,0 +1,238 @@
|
|
|
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 { a as s, i as c, o as l, t as u } from "./highlight-DNGJlCDY.js";
|
|
3
|
+
import { a as d, i as f, n as p, o as m, t as h } from "./embed-Dsu6b-MV.js";
|
|
4
|
+
import { useEffect as g, useMemo as _, useState as v } from "react";
|
|
5
|
+
import { LanguageDescription as y } from "@codemirror/language";
|
|
6
|
+
import { highlightTree as b, tagHighlighter as x } from "@lezer/highlight";
|
|
7
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
8
|
+
//#region src/render/highlightCode.ts
|
|
9
|
+
var w = x(u.map(({ tags: e, token: t }) => ({
|
|
10
|
+
tag: e,
|
|
11
|
+
class: `stylo-tok-${t}`
|
|
12
|
+
}))), T = {
|
|
13
|
+
"&": "&",
|
|
14
|
+
"<": "<",
|
|
15
|
+
">": ">"
|
|
16
|
+
}, E = (e) => e.replace(/[&<>]/g, (e) => T[e] ?? e);
|
|
17
|
+
function D(e, t) {
|
|
18
|
+
return typeof t == "function" ? t(e) : y.matchLanguageName(t, e, !0);
|
|
19
|
+
}
|
|
20
|
+
async function O(e, t, n) {
|
|
21
|
+
let r = /\S*/.exec(t)?.[0] ?? "";
|
|
22
|
+
if (!r) return null;
|
|
23
|
+
let i = D(r, n);
|
|
24
|
+
if (!i) return null;
|
|
25
|
+
let a;
|
|
26
|
+
if (i instanceof y) try {
|
|
27
|
+
a = (await i.load()).language;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
else a = i;
|
|
32
|
+
let o = a.parser.parse(e), s = "", c = 0;
|
|
33
|
+
return b(o, w, (t, n, r) => {
|
|
34
|
+
t > c && (s += E(e.slice(c, t))), s += `<span class="${r}">${E(e.slice(t, n))}</span>`, c = n;
|
|
35
|
+
}), c < e.length && (s += E(e.slice(c))), s;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/render/CodeBlock.tsx
|
|
39
|
+
function k({ code: e, language: t, codeLanguages: n, className: r }) {
|
|
40
|
+
let [i, a] = v(null);
|
|
41
|
+
return g(() => {
|
|
42
|
+
let r = !0;
|
|
43
|
+
return a(null), O(e, t, n).then((e) => {
|
|
44
|
+
r && a(e);
|
|
45
|
+
}), () => {
|
|
46
|
+
r = !1;
|
|
47
|
+
};
|
|
48
|
+
}, [
|
|
49
|
+
e,
|
|
50
|
+
t,
|
|
51
|
+
n
|
|
52
|
+
]), i == null ? /* @__PURE__ */ S("code", {
|
|
53
|
+
className: r,
|
|
54
|
+
children: e
|
|
55
|
+
}) : /* @__PURE__ */ S("code", {
|
|
56
|
+
className: r,
|
|
57
|
+
dangerouslySetInnerHTML: { __html: i }
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/render/remark-callout.ts
|
|
62
|
+
function A() {
|
|
63
|
+
return (e) => {
|
|
64
|
+
r(e, "blockquote", (e) => {
|
|
65
|
+
let t = e.children[0];
|
|
66
|
+
if (t?.type !== "paragraph") return;
|
|
67
|
+
let n = t.children[0];
|
|
68
|
+
if (n?.type !== "text") return;
|
|
69
|
+
let r = f.exec(n.value);
|
|
70
|
+
if (!r) return;
|
|
71
|
+
n.value = n.value.slice(r[0].length);
|
|
72
|
+
let i = r[1].toLowerCase();
|
|
73
|
+
e.data ??= {};
|
|
74
|
+
let a = e.data.hProperties ??= {};
|
|
75
|
+
a.className = ["stylo-callout", `stylo-callout-${d(i)}`], a["data-callout"] = i;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/render/remark-embed.ts
|
|
81
|
+
function j() {
|
|
82
|
+
return (e) => {
|
|
83
|
+
r(e, "paragraph", (e) => {
|
|
84
|
+
let t = e.children.length === 1 ? e.children[0] : void 0;
|
|
85
|
+
if (t?.type !== "text" || !p(t.value)) return;
|
|
86
|
+
h.lastIndex = 0;
|
|
87
|
+
let n = (h.exec(t.value.trim())?.[1] ?? "").trim();
|
|
88
|
+
n && (e.children = [], e.data ??= {}, e.data.hName = "div", e.data.hProperties = {
|
|
89
|
+
className: ["stylo-embed"],
|
|
90
|
+
"data-stylo-embed": n
|
|
91
|
+
});
|
|
92
|
+
}), r(e, "text", (e, t, n) => {
|
|
93
|
+
if (t == null || n == null || !e.value.includes("![[")) return;
|
|
94
|
+
let r = [], i = 0;
|
|
95
|
+
h.lastIndex = 0;
|
|
96
|
+
for (let t of e.value.matchAll(h)) {
|
|
97
|
+
let n = (t[1] ?? "").trim();
|
|
98
|
+
if (!n) continue;
|
|
99
|
+
let a = t.index ?? 0;
|
|
100
|
+
a > i && r.push({
|
|
101
|
+
type: "text",
|
|
102
|
+
value: e.value.slice(i, a)
|
|
103
|
+
}), r.push({
|
|
104
|
+
type: "text",
|
|
105
|
+
value: "",
|
|
106
|
+
data: {
|
|
107
|
+
hName: "span",
|
|
108
|
+
hProperties: {
|
|
109
|
+
className: ["stylo-embed"],
|
|
110
|
+
"data-stylo-embed-inline": n
|
|
111
|
+
},
|
|
112
|
+
hChildren: []
|
|
113
|
+
}
|
|
114
|
+
}), i = a + t[0].length;
|
|
115
|
+
}
|
|
116
|
+
if (r.length) return i < e.value.length && r.push({
|
|
117
|
+
type: "text",
|
|
118
|
+
value: e.value.slice(i)
|
|
119
|
+
}), n.children.splice(t, 1, ...r), [a, t + r.length];
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/render/remark-wikilink.ts
|
|
125
|
+
function M() {
|
|
126
|
+
return (e) => {
|
|
127
|
+
r(e, "text", (e, t, n) => {
|
|
128
|
+
if (n == null || t == null || !e.value.includes("[[")) return;
|
|
129
|
+
let r = [], i = 0;
|
|
130
|
+
for (let t of e.value.matchAll(s)) {
|
|
131
|
+
let [n = "", a = "", o] = t, s = t.index ?? 0;
|
|
132
|
+
s > i && r.push({
|
|
133
|
+
type: "text",
|
|
134
|
+
value: e.value.slice(i, s)
|
|
135
|
+
}), r.push({
|
|
136
|
+
type: "link",
|
|
137
|
+
url: "#",
|
|
138
|
+
data: { hProperties: { "data-wikilink": a.trim() } },
|
|
139
|
+
children: [{
|
|
140
|
+
type: "text",
|
|
141
|
+
value: (o ?? a).trim()
|
|
142
|
+
}]
|
|
143
|
+
}), i = s + n.length;
|
|
144
|
+
}
|
|
145
|
+
if (i !== 0) return i < e.value.length && r.push({
|
|
146
|
+
type: "text",
|
|
147
|
+
value: e.value.slice(i)
|
|
148
|
+
}), n.children.splice(t, 1, ...r), t + r.length;
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/render/Preview.tsx
|
|
154
|
+
var N = [t];
|
|
155
|
+
function P({ value: t, onWikiLinkClick: r, embedSource: a, onResolveError: s, frontmatter: u = "hidden", codeLanguages: d }) {
|
|
156
|
+
let f = u === "code" ? c(t) : null, p = _(() => [
|
|
157
|
+
i,
|
|
158
|
+
n,
|
|
159
|
+
o,
|
|
160
|
+
...a ? [j] : [],
|
|
161
|
+
M,
|
|
162
|
+
A
|
|
163
|
+
], [a]);
|
|
164
|
+
return /* @__PURE__ */ C("div", {
|
|
165
|
+
className: l.preview,
|
|
166
|
+
children: [f && /* @__PURE__ */ S("div", {
|
|
167
|
+
className: "stylo-frontmatter",
|
|
168
|
+
children: f.frontmatter
|
|
169
|
+
}), /* @__PURE__ */ S(e, {
|
|
170
|
+
remarkPlugins: p,
|
|
171
|
+
rehypePlugins: N,
|
|
172
|
+
components: {
|
|
173
|
+
a({ node: e, children: t, ...n }) {
|
|
174
|
+
let i = n["data-wikilink"];
|
|
175
|
+
return typeof i == "string" ? /* @__PURE__ */ S("a", {
|
|
176
|
+
...n,
|
|
177
|
+
href: "#",
|
|
178
|
+
onClick: (e) => {
|
|
179
|
+
e.preventDefault(), r?.(i);
|
|
180
|
+
},
|
|
181
|
+
children: t
|
|
182
|
+
}) : /* @__PURE__ */ S("a", {
|
|
183
|
+
...n,
|
|
184
|
+
rel: "noreferrer",
|
|
185
|
+
children: t
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
div({ node: e, children: t, ...n }) {
|
|
189
|
+
let r = n["data-stylo-embed"];
|
|
190
|
+
return typeof r == "string" && a ? /* @__PURE__ */ S("div", {
|
|
191
|
+
...n,
|
|
192
|
+
children: /* @__PURE__ */ S(m, {
|
|
193
|
+
reference: r,
|
|
194
|
+
source: a,
|
|
195
|
+
onError: s
|
|
196
|
+
})
|
|
197
|
+
}) : /* @__PURE__ */ S("div", {
|
|
198
|
+
...n,
|
|
199
|
+
children: t
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
span({ node: e, children: t, ...n }) {
|
|
203
|
+
let r = n["data-stylo-embed-inline"];
|
|
204
|
+
return typeof r == "string" && a ? /* @__PURE__ */ S("span", {
|
|
205
|
+
...n,
|
|
206
|
+
children: /* @__PURE__ */ S(m, {
|
|
207
|
+
reference: r,
|
|
208
|
+
source: a,
|
|
209
|
+
onError: s,
|
|
210
|
+
inline: !0
|
|
211
|
+
})
|
|
212
|
+
}) : /* @__PURE__ */ S("span", {
|
|
213
|
+
...n,
|
|
214
|
+
children: t
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
code({ node: e, className: t, children: n, ...r }) {
|
|
218
|
+
let i = /language-(\w+)/.exec(t || "")?.[1];
|
|
219
|
+
return i && d ? /* @__PURE__ */ S(k, {
|
|
220
|
+
className: t,
|
|
221
|
+
language: i,
|
|
222
|
+
code: String(n).replace(/\n$/, ""),
|
|
223
|
+
codeLanguages: d
|
|
224
|
+
}) : /* @__PURE__ */ S("code", {
|
|
225
|
+
...r,
|
|
226
|
+
className: t,
|
|
227
|
+
children: n
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
children: t
|
|
232
|
+
})]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
export { P as Preview };
|
|
237
|
+
|
|
238
|
+
//# sourceMappingURL=Preview-C5Oi_jpI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Preview-C5Oi_jpI.js","names":[],"sources":["../src/render/highlightCode.ts","../src/render/CodeBlock.tsx","../src/render/remark-callout.ts","../src/render/remark-embed.ts","../src/render/remark-wikilink.ts","../src/render/Preview.tsx"],"sourcesContent":["import { LanguageDescription, type Language } from \"@codemirror/language\"\nimport { highlightTree, tagHighlighter } from \"@lezer/highlight\"\nimport { SYNTAX_TAG_GROUPS } from \"../editor/highlight\"\nimport type { CodeLanguages } from \"../types\"\n\n/**\n * `preview`'s counterpart to `src/editor/highlight.ts`'s `styloHighlightStyle`\n * — same `SYNTAX_TAG_GROUPS`, same tags, but emitting plain `stylo-tok-<token>`\n * classes (styled in `stylo.module.css`) instead of a CodeMirror `StyleModule`,\n * since `highlightTree` here runs outside of any `EditorView`.\n */\nconst previewHighlighter = tagHighlighter(\n SYNTAX_TAG_GROUPS.map(({ tags, token }) => ({ tag: tags, class: `stylo-tok-${token}` })),\n)\n\nconst ESCAPES: Record<string, string> = { \"&\": \"&\", \"<\": \"<\", \">\": \">\" }\nconst escapeHtml = (text: string) => text.replace(/[&<>]/g, (c) => ESCAPES[c] ?? c)\n\n/**\n * Resolves a fence's language the same way `@codemirror/lang-markdown`\n * resolves `codeLanguages` for the CodeMirror surfaces, so a name that matches\n * on one matches on the other: the function form is called with the name\n * directly, an array is matched fuzzily by `LanguageDescription.matchLanguageName`.\n */\nfunction resolveLanguage(\n name: string,\n codeLanguages: CodeLanguages,\n): Language | LanguageDescription | null {\n if (typeof codeLanguages === \"function\") return codeLanguages(name)\n return LanguageDescription.matchLanguageName(codeLanguages, name, true)\n}\n\n/**\n * Tokenizes one fenced code block for `preview`, reusing the exact grammars\n * and colour mapping the in-place canvas's CodeMirror highlighter uses, so a\n * block looks identical whether the note is being read or edited. Returns\n * `null` — the block stays plain, un-highlighted text — when `codeLanguages`\n * has no match for `info`, or the match fails to load.\n */\nexport async function highlightToHtml(\n code: string,\n info: string,\n codeLanguages: CodeLanguages,\n): Promise<string | null> {\n const name = /\\S*/.exec(info)?.[0] ?? \"\"\n if (!name) return null\n\n const match = resolveLanguage(name, codeLanguages)\n if (!match) return null\n\n let language: Language\n if (match instanceof LanguageDescription) {\n try {\n language = (await match.load()).language\n } catch {\n return null\n }\n } else {\n language = match\n }\n\n const tree = language.parser.parse(code)\n let html = \"\"\n let pos = 0\n highlightTree(tree, previewHighlighter, (from, to, classes) => {\n if (from > pos) html += escapeHtml(code.slice(pos, from))\n html += `<span class=\"${classes}\">${escapeHtml(code.slice(from, to))}</span>`\n pos = to\n })\n if (pos < code.length) html += escapeHtml(code.slice(pos))\n return html\n}\n","import { useEffect, useState } from \"react\"\nimport type { CodeLanguages } from \"../types\"\nimport { highlightToHtml } from \"./highlightCode\"\n\ninterface CodeBlockProps {\n code: string\n language: string\n codeLanguages: CodeLanguages\n className?: string\n}\n\n/**\n * One fenced code block in `preview`. Renders plain text immediately — so\n * there is never a loading flash for something this small — then swaps in\n * `--stylo-syntax-*`-coloured spans once `codeLanguages` resolves and the\n * block's grammar parses. Per-language grammars stay exactly as lazy as they\n * already are for the CodeMirror surfaces (`codeLanguages` is host-supplied),\n * so a `preview`-only consumer never pays for one it never shows.\n */\nexport function CodeBlock({ code, language, codeLanguages, className }: CodeBlockProps) {\n const [html, setHtml] = useState<string | null>(null)\n\n useEffect(() => {\n let live = true\n setHtml(null)\n highlightToHtml(code, language, codeLanguages).then((result) => {\n if (live) setHtml(result)\n })\n return () => {\n live = false\n }\n }, [code, language, codeLanguages])\n\n if (html == null) return <code className={className}>{code}</code>\n // `html` is built in highlightCode.ts from the parsed source text (HTML-escaped)\n // and fixed `stylo-tok-*` class names only — no host or document input reaches it.\n return <code className={className} dangerouslySetInnerHTML={{ __html: html }} />\n}\n","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 { CodeLanguages, EmbedSource, FrontmatterDisplay, ResolveErrorInfo } from \"../types\"\nimport { CodeBlock } from \"./CodeBlock\"\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 * Grammars for fenced-code syntax highlighting, matching the CodeMirror\n * surfaces' `codeLanguages` prop exactly (same resolution rules, same\n * `--stylo-syntax-*` colours). Omit and fenced code renders as plain,\n * un-highlighted text — today's behaviour.\n */\n codeLanguages?: CodeLanguages\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 codeLanguages,\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 code({ node: _node, className, children, ...rest }) {\n const language = /language-(\\w+)/.exec(className || \"\")?.[1]\n if (language && codeLanguages) {\n return (\n <CodeBlock\n className={className}\n language={language}\n code={String(children).replace(/\\n$/, \"\")}\n codeLanguages={codeLanguages}\n />\n )\n }\n return (\n <code {...rest} className={className}>\n {children}\n </code>\n )\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":";;;;;;;;AAWA,IAAM,IAAqB,EACzB,EAAkB,KAAK,EAAE,SAAM,gBAAa;CAAE,KAAK;CAAM,OAAO,aAAa;AAAQ,EAAE,CACzF,GAEM,IAAkC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;AAAO,GAC3E,KAAc,MAAiB,EAAK,QAAQ,WAAW,MAAM,EAAQ,MAAM,CAAC;AAQlF,SAAS,EACP,GACA,GACuC;CAEvC,OADI,OAAO,KAAkB,aAAmB,EAAc,CAAI,IAC3D,EAAoB,kBAAkB,GAAe,GAAM,EAAI;AACxE;AASA,eAAsB,EACpB,GACA,GACA,GACwB;CACxB,IAAM,IAAO,MAAM,KAAK,CAAI,CAAC,GAAG,MAAM;CACtC,IAAI,CAAC,GAAM,OAAO;CAElB,IAAM,IAAQ,EAAgB,GAAM,CAAa;CACjD,IAAI,CAAC,GAAO,OAAO;CAEnB,IAAI;CACJ,IAAI,aAAiB,GACnB,IAAI;EACF,KAAY,MAAM,EAAM,KAAK,EAAA,CAAG;CAClC,QAAQ;EACN,OAAO;CACT;MAEA,IAAW;CAGb,IAAM,IAAO,EAAS,OAAO,MAAM,CAAI,GACnC,IAAO,IACP,IAAM;CAOV,OANA,EAAc,GAAM,IAAqB,GAAM,GAAI,MAAY;EAG7D,AAFI,IAAO,MAAK,KAAQ,EAAW,EAAK,MAAM,GAAK,CAAI,CAAC,IACxD,KAAQ,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H,kBAAC,QAAD;MAAM,GAAI;MAAiB;MACxB;KACG,CAAA;IAEV;GASgB;GAEX,UAAA;EACO,CAAA,CACP;;AAET"}
|
package/dist/SplitView.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { EditorView } from "@codemirror/view";
|
|
3
|
-
import type { CodeLanguages, EmbedSource, FrontmatterDisplay, ResolveErrorInfo, WikiLinkSource } from "./types";
|
|
3
|
+
import type { CodeLanguages, EmbedSource, FrontmatterDisplay, ResolveErrorInfo, TagSource, WikiLinkSource } from "./types";
|
|
4
4
|
export interface SplitViewProps {
|
|
5
5
|
value: string;
|
|
6
6
|
onChange: (next: string) => void;
|
|
@@ -9,6 +9,7 @@ export interface SplitViewProps {
|
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
codeLanguages?: CodeLanguages;
|
|
11
11
|
wikiLinkSource?: WikiLinkSource;
|
|
12
|
+
tagSource?: TagSource;
|
|
12
13
|
embedSource?: EmbedSource;
|
|
13
14
|
onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
|
|
14
15
|
frontmatter?: FrontmatterDisplay;
|
|
@@ -27,5 +28,5 @@ export interface SplitViewProps {
|
|
|
27
28
|
* Stylo root to have a bounded height — otherwise both panes grow and the page
|
|
28
29
|
* scrolls instead.
|
|
29
30
|
*/
|
|
30
|
-
export declare function SplitView({ value, onChange, onWikiLinkClick, readOnly, placeholder, codeLanguages, wikiLinkSource, embedSource, onResolveError, frontmatter, onSave, onViewChange, canvasHeader, }: SplitViewProps): import("react").JSX.Element;
|
|
31
|
+
export declare function SplitView({ value, onChange, onWikiLinkClick, readOnly, placeholder, codeLanguages, wikiLinkSource, tagSource, embedSource, onResolveError, frontmatter, onSave, onViewChange, canvasHeader, }: SplitViewProps): import("react").JSX.Element;
|
|
31
32
|
//# sourceMappingURL=SplitView.d.ts.map
|
package/dist/SplitView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
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AgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,SAAS,EACT,WAAW,EACX,cAAc,EACd,WAAW,EACX,MAAM,EACN,YAAY,EACZ,YAAY,GACb,EAAE,cAAc,+BAmEhB"}
|
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,EAAoB,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAExE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,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,oGA0LhB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { EditorView } from "@codemirror/view";
|
|
3
|
-
import type { CodeLanguages, ResolveErrorInfo, WikiLinkSource } from "../types";
|
|
3
|
+
import type { CodeLanguages, ResolveErrorInfo, TagSource, WikiLinkSource } from "../types";
|
|
4
4
|
export interface SourceViewProps {
|
|
5
5
|
value: string;
|
|
6
6
|
onChange: (next: string) => void;
|
|
@@ -10,7 +10,9 @@ export interface SourceViewProps {
|
|
|
10
10
|
codeLanguages?: CodeLanguages;
|
|
11
11
|
/** `[[wikilink]]` autocomplete source. Read once. */
|
|
12
12
|
wikiLinkSource?: WikiLinkSource;
|
|
13
|
-
/**
|
|
13
|
+
/** `#tag` autocomplete source. Read once. */
|
|
14
|
+
tagSource?: TagSource;
|
|
15
|
+
/** Notified when `wikiLinkSource` or `tagSource` rejects. */
|
|
14
16
|
onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
|
|
15
17
|
/** Called with the doc string on `Mod-s`. */
|
|
16
18
|
onSave?: (value: string) => void;
|
|
@@ -22,5 +24,5 @@ export interface SourceViewProps {
|
|
|
22
24
|
}) => ReactNode;
|
|
23
25
|
}
|
|
24
26
|
/** Raw CodeMirror 6 Markdown surface bound to the canonical string. */
|
|
25
|
-
export declare function SourceView({ value, onChange, readOnly, placeholder, codeLanguages, wikiLinkSource, onResolveError, onSave, onViewChange, canvasHeader, }: SourceViewProps): import("react").JSX.Element;
|
|
27
|
+
export declare function SourceView({ value, onChange, readOnly, placeholder, codeLanguages, wikiLinkSource, tagSource, onResolveError, onSave, onViewChange, canvasHeader, }: SourceViewProps): import("react").JSX.Element;
|
|
26
28
|
//# sourceMappingURL=SourceView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceView.d.ts","sourceRoot":"","sources":["../../src/editor/SourceView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"SourceView.d.ts","sourceRoot":"","sources":["../../src/editor/SourceView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAO1F,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,6CAA6C;IAC7C,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,6DAA6D;IAC7D,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;IAChD,kFAAkF;IAClF,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;KAAE,KAAK,SAAS,CAAA;CAC/D;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,SAAS,EACT,cAAc,EACd,MAAM,EACN,YAAY,EACZ,YAAY,GACb,EAAE,eAAe,+BAyCjB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Extension } from "@codemirror/state";
|
|
2
|
-
import type { CodeLanguages, ResolveErrorInfo, WikiLinkSource } from "../types";
|
|
2
|
+
import type { CodeLanguages, ResolveErrorInfo, TagSource, WikiLinkSource } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* Static extensions — created once with the view.
|
|
5
5
|
*
|
|
@@ -10,7 +10,7 @@ import type { CodeLanguages, ResolveErrorInfo, 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, onResolveError?: (error: unknown, info: ResolveErrorInfo) => void): Extension;
|
|
13
|
+
export declare function baseExtensions(codeLanguages?: CodeLanguages, wikiLinkSource?: WikiLinkSource, onResolveError?: (error: unknown, info: ResolveErrorInfo) => void, tagSource?: TagSource): 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,gBAAgB,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,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAQ1F;;;;;;;;;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,EACjE,SAAS,CAAC,EAAE,SAAS,GACpB,SAAS,CAyBX;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,4 +1,24 @@
|
|
|
1
1
|
import { HighlightStyle } from "@codemirror/language";
|
|
2
|
+
import { type Tag } from "@lezer/highlight";
|
|
3
|
+
/**
|
|
4
|
+
* One row per `--stylo-syntax-*` token: which Lezer tags map to it, and
|
|
5
|
+
* whether it reads italic. This is the single source of truth for fenced-code
|
|
6
|
+
* colour — `styloHighlightStyle` below builds the live CodeMirror extension
|
|
7
|
+
* from it, and `src/render/highlightCode.ts` builds `preview`'s tree-walking
|
|
8
|
+
* highlighter (a `tagHighlighter` emitting `stylo-tok-<token>` classes,
|
|
9
|
+
* styled in `stylo.module.css`) from the same list, so both surfaces agree by
|
|
10
|
+
* construction rather than by two hand-kept mappings staying in sync.
|
|
11
|
+
*
|
|
12
|
+
* `token` doubles as the `--stylo-syntax-<token>` suffix and the
|
|
13
|
+
* `stylo-tok-<token>` class suffix. `meta` shares its colour with `comment`
|
|
14
|
+
* but isn't italic, so it gets its own row rather than merging into it.
|
|
15
|
+
*/
|
|
16
|
+
export interface SyntaxTagGroup {
|
|
17
|
+
token: string;
|
|
18
|
+
tags: Tag[];
|
|
19
|
+
italic?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const SYNTAX_TAG_GROUPS: SyntaxTagGroup[];
|
|
2
22
|
/**
|
|
3
23
|
* Token colours for fenced code and any other embedded-language grammar.
|
|
4
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/editor/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/editor/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsB,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,eAAO,MAAM,iBAAiB,EAAE,cAAc,EA8B7C,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,gBAM/B,CAAA;AAED,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,uCAA0C,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type CompletionContext, type CompletionResult } from "@codemirror/autocomplete";
|
|
2
|
+
import type { Extension } from "@codemirror/state";
|
|
3
|
+
import type { ResolveErrorInfo, TagSource } from "../types";
|
|
4
|
+
type OnResolveError = (error: unknown, info: ResolveErrorInfo) => void;
|
|
5
|
+
/**
|
|
6
|
+
* The completion source. Exposed for unit tests; consumers use `tagCompletion`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function tagCompletionSource(source: TagSource, onError?: OnResolveError): (ctx: CompletionContext) => Promise<CompletionResult | null>;
|
|
9
|
+
/**
|
|
10
|
+
* `#tag` autocomplete. Off unless the host passes `tagSource`. Registered
|
|
11
|
+
* through the Markdown language data, so it is inert inside a fenced code
|
|
12
|
+
* block and leaves any embedded-language completions intact.
|
|
13
|
+
*/
|
|
14
|
+
export declare function tagCompletion(source?: TagSource, onError?: OnResolveError): Extension;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=tag-complete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-complete.d.ts","sourceRoot":"","sources":["../../src/editor/tag-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,EAAiB,SAAS,EAAE,MAAM,UAAU,CAAA;AAE1E,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAA;AAyBtE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,SAC1D,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA8BxE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAMrF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Extension } from "@codemirror/state";
|
|
2
2
|
import { EditorView } from "@codemirror/view";
|
|
3
|
-
import type { CodeLanguages, ResolveErrorInfo, WikiLinkSource } from "../types";
|
|
3
|
+
import type { CodeLanguages, ResolveErrorInfo, TagSource, WikiLinkSource } from "../types";
|
|
4
4
|
export interface UseCodeMirrorOptions {
|
|
5
5
|
value: string;
|
|
6
6
|
onChange: (next: string) => void;
|
|
@@ -19,12 +19,17 @@ export interface UseCodeMirrorOptions {
|
|
|
19
19
|
codeLanguages?: CodeLanguages;
|
|
20
20
|
/** `[[wikilink]]` autocomplete source. Read once. */
|
|
21
21
|
wikiLinkSource?: WikiLinkSource;
|
|
22
|
-
/**
|
|
22
|
+
/** `#tag` autocomplete source. Read once. */
|
|
23
|
+
tagSource?: TagSource;
|
|
24
|
+
/**
|
|
25
|
+
* Notified when `wikiLinkSource` or `tagSource` rejects. Reached through a
|
|
26
|
+
* stable wrapper.
|
|
27
|
+
*/
|
|
23
28
|
onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
26
31
|
* Owns a CodeMirror `EditorView` for the lifetime of the host element and keeps
|
|
27
32
|
* it in sync with a controlled Markdown string. Returns a ref for the container.
|
|
28
33
|
*/
|
|
29
|
-
export declare function useCodeMirror({ value, onChange, readOnly, placeholder, onSave, onViewChange, extensions, codeLanguages, wikiLinkSource, onResolveError, }: UseCodeMirrorOptions): import("react").RefObject<HTMLDivElement | null>;
|
|
34
|
+
export declare function useCodeMirror({ value, onChange, readOnly, placeholder, onSave, onViewChange, extensions, codeLanguages, wikiLinkSource, tagSource, onResolveError, }: UseCodeMirrorOptions): import("react").RefObject<HTMLDivElement | null>;
|
|
30
35
|
//# 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,gBAAgB,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,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAO1F,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,6CAA6C;IAC7C,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB;;;OAGG;IACH,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,SAAS,EACT,cAAc,GACf,EAAE,oBAAoB,oDA8EtB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { HighlightStyle as e, syntaxHighlighting as t } from "@codemirror/language";
|
|
2
|
+
import { tags as n } from "@lezer/highlight";
|
|
3
|
+
var r = {
|
|
4
|
+
root: "_root_113cr_1",
|
|
5
|
+
source: "_source_113cr_42",
|
|
6
|
+
inplace: "_inplace_113cr_57",
|
|
7
|
+
toolbar: "_toolbar_113cr_63",
|
|
8
|
+
toolbarGroup: "_toolbarGroup_113cr_75",
|
|
9
|
+
toolbarButton: "_toolbarButton_113cr_81",
|
|
10
|
+
toolbarSep: "_toolbarSep_113cr_140",
|
|
11
|
+
toolbarSticky: "_toolbarSticky_113cr_150",
|
|
12
|
+
toolbarStickyBottom: "_toolbarStickyBottom_113cr_150",
|
|
13
|
+
toolbarStickyTop: "_toolbarStickyTop_113cr_150",
|
|
14
|
+
toolbarStickyHidden: "_toolbarStickyHidden_113cr_219",
|
|
15
|
+
stickyToolbarRootBottom: "_stickyToolbarRootBottom_113cr_230",
|
|
16
|
+
stickyToolbarRootTop: "_stickyToolbarRootTop_113cr_235",
|
|
17
|
+
split: "_split_113cr_249",
|
|
18
|
+
splitPane: "_splitPane_113cr_256",
|
|
19
|
+
preview: "_preview_113cr_282"
|
|
20
|
+
}, i = /\[\[([^\]|\n]+?)(?:\|([^\]\n]+?))?\]\]/g;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/frontmatter.ts
|
|
23
|
+
function a(e) {
|
|
24
|
+
if (e.lines < 2 || e.line(1).text.trim() !== "---") return null;
|
|
25
|
+
for (let t = 2; t <= e.lines; t++) if (e.line(t).text.trim() === "---") return {
|
|
26
|
+
from: 0,
|
|
27
|
+
to: e.line(t).to
|
|
28
|
+
};
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
var o = /^---\r?\n(?:([\s\S]*?)\r?\n)?---[ \t]*(?:\r?\n|$)/;
|
|
32
|
+
function s(e) {
|
|
33
|
+
let t = o.exec(e);
|
|
34
|
+
return t ? {
|
|
35
|
+
frontmatter: t[1] ?? "",
|
|
36
|
+
body: e.slice(t[0].length)
|
|
37
|
+
} : null;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/editor/highlight.ts
|
|
41
|
+
var c = [
|
|
42
|
+
{
|
|
43
|
+
token: "keyword",
|
|
44
|
+
tags: [
|
|
45
|
+
n.keyword,
|
|
46
|
+
n.modifier,
|
|
47
|
+
n.controlKeyword,
|
|
48
|
+
n.operatorKeyword,
|
|
49
|
+
n.definitionKeyword,
|
|
50
|
+
n.moduleKeyword
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
token: "string",
|
|
55
|
+
tags: [
|
|
56
|
+
n.string,
|
|
57
|
+
n.special(n.string),
|
|
58
|
+
n.regexp,
|
|
59
|
+
n.attributeValue
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
token: "escape",
|
|
64
|
+
tags: [n.escape, n.character]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
token: "comment",
|
|
68
|
+
tags: [
|
|
69
|
+
n.comment,
|
|
70
|
+
n.lineComment,
|
|
71
|
+
n.blockComment,
|
|
72
|
+
n.docComment
|
|
73
|
+
],
|
|
74
|
+
italic: !0
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
token: "number",
|
|
78
|
+
tags: [
|
|
79
|
+
n.number,
|
|
80
|
+
n.integer,
|
|
81
|
+
n.float
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
token: "constant",
|
|
86
|
+
tags: [
|
|
87
|
+
n.bool,
|
|
88
|
+
n.null,
|
|
89
|
+
n.atom,
|
|
90
|
+
n.constant(n.name)
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
token: "function",
|
|
95
|
+
tags: [
|
|
96
|
+
n.function(n.variableName),
|
|
97
|
+
n.function(n.propertyName),
|
|
98
|
+
n.macroName
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
token: "type",
|
|
103
|
+
tags: [
|
|
104
|
+
n.typeName,
|
|
105
|
+
n.className,
|
|
106
|
+
n.namespace
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
token: "property",
|
|
111
|
+
tags: [n.propertyName, n.attributeName]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
token: "tag",
|
|
115
|
+
tags: [n.tagName]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
token: "meta",
|
|
119
|
+
tags: [n.meta, n.annotation]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
token: "invalid",
|
|
123
|
+
tags: [n.invalid]
|
|
124
|
+
}
|
|
125
|
+
], l = e.define(c.map(({ tags: e, token: t, italic: n }) => ({
|
|
126
|
+
tag: e,
|
|
127
|
+
color: `var(--stylo-syntax-${t === "meta" ? "comment" : t})`,
|
|
128
|
+
...n ? { fontStyle: "italic" } : {}
|
|
129
|
+
}))), u = t(l);
|
|
130
|
+
//#endregion
|
|
131
|
+
export { i as a, s as i, u as n, r as o, a as r, c as t };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=highlight-DNGJlCDY.js.map
|