slidev-theme-kotlin 0.11.0 → 0.12.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 (34) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +87 -10
  3. package/annotation-editor.d.ts +2 -0
  4. package/annotation-editor.mjs +5 -0
  5. package/assets/edit-3-svgrepo-com.svg +5 -0
  6. package/components/DrawnAnnotation.vue +1106 -456
  7. package/components/DrawnAnnotationEditorLauncher.vue +50 -0
  8. package/components/DrawnAnnotationEditorToolbar.vue +264 -0
  9. package/components/InlineCompilerError.vue +57 -67
  10. package/components/Kodee.vue +60 -77
  11. package/components/KodeeWrapper.vue +11 -27
  12. package/components/MagicMoveBetween.vue +276 -0
  13. package/components/README.md +126 -46
  14. package/components/annotation-label-markdown.test.ts +22 -0
  15. package/components/annotation-label-markdown.ts +34 -0
  16. package/components/code-text-match.ts +78 -0
  17. package/components/drawn-annotation/editor-store.test.ts +141 -0
  18. package/components/drawn-annotation/editor-store.ts +137 -0
  19. package/components/drawn-annotation/geometry.test.ts +88 -0
  20. package/components/drawn-annotation/geometry.ts +239 -0
  21. package/components/drawn-annotation/writer-client.ts +81 -0
  22. package/components/kodee-props.ts +16 -0
  23. package/global-top.vue +26 -0
  24. package/package.json +22 -5
  25. package/plugins/drawn-annotation-editor.d.ts +30 -0
  26. package/plugins/drawn-annotation-editor.mjs +391 -0
  27. package/plugins/drawn-annotation-editor.test.ts +386 -0
  28. package/setup/code-window-icon.ts +4 -0
  29. package/setup/magic-move-between.ts +191 -0
  30. package/setup/preparser.ts +24 -0
  31. package/setup/transformers.ts +190 -2
  32. package/styles/fonts.css +59 -0
  33. package/styles/index.ts +2 -0
  34. package/styles/layout.css +56 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.12.0
6
+
7
+ ### Added
8
+
9
+ - Support Magic Move between slides: a `magic-move` separator (or `magicMove: true` frontmatter) links consecutive slides, and their top-level code fences morph across the slide boundary in both navigation directions. Code windows pair up by position, so parallel snippets (for example Kotlin next to SQL) animate independently, and decks using `transition: view-transition` pair the code windows through the View Transitions API instead of cross-fading them.
10
+ - Support per-click line highlighting (`{1|2-3}`) and fence options (`{lines:true, at:2}`) on chained fences: the ranges register as clicks on their slide and step through before navigation moves on, matching classic Magic Move behaviour.
11
+ - Add a development-only visual annotation editor: `drawnAnnotationEditor()` (exported as `slidev-theme-kotlin/annotation-editor`) injects transient source locators while serving, and persists dragged label, width, and connector geometry as a normalized `:geometry` binding on exactly the edited `DrawnAnnotation` tag — with keyboard nudging, undo, revision-conflict detection, and reset controls. Builds and exports carry no editor code.
12
+ - Add the `geometry` prop to `DrawnAnnotation`: normalized source-local label and connector geometry, including quadratic Bézier connectors, that overrides automatic placement.
13
+ - Add `DrawnAnnotation`'s passive mode for observing a click already owned by nearby `v-click` / `v-clicks` content without registering an extra click step.
14
+ - Add JDBC and R2DBC identity badges and border colours for Kotlin code fences with the `jdbc` and `r2dbc` modifiers.
15
+
16
+ ### Changed
17
+
18
+ - Make automatic `DrawnAnnotation` label placement deterministic: candidates prefer the requested side and stay clear of the slide's laid-out content (including still-hidden v-click content, so a label never sits where the slide is about to grow), of the annotation's own mark, of labels placed by earlier annotations, and of `avoid-selector` matches (kept at `clearance` distance), wrapping into free space when needed.
19
+ - **Breaking**: replace `DrawnAnnotation`'s `label-x` / `label-y` / `label-width` props with the normalized `geometry.label` binding.
20
+ - **Breaking**: a `DrawnAnnotation` without `at`/`on` is now part of the initial slide state instead of taking the next automatic click; give `at` or `on` for a reveal.
21
+ - Render `DrawnAnnotation` labels as safe Markdown; inline code and block quotes use the theme's local-first JetBrains Mono stack.
22
+
23
+ ### Fixed
24
+
25
+ - Persist curved-connector edits: the source writer no longer rejects the `type: 'quadratic'` connector shape its own serializer emits.
26
+ - Ship `slidev-theme-kotlin/annotation-editor` as plain JavaScript with type declarations, so a consuming deck's `vite.config.ts` can load it under Node instead of failing on raw TypeScript inside node_modules.
27
+ - Keep a save conflict recoverable: after a 409 the write client no longer adopts the other author's revision, so a continuing drag cannot silently overwrite their edit.
28
+ - Persist a width-only first edit by materializing the label's current position, instead of silently dropping the width while reporting "Annotation saved".
29
+ - Translate a quadratic connector's control point with arrow-key body nudges, matching pointer body drags instead of distorting the saved curve.
30
+ - Match the Alt+Shift+A editor shortcut by physical key so it works on macOS, where Option+Shift+A composes "Å".
31
+ - Escape quotes in cross-slide Magic Move fence titles and options, so titles like `[Bob's file.kt]` and options like `{at:"+2"}` no longer break the slide markup.
32
+ - Morph cross-slide Magic Move from the correct step when a chain slide contributes no fence at a position, and give duplicate identical fences on one slide their own animation identity.
33
+ - Decode annotation source locators as UTF-8 in the browser, so decks with non-ASCII filenames can save geometry.
34
+ - Do not apply the code-chip background to inline Markdown code in `DrawnAnnotation` labels.
35
+
3
36
  ## 0.11.0
4
37
 
5
38
  ### Added
package/README.md CHANGED
@@ -8,16 +8,17 @@ This theme provides a professional presentation template tailored for Kotlin dev
8
8
 
9
9
  - **Kodee Mascot Integration**: Animated Kodee character with multiple variants (greeting, wink, wave, jumping, sitting, drinking, heart, in-love, welcome, winter, tiny)
10
10
  - **Magic Move Animations**: Smooth transitions for Kodee between slides with configurable size and position
11
+ - **Magic Move between slides**: Link slides with a `magic-move` separator and their code windows morph across the slide boundary, including several parallel snippets per slide
11
12
  - **Kotlin Syntax Highlighting**: Custom Shiki configuration optimized for Kotlin code
12
13
  - **Multiple Layouts**: Pre-built layouts including default, cover, and intro
13
14
  - **Kotlin Branding**: Official Kotlin logos for both light and dark modes
14
- - **JetBrains Fonts**: Uses Inter for sans-serif and JetBrains Mono for code
15
+ - **JetBrains Fonts**: Prefers locally installed JetBrains Sans and JetBrains Mono, with Inter and Google-hosted JetBrains Mono fallbacks
15
16
  - **Drawn annotations**: Click-aware, hand-drawn marks, labels, and connectors for elements and code
16
17
  - **Inline compiler diagnostics**: IntelliJ-style squiggles and messages for static and Magic Move code blocks
17
18
 
18
19
  ## Requirements
19
20
 
20
- - **Node.js**: >= 18.0.0
21
+ - **Node.js**: >= 20.12.0
21
22
  - **Package Manager**: npm (or pnpm with shamefully-hoist=true)
22
23
 
23
24
  ## Installation
@@ -30,6 +31,29 @@ npm install slidev-theme-kotlin
30
31
 
31
32
  ## Usage
32
33
 
34
+ ### Visual annotation editor (development)
35
+
36
+ Enable the optional, development-only source writer in the consuming deck's
37
+ `vite.config.ts`:
38
+
39
+ ```ts
40
+ import { defineConfig } from 'vite'
41
+ import { drawnAnnotationEditor } from 'slidev-theme-kotlin/annotation-editor'
42
+
43
+ export default defineConfig({
44
+ plugins: [drawnAnnotationEditor()],
45
+ })
46
+ ```
47
+
48
+ Open Slidev's annotation editor (or press **Alt+Shift+A**) and drag a visible
49
+ label, its width handle, or a connector control. The editor persists normalized
50
+ `:geometry` on exactly that `DrawnAnnotation` tag. **Cmd/Ctrl+Z** undoes a
51
+ saved edit; reset controls restore label, connector, or all geometry. Source
52
+ revisions are checked, so a conflict preserves the local draft until **Reload
53
+ saved geometry** is chosen. The locator, toolbar, and write endpoint exist only
54
+ while Vite serves the deck; builds and exports render saved geometry without
55
+ editor code.
56
+
33
57
  ### Basic Setup
34
58
 
35
59
  Add the theme to your slides' frontmatter:
@@ -71,10 +95,11 @@ SELECT * FROM presentations;
71
95
  ```
72
96
  ````
73
97
 
74
- `kotlin`, `kt`, and `kts` use the Kotlin icon; each with a `gradle` modifier
75
- uses the Gradle icon. `yaml toolchain`, `java`, `bash`, `xml maven`, and `sql` use the
76
- Amper, Java, Terminal, Maven, and PostgreSQL icons respectively. All other fences
77
- remain plain code surfaces.
98
+ `kotlin`, `kt`, and `kts` use the Kotlin icon; each with a `gradle`, `jdbc`,
99
+ or `r2dbc` modifier uses the Gradle, JDBC, or R2DBC identity respectively.
100
+ `yaml toolchain`, `java`, `bash`, `xml maven`, and `sql` use the Amper, Java,
101
+ Terminal, Maven, and PostgreSQL icons respectively. All other fences remain plain
102
+ code surfaces.
78
103
 
79
104
  The identity border colours are exposed as theme variables and can be
80
105
  customized from a deck stylesheet. Each variable has a light and dark-mode
@@ -89,6 +114,8 @@ value:
89
114
  --code-window-terminal-color: #6c707e;
90
115
  --code-window-maven-color: #3574f0;
91
116
  --code-window-postgresql-color: #336791;
117
+ --code-window-jdbc-color: #f59e0b;
118
+ --code-window-r2dbc-color: #06b6d4;
92
119
  }
93
120
 
94
121
  html.dark {
@@ -114,6 +141,55 @@ layout with different horizontal spacing can override
114
141
  `--code-window-inline-space`. To bypass column-based sizing entirely, set an
115
142
  explicit `--code-window-font-size`, for example `1.25rem`.
116
143
 
144
+ ### Magic Move between slides
145
+
146
+ Slidev's classic Magic Move animates code inside one slide, on clicks. This
147
+ theme additionally supports morphing code **across slides**: put `magic-move`
148
+ in the separator between two slides and their code windows animate from one to
149
+ the next when you navigate.
150
+
151
+ ````md
152
+ # My Slide
153
+
154
+ ```kotlin
155
+ class Person
156
+ ```
157
+
158
+ ---
159
+ magic-move
160
+ ---
161
+
162
+ # My Slide
163
+
164
+ ```kotlin
165
+ class Person(val name: String)
166
+ ```
167
+ ````
168
+
169
+ Details:
170
+
171
+ - The separator links the slide it precedes to the one before it, so the last
172
+ slide of a chain needs no marker. Any number of slides can be chained by
173
+ repeating the `magic-move` separator.
174
+ - Code windows pair up **by position**: the first fence of a slide morphs into
175
+ the first fence of the next, the second into the second, and so on. Several
176
+ parallel snippets (say Kotlin next to SQL) each animate independently.
177
+ - Everything outside the code fences is a normal slide — headings, prose, and
178
+ layout can change freely and follow the deck's regular slide transition.
179
+ - With `transition: view-transition`, the code windows of both slides are
180
+ paired through the View Transitions API, so the window glides to its new
181
+ position while the tokens morph, instead of cross-fading with the page.
182
+ - Navigating backward plays the animation in reverse. Deep links, the
183
+ overview, and PDF/PNG exports render each slide's own step statically.
184
+ - Fence metadata still works: the code-window identity icons, `[Title]`
185
+ labels, and `{lines:true}` line numbers apply per chain. Per-click line
186
+ highlighting works too — `` ```kotlin {1|2-3} `` registers clicks on that
187
+ slide and steps through the ranges before navigation moves on, exactly like
188
+ one step of a classic Magic Move block. Snippet imports (`<<< @/...`) do
189
+ not participate in chains.
190
+ - `magicMove: true` in the slide's YAML frontmatter is equivalent to the bare
191
+ `magic-move` separator and can be combined with other frontmatter keys.
192
+
117
193
  ### Using Kodee Mascot
118
194
 
119
195
  Enable Kodee once for the whole deck with `themeConfig`:
@@ -187,7 +263,7 @@ kodee:
187
263
 
188
264
  ### Using DrawnAnnotation
189
265
 
190
- `<DrawnAnnotation>` is auto-registered for every deck using the theme. It can mark an element with a selector or exact text inside a Shiki or Magic Move code block, then connect that mark to a label or another element.
266
+ `<DrawnAnnotation>` is auto-registered for every deck using the theme. It can mark an element with a selector or exact text inside a Shiki or Magic Move code block, then connect that mark to a label or another element. Labels accept safe Markdown: backticked inline code and `>` quotes use the local-first JetBrains Mono stack.
191
267
 
192
268
  ````md
193
269
  <DrawnAnnotation type="circle" text="fun main" label="program entry point" :on="1">
@@ -406,11 +482,12 @@ layout: cover
406
482
  ## Dependencies
407
483
 
408
484
  ### Runtime Dependencies
409
- - `@slidev/types` (^52.2.5) - Slidev type definitions
410
- - `roughjs` (^4.6.6) - Hand-drawn SVG paths for `DrawnAnnotation`
485
+ - `@shikijs/magic-move` (4.4.3) - Code-token morphing for Magic Move
486
+ - `@slidev/types` (52.19.1) - Slidev type definitions
487
+ - `roughjs` (4.6.6) - Hand-drawn SVG paths for `DrawnAnnotation`
411
488
 
412
489
  ### Development Dependencies
413
- - `@slidev/cli` (^52.2.5) - Slidev command-line interface
490
+ - `@slidev/cli` (52.19.1) - Slidev command-line interface
414
491
 
415
492
  ## Contributing
416
493
 
@@ -0,0 +1,2 @@
1
+ export { drawnAnnotationEditor } from './plugins/drawn-annotation-editor'
2
+ export type { DrawnAnnotationEditorOptions, DrawnAnnotationGeometryPatch, DrawnAnnotationLabelGeometry } from './plugins/drawn-annotation-editor'
@@ -0,0 +1,5 @@
1
+ // Loaded by Node itself when a consuming deck's `vite.config.ts` imports
2
+ // `slidev-theme-kotlin/annotation-editor`, so this entry must be plain
3
+ // JavaScript: Vite's config bundler externalizes resolved node_modules
4
+ // imports, and Node refuses raw TypeScript under node_modules.
5
+ export { drawnAnnotationEditor } from './plugins/drawn-annotation-editor.mjs'
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M19.767 3.33517L22.5484 6.2099L12.4869 15.9447L8.94013 16.5933L9.70549 13.0699L19.767 3.33517Z" stroke="#333333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M20 14V17C20 18.6569 18.6569 20 17 20H7C5.34315 20 4 18.6569 4 17V7C4 5.34315 5.34315 4 7 4H12" stroke="#333333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
5
+ </svg>