@damiro/stylo 0.5.0 → 0.9.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.
Files changed (147) hide show
  1. package/README.md +42 -19
  2. package/dist/{InPlaceView-B1GXXnoz.js → InPlaceView-Bu91_3Ig.js} +1200 -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 +5 -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 +6 -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/theme.d.ts.map +1 -1
  14. package/dist/editor/useCodeMirror.d.ts +6 -2
  15. package/dist/editor/useCodeMirror.d.ts.map +1 -1
  16. package/dist/editor/wikilink-complete.d.ts +17 -0
  17. package/dist/editor/wikilink-complete.d.ts.map +1 -0
  18. package/dist/embed-B2Dfkpd_.js +124 -0
  19. package/dist/embed-B2Dfkpd_.js.map +1 -0
  20. package/dist/embed.d.ts +14 -0
  21. package/dist/embed.d.ts.map +1 -0
  22. package/dist/frontmatter-DGUkb9z-.js +39 -0
  23. package/dist/frontmatter-DGUkb9z-.js.map +1 -0
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/inplace/InPlaceView.d.ts +13 -2
  27. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  28. package/dist/inplace/config.d.ts +8 -0
  29. package/dist/inplace/config.d.ts.map +1 -1
  30. package/dist/inplace/context-menu-actions.d.ts +5 -14
  31. package/dist/inplace/context-menu-actions.d.ts.map +1 -1
  32. package/dist/inplace/context-menu-helpers.d.ts +30 -0
  33. package/dist/inplace/context-menu-helpers.d.ts.map +1 -0
  34. package/dist/inplace/context-menu-shell.d.ts +23 -0
  35. package/dist/inplace/context-menu-shell.d.ts.map +1 -0
  36. package/dist/inplace/context-menu-types.d.ts +46 -0
  37. package/dist/inplace/context-menu-types.d.ts.map +1 -0
  38. package/dist/inplace/context-menu.d.ts +2 -42
  39. package/dist/inplace/context-menu.d.ts.map +1 -1
  40. package/dist/inplace/decorate.d.ts.map +1 -1
  41. package/dist/inplace/edit-boundaries.d.ts +1 -25
  42. package/dist/inplace/edit-boundaries.d.ts.map +1 -1
  43. package/dist/inplace/edit-divider.d.ts +27 -0
  44. package/dist/inplace/edit-divider.d.ts.map +1 -0
  45. package/dist/inplace/embed-registry.d.ts +39 -0
  46. package/dist/inplace/embed-registry.d.ts.map +1 -0
  47. package/dist/inplace/embed.d.ts +8 -0
  48. package/dist/inplace/embed.d.ts.map +1 -0
  49. package/dist/inplace/extension.d.ts +6 -0
  50. package/dist/inplace/extension.d.ts.map +1 -1
  51. package/dist/inplace/inline-md.d.ts +6 -1
  52. package/dist/inplace/inline-md.d.ts.map +1 -1
  53. package/dist/inplace/link-row.d.ts +21 -0
  54. package/dist/inplace/link-row.d.ts.map +1 -0
  55. package/dist/inplace/math-edit.d.ts +36 -0
  56. package/dist/inplace/math-edit.d.ts.map +1 -0
  57. package/dist/inplace/math.d.ts +12 -0
  58. package/dist/inplace/math.d.ts.map +1 -1
  59. package/dist/inplace/menu-plugin.d.ts.map +1 -1
  60. package/dist/inplace/nodes-blocks.d.ts +14 -0
  61. package/dist/inplace/nodes-blocks.d.ts.map +1 -0
  62. package/dist/inplace/nodes-inline.d.ts +16 -0
  63. package/dist/inplace/nodes-inline.d.ts.map +1 -0
  64. package/dist/inplace/nodes.d.ts +3 -2
  65. package/dist/inplace/nodes.d.ts.map +1 -1
  66. package/dist/inplace/scan.d.ts +6 -0
  67. package/dist/inplace/scan.d.ts.map +1 -1
  68. package/dist/inplace/selection-bar-position.d.ts +31 -0
  69. package/dist/inplace/selection-bar-position.d.ts.map +1 -0
  70. package/dist/inplace/selection-bar.d.ts +0 -2
  71. package/dist/inplace/selection-bar.d.ts.map +1 -1
  72. package/dist/inplace/table-widget-caret.d.ts +11 -0
  73. package/dist/inplace/table-widget-caret.d.ts.map +1 -0
  74. package/dist/inplace/table-widget-render.d.ts +18 -0
  75. package/dist/inplace/table-widget-render.d.ts.map +1 -0
  76. package/dist/inplace/table-widget.d.ts +5 -2
  77. package/dist/inplace/table-widget.d.ts.map +1 -1
  78. package/dist/inplace/tables.d.ts.map +1 -1
  79. package/dist/inplace/theme-callout.d.ts +50 -0
  80. package/dist/inplace/theme-callout.d.ts.map +1 -0
  81. package/dist/inplace/theme-canvas.d.ts +166 -0
  82. package/dist/inplace/theme-canvas.d.ts.map +1 -0
  83. package/dist/inplace/theme-fonts.d.ts +4 -0
  84. package/dist/inplace/theme-fonts.d.ts.map +1 -0
  85. package/dist/inplace/theme-menu.d.ts +87 -0
  86. package/dist/inplace/theme-menu.d.ts.map +1 -0
  87. package/dist/inplace/theme-popups.d.ts +94 -0
  88. package/dist/inplace/theme-popups.d.ts.map +1 -0
  89. package/dist/inplace/theme-table-gizmos.d.ts +57 -0
  90. package/dist/inplace/theme-table-gizmos.d.ts.map +1 -0
  91. package/dist/inplace/theme-table.d.ts +30 -0
  92. package/dist/inplace/theme-table.d.ts.map +1 -0
  93. package/dist/inplace/theme.d.ts +5 -0
  94. package/dist/inplace/theme.d.ts.map +1 -1
  95. package/dist/inplace/wikilinks.d.ts.map +1 -1
  96. package/dist/inplace/wrap-at.d.ts +32 -0
  97. package/dist/inplace/wrap-at.d.ts.map +1 -0
  98. package/dist/{markdown-N3lRmU2n.js → markdown-BYXs9Tj8.js} +2 -2
  99. package/dist/{markdown-N3lRmU2n.js.map → markdown-BYXs9Tj8.js.map} +1 -1
  100. package/dist/render/Embed.d.ts +24 -0
  101. package/dist/render/Embed.d.ts.map +1 -0
  102. package/dist/render/Preview.d.ts +6 -2
  103. package/dist/render/Preview.d.ts.map +1 -1
  104. package/dist/render/embed-cache.d.ts +10 -0
  105. package/dist/render/embed-cache.d.ts.map +1 -0
  106. package/dist/render/remark-embed.d.ts +19 -0
  107. package/dist/render/remark-embed.d.ts.map +1 -0
  108. package/dist/styles.css +1 -1
  109. package/dist/stylo.js +75 -54
  110. package/dist/stylo.js.map +1 -1
  111. package/dist/toolbar/block.d.ts +0 -26
  112. package/dist/toolbar/block.d.ts.map +1 -1
  113. package/dist/toolbar/command-helpers.d.ts +57 -0
  114. package/dist/toolbar/command-helpers.d.ts.map +1 -0
  115. package/dist/toolbar/commands.d.ts +1 -21
  116. package/dist/toolbar/commands.d.ts.map +1 -1
  117. package/dist/toolbar/frontmatter-toggle.d.ts +13 -0
  118. package/dist/toolbar/frontmatter-toggle.d.ts.map +1 -0
  119. package/dist/toolbar/heading.d.ts +10 -0
  120. package/dist/toolbar/heading.d.ts.map +1 -0
  121. package/dist/toolbar/inline-ops.d.ts +3 -53
  122. package/dist/toolbar/inline-ops.d.ts.map +1 -1
  123. package/dist/toolbar/link-ops.d.ts +22 -0
  124. package/dist/toolbar/link-ops.d.ts.map +1 -0
  125. package/dist/toolbar/rule.d.ts +11 -0
  126. package/dist/toolbar/rule.d.ts.map +1 -0
  127. package/dist/toolbar/table-position.d.ts +32 -0
  128. package/dist/toolbar/table-position.d.ts.map +1 -0
  129. package/dist/toolbar/table.d.ts +1 -16
  130. package/dist/toolbar/table.d.ts.map +1 -1
  131. package/dist/toolbar/underline-ops.d.ts +15 -0
  132. package/dist/toolbar/underline-ops.d.ts.map +1 -0
  133. package/dist/toolbar/wikilink-ops.d.ts +22 -0
  134. package/dist/toolbar/wikilink-ops.d.ts.map +1 -0
  135. package/dist/types.d.ts +73 -0
  136. package/dist/types.d.ts.map +1 -1
  137. package/dist/{useCodeMirror-hLeJQw6e.js → useCodeMirror-DtwupFgc.js} +590 -526
  138. package/dist/useCodeMirror-DtwupFgc.js.map +1 -0
  139. package/package.json +5 -1
  140. package/dist/InPlaceView-B1GXXnoz.js.map +0 -1
  141. package/dist/Preview-Dxb9zPVv.js +0 -93
  142. package/dist/Preview-Dxb9zPVv.js.map +0 -1
  143. package/dist/callout-oLE630ZP.js +0 -37
  144. package/dist/callout-oLE630ZP.js.map +0 -1
  145. package/dist/useCodeMirror-hLeJQw6e.js.map +0 -1
  146. package/dist/wikilink-BFpTehto.js +0 -42
  147. package/dist/wikilink-BFpTehto.js.map +0 -1
package/README.md CHANGED
@@ -26,7 +26,11 @@ built in.
26
26
  - **First-class math** — `$…$` and `$$…$$` rendered with KaTeX, live in the
27
27
  canvas and in preview.
28
28
  - **`[[wikilinks]]`** — recognised, styled, and clickable, with an
29
- `onWikiLinkClick` callback.
29
+ `onWikiLinkClick` callback and opt-in `[[` autocomplete from an index you
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.
30
34
  - **Interactive tables** — edit a rendered table cell by cell in the in-place
31
35
  canvas, with row / column controls; or keep plain source pipes.
32
36
  - **Callouts** — `> [!note]` blockquotes render as tinted admonition blocks
@@ -70,7 +74,11 @@ npm install @codemirror/state @codemirror/view @codemirror/commands \
70
74
  @codemirror/language @codemirror/lang-markdown @lezer/common @lezer/highlight
71
75
  ```
72
76
 
73
- 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).
74
82
 
75
83
  The optional `@damiro/stylo/toolbar-settings` component (an end-user toolbar
76
84
  customizer) additionally needs `@dnd-kit/core @dnd-kit/sortable
@@ -102,15 +110,16 @@ truth.** The editor is a thin, composable surface over it.
102
110
 
103
111
  ## Stack
104
112
 
105
- | Concern | Library |
106
- | ---------------- | --------------------------------------------------------------------------- |
107
- | Editing surface | CodeMirror 6 (`@codemirror/lang-markdown`) |
108
- | Find / replace | `@codemirror/search` — `Mod-f` on every editing surface |
109
- | Render / preview | `react-markdown` + `remark-gfm` + `remark-math` + `rehype-katex` + `katex` |
110
- | `[[wikilinks]]` | small custom `remark` plugin |
111
- | Frontmatter | `remark-frontmatter` — fences recognised; key/value parsing deferred |
112
- | Styling | CSS Modules + `--stylo-*` CSS custom properties — no Tailwind, no CSS-in-JS |
113
- | Icons | inline SVG, swappable via the `icons` prop — no icon-package dependency |
113
+ | Concern | Library |
114
+ | ---------------- | -------------------------------------------------------------------------------------------- |
115
+ | Editing surface | CodeMirror 6 (`@codemirror/lang-markdown`) |
116
+ | Find / replace | `@codemirror/search` — `Mod-f` on every editing surface |
117
+ | Render / preview | `react-markdown` + `remark-gfm` + `remark-math` + `rehype-katex` + `katex` |
118
+ | `[[wikilinks]]` | small custom `remark` plugin |
119
+ | `![[embeds]]` | `remark` plugin (preview) + `EmbedWidget` portal registry (in-place), one host `embedSource` |
120
+ | Frontmatter | `remark-frontmatter` — fences recognised; key/value parsing deferred |
121
+ | Styling | CSS Modules + `--stylo-*` CSS custom properties — no Tailwind, no CSS-in-JS |
122
+ | Icons | inline SVG, swappable via the `icons` prop — no icon-package dependency |
114
123
 
115
124
  Styling and icon decisions are recorded in
116
125
  [ADR-002](./docs/journal/2026-09/2026-09-01_adr-002-editor-ux-and-customization.md);
@@ -149,11 +158,21 @@ function Editor() {
149
158
  your own `ToolbarCustomItem` buttons, and a `render` slot to wrap it. See the
150
159
  [toolbar reference](./docs/wiki/reference/toolbar.md).
151
160
 
152
- `inPlace` and `codeLanguages` are read once, when the editing surface mounts —
153
- give `<Stylo>` a `key` derived from the config to apply a change. Every other
154
- prop is fully reactive. See
161
+ `inPlace`, `codeLanguages`, and `wikiLinkSource` are read once, when the editing
162
+ surface mounts — give `<Stylo>` a `key` derived from the config to apply a
163
+ change. Every other prop is fully reactive. See
155
164
  [props · applied at mount](./docs/wiki/reference/props.md#config-applied-at-mount).
156
165
 
166
+ Pass `wikiLinkSource` — `(query) => { target, label? }[]`, sync or async — to
167
+ turn on `[[wikilink]]` autocomplete backed by your own index. See
168
+ [Wikilink autocomplete](./docs/wiki/reference/props.md#wikilink-autocomplete).
169
+
170
+ Pass `embedSource` — `(ref) => ReactNode`, sync or async — to resolve
171
+ `![[embed]]` transclusion on every rendered surface, the in-place canvas
172
+ included. Stylo detects the `![[…]]` (when it is alone on its line) and renders
173
+ whatever you return; on the canvas the caret reveals the raw source. See
174
+ [Embeds](./docs/wiki/reference/props.md#embeds).
175
+
157
176
  Fenced code blocks render in plain monospace — no token colours — until you pass
158
177
  `codeLanguages` with the grammars you want. Stylo bundles none by design (the
159
178
  full grammar set is ~110 lazy chunks). See
@@ -164,8 +183,9 @@ full grammar set is ~110 lazy chunks). See
164
183
  Every colour is a `--stylo-*` custom property; override any of them on `.stylo`
165
184
  or an ancestor. A dark palette ships built in and activates under a `.dark` or
166
185
  `[data-theme="dark"]` ancestor — the `next-themes` / shadcn convention.
167
- `--stylo-font-size` (default `0.9375rem`) sets the base editor size; everything
168
- inside scales from it.
186
+ `--stylo-font-size` (default `0.9375rem`) sets the base editor size and
187
+ everything inside scales from it; `--stylo-font-family` and
188
+ `--stylo-font-family-mono` set the prose and code fonts.
169
189
 
170
190
  ---
171
191
 
@@ -208,12 +228,15 @@ Engineering journal and Architectural Decision Records:
208
228
 
209
229
  ```bash
210
230
  npm install
211
- npm run dev # playground
231
+ npm run dev # playground
212
232
  npm run typecheck
213
- npm run test
214
- npm run build # library bundle
233
+ npm run test # unit suite (Vitest + jsdom)
234
+ npm run test:browser # in-place canvas in real Chromium (Playwright)
235
+ npm run build # library bundle
215
236
  ```
216
237
 
238
+ `npm run test:browser` needs the browser once: `npx playwright install chromium`.
239
+
217
240
  ## License
218
241
 
219
242
  MIT © damiro