@damiro/stylo 0.4.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/LICENSE +21 -0
- package/README.md +144 -0
- package/dist/InPlaceView-Ba7JCZ2Y.js +2346 -0
- package/dist/InPlaceView-Ba7JCZ2Y.js.map +1 -0
- package/dist/Preview-Dxb9zPVv.js +93 -0
- package/dist/Preview-Dxb9zPVv.js.map +1 -0
- package/dist/SplitView.d.ts +23 -0
- package/dist/SplitView.d.ts.map +1 -0
- package/dist/Stylo.d.ts +15 -0
- package/dist/Stylo.d.ts.map +1 -0
- package/dist/callout-oLE630ZP.js +37 -0
- package/dist/callout-oLE630ZP.js.map +1 -0
- package/dist/callout.d.ts +18 -0
- package/dist/callout.d.ts.map +1 -0
- package/dist/config-DTBxVhtH.js +101 -0
- package/dist/config-DTBxVhtH.js.map +1 -0
- package/dist/editor/SourceView.d.ts +17 -0
- package/dist/editor/SourceView.d.ts.map +1 -0
- package/dist/editor/extensions.d.ts +20 -0
- package/dist/editor/extensions.d.ts.map +1 -0
- package/dist/editor/highlight.d.ts +19 -0
- package/dist/editor/highlight.d.ts.map +1 -0
- package/dist/editor/save.d.ts +12 -0
- package/dist/editor/save.d.ts.map +1 -0
- package/dist/editor/theme.d.ts +3 -0
- package/dist/editor/theme.d.ts.map +1 -0
- package/dist/editor/useCodeMirror.d.ts +26 -0
- package/dist/editor/useCodeMirror.d.ts.map +1 -0
- package/dist/frontmatter.d.ts +21 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/inplace/InPlaceView.d.ts +30 -0
- package/dist/inplace/InPlaceView.d.ts.map +1 -0
- package/dist/inplace/autoformat.d.ts +23 -0
- package/dist/inplace/autoformat.d.ts.map +1 -0
- package/dist/inplace/config.d.ts +57 -0
- package/dist/inplace/config.d.ts.map +1 -0
- package/dist/inplace/context-menu-actions.d.ts +53 -0
- package/dist/inplace/context-menu-actions.d.ts.map +1 -0
- package/dist/inplace/context-menu.d.ts +50 -0
- package/dist/inplace/context-menu.d.ts.map +1 -0
- package/dist/inplace/decorate.d.ts +17 -0
- package/dist/inplace/decorate.d.ts.map +1 -0
- package/dist/inplace/edit-boundaries.d.ts +59 -0
- package/dist/inplace/edit-boundaries.d.ts.map +1 -0
- package/dist/inplace/edit-insert-assoc.d.ts +17 -0
- package/dist/inplace/edit-insert-assoc.d.ts.map +1 -0
- package/dist/inplace/edit-line-prefix.d.ts +23 -0
- package/dist/inplace/edit-line-prefix.d.ts.map +1 -0
- package/dist/inplace/extension.d.ts +21 -0
- package/dist/inplace/extension.d.ts.map +1 -0
- package/dist/inplace/frontmatter.d.ts +13 -0
- package/dist/inplace/frontmatter.d.ts.map +1 -0
- package/dist/inplace/inline-md.d.ts +13 -0
- package/dist/inplace/inline-md.d.ts.map +1 -0
- package/dist/inplace/lazyInPlace.d.ts +7 -0
- package/dist/inplace/lazyInPlace.d.ts.map +1 -0
- package/dist/inplace/link-click.d.ts +24 -0
- package/dist/inplace/link-click.d.ts.map +1 -0
- package/dist/inplace/link-hover.d.ts +11 -0
- package/dist/inplace/link-hover.d.ts.map +1 -0
- package/dist/inplace/list-guides.d.ts +16 -0
- package/dist/inplace/list-guides.d.ts.map +1 -0
- package/dist/inplace/long-press.d.ts +39 -0
- package/dist/inplace/long-press.d.ts.map +1 -0
- package/dist/inplace/math.d.ts +16 -0
- package/dist/inplace/math.d.ts.map +1 -0
- package/dist/inplace/menu-plugin.d.ts +30 -0
- package/dist/inplace/menu-plugin.d.ts.map +1 -0
- package/dist/inplace/nodes.d.ts +24 -0
- package/dist/inplace/nodes.d.ts.map +1 -0
- package/dist/inplace/plugin.d.ts +21 -0
- package/dist/inplace/plugin.d.ts.map +1 -0
- package/dist/inplace/reveal.d.ts +8 -0
- package/dist/inplace/reveal.d.ts.map +1 -0
- package/dist/inplace/scan.d.ts +11 -0
- package/dist/inplace/scan.d.ts.map +1 -0
- package/dist/inplace/selection-bar.d.ts +38 -0
- package/dist/inplace/selection-bar.d.ts.map +1 -0
- package/dist/inplace/table-cell-dom.d.ts +30 -0
- package/dist/inplace/table-cell-dom.d.ts.map +1 -0
- package/dist/inplace/table-enter.d.ts +22 -0
- package/dist/inplace/table-enter.d.ts.map +1 -0
- package/dist/inplace/table-gizmos.d.ts +55 -0
- package/dist/inplace/table-gizmos.d.ts.map +1 -0
- package/dist/inplace/table-structure.d.ts +23 -0
- package/dist/inplace/table-structure.d.ts.map +1 -0
- package/dist/inplace/table-widget.d.ts +81 -0
- package/dist/inplace/table-widget.d.ts.map +1 -0
- package/dist/inplace/tables.d.ts +8 -0
- package/dist/inplace/tables.d.ts.map +1 -0
- package/dist/inplace/theme.d.ts +14 -0
- package/dist/inplace/theme.d.ts.map +1 -0
- package/dist/inplace/widgets.d.ts +25 -0
- package/dist/inplace/widgets.d.ts.map +1 -0
- package/dist/inplace/wikilinks.d.ts +10 -0
- package/dist/inplace/wikilinks.d.ts.map +1 -0
- package/dist/katex-BfiLlqfN.js +21979 -0
- package/dist/katex-BfiLlqfN.js.map +1 -0
- package/dist/katex.css +3 -0
- package/dist/markdown-N3lRmU2n.js +8524 -0
- package/dist/markdown-N3lRmU2n.js.map +1 -0
- package/dist/render/Preview.d.ts +10 -0
- package/dist/render/Preview.d.ts.map +1 -0
- package/dist/render/lazyPreview.d.ts +8 -0
- package/dist/render/lazyPreview.d.ts.map +1 -0
- package/dist/render/remark-callout.d.ts +10 -0
- package/dist/render/remark-callout.d.ts.map +1 -0
- package/dist/render/remark-wikilink.d.ts +8 -0
- package/dist/render/remark-wikilink.d.ts.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/stylo.js +293 -0
- package/dist/stylo.js.map +1 -0
- package/dist/toolbar/Toolbar.d.ts +28 -0
- package/dist/toolbar/Toolbar.d.ts.map +1 -0
- package/dist/toolbar/block.d.ts +56 -0
- package/dist/toolbar/block.d.ts.map +1 -0
- package/dist/toolbar/cell-inline.d.ts +16 -0
- package/dist/toolbar/cell-inline.d.ts.map +1 -0
- package/dist/toolbar/commands.d.ts +25 -0
- package/dist/toolbar/commands.d.ts.map +1 -0
- package/dist/toolbar/config.d.ts +21 -0
- package/dist/toolbar/config.d.ts.map +1 -0
- package/dist/toolbar/fence.d.ts +28 -0
- package/dist/toolbar/fence.d.ts.map +1 -0
- package/dist/toolbar/floating-watchdog.d.ts +18 -0
- package/dist/toolbar/floating-watchdog.d.ts.map +1 -0
- package/dist/toolbar/icon-paths.d.ts +10 -0
- package/dist/toolbar/icon-paths.d.ts.map +1 -0
- package/dist/toolbar/icons.d.ts +10 -0
- package/dist/toolbar/icons.d.ts.map +1 -0
- package/dist/toolbar/inline-ops.d.ts +101 -0
- package/dist/toolbar/inline-ops.d.ts.map +1 -0
- package/dist/toolbar/inline.d.ts +38 -0
- package/dist/toolbar/inline.d.ts.map +1 -0
- package/dist/toolbar/keyboard-inset.d.ts +10 -0
- package/dist/toolbar/keyboard-inset.d.ts.map +1 -0
- package/dist/toolbar/keymap.d.ts +8 -0
- package/dist/toolbar/keymap.d.ts.map +1 -0
- package/dist/toolbar/labels.d.ts +16 -0
- package/dist/toolbar/labels.d.ts.map +1 -0
- package/dist/toolbar/table-grid.d.ts +23 -0
- package/dist/toolbar/table-grid.d.ts.map +1 -0
- package/dist/toolbar/table.d.ts +35 -0
- package/dist/toolbar/table.d.ts.map +1 -0
- package/dist/toolbar-settings/SortableRow.d.ts +15 -0
- package/dist/toolbar-settings/SortableRow.d.ts.map +1 -0
- package/dist/toolbar-settings/StyloToolbarSettings.d.ts +29 -0
- package/dist/toolbar-settings/StyloToolbarSettings.d.ts.map +1 -0
- package/dist/toolbar-settings/index.d.ts +3 -0
- package/dist/toolbar-settings/index.d.ts.map +1 -0
- package/dist/toolbar-settings/items.d.ts +24 -0
- package/dist/toolbar-settings/items.d.ts.map +1 -0
- package/dist/toolbar-settings.js +269 -0
- package/dist/toolbar-settings.js.map +1 -0
- package/dist/types.d.ts +264 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useCodeMirror-YnIFkvKn.js +1361 -0
- package/dist/useCodeMirror-YnIFkvKn.js.map +1 -0
- package/dist/wikilink-BFpTehto.js +42 -0
- package/dist/wikilink-BFpTehto.js.map +1 -0
- package/dist/wikilink.d.ts +11 -0
- package/dist/wikilink.d.ts.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "./markdown-N3lRmU2n.js";
|
|
2
|
+
import { i as o, r as s, t as c } from "./wikilink-BFpTehto.js";
|
|
3
|
+
import { n as l, r as u } from "./callout-oLE630ZP.js";
|
|
4
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
5
|
+
//#region src/render/remark-callout.ts
|
|
6
|
+
function p() {
|
|
7
|
+
return (e) => {
|
|
8
|
+
r(e, "blockquote", (e) => {
|
|
9
|
+
let t = e.children[0];
|
|
10
|
+
if (t?.type !== "paragraph") return;
|
|
11
|
+
let n = t.children[0];
|
|
12
|
+
if (n?.type !== "text") return;
|
|
13
|
+
let r = l.exec(n.value);
|
|
14
|
+
if (!r) return;
|
|
15
|
+
n.value = n.value.slice(r[0].length);
|
|
16
|
+
let i = r[1].toLowerCase();
|
|
17
|
+
e.data ??= {};
|
|
18
|
+
let a = e.data.hProperties ??= {};
|
|
19
|
+
a.className = ["stylo-callout", `stylo-callout-${u(i)}`], a["data-callout"] = i;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/render/remark-wikilink.ts
|
|
25
|
+
function m() {
|
|
26
|
+
return (e) => {
|
|
27
|
+
r(e, "text", (e, t, n) => {
|
|
28
|
+
if (n == null || t == null || !e.value.includes("[[")) return;
|
|
29
|
+
let r = [], i = 0;
|
|
30
|
+
for (let t of e.value.matchAll(c)) {
|
|
31
|
+
let [n = "", a = "", o] = t, s = t.index ?? 0;
|
|
32
|
+
s > i && r.push({
|
|
33
|
+
type: "text",
|
|
34
|
+
value: e.value.slice(i, s)
|
|
35
|
+
}), r.push({
|
|
36
|
+
type: "link",
|
|
37
|
+
url: "#",
|
|
38
|
+
data: { hProperties: { "data-wikilink": a.trim() } },
|
|
39
|
+
children: [{
|
|
40
|
+
type: "text",
|
|
41
|
+
value: (o ?? a).trim()
|
|
42
|
+
}]
|
|
43
|
+
}), i = s + n.length;
|
|
44
|
+
}
|
|
45
|
+
if (i !== 0) return i < e.value.length && r.push({
|
|
46
|
+
type: "text",
|
|
47
|
+
value: e.value.slice(i)
|
|
48
|
+
}), n.children.splice(t, 1, ...r), t + r.length;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/render/Preview.tsx
|
|
54
|
+
var h = [
|
|
55
|
+
i,
|
|
56
|
+
n,
|
|
57
|
+
a,
|
|
58
|
+
m,
|
|
59
|
+
p
|
|
60
|
+
], g = [t];
|
|
61
|
+
function _({ value: t, onWikiLinkClick: n, frontmatter: r = "hidden" }) {
|
|
62
|
+
let i = r === "code" ? s(t) : null;
|
|
63
|
+
return /* @__PURE__ */ f("div", {
|
|
64
|
+
className: o.preview,
|
|
65
|
+
children: [i && /* @__PURE__ */ d("div", {
|
|
66
|
+
className: "stylo-frontmatter",
|
|
67
|
+
children: i.frontmatter
|
|
68
|
+
}), /* @__PURE__ */ d(e, {
|
|
69
|
+
remarkPlugins: h,
|
|
70
|
+
rehypePlugins: g,
|
|
71
|
+
components: { a({ node: e, children: t, ...r }) {
|
|
72
|
+
let i = r["data-wikilink"];
|
|
73
|
+
return typeof i == "string" ? /* @__PURE__ */ d("a", {
|
|
74
|
+
...r,
|
|
75
|
+
href: "#",
|
|
76
|
+
onClick: (e) => {
|
|
77
|
+
e.preventDefault(), n?.(i);
|
|
78
|
+
},
|
|
79
|
+
children: t
|
|
80
|
+
}) : /* @__PURE__ */ d("a", {
|
|
81
|
+
...r,
|
|
82
|
+
rel: "noreferrer",
|
|
83
|
+
children: t
|
|
84
|
+
});
|
|
85
|
+
} },
|
|
86
|
+
children: t
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { _ as Preview };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=Preview-Dxb9zPVv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Preview-Dxb9zPVv.js","names":[],"sources":["../src/render/remark-callout.ts","../src/render/remark-wikilink.ts","../src/render/Preview.tsx"],"sourcesContent":["import type { Blockquote, Root } from \"mdast\"\nimport { visit } from \"unist-util-visit\"\nimport { CALLOUT_TOKEN, calloutBucket } from \"../callout\"\n\n/**\n * Turns an Obsidian callout blockquote (`> [!note] Title`) into a\n * `<blockquote class=\"stylo-callout stylo-callout-<bucket>\" data-callout=\"note\">`.\n * The `[!type]` token is stripped from the first line; a `::before` label keyed\n * off `data-callout` stands in for it (matching the in-place canvas). The\n * `-` / `+` fold marker is accepted and ignored — the box always renders open.\n */\nexport function remarkCallout() {\n return (tree: Root) => {\n visit(tree, \"blockquote\", (node: Blockquote) => {\n const para = node.children[0]\n if (para?.type !== \"paragraph\") return\n const first = para.children[0]\n if (first?.type !== \"text\") return\n\n const m = CALLOUT_TOKEN.exec(first.value)\n if (!m) return\n\n first.value = first.value.slice(m[0].length)\n const type = m[1]!.toLowerCase()\n node.data ??= {}\n const props = (node.data.hProperties ??= {}) as Record<string, unknown>\n props.className = [\"stylo-callout\", `stylo-callout-${calloutBucket(type)}`]\n props[\"data-callout\"] = type\n })\n }\n}\n","import type { 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 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 { FrontmatterDisplay } from \"../types\"\nimport { remarkCallout } from \"./remark-callout\"\nimport { remarkWikilink } from \"./remark-wikilink\"\n\nconst REMARK_PLUGINS = [remarkFrontmatter, remarkGfm, remarkMath, remarkWikilink, remarkCallout]\nconst REHYPE_PLUGINS = [rehypeKatex]\n\nexport interface PreviewProps {\n value: string\n onWikiLinkClick?: (target: string) => void\n /** `\"code\"` renders the `---` block as a styled `<pre>`; `\"hidden\"` (default) drops it. */\n frontmatter?: FrontmatterDisplay\n}\n\n/** Rendered Markdown + KaTeX view. A pure function of the string. */\nexport function Preview({ value, onWikiLinkClick, frontmatter = \"hidden\" }: PreviewProps) {\n const fm = frontmatter === \"code\" ? splitFrontmatter(value) : null\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 }\n\n return (\n <div className={styles.preview}>\n {fm && <div className=\"stylo-frontmatter\">{fm.frontmatter}</div>}\n <Markdown\n remarkPlugins={REMARK_PLUGINS}\n rehypePlugins={REHYPE_PLUGINS}\n components={components}\n >\n {value}\n </Markdown>\n </div>\n )\n}\n"],"mappings":";;;;;AAWA,SAAgB,IAAgB;CAC9B,QAAQ,MAAe;EACrB,EAAM,GAAM,eAAe,MAAqB;GAC9C,IAAM,IAAO,EAAK,SAAS;GAC3B,IAAI,GAAM,SAAS,aAAa;GAChC,IAAM,IAAQ,EAAK,SAAS;GAC5B,IAAI,GAAO,SAAS,QAAQ;GAE5B,IAAM,IAAI,EAAc,KAAK,EAAM,KAAK;GACxC,IAAI,CAAC,GAAG;GAER,EAAM,QAAQ,EAAM,MAAM,MAAM,EAAE,EAAE,CAAC,MAAM;GAC3C,IAAM,IAAO,EAAE,EAAE,CAAE,YAAY;GAC/B,EAAK,SAAS,CAAC;GACf,IAAM,IAAS,EAAK,KAAK,gBAAgB,CAAC;GAE1C,AADA,EAAM,YAAY,CAAC,iBAAiB,iBAAiB,EAAc,CAAI,GAAG,GAC1E,EAAM,kBAAkB;EAC1B,CAAC;CACH;AACF;;;ACrBA,SAAgB,IAAiB;CAC/B,QAAQ,MAAe;EACrB,EAAM,GAAM,SAAS,GAAY,GAAO,MAAW;GACjD,IAAI,KAAU,QAAQ,KAAS,QAAQ,CAAC,EAAK,MAAM,SAAS,IAAI,GAAG;GAEnE,IAAM,IAA0B,CAAC,GAC7B,IAAS;GAEb,KAAK,IAAM,KAAS,EAAK,MAAM,SAAS,CAAgB,GAAG;IACzD,IAAM,CAAC,IAAM,IAAI,IAAY,IAAI,KAAY,GACvC,IAAQ,EAAM,SAAS;IAU7B,AATI,IAAQ,KACV,EAAI,KAAK;KAAE,MAAM;KAAQ,OAAO,EAAK,MAAM,MAAM,GAAQ,CAAK;IAAE,CAAC,GAEnE,EAAI,KAAK;KACP,MAAM;KACN,KAAK;KACL,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAU,KAAK,EAAE,EAAE;KAC3D,UAAU,CAAC;MAAE,MAAM;MAAQ,QAAQ,KAAY,EAAA,CAAW,KAAK;KAAE,CAAC;IACpE,CAAC,GACD,IAAS,IAAQ,EAAI;GACvB;GAEI,UAAW,GAMf,OALI,IAAS,EAAK,MAAM,UACtB,EAAI,KAAK;IAAE,MAAM;IAAQ,OAAO,EAAK,MAAM,MAAM,CAAM;GAAE,CAAC,GAG5D,EAAO,SAAS,OAAO,GAAO,GAAG,GAAG,CAAG,GAChC,IAAQ,EAAI;EACrB,CAAC;CACH;AACF;;;AC9BA,IAAM,IAAiB;CAAC;CAAmB;CAAW;CAAY;CAAgB;AAAa,GACzF,IAAiB,CAAC,CAAW;AAUnC,SAAgB,EAAQ,EAAE,UAAO,oBAAiB,iBAAc,YAA0B;CACxF,IAAM,IAAK,MAAgB,SAAS,EAAiB,CAAK,IAAI;CA0B9D,OACE,kBAAC,OAAD;EAAK,WAAW,EAAO;EAAvB,UAAA,CACG,KAAM,kBAAC,OAAD;GAAK,WAAU;GAAqB,UAAA,EAAG;EAAiB,CAAA,GAC/D,kBAAC,GAAD;GACE,eAAe;GACf,eAAe;GACH,YAAA,EA9BhB,EAAE,EAAE,MAAM,GAAO,aAAU,GAAG,KAAQ;IACpC,IAAM,IAAU,EAAiC;IAejD,OAdI,OAAO,KAAW,WAElB,kBAAC,KAAD;KACE,GAAI;KACJ,MAAK;KACL,UAAU,MAAU;MAElB,AADA,EAAM,eAAe,GACrB,IAAkB,CAAM;KAC1B;KAEC;IACA,CAAA,IAIL,kBAAC,KAAD;KAAG,GAAI;KAAM,KAAI;KACd;IACA,CAAA;GAEP,EASgB;GAEX,UAAA;EACO,CAAA,CACP;;AAET"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EditorView } from "@codemirror/view";
|
|
2
|
+
import type { CodeLanguages, FrontmatterDisplay } from "./types";
|
|
3
|
+
export interface SplitViewProps {
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (next: string) => void;
|
|
6
|
+
onWikiLinkClick?: (target: string) => void;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
codeLanguages?: CodeLanguages;
|
|
10
|
+
frontmatter?: FrontmatterDisplay;
|
|
11
|
+
/** Called with the doc string on `Mod-s`. */
|
|
12
|
+
onSave?: (value: string) => void;
|
|
13
|
+
/** Forwarded the source pane's `EditorView` for the shared toolbar. */
|
|
14
|
+
onViewChange?: (view: EditorView | null) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Source and preview side by side. Both panes are a pure function of the same
|
|
18
|
+
* string; the only link between them is a proportional scroll sync. Expects the
|
|
19
|
+
* Stylo root to have a bounded height — otherwise both panes grow and the page
|
|
20
|
+
* scrolls instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare function SplitView({ value, onChange, onWikiLinkClick, readOnly, placeholder, codeLanguages, frontmatter, onSave, onViewChange, }: SplitViewProps): import("react").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=SplitView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitView.d.ts","sourceRoot":"","sources":["../src/SplitView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEhE,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,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,6CAA6C;IAC7C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,uEAAuE;IACvE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAA;CACjD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,MAAM,EACN,YAAY,GACb,EAAE,cAAc,+BAwDhB"}
|
package/dist/Stylo.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./styles/tokens.css";
|
|
2
|
+
import type { StyloHandle, StyloProps } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Plain-text-first Markdown editor. `value` is the canonical Markdown string;
|
|
5
|
+
* every view is a pure function of it.
|
|
6
|
+
*
|
|
7
|
+
* The default `mode` is `in-place`, the live decoration canvas (ADR-002 §1,
|
|
8
|
+
* ADR-004). Pass `mode="source"` for the plain surface with no lazy render
|
|
9
|
+
* chunk. `preview` and `split` are also available.
|
|
10
|
+
*
|
|
11
|
+
* A formatting `toolbar` sits above every editing surface (all modes but
|
|
12
|
+
* `preview`); pass `toolbar={false}` to drop it or a `ToolbarConfig` to trim it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const Stylo: import("react").ForwardRefExoticComponent<StyloProps & import("react").RefAttributes<StyloHandle>>;
|
|
15
|
+
//# sourceMappingURL=Stylo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stylo.d.ts","sourceRoot":"","sources":["../src/Stylo.tsx"],"names":[],"mappings":"AAUA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,oGAwJhB,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/callout.ts
|
|
2
|
+
var e = /^\[!(\w+)\][+-]?[ \t]*/, t = /^([\s>]*)(\[!(\w+)\][+-]?[ \t]*)/, n = {
|
|
3
|
+
note: "note",
|
|
4
|
+
info: "note",
|
|
5
|
+
abstract: "note",
|
|
6
|
+
summary: "note",
|
|
7
|
+
tldr: "note",
|
|
8
|
+
tip: "tip",
|
|
9
|
+
hint: "tip",
|
|
10
|
+
important: "tip",
|
|
11
|
+
success: "tip",
|
|
12
|
+
check: "tip",
|
|
13
|
+
done: "tip",
|
|
14
|
+
question: "warn",
|
|
15
|
+
help: "warn",
|
|
16
|
+
faq: "warn",
|
|
17
|
+
warning: "warn",
|
|
18
|
+
caution: "warn",
|
|
19
|
+
attention: "warn",
|
|
20
|
+
todo: "warn",
|
|
21
|
+
failure: "danger",
|
|
22
|
+
fail: "danger",
|
|
23
|
+
missing: "danger",
|
|
24
|
+
danger: "danger",
|
|
25
|
+
error: "danger",
|
|
26
|
+
bug: "danger",
|
|
27
|
+
example: "example",
|
|
28
|
+
quote: "example",
|
|
29
|
+
cite: "example"
|
|
30
|
+
};
|
|
31
|
+
function r(e) {
|
|
32
|
+
return n[e.toLowerCase()] ?? "note";
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { e as n, r, t };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=callout-oLE630ZP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callout-oLE630ZP.js","names":[],"sources":["../src/callout.ts"],"sourcesContent":["/**\n * Obsidian-style callouts: a blockquote whose first line is `> [!type]`,\n * optionally `> [!type] Title` or `> [!type]- Title` (the `-` / `+` fold marker\n * is parsed but Stylo always renders expanded).\n *\n * Single source of truth for the in-place decoration scanner (`nodes.ts`) and\n * the preview remark plugin (`remark-callout.ts`), so the two never drift. The\n * many Obsidian type names collapse to five colour buckets; the raw type is kept\n * on a `data-callout` attribute for a `::before` label and consumer styling.\n */\n\n/** `[!type]` with an optional fold marker, anchored after any `>` prefix. */\nexport const CALLOUT_TOKEN = /^\\[!(\\w+)\\][+-]?[ \\t]*/\n\n/** A blockquote head line in the in-place canvas: `> ` prefix, then the token. */\nexport const CALLOUT_HEAD_LINE = /^([\\s>]*)(\\[!(\\w+)\\][+-]?[ \\t]*)/\n\nexport type CalloutBucket = \"note\" | \"tip\" | \"warn\" | \"danger\" | \"example\"\n\nconst BUCKET: Record<string, CalloutBucket> = {\n note: \"note\",\n info: \"note\",\n abstract: \"note\",\n summary: \"note\",\n tldr: \"note\",\n tip: \"tip\",\n hint: \"tip\",\n important: \"tip\",\n success: \"tip\",\n check: \"tip\",\n done: \"tip\",\n question: \"warn\",\n help: \"warn\",\n faq: \"warn\",\n warning: \"warn\",\n caution: \"warn\",\n attention: \"warn\",\n todo: \"warn\",\n failure: \"danger\",\n fail: \"danger\",\n missing: \"danger\",\n danger: \"danger\",\n error: \"danger\",\n bug: \"danger\",\n example: \"example\",\n quote: \"example\",\n cite: \"example\",\n}\n\n/** The colour bucket for a callout type; unknown types read as `note`. */\nexport function calloutBucket(type: string): CalloutBucket {\n return BUCKET[type.toLowerCase()] ?? \"note\"\n}\n"],"mappings":";AAYA,IAAa,IAAgB,0BAGhB,IAAoB,oCAI3B,IAAwC;CAC5C,MAAM;CACN,MAAM;CACN,UAAU;CACV,SAAS;CACT,MAAM;CACN,KAAK;CACL,MAAM;CACN,WAAW;CACX,SAAS;CACT,OAAO;CACP,MAAM;CACN,UAAU;CACV,MAAM;CACN,KAAK;CACL,SAAS;CACT,SAAS;CACT,WAAW;CACX,MAAM;CACN,SAAS;CACT,MAAM;CACN,SAAS;CACT,QAAQ;CACR,OAAO;CACP,KAAK;CACL,SAAS;CACT,OAAO;CACP,MAAM;AACR;AAGA,SAAgB,EAAc,GAA6B;CACzD,OAAO,EAAO,EAAK,YAAY,MAAM;AACvC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Obsidian-style callouts: a blockquote whose first line is `> [!type]`,
|
|
3
|
+
* optionally `> [!type] Title` or `> [!type]- Title` (the `-` / `+` fold marker
|
|
4
|
+
* is parsed but Stylo always renders expanded).
|
|
5
|
+
*
|
|
6
|
+
* Single source of truth for the in-place decoration scanner (`nodes.ts`) and
|
|
7
|
+
* the preview remark plugin (`remark-callout.ts`), so the two never drift. The
|
|
8
|
+
* many Obsidian type names collapse to five colour buckets; the raw type is kept
|
|
9
|
+
* on a `data-callout` attribute for a `::before` label and consumer styling.
|
|
10
|
+
*/
|
|
11
|
+
/** `[!type]` with an optional fold marker, anchored after any `>` prefix. */
|
|
12
|
+
export declare const CALLOUT_TOKEN: RegExp;
|
|
13
|
+
/** A blockquote head line in the in-place canvas: `> ` prefix, then the token. */
|
|
14
|
+
export declare const CALLOUT_HEAD_LINE: RegExp;
|
|
15
|
+
export type CalloutBucket = "note" | "tip" | "warn" | "danger" | "example";
|
|
16
|
+
/** The colour bucket for a callout type; unknown types read as `note`. */
|
|
17
|
+
export declare function calloutBucket(type: string): CalloutBucket;
|
|
18
|
+
//# sourceMappingURL=callout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callout.d.ts","sourceRoot":"","sources":["../src/callout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,aAAa,QAA2B,CAAA;AAErD,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,QAAqC,CAAA;AAEnE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;AAgC1E,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAEzD"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
//#region src/toolbar/icon-paths.ts
|
|
3
|
+
var t = {
|
|
4
|
+
undo: "M9 14 4 9l5-5|M4 9h11a5 5 0 0 1 0 10h-4",
|
|
5
|
+
redo: "m15 14 5-5-5-5|M20 9H9a5 5 0 0 0 0 10h4",
|
|
6
|
+
save: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z|M17 21v-8H7v8|M7 3v5h8",
|
|
7
|
+
search: "M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z|m21 21-4.35-4.35",
|
|
8
|
+
bold: "M7 5h6a3.5 3.5 0 0 1 0 7H7z|M7 12h7a3.5 3.5 0 0 1 0 7H7z",
|
|
9
|
+
italic: "M19 5h-7|M12 19H5|M15 5l-4 14",
|
|
10
|
+
strike: "M4 12h16|M8 8a4 3 0 0 1 4-3h1.5|M14 12a3 3 0 0 1 0 6h-2.5",
|
|
11
|
+
underline: "M6 4v6a6 6 0 0 0 12 0V4|M5 20h14",
|
|
12
|
+
code: "m16 18 6-6-6-6|M8 6l-6 6 6 6",
|
|
13
|
+
codeBlock: "M4 4h16v16H4z|m10 10-2 2 2 2|m14 10 2 2-2 2",
|
|
14
|
+
link: "M10 13a5 5 0 0 0 7.07 0l3-3A5 5 0 0 0 13 3l-1.5 1.5|M14 11a5 5 0 0 0-7.07 0l-3 3A5 5 0 0 0 11 21l1.5-1.5",
|
|
15
|
+
wikilink: "M10 5H6v14h4|M18 5H14v14h4",
|
|
16
|
+
quote: "M7 7H4v6h3l-2 4|M17 7h-3v6h3l-2 4",
|
|
17
|
+
bulletList: "M9 6h11|M9 12h11|M9 18h11|M4.5 6h.01|M4.5 12h.01|M4.5 18h.01",
|
|
18
|
+
orderedList: "M10 6h11|M10 12h11|M10 18h11|M4 6l1-.75V10|M4 18h2.5a1 1 0 0 0 .7-1.7L4 13.5h3",
|
|
19
|
+
task: "m9 11 2.5 2.5L20 5|M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9",
|
|
20
|
+
hr: "M4 12h4|M10 12h4|M16 12h4",
|
|
21
|
+
table: "M4 5h16v14H4z|M4 10h16|M4 15h16|M10 5v14",
|
|
22
|
+
math: "M19 5H7l5.5 7L7 19h12",
|
|
23
|
+
mathBlock: "M4 4h16v16H4z|M15 8H9l4 4-4 4h6",
|
|
24
|
+
insert: "M12 5v14|M5 12h14",
|
|
25
|
+
heading: "M6 4v16|M18 4v16|M6 12h12",
|
|
26
|
+
format: "M4 20l6-15 6 15|M6.5 14h7|M4 22h16",
|
|
27
|
+
paragraph: "M17 4H10a5 5 0 0 0 0 10h3|M13 4v16|M17 4v16",
|
|
28
|
+
body: "M5 6h14|M5 12h14|M5 18h9",
|
|
29
|
+
frontmatter: "M4 5h16v4H4z|M4 13h10|M4 17h10",
|
|
30
|
+
cut: "M6 3a3 3 0 1 0 0 6 3 3 0 0 0 0-6z|M6 15a3 3 0 1 0 0 6 3 3 0 0 0 0-6z|M8.6 8.6 20 20|M8.6 15.4 20 4",
|
|
31
|
+
copy: "M9 9h11v11H9z|M5 15H4V4h11v1",
|
|
32
|
+
paste: "M9 3h6v4H9z|M7 5h10v16H7z"
|
|
33
|
+
}, n = "http://www.w3.org/2000/svg";
|
|
34
|
+
function r(e, t) {
|
|
35
|
+
let r = e.createElementNS(n, "svg");
|
|
36
|
+
r.setAttribute("viewBox", "0 0 24 24"), r.setAttribute("fill", "none"), r.setAttribute("stroke", "currentColor"), r.setAttribute("stroke-width", "2"), r.setAttribute("stroke-linecap", "round"), r.setAttribute("stroke-linejoin", "round");
|
|
37
|
+
for (let i of t.split("|")) {
|
|
38
|
+
let t = e.createElementNS(n, "path");
|
|
39
|
+
t.setAttribute("d", i), r.appendChild(t);
|
|
40
|
+
}
|
|
41
|
+
return r;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/toolbar/icons.tsx
|
|
45
|
+
function i({ d: t }) {
|
|
46
|
+
return /* @__PURE__ */ e("svg", {
|
|
47
|
+
viewBox: "0 0 24 24",
|
|
48
|
+
fill: "none",
|
|
49
|
+
stroke: "currentColor",
|
|
50
|
+
strokeWidth: 2,
|
|
51
|
+
strokeLinecap: "round",
|
|
52
|
+
strokeLinejoin: "round",
|
|
53
|
+
children: t.split("|").map((t, n) => /* @__PURE__ */ e("path", { d: t }, n))
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
var a = {
|
|
57
|
+
undo: /* @__PURE__ */ e(i, { d: t.undo }),
|
|
58
|
+
redo: /* @__PURE__ */ e(i, { d: t.redo }),
|
|
59
|
+
save: /* @__PURE__ */ e(i, { d: t.save }),
|
|
60
|
+
search: /* @__PURE__ */ e(i, { d: t.search }),
|
|
61
|
+
h1: /* @__PURE__ */ e("b", {
|
|
62
|
+
"aria-hidden": "true",
|
|
63
|
+
children: "H1"
|
|
64
|
+
}),
|
|
65
|
+
h2: /* @__PURE__ */ e("b", {
|
|
66
|
+
"aria-hidden": "true",
|
|
67
|
+
children: "H2"
|
|
68
|
+
}),
|
|
69
|
+
h3: /* @__PURE__ */ e("b", {
|
|
70
|
+
"aria-hidden": "true",
|
|
71
|
+
children: "H3"
|
|
72
|
+
}),
|
|
73
|
+
body: /* @__PURE__ */ e(i, { d: t.body }),
|
|
74
|
+
bold: /* @__PURE__ */ e(i, { d: t.bold }),
|
|
75
|
+
italic: /* @__PURE__ */ e(i, { d: t.italic }),
|
|
76
|
+
strike: /* @__PURE__ */ e(i, { d: t.strike }),
|
|
77
|
+
underline: /* @__PURE__ */ e(i, { d: t.underline }),
|
|
78
|
+
code: /* @__PURE__ */ e(i, { d: t.code }),
|
|
79
|
+
codeBlock: /* @__PURE__ */ e(i, { d: t.codeBlock }),
|
|
80
|
+
link: /* @__PURE__ */ e(i, { d: t.link }),
|
|
81
|
+
wikilink: /* @__PURE__ */ e(i, { d: t.wikilink }),
|
|
82
|
+
quote: /* @__PURE__ */ e(i, { d: t.quote }),
|
|
83
|
+
bulletList: /* @__PURE__ */ e(i, { d: t.bulletList }),
|
|
84
|
+
orderedList: /* @__PURE__ */ e(i, { d: t.orderedList }),
|
|
85
|
+
task: /* @__PURE__ */ e(i, { d: t.task }),
|
|
86
|
+
hr: /* @__PURE__ */ e(i, { d: t.hr }),
|
|
87
|
+
frontmatter: /* @__PURE__ */ e("code", {
|
|
88
|
+
"aria-hidden": "true",
|
|
89
|
+
children: "fm"
|
|
90
|
+
}),
|
|
91
|
+
table: /* @__PURE__ */ e(i, { d: t.table }),
|
|
92
|
+
math: /* @__PURE__ */ e(i, { d: t.math }),
|
|
93
|
+
mathBlock: /* @__PURE__ */ e(i, { d: t.mathBlock })
|
|
94
|
+
}, o = /* @__PURE__ */ "undo.redo.|.h1.h2.h3.|.bold.italic.strike.link.wikilink.|.bulletList.orderedList.task.|.quote.hr.frontmatter.table.|.code.codeBlock.math.mathBlock".split(".");
|
|
95
|
+
function s(e) {
|
|
96
|
+
return e === !1 ? null : e === void 0 || e === !0 ? o : e.items ?? o;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { r as a, t as i, s as n, a as r, o as t };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=config-DTBxVhtH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-DTBxVhtH.js","names":[],"sources":["../src/toolbar/icon-paths.ts","../src/toolbar/icons.tsx","../src/toolbar/config.ts"],"sourcesContent":["/**\n * Single source of truth for the built-in glyphs: 24×24 stroke-path data,\n * segments joined by \"|\". Consumed by the React toolbar (`icons.tsx`), the\n * in-place selection bar, and the in-place right-click menu, so none of them\n * carries its own copy.\n */\nexport const ICON_PATHS: Record<string, string> = {\n undo: \"M9 14 4 9l5-5|M4 9h11a5 5 0 0 1 0 10h-4\",\n redo: \"m15 14 5-5-5-5|M20 9H9a5 5 0 0 0 0 10h4\",\n save: \"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z|M17 21v-8H7v8|M7 3v5h8\",\n search: \"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z|m21 21-4.35-4.35\",\n bold: \"M7 5h6a3.5 3.5 0 0 1 0 7H7z|M7 12h7a3.5 3.5 0 0 1 0 7H7z\",\n italic: \"M19 5h-7|M12 19H5|M15 5l-4 14\",\n strike: \"M4 12h16|M8 8a4 3 0 0 1 4-3h1.5|M14 12a3 3 0 0 1 0 6h-2.5\",\n underline: \"M6 4v6a6 6 0 0 0 12 0V4|M5 20h14\",\n code: \"m16 18 6-6-6-6|M8 6l-6 6 6 6\",\n codeBlock: \"M4 4h16v16H4z|m10 10-2 2 2 2|m14 10 2 2-2 2\",\n link: \"M10 13a5 5 0 0 0 7.07 0l3-3A5 5 0 0 0 13 3l-1.5 1.5|M14 11a5 5 0 0 0-7.07 0l-3 3A5 5 0 0 0 11 21l1.5-1.5\",\n wikilink: \"M10 5H6v14h4|M18 5H14v14h4\",\n quote: \"M7 7H4v6h3l-2 4|M17 7h-3v6h3l-2 4\",\n bulletList: \"M9 6h11|M9 12h11|M9 18h11|M4.5 6h.01|M4.5 12h.01|M4.5 18h.01\",\n orderedList: \"M10 6h11|M10 12h11|M10 18h11|M4 6l1-.75V10|M4 18h2.5a1 1 0 0 0 .7-1.7L4 13.5h3\",\n task: \"m9 11 2.5 2.5L20 5|M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9\",\n hr: \"M4 12h4|M10 12h4|M16 12h4\",\n table: \"M4 5h16v14H4z|M4 10h16|M4 15h16|M10 5v14\",\n math: \"M19 5H7l5.5 7L7 19h12\",\n mathBlock: \"M4 4h16v16H4z|M15 8H9l4 4-4 4h6\",\n // Menu-only glyphs (the toolbar renders these ids as text, or not at all).\n insert: \"M12 5v14|M5 12h14\",\n heading: \"M6 4v16|M18 4v16|M6 12h12\",\n format: \"M4 20l6-15 6 15|M6.5 14h7|M4 22h16\",\n paragraph: \"M17 4H10a5 5 0 0 0 0 10h3|M13 4v16|M17 4v16\",\n body: \"M5 6h14|M5 12h14|M5 18h9\",\n frontmatter: \"M4 5h16v4H4z|M4 13h10|M4 17h10\",\n cut: \"M6 3a3 3 0 1 0 0 6 3 3 0 0 0 0-6z|M6 15a3 3 0 1 0 0 6 3 3 0 0 0 0-6z|M8.6 8.6 20 20|M8.6 15.4 20 4\",\n copy: \"M9 9h11v11H9z|M5 15H4V4h11v1\",\n paste: \"M9 3h6v4H9z|M7 5h10v16H7z\",\n}\n\nconst SVGNS = \"http://www.w3.org/2000/svg\"\n\n/** Build a stroke `<svg>` for `d` (as an `ICON_PATHS` value) as detached DOM. */\nexport function iconSvg(doc: Document, d: string): SVGElement {\n const svg = doc.createElementNS(SVGNS, \"svg\")\n svg.setAttribute(\"viewBox\", \"0 0 24 24\")\n svg.setAttribute(\"fill\", \"none\")\n svg.setAttribute(\"stroke\", \"currentColor\")\n svg.setAttribute(\"stroke-width\", \"2\")\n svg.setAttribute(\"stroke-linecap\", \"round\")\n svg.setAttribute(\"stroke-linejoin\", \"round\")\n for (const seg of d.split(\"|\")) {\n const p = doc.createElementNS(SVGNS, \"path\")\n p.setAttribute(\"d\", seg)\n svg.appendChild(p)\n }\n return svg\n}\n","import type { ReactNode } from \"react\"\nimport type { ToolbarCommandId } from \"../types\"\nimport { ICON_PATHS } from \"./icon-paths\"\n\n/** One 24×24 stroke icon; `d` holds one or more paths joined by `|`. */\nfunction Svg({ d }: { d: string }): ReactNode {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n {d.split(\"|\").map((seg, i) => (\n <path key={i} d={seg} />\n ))}\n </svg>\n )\n}\n\n/**\n * Built-in glyphs — the fallback when the consumer passes no `icons` override\n * for an id. Inline SVG only; no icon package in the dependency tree (ADR-002\n * §4). Path data is shared with the in-place UI via `./icon-paths`. Headings\n * render as text so the level reads at a glance.\n */\nexport const DEFAULT_ICONS: Record<ToolbarCommandId, ReactNode> = {\n undo: <Svg d={ICON_PATHS.undo!} />,\n redo: <Svg d={ICON_PATHS.redo!} />,\n save: <Svg d={ICON_PATHS.save!} />,\n search: <Svg d={ICON_PATHS.search!} />,\n h1: <b aria-hidden=\"true\">H1</b>,\n h2: <b aria-hidden=\"true\">H2</b>,\n h3: <b aria-hidden=\"true\">H3</b>,\n body: <Svg d={ICON_PATHS.body!} />,\n bold: <Svg d={ICON_PATHS.bold!} />,\n italic: <Svg d={ICON_PATHS.italic!} />,\n strike: <Svg d={ICON_PATHS.strike!} />,\n underline: <Svg d={ICON_PATHS.underline!} />,\n code: <Svg d={ICON_PATHS.code!} />,\n codeBlock: <Svg d={ICON_PATHS.codeBlock!} />,\n link: <Svg d={ICON_PATHS.link!} />,\n wikilink: <Svg d={ICON_PATHS.wikilink!} />,\n quote: <Svg d={ICON_PATHS.quote!} />,\n bulletList: <Svg d={ICON_PATHS.bulletList!} />,\n orderedList: <Svg d={ICON_PATHS.orderedList!} />,\n task: <Svg d={ICON_PATHS.task!} />,\n hr: <Svg d={ICON_PATHS.hr!} />,\n frontmatter: <code aria-hidden=\"true\">fm</code>,\n table: <Svg d={ICON_PATHS.table!} />,\n math: <Svg d={ICON_PATHS.math!} />,\n mathBlock: <Svg d={ICON_PATHS.mathBlock!} />,\n}\n","import type { ToolbarCommandId, ToolbarConfig, ToolbarItem } from \"../types\"\n\n/**\n * An entry in the rendered bar: a built-in command id, `\"|\"` for a separator,\n * or a consumer-supplied {@link ToolbarCustomItem}. Defined in `types.ts`;\n * re-exported here because the toolbar internals are the main consumers.\n */\nexport type { ToolbarItem }\n\n/**\n * The full built-in bar, in display order. Grouped by kind: history, headings,\n * inline text (+ link), the three list markers, block structure, then code and\n * math together. Built-in ids only — a consumer adds custom items through the\n * `toolbar` prop.\n */\nexport const DEFAULT_TOOLBAR_ITEMS: (ToolbarCommandId | \"|\")[] = [\n \"undo\",\n \"redo\",\n \"|\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"|\",\n \"bold\",\n \"italic\",\n \"strike\",\n \"link\",\n \"wikilink\",\n \"|\",\n \"bulletList\",\n \"orderedList\",\n \"task\",\n \"|\",\n \"quote\",\n \"hr\",\n \"frontmatter\",\n \"table\",\n \"|\",\n \"code\",\n \"codeBlock\",\n \"math\",\n \"mathBlock\",\n]\n\n/**\n * Resolve the `toolbar` prop to the list to render:\n * `undefined` / `true` → the default set, `false` → no bar (`null`), an object →\n * its `items` or the default.\n */\nexport function resolveToolbarItems(\n config: boolean | ToolbarConfig | undefined,\n): ToolbarItem[] | null {\n if (config === false) return null\n if (config === undefined || config === true) return DEFAULT_TOOLBAR_ITEMS\n return config.items ?? DEFAULT_TOOLBAR_ITEMS\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EditorView } from "@codemirror/view";
|
|
2
|
+
import type { CodeLanguages } from "../types";
|
|
3
|
+
export interface SourceViewProps {
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (next: string) => void;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** Fenced-code grammars, forwarded to the Markdown language. Read once. */
|
|
9
|
+
codeLanguages?: CodeLanguages;
|
|
10
|
+
/** Called with the doc string on `Mod-s`. */
|
|
11
|
+
onSave?: (value: string) => void;
|
|
12
|
+
/** Called with the `EditorView` once created, and with `null` on teardown. */
|
|
13
|
+
onViewChange?: (view: EditorView | null) => void;
|
|
14
|
+
}
|
|
15
|
+
/** Raw CodeMirror 6 Markdown surface bound to the canonical string. */
|
|
16
|
+
export declare function SourceView({ value, onChange, readOnly, placeholder, codeLanguages, onSave, onViewChange, }: SourceViewProps): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=SourceView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceView.d.ts","sourceRoot":"","sources":["../../src/editor/SourceView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C,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,6CAA6C;IAC7C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,8EAA8E;IAC9E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAA;CACjD;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,aAAa,EACb,MAAM,EACN,YAAY,GACb,EAAE,eAAe,+BAWjB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Extension } from "@codemirror/state";
|
|
2
|
+
import type { CodeLanguages } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Static extensions — created once with the view.
|
|
5
|
+
*
|
|
6
|
+
* `codeLanguages` is forwarded verbatim to `@codemirror/lang-markdown` for
|
|
7
|
+
* fenced-code sub-highlighting. Stylo bundles none: passing the full
|
|
8
|
+
* `@codemirror/language-data` grammar set emitted ~110 lazy language chunks into
|
|
9
|
+
* the published package — the zero-bloat mandate inverted for a notes editor. A
|
|
10
|
+
* consumer opts in with exactly the set they want. See the 2026-09-01 journal
|
|
11
|
+
* note and the ADR-001 amendment.
|
|
12
|
+
*/
|
|
13
|
+
export declare function baseExtensions(codeLanguages?: CodeLanguages): Extension;
|
|
14
|
+
/** Extensions that depend on props and are swapped via a compartment on change. */
|
|
15
|
+
export declare function dynamicConfig(opts: {
|
|
16
|
+
readOnly: boolean;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
save?: (value: string) => void;
|
|
19
|
+
}): Extension;
|
|
20
|
+
//# sourceMappingURL=extensions.d.ts.map
|
|
@@ -0,0 +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,MAAM,UAAU,CAAA;AAK7C;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAmBvE;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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HighlightStyle } from "@codemirror/language";
|
|
2
|
+
/**
|
|
3
|
+
* Token colours for fenced code and any other embedded-language grammar.
|
|
4
|
+
*
|
|
5
|
+
* Every colour resolves to a `--stylo-syntax-*` custom property, so the host
|
|
6
|
+
* restyles code the same way as the rest of the `--stylo-*` palette; the values
|
|
7
|
+
* in `tokens.css` are the defaults. Both `@codemirror/language` and
|
|
8
|
+
* `@lezer/highlight` are already transitive dependencies of
|
|
9
|
+
* `@codemirror/lang-markdown`, so this adds no package weight.
|
|
10
|
+
*
|
|
11
|
+
* Markdown's own structural tokens (heading marks, emphasis markers, link
|
|
12
|
+
* brackets) are deliberately left undefined: the in-place canvas styles those
|
|
13
|
+
* with decorations, and `source` mode keeps its plain, un-tinted look. Only
|
|
14
|
+
* tokens that come from a real programming-language parser get a colour.
|
|
15
|
+
*/
|
|
16
|
+
export declare const styloHighlightStyle: HighlightStyle;
|
|
17
|
+
/** The highlight style wrapped as an editor extension. */
|
|
18
|
+
export declare const styloHighlighting: import("@codemirror/state").Extension;
|
|
19
|
+
//# sourceMappingURL=highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/editor/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsB,MAAM,sBAAsB,CAAA;AAGzE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,gBAiC9B,CAAA;AAEF,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,uCAA0C,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Facet } from "@codemirror/state";
|
|
2
|
+
import type { EditorView } from "@codemirror/view";
|
|
3
|
+
/**
|
|
4
|
+
* The consumer's `onSave` handler, surfaced into editor state so the `Mod-s`
|
|
5
|
+
* keymap and the toolbar's `save` command share one path. Absent when no
|
|
6
|
+
* `onSave` prop is set — the `save` button then renders disabled and `Mod-s`
|
|
7
|
+
* falls through to the browser.
|
|
8
|
+
*/
|
|
9
|
+
export declare const saveHandler: Facet<(value: string) => void, ((value: string) => void) | null>;
|
|
10
|
+
/** Run the registered save handler with the current document. `false` if none. */
|
|
11
|
+
export declare function runSave(view: EditorView): boolean;
|
|
12
|
+
//# sourceMappingURL=save.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../src/editor/save.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,gBAAwB,MAAM,KAAK,IAAI,WAAW,MAAM,KAAK,IAAI,SAEvF,CAAA;AAEF,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAKjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/editor/theme.ts"],"names":[],"mappings":"AAEA,yFAAyF;AACzF,eAAO,MAAM,UAAU,uCAsFrB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Extension } from "@codemirror/state";
|
|
2
|
+
import { EditorView } from "@codemirror/view";
|
|
3
|
+
import type { CodeLanguages } from "../types";
|
|
4
|
+
export interface UseCodeMirrorOptions {
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (next: string) => void;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
/** Called with the doc string on `Mod-s`; suppresses the browser dialog when set. */
|
|
10
|
+
onSave?: (value: string) => void;
|
|
11
|
+
/** Called with the `EditorView` once it is created, and with `null` on teardown. */
|
|
12
|
+
onViewChange?: (view: EditorView | null) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Extra extensions merged in at construction (e.g. the in-place decoration
|
|
15
|
+
* layer). Captured once — pass a stable, module-level array.
|
|
16
|
+
*/
|
|
17
|
+
extensions?: Extension[];
|
|
18
|
+
/** Fenced-code grammars, forwarded to the Markdown language. Read once. */
|
|
19
|
+
codeLanguages?: CodeLanguages;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Owns a CodeMirror `EditorView` for the lifetime of the host element and keeps
|
|
23
|
+
* it in sync with a controlled Markdown string. Returns a ref for the container.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useCodeMirror({ value, onChange, readOnly, placeholder, onSave, onViewChange, extensions, codeLanguages, }: UseCodeMirrorOptions): import("react").RefObject<HTMLDivElement | null>;
|
|
26
|
+
//# sourceMappingURL=useCodeMirror.d.ts.map
|
|
@@ -0,0 +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,MAAM,UAAU,CAAA;AAO7C,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;CAC9B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,WAAW,EACX,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,GACd,EAAE,oBAAoB,oDAwEtB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Text } from "@codemirror/state";
|
|
2
|
+
/**
|
|
3
|
+
* The leading `---` … `---` YAML block, if present. The CodeMirror Markdown
|
|
4
|
+
* grammar has no frontmatter node — it parses the fences as two thematic breaks
|
|
5
|
+
* — so the region is located by hand. Shared by the in-place decoration layer
|
|
6
|
+
* and the toolbar's frontmatter command.
|
|
7
|
+
*/
|
|
8
|
+
export declare function frontmatterRange(doc: Text): {
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
} | null;
|
|
12
|
+
/**
|
|
13
|
+
* Split a leading `---` … `---` block off a Markdown string. `frontmatter` is
|
|
14
|
+
* the inner text (`""` for an empty block); `body` is everything after the
|
|
15
|
+
* closing fence. Used by `preview` to render the block instead of dropping it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function splitFrontmatter(md: string): {
|
|
18
|
+
frontmatter: string;
|
|
19
|
+
body: string;
|
|
20
|
+
} | null;
|
|
21
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAE7C;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAM/E;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGzF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Stylo } from "./Stylo";
|
|
2
|
+
export { splitFrontmatter } from "./frontmatter";
|
|
3
|
+
export type { CodeLanguages, FrontmatterDisplay, InPlaceConfig, InPlaceDecorationToggles, RevealMode, SelectionUI, StyloHandle, StyloMode, StyloProps, TableEditing, ToolbarCommandId, ToolbarConfig, ToolbarCustomItem, ToolbarItem, } from "./types";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EditorView } from "@codemirror/view";
|
|
2
|
+
import type { CodeLanguages, InPlaceConfig } from "../types";
|
|
3
|
+
export interface InPlaceViewProps {
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (next: string) => void;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
onWikiLinkClick?: (target: string) => void;
|
|
9
|
+
/** Fired by the link editor's "Open link" action. */
|
|
10
|
+
onLinkClick?: (href: string) => void;
|
|
11
|
+
/** Read once, when the canvas mounts — see ADR-005. */
|
|
12
|
+
inPlace?: InPlaceConfig;
|
|
13
|
+
/** Fenced-code grammars, forwarded to the Markdown language. Read once. */
|
|
14
|
+
codeLanguages?: CodeLanguages;
|
|
15
|
+
/** Called with the doc string on `Mod-s`. */
|
|
16
|
+
onSave?: (value: string) => void;
|
|
17
|
+
/** Called with the `EditorView` once created, and with `null` on teardown. */
|
|
18
|
+
onViewChange?: (view: EditorView | null) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The in-place canvas: a CodeMirror surface that renders Markdown structure live
|
|
22
|
+
* via view decorations, revealing the raw source under the cursor. Loaded lazily
|
|
23
|
+
* so `mode="source"` consumers never pull it in.
|
|
24
|
+
*
|
|
25
|
+
* The extension array (and the `inPlace` config baked into it) is built once;
|
|
26
|
+
* `onWikiLinkClick` is reached through a ref so a changed handler does not force
|
|
27
|
+
* the editor to be rebuilt.
|
|
28
|
+
*/
|
|
29
|
+
export declare function InPlaceView({ value, onChange, readOnly, placeholder, onWikiLinkClick, onLinkClick, inPlace, codeLanguages, onSave, onViewChange, }: InPlaceViewProps): import("react").JSX.Element;
|
|
30
|
+
//# sourceMappingURL=InPlaceView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InPlaceView.d.ts","sourceRoot":"","sources":["../../src/inplace/InPlaceView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG5D,MAAM,WAAW,gBAAgB;IAC/B,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,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,qDAAqD;IACrD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,uDAAuD;IACvD,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,6CAA6C;IAC7C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,8EAA8E;IAC9E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAA;CACjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,eAAe,EACf,WAAW,EACX,OAAO,EACP,aAAa,EACb,MAAM,EACN,YAAY,GACb,EAAE,gBAAgB,+BA0BlB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-007 Stage 5 — autoformat on type. After a single typed character at the
|
|
3
|
+
* end of a line, expand a few shorthands the way Obsidian / Typora do:
|
|
4
|
+
*
|
|
5
|
+
* - `[] ` / `[ ] ` at the line start → `- [ ] ` (a task item)
|
|
6
|
+
* - ` ``` ` alone on a line → a fenced block, caret on the line between
|
|
7
|
+
* - `$$` alone on a line → a math block, caret between
|
|
8
|
+
* - `---` typed directly under text → a blank line is inserted above it, so
|
|
9
|
+
* Markdown reads it as a thematic break, not a Setext `<h2>` underline —
|
|
10
|
+
* matching `***` / `___`, which have no Setext meaning and already do this
|
|
11
|
+
* - a rule (`---` / `***` / `___`) completed as the last line → append `\n`,
|
|
12
|
+
* so the caret steps off the rule instead of being stranded on it
|
|
13
|
+
*
|
|
14
|
+
* Headings (`# `), bullets (`- `), and quotes (`> `) need nothing here — their
|
|
15
|
+
* markers already hide as you type them.
|
|
16
|
+
*
|
|
17
|
+
* One `transactionFilter`: it appends its rewrite to the keystroke's own
|
|
18
|
+
* transaction (`sequential`), so a single undo takes the shorthand back to the
|
|
19
|
+
* literal text.
|
|
20
|
+
*/
|
|
21
|
+
import { type Extension } from "@codemirror/state";
|
|
22
|
+
export declare const inPlaceAutoformat: Extension;
|
|
23
|
+
//# sourceMappingURL=autoformat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoformat.d.ts","sourceRoot":"","sources":["../../src/inplace/autoformat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAe,KAAK,SAAS,EAAwB,MAAM,mBAAmB,CAAA;AAKrF,eAAO,MAAM,iBAAiB,EAAE,SAsD9B,CAAA"}
|