@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 damiro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Stylo
|
|
2
|
+
|
|
3
|
+
**A plain-text-first Markdown editor for React, with first-class LaTeX support.**
|
|
4
|
+
|
|
5
|
+
Stylo is a zero-bloat Markdown editor component for React. Plain text stays
|
|
6
|
+
canonical — there is no WYSIWYG document model — so notes round-trip losslessly
|
|
7
|
+
with Obsidian and any other Markdown tool. CodeMirror 6 handles editing;
|
|
8
|
+
`remark` / `rehype` + KaTeX handle rendering; `[[wikilinks]]` and `$…$` math are
|
|
9
|
+
built in.
|
|
10
|
+
|
|
11
|
+
> **Status:** working library, pre-1.0. The in-place canvas, `source` / `preview`
|
|
12
|
+
> / `split` modes, the formatting toolbar, `[[wikilinks]]`, and KaTeX math all
|
|
13
|
+
> ship and are covered by an integration test suite (`npm run test`). The public
|
|
14
|
+
> API may still shift before 1.0.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
Not on npm yet — install straight from git. The `prepare` script builds the
|
|
21
|
+
bundle during install, so there is nothing else to wire up:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install github:studiodamiro/stylo
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
CodeMirror, Lezer, and React are **peer dependencies** — Stylo shares the host's
|
|
28
|
+
copy rather than bundling its own, so editor state, facets, and the syntax tree
|
|
29
|
+
have a single identity (see [ADR-008](docs/journal/2026-09/2026-09-04_adr-008-codemirror-peer-dependency.md)).
|
|
30
|
+
Add them alongside Stylo if they are not already in your app:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @codemirror/state @codemirror/view @codemirror/commands \
|
|
34
|
+
@codemirror/language @codemirror/lang-markdown @lezer/common @lezer/highlight
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
React 18+ is also a peer dependency. Import lines are in [Usage](#usage).
|
|
38
|
+
|
|
39
|
+
The optional `@damiro/stylo/toolbar-settings` component (an end-user toolbar
|
|
40
|
+
customizer) additionally needs `@dnd-kit/core @dnd-kit/sortable
|
|
41
|
+
@dnd-kit/utilities` — optional peers, install them only if you render it. See
|
|
42
|
+
[its reference](./docs/wiki/reference/toolbar-settings.md).
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Why
|
|
47
|
+
|
|
48
|
+
Most React "Markdown editors" are either a bare `<textarea>` with a preview pane,
|
|
49
|
+
or a full ProseMirror/Lexical rich-text stack that turns your document into an
|
|
50
|
+
in-memory model you must serialize back to Markdown — lossy for frontmatter,
|
|
51
|
+
wikilinks, and math, and hostile to files other tools also edit.
|
|
52
|
+
|
|
53
|
+
Stylo takes the Obsidian stance instead: **the Markdown string is the source of
|
|
54
|
+
truth.** The editor is a thin, composable surface over it.
|
|
55
|
+
|
|
56
|
+
## Design stance
|
|
57
|
+
|
|
58
|
+
- **Plain text is canonical.** The component's value is a Markdown string. No
|
|
59
|
+
intermediate document model.
|
|
60
|
+
- **Compose, don't adopt a framework.** CodeMirror 6 for the editing surface;
|
|
61
|
+
the unified/`remark` ecosystem + KaTeX for rendering.
|
|
62
|
+
- **Zero-bloat.** Every dependency is modular, tree-shakeable, and MIT. Nothing
|
|
63
|
+
is pulled in "just in case."
|
|
64
|
+
- **Interoperable.** YAML frontmatter, `[[wikilinks]]`, and `$…$` / `$$…$$` math
|
|
65
|
+
survive a full edit round-trip.
|
|
66
|
+
|
|
67
|
+
## Stack
|
|
68
|
+
|
|
69
|
+
| Concern | Library |
|
|
70
|
+
| ---------------- | --------------------------------------------------------------------------- |
|
|
71
|
+
| Editing surface | CodeMirror 6 (`@codemirror/lang-markdown`) |
|
|
72
|
+
| Find / replace | `@codemirror/search` — `Mod-f` on every editing surface |
|
|
73
|
+
| Render / preview | `react-markdown` + `remark-gfm` + `remark-math` + `rehype-katex` + `katex` |
|
|
74
|
+
| `[[wikilinks]]` | small custom `remark` plugin |
|
|
75
|
+
| Frontmatter | `remark-frontmatter` — fences recognised; key/value parsing deferred |
|
|
76
|
+
| Styling | CSS Modules + `--stylo-*` CSS custom properties — no Tailwind, no CSS-in-JS |
|
|
77
|
+
| Icons | inline SVG, swappable via the `icons` prop — no icon-package dependency |
|
|
78
|
+
|
|
79
|
+
Styling and icon decisions are recorded in
|
|
80
|
+
[ADR-002](./docs/journal/2026-09/2026-09-01_adr-002-editor-ux-and-customization.md);
|
|
81
|
+
the math engine and KaTeX asset delivery in
|
|
82
|
+
[ADR-003](./docs/journal/2026-09/2026-09-01_adr-003-katex-math-rendering.md).
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { Stylo, type StyloHandle } from "@damiro/stylo"
|
|
88
|
+
import "@damiro/stylo/styles.css"
|
|
89
|
+
import "@damiro/stylo/katex.css" // KaTeX stylesheet + fonts (or import "katex/dist/katex.min.css")
|
|
90
|
+
|
|
91
|
+
function Editor() {
|
|
92
|
+
const [doc, setDoc] = useState("# Hello\n\nInline math: $e^{i\\pi} + 1 = 0$")
|
|
93
|
+
const editor = useRef<StyloHandle>(null)
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Stylo
|
|
97
|
+
ref={editor}
|
|
98
|
+
value={doc}
|
|
99
|
+
onChange={setDoc}
|
|
100
|
+
mode="in-place" // default — also "source" | "preview" | "split"
|
|
101
|
+
onSave={(md) => persist(md)} // fires on Mod-s
|
|
102
|
+
onFrontmatter={(raw) => setMeta(raw)} // raw `---` block; parse it yourself
|
|
103
|
+
onWikiLinkClick={(target) => navigate(target)}
|
|
104
|
+
/>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`ref` gives an imperative handle: `focus()`, `scrollToHeading(text)`,
|
|
110
|
+
`insertAtCursor(md)`, and `getView()` for the raw CodeMirror `EditorView`.
|
|
111
|
+
|
|
112
|
+
`toolbar` trims, reorders, or extends the formatting bar — built-in command ids,
|
|
113
|
+
your own `ToolbarCustomItem` buttons, and a `render` slot to wrap it. See the
|
|
114
|
+
[toolbar reference](./docs/wiki/reference/toolbar.md).
|
|
115
|
+
|
|
116
|
+
`inPlace` and `codeLanguages` are read once, when the editing surface mounts —
|
|
117
|
+
give `<Stylo>` a `key` derived from the config to apply a change. Every other
|
|
118
|
+
prop is fully reactive. See
|
|
119
|
+
[props · applied at mount](./docs/wiki/reference/props.md#config-applied-at-mount).
|
|
120
|
+
|
|
121
|
+
Fenced code blocks render in plain monospace — no token colours — until you pass
|
|
122
|
+
`codeLanguages` with the grammars you want. Stylo bundles none by design (the
|
|
123
|
+
full grammar set is ~110 lazy chunks). See
|
|
124
|
+
[Fenced-code highlighting](./docs/wiki/reference/code-languages.md).
|
|
125
|
+
|
|
126
|
+
### Theming
|
|
127
|
+
|
|
128
|
+
Every colour is a `--stylo-*` custom property; override any of them on `.stylo`
|
|
129
|
+
or an ancestor. A dark palette ships built in and activates under a `.dark` or
|
|
130
|
+
`[data-theme="dark"]` ancestor — the `next-themes` / shadcn convention.
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm install
|
|
136
|
+
npm run dev # playground
|
|
137
|
+
npm run typecheck
|
|
138
|
+
npm run test
|
|
139
|
+
npm run build # library bundle
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT © damiro
|