@damiro/stylo 0.7.0 → 0.9.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.
Files changed (146) hide show
  1. package/README.md +41 -14
  2. package/dist/{InPlaceView-CS1qy-Ba.js → InPlaceView-Bu91_3Ig.js} +1199 -855
  3. package/dist/InPlaceView-Bu91_3Ig.js.map +1 -0
  4. package/dist/Preview-AaGGwLQP.js +170 -0
  5. package/dist/Preview-AaGGwLQP.js.map +1 -0
  6. package/dist/SplitView.d.ts +4 -2
  7. package/dist/SplitView.d.ts.map +1 -1
  8. package/dist/Stylo.d.ts.map +1 -1
  9. package/dist/editor/SourceView.d.ts +4 -2
  10. package/dist/editor/SourceView.d.ts.map +1 -1
  11. package/dist/editor/extensions.d.ts +2 -2
  12. package/dist/editor/extensions.d.ts.map +1 -1
  13. package/dist/editor/useCodeMirror.d.ts +4 -2
  14. package/dist/editor/useCodeMirror.d.ts.map +1 -1
  15. package/dist/editor/wikilink-complete.d.ts +5 -3
  16. package/dist/editor/wikilink-complete.d.ts.map +1 -1
  17. package/dist/embed-B2Dfkpd_.js +124 -0
  18. package/dist/embed-B2Dfkpd_.js.map +1 -0
  19. package/dist/embed.d.ts +14 -0
  20. package/dist/embed.d.ts.map +1 -0
  21. package/dist/frontmatter-DGUkb9z-.js +39 -0
  22. package/dist/frontmatter-DGUkb9z-.js.map +1 -0
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/inplace/InPlaceView.d.ts +11 -2
  26. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  27. package/dist/inplace/config.d.ts +8 -0
  28. package/dist/inplace/config.d.ts.map +1 -1
  29. package/dist/inplace/context-menu-actions.d.ts +5 -14
  30. package/dist/inplace/context-menu-actions.d.ts.map +1 -1
  31. package/dist/inplace/context-menu-helpers.d.ts +30 -0
  32. package/dist/inplace/context-menu-helpers.d.ts.map +1 -0
  33. package/dist/inplace/context-menu-shell.d.ts +23 -0
  34. package/dist/inplace/context-menu-shell.d.ts.map +1 -0
  35. package/dist/inplace/context-menu-types.d.ts +46 -0
  36. package/dist/inplace/context-menu-types.d.ts.map +1 -0
  37. package/dist/inplace/context-menu.d.ts +2 -42
  38. package/dist/inplace/context-menu.d.ts.map +1 -1
  39. package/dist/inplace/decorate.d.ts.map +1 -1
  40. package/dist/inplace/edit-boundaries.d.ts +1 -25
  41. package/dist/inplace/edit-boundaries.d.ts.map +1 -1
  42. package/dist/inplace/edit-divider.d.ts +27 -0
  43. package/dist/inplace/edit-divider.d.ts.map +1 -0
  44. package/dist/inplace/embed-registry.d.ts +39 -0
  45. package/dist/inplace/embed-registry.d.ts.map +1 -0
  46. package/dist/inplace/embed.d.ts +8 -0
  47. package/dist/inplace/embed.d.ts.map +1 -0
  48. package/dist/inplace/extension.d.ts +6 -0
  49. package/dist/inplace/extension.d.ts.map +1 -1
  50. package/dist/inplace/inline-md.d.ts +6 -1
  51. package/dist/inplace/inline-md.d.ts.map +1 -1
  52. package/dist/inplace/link-row.d.ts +21 -0
  53. package/dist/inplace/link-row.d.ts.map +1 -0
  54. package/dist/inplace/math-edit.d.ts +36 -0
  55. package/dist/inplace/math-edit.d.ts.map +1 -0
  56. package/dist/inplace/math.d.ts +12 -0
  57. package/dist/inplace/math.d.ts.map +1 -1
  58. package/dist/inplace/menu-plugin.d.ts.map +1 -1
  59. package/dist/inplace/nodes-blocks.d.ts +14 -0
  60. package/dist/inplace/nodes-blocks.d.ts.map +1 -0
  61. package/dist/inplace/nodes-inline.d.ts +16 -0
  62. package/dist/inplace/nodes-inline.d.ts.map +1 -0
  63. package/dist/inplace/nodes.d.ts +3 -2
  64. package/dist/inplace/nodes.d.ts.map +1 -1
  65. package/dist/inplace/scan.d.ts +6 -0
  66. package/dist/inplace/scan.d.ts.map +1 -1
  67. package/dist/inplace/selection-bar-position.d.ts +31 -0
  68. package/dist/inplace/selection-bar-position.d.ts.map +1 -0
  69. package/dist/inplace/selection-bar.d.ts +0 -2
  70. package/dist/inplace/selection-bar.d.ts.map +1 -1
  71. package/dist/inplace/table-widget-caret.d.ts +11 -0
  72. package/dist/inplace/table-widget-caret.d.ts.map +1 -0
  73. package/dist/inplace/table-widget-render.d.ts +18 -0
  74. package/dist/inplace/table-widget-render.d.ts.map +1 -0
  75. package/dist/inplace/table-widget.d.ts +5 -2
  76. package/dist/inplace/table-widget.d.ts.map +1 -1
  77. package/dist/inplace/tables.d.ts.map +1 -1
  78. package/dist/inplace/theme-callout.d.ts +50 -0
  79. package/dist/inplace/theme-callout.d.ts.map +1 -0
  80. package/dist/inplace/theme-canvas.d.ts +166 -0
  81. package/dist/inplace/theme-canvas.d.ts.map +1 -0
  82. package/dist/inplace/theme-fonts.d.ts +4 -0
  83. package/dist/inplace/theme-fonts.d.ts.map +1 -0
  84. package/dist/inplace/theme-menu.d.ts +87 -0
  85. package/dist/inplace/theme-menu.d.ts.map +1 -0
  86. package/dist/inplace/theme-popups.d.ts +94 -0
  87. package/dist/inplace/theme-popups.d.ts.map +1 -0
  88. package/dist/inplace/theme-table-gizmos.d.ts +57 -0
  89. package/dist/inplace/theme-table-gizmos.d.ts.map +1 -0
  90. package/dist/inplace/theme-table.d.ts +30 -0
  91. package/dist/inplace/theme-table.d.ts.map +1 -0
  92. package/dist/inplace/theme.d.ts +5 -0
  93. package/dist/inplace/theme.d.ts.map +1 -1
  94. package/dist/inplace/wikilinks.d.ts.map +1 -1
  95. package/dist/inplace/wrap-at.d.ts +32 -0
  96. package/dist/inplace/wrap-at.d.ts.map +1 -0
  97. package/dist/{markdown-N3lRmU2n.js → markdown-BYXs9Tj8.js} +2 -2
  98. package/dist/{markdown-N3lRmU2n.js.map → markdown-BYXs9Tj8.js.map} +1 -1
  99. package/dist/render/Embed.d.ts +24 -0
  100. package/dist/render/Embed.d.ts.map +1 -0
  101. package/dist/render/Preview.d.ts +6 -2
  102. package/dist/render/Preview.d.ts.map +1 -1
  103. package/dist/render/embed-cache.d.ts +10 -0
  104. package/dist/render/embed-cache.d.ts.map +1 -0
  105. package/dist/render/remark-embed.d.ts +19 -0
  106. package/dist/render/remark-embed.d.ts.map +1 -0
  107. package/dist/styles.css +1 -1
  108. package/dist/stylo.js +70 -54
  109. package/dist/stylo.js.map +1 -1
  110. package/dist/toolbar/block.d.ts +0 -26
  111. package/dist/toolbar/block.d.ts.map +1 -1
  112. package/dist/toolbar/command-helpers.d.ts +57 -0
  113. package/dist/toolbar/command-helpers.d.ts.map +1 -0
  114. package/dist/toolbar/commands.d.ts +1 -21
  115. package/dist/toolbar/commands.d.ts.map +1 -1
  116. package/dist/toolbar/frontmatter-toggle.d.ts +13 -0
  117. package/dist/toolbar/frontmatter-toggle.d.ts.map +1 -0
  118. package/dist/toolbar/heading.d.ts +10 -0
  119. package/dist/toolbar/heading.d.ts.map +1 -0
  120. package/dist/toolbar/inline-ops.d.ts +3 -53
  121. package/dist/toolbar/inline-ops.d.ts.map +1 -1
  122. package/dist/toolbar/link-ops.d.ts +22 -0
  123. package/dist/toolbar/link-ops.d.ts.map +1 -0
  124. package/dist/toolbar/rule.d.ts +11 -0
  125. package/dist/toolbar/rule.d.ts.map +1 -0
  126. package/dist/toolbar/table-position.d.ts +32 -0
  127. package/dist/toolbar/table-position.d.ts.map +1 -0
  128. package/dist/toolbar/table.d.ts +1 -16
  129. package/dist/toolbar/table.d.ts.map +1 -1
  130. package/dist/toolbar/underline-ops.d.ts +15 -0
  131. package/dist/toolbar/underline-ops.d.ts.map +1 -0
  132. package/dist/toolbar/wikilink-ops.d.ts +22 -0
  133. package/dist/toolbar/wikilink-ops.d.ts.map +1 -0
  134. package/dist/types.d.ts +48 -0
  135. package/dist/types.d.ts.map +1 -1
  136. package/dist/{useCodeMirror-GPSkaYW6.js → useCodeMirror-DtwupFgc.js} +559 -531
  137. package/dist/useCodeMirror-DtwupFgc.js.map +1 -0
  138. package/package.json +2 -1
  139. package/dist/InPlaceView-CS1qy-Ba.js.map +0 -1
  140. package/dist/Preview-Bw0k3Mev.js +0 -93
  141. package/dist/Preview-Bw0k3Mev.js.map +0 -1
  142. package/dist/callout-oLE630ZP.js +0 -37
  143. package/dist/callout-oLE630ZP.js.map +0 -1
  144. package/dist/useCodeMirror-GPSkaYW6.js.map +0 -1
  145. package/dist/wikilink-CTR8IFKc.js +0 -42
  146. package/dist/wikilink-CTR8IFKc.js.map +0 -1
package/README.md CHANGED
@@ -28,6 +28,9 @@ built in.
28
28
  - **`[[wikilinks]]`** — recognised, styled, and clickable, with an
29
29
  `onWikiLinkClick` callback and opt-in `[[` autocomplete from an index you
30
30
  supply (`wikiLinkSource`).
31
+ - **`![[embed]]` transclusion** — opt-in on every rendered surface (`preview`,
32
+ `split`, and the in-place canvas): pass `embedSource` and Stylo hands you the
33
+ reference, you return the node to render in its place.
31
34
  - **Interactive tables** — edit a rendered table cell by cell in the in-place
32
35
  canvas, with row / column controls; or keep plain source pipes.
33
36
  - **Callouts** — `> [!note]` blockquotes render as tinted admonition blocks
@@ -71,7 +74,11 @@ npm install @codemirror/state @codemirror/view @codemirror/commands \
71
74
  @codemirror/language @codemirror/lang-markdown @lezer/common @lezer/highlight
72
75
  ```
73
76
 
74
- React 18+ is also a peer dependency. Import lines are in [Usage](#usage).
77
+ React 18 or 19 is also a peer dependency (`react` + `react-dom`). Stylo ships
78
+ **ES modules only** — there is no CommonJS build — so it needs a bundler (Vite,
79
+ Next.js, …) or a native-ESM runtime. Stylesheet imports are in [Usage](#usage);
80
+ the full setup checklist is in the
81
+ [integration guide](./docs/wiki/guides/integration.md#requirements).
75
82
 
76
83
  The optional `@damiro/stylo/toolbar-settings` component (an end-user toolbar
77
84
  customizer) additionally needs `@dnd-kit/core @dnd-kit/sortable
@@ -82,10 +89,23 @@ customizer) additionally needs `@dnd-kit/core @dnd-kit/sortable
82
89
 
83
90
  ## Why
84
91
 
85
- Most React "Markdown editors" are either a bare `<textarea>` with a preview pane,
86
- or a full ProseMirror/Lexical rich-text stack that turns your document into an
87
- in-memory model you must serialize back to Markdown — lossy for frontmatter,
88
- wikilinks, and math, and hostile to files other tools also edit.
92
+ Round-trip fidelity — plain Markdown in, the same plain Markdown out — rules out
93
+ most of the field before features even enter it:
94
+
95
+ - **TipTap, Milkdown, BlockNote** (all ProseMirror) and **Lexical** keep their
96
+ own document tree as the source of truth and serialize to Markdown on save —
97
+ exactly where frontmatter, `[[wikilinks]]` (not standard Markdown; needs a
98
+ custom node type), and math risk silently mangling on a round-trip.
99
+ **Toast UI Editor** is the same shape under different branding, and
100
+ considerably less themeable.
101
+ - **EasyMDE / SimpleMDE** get the one axis that matters most right — genuinely
102
+ canonical Markdown in and out — but on CodeMirror 5, with no in-place live
103
+ rendering (raw source or a separate preview pane, not an Obsidian-style
104
+ live-preview feel), no wikilinks, no embeds, no frontmatter handling.
105
+ Adopting one means rebuilding most of what Stylo already does.
106
+ - **Raw CodeMirror 6, no wrapper** is what's left after ruling those out — and
107
+ building the decoration canvas, the wikilink/embed/frontmatter layer, and a
108
+ theming contract from scratch is the reinvention Stylo exists to avoid.
89
109
 
90
110
  Stylo takes the Obsidian stance instead: **the Markdown string is the source of
91
111
  truth.** The editor is a thin, composable surface over it.
@@ -103,15 +123,16 @@ truth.** The editor is a thin, composable surface over it.
103
123
 
104
124
  ## Stack
105
125
 
106
- | Concern | Library |
107
- | ---------------- | --------------------------------------------------------------------------- |
108
- | Editing surface | CodeMirror 6 (`@codemirror/lang-markdown`) |
109
- | Find / replace | `@codemirror/search` — `Mod-f` on every editing surface |
110
- | Render / preview | `react-markdown` + `remark-gfm` + `remark-math` + `rehype-katex` + `katex` |
111
- | `[[wikilinks]]` | small custom `remark` plugin |
112
- | Frontmatter | `remark-frontmatter` — fences recognised; key/value parsing deferred |
113
- | Styling | CSS Modules + `--stylo-*` CSS custom properties — no Tailwind, no CSS-in-JS |
114
- | Icons | inline SVG, swappable via the `icons` prop — no icon-package dependency |
126
+ | Concern | Library |
127
+ | ---------------- | -------------------------------------------------------------------------------------------- |
128
+ | Editing surface | CodeMirror 6 (`@codemirror/lang-markdown`) |
129
+ | Find / replace | `@codemirror/search` — `Mod-f` on every editing surface |
130
+ | Render / preview | `react-markdown` + `remark-gfm` + `remark-math` + `rehype-katex` + `katex` |
131
+ | `[[wikilinks]]` | small custom `remark` plugin |
132
+ | `![[embeds]]` | `remark` plugin (preview) + `EmbedWidget` portal registry (in-place), one host `embedSource` |
133
+ | Frontmatter | `remark-frontmatter` — fences recognised; key/value parsing deferred |
134
+ | Styling | CSS Modules + `--stylo-*` CSS custom properties — no Tailwind, no CSS-in-JS |
135
+ | Icons | inline SVG, swappable via the `icons` prop — no icon-package dependency |
115
136
 
116
137
  Styling and icon decisions are recorded in
117
138
  [ADR-002](./docs/journal/2026-09/2026-09-01_adr-002-editor-ux-and-customization.md);
@@ -159,6 +180,12 @@ Pass `wikiLinkSource` — `(query) => { target, label? }[]`, sync or async — t
159
180
  turn on `[[wikilink]]` autocomplete backed by your own index. See
160
181
  [Wikilink autocomplete](./docs/wiki/reference/props.md#wikilink-autocomplete).
161
182
 
183
+ Pass `embedSource` — `(ref) => ReactNode`, sync or async — to resolve
184
+ `![[embed]]` transclusion on every rendered surface, the in-place canvas
185
+ included. Stylo detects the `![[…]]` (when it is alone on its line) and renders
186
+ whatever you return; on the canvas the caret reveals the raw source. See
187
+ [Embeds](./docs/wiki/reference/props.md#embeds).
188
+
162
189
  Fenced code blocks render in plain monospace — no token colours — until you pass
163
190
  `codeLanguages` with the grammars you want. Stylo bundles none by design (the
164
191
  full grammar set is ~110 lazy chunks). See