@damiro/stylo 0.14.0 → 0.15.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.
@@ -1,46 +1,46 @@
1
1
  import { a as e, c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./markdown-DcS6jMel.js";
2
2
  import { a as c, i as l, o as u, t as d } from "./highlight-BLVSvron.js";
3
3
  import { a as f, i as p, n as m, o as h, t as g } from "./embed-Dsu6b-MV.js";
4
- import { useEffect as _, useMemo as v, useState as y } from "react";
5
- import { LanguageDescription as b } from "@codemirror/language";
6
- import { highlightTree as x, tagHighlighter as S } from "@lezer/highlight";
7
- import { jsx as C, jsxs as w } from "react/jsx-runtime";
4
+ import { Children as _, cloneElement as v, isValidElement as y, useEffect as b, useMemo as x, useState as S } from "react";
5
+ import { LanguageDescription as C } from "@codemirror/language";
6
+ import { highlightTree as w, tagHighlighter as T } from "@lezer/highlight";
7
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
8
8
  //#region src/render/highlightCode.ts
9
- var T = S(d.map(({ tags: e, token: t }) => ({
9
+ var O = T(d.map(({ tags: e, token: t }) => ({
10
10
  tag: e,
11
11
  class: `stylo-tok-${t}`
12
- }))), E = {
12
+ }))), k = {
13
13
  "&": "&",
14
14
  "<": "&lt;",
15
15
  ">": "&gt;"
16
- }, D = (e) => e.replace(/[&<>]/g, (e) => E[e] ?? e);
17
- function O(e, t) {
18
- return typeof t == "function" ? t(e) : b.matchLanguageName(t, e, !0);
16
+ }, A = (e) => e.replace(/[&<>]/g, (e) => k[e] ?? e);
17
+ function j(e, t) {
18
+ return typeof t == "function" ? t(e) : C.matchLanguageName(t, e, !0);
19
19
  }
20
- async function k(e, t, n) {
20
+ async function M(e, t, n) {
21
21
  let r = /\S*/.exec(t)?.[0] ?? "";
22
22
  if (!r) return null;
23
- let i = O(r, n);
23
+ let i = j(r, n);
24
24
  if (!i) return null;
25
25
  let a;
26
- if (i instanceof b) try {
26
+ if (i instanceof C) try {
27
27
  a = (await i.load()).language;
28
28
  } catch {
29
29
  return null;
30
30
  }
31
31
  else a = i;
32
32
  let o = a.parser.parse(e), s = "", c = 0;
33
- return x(o, T, (t, n, r) => {
34
- t > c && (s += D(e.slice(c, t))), s += `<span class="${r}">${D(e.slice(t, n))}</span>`, c = n;
35
- }), c < e.length && (s += D(e.slice(c))), s;
33
+ return w(o, O, (t, n, r) => {
34
+ t > c && (s += A(e.slice(c, t))), s += `<span class="${r}">${A(e.slice(t, n))}</span>`, c = n;
35
+ }), c < e.length && (s += A(e.slice(c))), s;
36
36
  }
37
37
  //#endregion
38
38
  //#region src/render/CodeBlock.tsx
39
- function A({ code: e, language: t, codeLanguages: n, className: r }) {
40
- let [i, a] = y(null);
41
- return _(() => {
39
+ function N({ code: e, language: t, codeLanguages: n, className: r }) {
40
+ let [i, a] = S(null);
41
+ return b(() => {
42
42
  let r = !0;
43
- return a(null), k(e, t, n).then((e) => {
43
+ return a(null), M(e, t, n).then((e) => {
44
44
  r && a(e);
45
45
  }), () => {
46
46
  r = !1;
@@ -49,17 +49,17 @@ function A({ code: e, language: t, codeLanguages: n, className: r }) {
49
49
  e,
50
50
  t,
51
51
  n
52
- ]), i == null ? /* @__PURE__ */ C("code", {
52
+ ]), i == null ? /* @__PURE__ */ E("code", {
53
53
  className: r,
54
54
  children: e
55
- }) : /* @__PURE__ */ C("code", {
55
+ }) : /* @__PURE__ */ E("code", {
56
56
  className: r,
57
57
  dangerouslySetInnerHTML: { __html: i }
58
58
  });
59
59
  }
60
60
  //#endregion
61
61
  //#region src/render/remark-callout.ts
62
- function j() {
62
+ function P() {
63
63
  return (e) => {
64
64
  o(e, "blockquote", (e) => {
65
65
  let t = e.children[0];
@@ -78,7 +78,7 @@ function j() {
78
78
  }
79
79
  //#endregion
80
80
  //#region src/render/remark-embed.ts
81
- function M() {
81
+ function F() {
82
82
  return (e) => {
83
83
  o(e, "paragraph", (e) => {
84
84
  let t = e.children.length === 1 ? e.children[0] : void 0;
@@ -121,8 +121,20 @@ function M() {
121
121
  };
122
122
  }
123
123
  //#endregion
124
+ //#region src/render/taskCheckbox.ts
125
+ var I = /^[ \t]*(?:[-*+]|\d+[.)])[ \t]+\[([ xX])\]/;
126
+ function L(e, t) {
127
+ let n = e.slice(t, t + 40), r = I.exec(n);
128
+ if (!r) return null;
129
+ let i = t + r[0].length - 3;
130
+ return {
131
+ start: i,
132
+ end: i + 3
133
+ };
134
+ }
135
+ //#endregion
124
136
  //#region src/render/remark-wikilink.ts
125
- function N() {
137
+ function R() {
126
138
  return (e) => {
127
139
  o(e, "text", (e, t, n) => {
128
140
  if (n == null || t == null || !e.value.includes("[[")) return;
@@ -151,36 +163,63 @@ function N() {
151
163
  }
152
164
  //#endregion
153
165
  //#region src/render/Preview.tsx
154
- var P = [e];
155
- function F({ value: e, onWikiLinkClick: t, embedSource: o, onResolveError: c, frontmatter: d = "hidden", codeLanguages: f, softBreaks: p }) {
156
- let m = d === "code" ? l(e) : null, g = v(() => [
166
+ var z = [e];
167
+ function B(e, t, n, r) {
168
+ if (!r || typeof t != "string" || !t.includes("task-list-item")) return null;
169
+ let i = e?.position?.start.offset;
170
+ if (i === void 0) return null;
171
+ let a = L(n, i);
172
+ return a ? (e) => r({
173
+ ...a,
174
+ checked: e.target.checked
175
+ }) : null;
176
+ }
177
+ function V(e, t) {
178
+ if (!y(e)) return { done: !1 };
179
+ if (e.type === "input") return {
180
+ done: !0,
181
+ node: v(e, {
182
+ disabled: !1,
183
+ onChange: t
184
+ })
185
+ };
186
+ let n = _.toArray(e.props.children);
187
+ if (n.length === 0) return { done: !1 };
188
+ let r = V(n[0], t);
189
+ return r.done ? {
190
+ done: !0,
191
+ node: v(e, {}, [r.node, ...n.slice(1)])
192
+ } : { done: !1 };
193
+ }
194
+ function H({ value: e, onWikiLinkClick: t, embedSource: o, onResolveError: c, frontmatter: d = "hidden", codeLanguages: f, softBreaks: p, onTaskToggle: m }) {
195
+ let g = d === "code" ? l(e) : null, v = x(() => [
157
196
  a,
158
197
  r,
159
198
  s,
160
199
  ...p ? [n] : [],
161
- ...o ? [M] : [],
162
- N,
163
- j
200
+ ...o ? [F] : [],
201
+ R,
202
+ P
164
203
  ], [o, p]);
165
- return /* @__PURE__ */ w("div", {
204
+ return /* @__PURE__ */ D("div", {
166
205
  className: u.preview,
167
- children: [m && /* @__PURE__ */ C("div", {
206
+ children: [g && /* @__PURE__ */ E("div", {
168
207
  className: "stylo-frontmatter",
169
- children: m.frontmatter
170
- }), /* @__PURE__ */ C(i, {
171
- remarkPlugins: g,
172
- rehypePlugins: P,
208
+ children: g.frontmatter
209
+ }), /* @__PURE__ */ E(i, {
210
+ remarkPlugins: v,
211
+ rehypePlugins: z,
173
212
  components: {
174
213
  a({ node: e, children: n, ...r }) {
175
214
  let i = r["data-wikilink"];
176
- return typeof i == "string" ? /* @__PURE__ */ C("a", {
215
+ return typeof i == "string" ? /* @__PURE__ */ E("a", {
177
216
  ...r,
178
217
  href: "#",
179
218
  onClick: (e) => {
180
219
  e.preventDefault(), t?.(i);
181
220
  },
182
221
  children: n
183
- }) : /* @__PURE__ */ C("a", {
222
+ }) : /* @__PURE__ */ E("a", {
184
223
  ...r,
185
224
  rel: "noreferrer",
186
225
  children: n
@@ -188,41 +227,58 @@ function F({ value: e, onWikiLinkClick: t, embedSource: o, onResolveError: c, fr
188
227
  },
189
228
  div({ node: e, children: t, ...n }) {
190
229
  let r = n["data-stylo-embed"];
191
- return typeof r == "string" && o ? /* @__PURE__ */ C("div", {
230
+ return typeof r == "string" && o ? /* @__PURE__ */ E("div", {
192
231
  ...n,
193
- children: /* @__PURE__ */ C(h, {
232
+ children: /* @__PURE__ */ E(h, {
194
233
  reference: r,
195
234
  source: o,
196
235
  onError: c
197
236
  })
198
- }) : /* @__PURE__ */ C("div", {
237
+ }) : /* @__PURE__ */ E("div", {
199
238
  ...n,
200
239
  children: t
201
240
  });
202
241
  },
203
242
  span({ node: e, children: t, ...n }) {
204
243
  let r = n["data-stylo-embed-inline"];
205
- return typeof r == "string" && o ? /* @__PURE__ */ C("span", {
244
+ return typeof r == "string" && o ? /* @__PURE__ */ E("span", {
206
245
  ...n,
207
- children: /* @__PURE__ */ C(h, {
246
+ children: /* @__PURE__ */ E(h, {
208
247
  reference: r,
209
248
  source: o,
210
249
  onError: c,
211
250
  inline: !0
212
251
  })
213
- }) : /* @__PURE__ */ C("span", {
252
+ }) : /* @__PURE__ */ E("span", {
214
253
  ...n,
215
254
  children: t
216
255
  });
217
256
  },
257
+ li({ node: t, children: n, ...r }) {
258
+ let i = B(t, r.className, e, m);
259
+ if (i) {
260
+ let e = _.toArray(n), t = e.findIndex((e) => y(e)), a = t === -1 ? null : V(e[t], i);
261
+ if (a?.done) {
262
+ let n = e.map((e, n) => n === t ? a.node : e);
263
+ return /* @__PURE__ */ E("li", {
264
+ ...r,
265
+ children: n
266
+ });
267
+ }
268
+ }
269
+ return /* @__PURE__ */ E("li", {
270
+ ...r,
271
+ children: n
272
+ });
273
+ },
218
274
  code({ node: e, className: t, children: n, ...r }) {
219
275
  let i = /language-(\w+)/.exec(t || "")?.[1];
220
- return i && f ? /* @__PURE__ */ C(A, {
276
+ return i && f ? /* @__PURE__ */ E(N, {
221
277
  className: t,
222
278
  language: i,
223
279
  code: String(n).replace(/\n$/, ""),
224
280
  codeLanguages: f
225
- }) : /* @__PURE__ */ C("code", {
281
+ }) : /* @__PURE__ */ E("code", {
226
282
  ...r,
227
283
  className: t,
228
284
  children: n
@@ -234,6 +290,6 @@ function F({ value: e, onWikiLinkClick: t, embedSource: o, onResolveError: c, fr
234
290
  });
235
291
  }
236
292
  //#endregion
237
- export { F as Preview };
293
+ export { H as Preview };
238
294
 
239
- //# sourceMappingURL=Preview-CmZnIEzi.js.map
295
+ //# sourceMappingURL=Preview-DKOoZ-vr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Preview-DKOoZ-vr.js","names":[],"sources":["../src/render/highlightCode.ts","../src/render/CodeBlock.tsx","../src/render/remark-callout.ts","../src/render/remark-embed.ts","../src/render/taskCheckbox.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> = { \"&\": \"&amp;\", \"<\": \"&lt;\", \">\": \"&gt;\" }\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","/**\n * A task-list item's own `[ ]` / `[x]` marker sits right after its bullet or\n * ordinal and indentation — nothing else can appear before it on the line.\n * Anchoring the match to the very start of the item's raw text (from mdast's\n * `position.start.offset`) makes this safe even when the item's own text\n * could otherwise read as another marker further into the line.\n */\nconst CHECKBOX_PREFIX = /^[ \\t]*(?:[-*+]|\\d+[.)])[ \\t]+\\[([ xX])\\]/\n\n/**\n * Locates the exact `[ ]` / `[x]` substring of a task-list item within\n * `value`, given the raw offset where the item itself starts (a GFM\n * `listItem`'s `position.start.offset`, as parsed by `remark-gfm`).\n * Returns `null` if the prefix doesn't match a checkbox — it always should\n * for a node `remark-gfm` marked `checked`, but a raw markdown edit racing\n * the render is not impossible.\n */\nexport function findCheckboxOffsets(\n value: string,\n itemStart: number,\n): { start: number; end: number } | null {\n const prefix = value.slice(itemStart, itemStart + 40)\n const match = CHECKBOX_PREFIX.exec(prefix)\n if (!match) return null\n const start = itemStart + match[0].length - 3\n return { start, end: start + 3 }\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 {\n Children,\n cloneElement,\n isValidElement,\n useMemo,\n type ChangeEvent,\n type ReactElement,\n type ReactNode,\n} from \"react\"\nimport Markdown, { type Components } from \"react-markdown\"\nimport rehypeKatex from \"rehype-katex\"\nimport remarkBreaks from \"remark-breaks\"\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 {\n CodeLanguages,\n EmbedSource,\n FrontmatterDisplay,\n ResolveErrorInfo,\n TaskToggleInfo,\n} from \"../types\"\nimport { CodeBlock } from \"./CodeBlock\"\nimport { Embed } from \"./Embed\"\nimport { remarkCallout } from \"./remark-callout\"\nimport { remarkEmbed } from \"./remark-embed\"\nimport { findCheckboxOffsets } from \"./taskCheckbox\"\nimport { remarkWikilink } from \"./remark-wikilink\"\n\nconst REHYPE_PLUGINS = [rehypeKatex]\n\n/**\n * Builds the checkbox's `onChange` handler for a rendered `<li>`, or `null`\n * when it isn't an eligible task item — not a task list item at all,\n * `onTaskToggle` unset, no position data, or (a raw-edit race, effectively\n * never) a marker `findCheckboxOffsets` can't locate.\n */\nfunction makeToggleHandler(\n node: { position?: { start: { offset?: number } } } | undefined,\n className: string | undefined,\n value: string,\n onTaskToggle: ((info: TaskToggleInfo) => void) | undefined,\n): ((event: ChangeEvent<HTMLInputElement>) => void) | null {\n if (!onTaskToggle || typeof className !== \"string\" || !className.includes(\"task-list-item\")) {\n return null\n }\n const itemStart = node?.position?.start.offset\n if (itemStart === undefined) return null\n const offsets = findCheckboxOffsets(value, itemStart)\n if (!offsets) return null\n return (event) => onTaskToggle({ ...offsets, checked: event.target.checked })\n}\n\n/**\n * A task item's checkbox `<input>` is always the leftmost leaf of its `<li>`\n * — `mdast-util-to-hast` unshifts it onto the first paragraph, itself the\n * first result, whether or not GFM kept that paragraph wrapped (a \"loose\"\n * list, blank lines between items) or unwrapped it (a \"tight\" one). Walking\n * only the first-child spine finds it either way without ever wandering into\n * a nested sub-list's own checkbox, which lives as a later sibling, not a\n * descendant of the first child.\n */\nfunction enableLeadingCheckbox(\n node: ReactNode,\n onChange: (event: ChangeEvent<HTMLInputElement>) => void,\n): { done: true; node: ReactNode } | { done: false } {\n if (!isValidElement(node)) return { done: false }\n if (node.type === \"input\") {\n return {\n done: true,\n node: cloneElement(node as ReactElement<Record<string, unknown>>, {\n disabled: false,\n onChange,\n }),\n }\n }\n const kids = Children.toArray((node.props as { children?: ReactNode }).children)\n if (kids.length === 0) return { done: false }\n const result = enableLeadingCheckbox(kids[0], onChange)\n if (!result.done) return { done: false }\n return {\n done: true,\n node: cloneElement(node as ReactElement<{ children?: ReactNode }>, {}, [\n result.node,\n ...kids.slice(1),\n ]),\n }\n}\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 * Turn a single line ending into a real line break (`<br>`) instead of\n * CommonMark's default — a blank line required to start a new paragraph,\n * otherwise consecutive lines join into one run. Obsidian's Live Preview\n * reads this way. Off by default: every existing `preview` render keeps\n * today's paragraph-joining behaviour unless a host opts in. Has no effect\n * on `in-place` / `source` — CodeMirror already decorates each source line\n * independently there.\n */\n softBreaks?: boolean\n /**\n * Makes task-list checkboxes clickable instead of `disabled`. Fired with\n * raw `value` offsets bracketing the clicked marker and its new state; the\n * host owns splicing `value` and calling its own `onChange`. Off by\n * default — every checkbox stays `disabled`, today's behaviour, until a\n * host opts in.\n */\n onTaskToggle?: (info: TaskToggleInfo) => void\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 softBreaks,\n onTaskToggle,\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 ...(softBreaks ? [remarkBreaks] : []),\n ...(embedSource ? [remarkEmbed] : []),\n remarkWikilink,\n remarkCallout,\n ],\n [embedSource, softBreaks],\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 li({ node, children, ...rest }) {\n const handleToggle = makeToggleHandler(node, rest.className, value, onTaskToggle)\n if (handleToggle) {\n // A loose list (blank line between items) keeps the `<li>`'s content\n // wrapped in a `<p>`, itself preceded by a formatting `\"\\n\"` text\n // node — skip past that to the first real element.\n const kids = Children.toArray(children)\n const firstElementIndex = kids.findIndex((kid) => isValidElement(kid))\n const enabled =\n firstElementIndex === -1\n ? null\n : enableLeadingCheckbox(kids[firstElementIndex], handleToggle)\n if (enabled?.done) {\n const nextKids: ReactNode[] = kids.map((kid, i) =>\n i === firstElementIndex ? enabled.node : kid,\n )\n return <li {...rest}>{nextKids}</li>\n }\n }\n return <li {...rest}>{children}</li>\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,gBAAgB,EAAQ,IAAI,EAAW,EAAK,MAAM,GAAM,CAAE,CAAC,EAAE,UACrE,IAAM;CACR,CAAC,GACG,IAAM,EAAK,WAAQ,KAA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;KACA,OAAO,kBAAC,MAAD;MAAI,GAAI;MAAO;KAAa,CAAA;IACrC;IACA,KAAK,EAAE,MAAM,GAAO,cAAW,aAAU,GAAG,KAAQ;KAClD,IAAM,IAAW,iBAAiB,KAAK,KAAa,EAAE,CAAC,GAAG;KAW1D,OAVI,KAAY,IAEZ,kBAAC,GAAD;MACa;MACD;MACV,MAAM,OAAO,CAAQ,CAAC,CAAC,QAAQ,OAAO,EAAE;MACzB;KAChB,CAAA,IAIH,kBAAC,QAAD;MAAM,GAAI;MAAiB;MACxB;KACG,CAAA;IAEV;GASgB;GAEX,UAAA;EACO,CAAA,CACP;;AAET"}
@@ -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, TagSource, WikiLinkSource } from "./types";
3
+ import type { CodeLanguages, EmbedSource, FrontmatterDisplay, ResolveErrorInfo, TagSource, TaskToggleInfo, WikiLinkSource } from "./types";
4
4
  export interface SplitViewProps {
5
5
  value: string;
6
6
  onChange: (next: string) => void;
@@ -14,6 +14,7 @@ export interface SplitViewProps {
14
14
  onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
15
15
  frontmatter?: FrontmatterDisplay;
16
16
  softBreaks?: boolean;
17
+ onTaskToggle?: (info: TaskToggleInfo) => void;
17
18
  /** Called with the doc string on `Mod-s`. */
18
19
  onSave?: (value: string) => void;
19
20
  /** Forwarded the source pane's `EditorView` for the shared toolbar. */
@@ -29,5 +30,5 @@ export interface SplitViewProps {
29
30
  * Stylo root to have a bounded height — otherwise both panes grow and the page
30
31
  * scrolls instead.
31
32
  */
32
- export declare function SplitView({ value, onChange, onWikiLinkClick, readOnly, placeholder, codeLanguages, wikiLinkSource, tagSource, embedSource, onResolveError, frontmatter, softBreaks, onSave, onViewChange, canvasHeader, }: SplitViewProps): import("react").JSX.Element;
33
+ export declare function SplitView({ value, onChange, onWikiLinkClick, readOnly, placeholder, codeLanguages, wikiLinkSource, tagSource, embedSource, onResolveError, frontmatter, softBreaks, onTaskToggle, onSave, onViewChange, canvasHeader, }: SplitViewProps): import("react").JSX.Element;
33
34
  //# sourceMappingURL=SplitView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SplitView.d.ts","sourceRoot":"","sources":["../src/SplitView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,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,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,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,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,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;IAChD,iFAAiF;IACjF,YAAY,C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AAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAA;IAC7C,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;IAChD,iFAAiF;IACjF,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;KAAE,KAAK,SAAS,CAAA;CAC/D;AAED;;;;;GAKG;AACH,wBAAgB,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,UAAU,EACV,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,YAAY,GACb,EAAE,cAAc,+BAqEhB"}
@@ -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,oGA6LhB,CAAA"}
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,oGAgMhB,CAAA"}
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, EmbedSource, FrontmatterDisplay, InPlaceConfig, InPlaceDecorationToggles, ResolveErrorInfo, RevealMode, SelectionUI, StyloHandle, StyloMode, StyloProps, TableEditing, TagCompletion, TagSource, ToolbarCommandId, ToolbarConfig, ToolbarCustomItem, ToolbarItem, WikiLinkCompletion, WikiLinkSource, } from "./types";
3
+ export type { CodeLanguages, EmbedSource, FrontmatterDisplay, InPlaceConfig, InPlaceDecorationToggles, ResolveErrorInfo, RevealMode, SelectionUI, StyloHandle, StyloMode, StyloProps, TableEditing, TagCompletion, TagSource, TaskToggleInfo, ToolbarCommandId, ToolbarConfig, ToolbarCustomItem, ToolbarItem, WikiLinkCompletion, WikiLinkSource, } from "./types";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -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,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,aAAa,EACb,SAAS,EACT,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,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAA"}
@@ -7,6 +7,7 @@ export declare const tableGizmosTheme: {
7
7
  position: string;
8
8
  display: string;
9
9
  maxWidth: string;
10
+ overflow: string;
10
11
  padding: string;
11
12
  };
12
13
  ".cm-inplace-table-gizmos": {
@@ -1 +1 @@
1
- {"version":3,"file":"theme-table-gizmos.d.ts","sourceRoot":"","sources":["../../src/inplace/theme-table-gizmos.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,gBAAgB;IAC3B,wBAAwB;QACtB,QAAQ;QACR,OAAO;QACP,QAAQ;QAMR,OAAO;;IAET,0BAA0B;QACxB,QAAQ;QACR,KAAK;QACL,aAAa;;IAMf,qBAAqB;QACnB,QAAQ;QACR,OAAO;QACP,UAAU;QACV,cAAc;QACd,aAAa;QACb,OAAO;QACP,IAAI;QACJ,MAAM;QACN,UAAU;QACV,MAAM;QACN,OAAO;QACP,UAAU;;IAEZ,2BAA2B;QACzB,OAAO;QACP,UAAU;;IAEZ,uBAAuB;QAAI,KAAK;;IAChC,uBAAuB;QAAI,MAAM;;IAKjC,qBAAqB;QACnB,KAAK;QACL,MAAM;QACN,KAAK;QACL,UAAU;QAGV,aAAa;;IAEf,+CAA+C;QAAI,KAAK;;IAGxD,sBAAsB;QACpB,qBAAqB;YAAI,OAAO;;;CAEnC,CAAA"}
1
+ {"version":3,"file":"theme-table-gizmos.d.ts","sourceRoot":"","sources":["../../src/inplace/theme-table-gizmos.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,gBAAgB;IAC3B,wBAAwB;QACtB,QAAQ;QACR,OAAO;QACP,QAAQ;QAIR,QAAQ;QAYR,OAAO;;IAET,0BAA0B;QACxB,QAAQ;QACR,KAAK;QACL,aAAa;;IAMf,qBAAqB;QACnB,QAAQ;QACR,OAAO;QACP,UAAU;QACV,cAAc;QACd,aAAa;QACb,OAAO;QACP,IAAI;QACJ,MAAM;QACN,UAAU;QACV,MAAM;QACN,OAAO;QACP,UAAU;;IAEZ,2BAA2B;QACzB,OAAO;QACP,UAAU;;IAEZ,uBAAuB;QAAI,KAAK;;IAChC,uBAAuB;QAAI,MAAM;;IAKjC,qBAAqB;QACnB,KAAK;QACL,MAAM;QACN,KAAK;QACL,UAAU;QAGV,aAAa;;IAEf,+CAA+C;QAAI,KAAK;;IAGxD,sBAAsB;QACpB,qBAAqB;YAAI,OAAO;;;CAEnC,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { CodeLanguages, EmbedSource, FrontmatterDisplay, ResolveErrorInfo } from "../types";
1
+ import type { CodeLanguages, EmbedSource, FrontmatterDisplay, ResolveErrorInfo, TaskToggleInfo } from "../types";
2
2
  export interface PreviewProps {
3
3
  value: string;
4
4
  onWikiLinkClick?: (target: string) => void;
@@ -25,7 +25,15 @@ export interface PreviewProps {
25
25
  * independently there.
26
26
  */
27
27
  softBreaks?: boolean;
28
+ /**
29
+ * Makes task-list checkboxes clickable instead of `disabled`. Fired with
30
+ * raw `value` offsets bracketing the clicked marker and its new state; the
31
+ * host owns splicing `value` and calling its own `onChange`. Off by
32
+ * default — every checkbox stays `disabled`, today's behaviour, until a
33
+ * host opts in.
34
+ */
35
+ onTaskToggle?: (info: TaskToggleInfo) => void;
28
36
  }
29
37
  /** Rendered Markdown + KaTeX view. A pure function of the string. */
30
- export declare function Preview({ value, onWikiLinkClick, embedSource, onResolveError, frontmatter, codeLanguages, softBreaks, }: PreviewProps): import("react").JSX.Element;
38
+ export declare function Preview({ value, onWikiLinkClick, embedSource, onResolveError, frontmatter, codeLanguages, softBreaks, onTaskToggle, }: PreviewProps): import("react").JSX.Element;
31
39
  //# sourceMappingURL=Preview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Preview.d.ts","sourceRoot":"","sources":["../../src/render/Preview.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,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;;;;OAQG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAA;CAC9C;AAED,qEAAqE;AACrE,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,eAAe,EACf,WAAW,EACX,cAAc,EACd,WAAsB,EACtB,aAAa,EACb,UAAU,EACV,YAAY,GACb,EAAE,YAAY,+BAqHd"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Locates the exact `[ ]` / `[x]` substring of a task-list item within
3
+ * `value`, given the raw offset where the item itself starts (a GFM
4
+ * `listItem`'s `position.start.offset`, as parsed by `remark-gfm`).
5
+ * Returns `null` if the prefix doesn't match a checkbox — it always should
6
+ * for a node `remark-gfm` marked `checked`, but a raw markdown edit racing
7
+ * the render is not impossible.
8
+ */
9
+ export declare function findCheckboxOffsets(value: string, itemStart: number): {
10
+ start: number;
11
+ end: number;
12
+ } | null;
13
+ //# sourceMappingURL=taskCheckbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taskCheckbox.d.ts","sourceRoot":"","sources":["../../src/render/taskCheckbox.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMvC"}