@damiro/stylo 0.13.6 → 0.14.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/dist/Preview-CmZnIEzi.js +239 -0
- package/dist/{Preview-ClaSJYJW.js.map → Preview-CmZnIEzi.js.map} +1 -1
- package/dist/SplitView.d.ts +2 -1
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/{markdown-BYXs9Tj8.js → markdown-DcS6jMel.js} +484 -469
- package/dist/markdown-DcS6jMel.js.map +1 -0
- package/dist/render/Preview.d.ts +11 -1
- package/dist/render/Preview.d.ts.map +1 -1
- package/dist/stylo.js +60 -57
- package/dist/stylo.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/Preview-ClaSJYJW.js +0 -238
- package/dist/markdown-BYXs9Tj8.js.map +0 -1
package/dist/Preview-ClaSJYJW.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
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-BLVSvron.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-ClaSJYJW.js.map
|