@renko_1055/slidev-addon-studio 0.0.0-stage → 0.4.0-renko.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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +369 -2
  3. package/client/actions.ts +232 -0
  4. package/client/blocks.ts +85 -0
  5. package/client/component-fields.ts +31 -0
  6. package/client/composables/useCatalog.ts +61 -0
  7. package/client/composables/useDeckActions.ts +31 -0
  8. package/client/composables/useDeckApi.ts +80 -0
  9. package/client/composables/useDeckPaint.ts +32 -0
  10. package/client/composables/useDomEvent.ts +20 -0
  11. package/client/composables/useEditorMode.ts +75 -0
  12. package/client/composables/useElementProperties.ts +22 -0
  13. package/client/composables/useImageInsertion.ts +119 -0
  14. package/client/composables/useObjectClipboard.ts +71 -0
  15. package/client/composables/usePageBackground.ts +42 -0
  16. package/client/composables/useProject.ts +57 -0
  17. package/client/composables/useSelection.ts +310 -0
  18. package/client/composables/useSelectionRebind.ts +187 -0
  19. package/client/composables/useShapeTools.ts +161 -0
  20. package/client/composables/useSlideCanvas.ts +142 -0
  21. package/client/composables/useSlideSource.ts +181 -0
  22. package/client/composables/useSnapping.ts +137 -0
  23. package/client/composables/useTextEditor.ts +206 -0
  24. package/client/composables/useTransformGizmo.ts +551 -0
  25. package/client/context.ts +69 -0
  26. package/client/dom.ts +38 -0
  27. package/client/editor-view.ts +12 -0
  28. package/client/i18n/catalog.ts +65 -0
  29. package/client/i18n/en.ts +563 -0
  30. package/client/i18n/errors.ts +24 -0
  31. package/client/i18n/index.ts +69 -0
  32. package/client/i18n/zh-CN.ts +565 -0
  33. package/client/layers.ts +57 -0
  34. package/client/md/background.ts +45 -0
  35. package/client/md/batch.ts +67 -0
  36. package/client/md/classes.ts +80 -0
  37. package/client/md/clicks.ts +193 -0
  38. package/client/md/clipboard.ts +77 -0
  39. package/client/md/component-fields.ts +50 -0
  40. package/client/md/drag.ts +170 -0
  41. package/client/md/elements.ts +140 -0
  42. package/client/md/format.ts +158 -0
  43. package/client/md/frontmatter.ts +108 -0
  44. package/client/md/html.ts +110 -0
  45. package/client/md/inline.ts +316 -0
  46. package/client/md/insert.ts +28 -0
  47. package/client/md/interactions.ts +253 -0
  48. package/client/md/layers.ts +41 -0
  49. package/client/md/lines.ts +296 -0
  50. package/client/md/literals.ts +227 -0
  51. package/client/md/locate.ts +179 -0
  52. package/client/md/motion.ts +105 -0
  53. package/client/md/props.ts +104 -0
  54. package/client/md/shapes.ts +56 -0
  55. package/client/md/tags.ts +173 -0
  56. package/client/page-presets.ts +70 -0
  57. package/client/project-host.ts +15 -0
  58. package/client/project-save.ts +53 -0
  59. package/client/selection-geometry.ts +38 -0
  60. package/client/selection-target.ts +188 -0
  61. package/client/source-label.ts +7 -0
  62. package/client/state.ts +81 -0
  63. package/client/text/editor.ts +311 -0
  64. package/client/text/source.ts +166 -0
  65. package/client/types.ts +86 -0
  66. package/client/ui/InlineEditor.vue +309 -0
  67. package/client/ui/QuestionRelations.vue +48 -0
  68. package/client/ui/SelectionLayer.vue +247 -0
  69. package/client/ui/ShapeDrawingLayer.vue +23 -0
  70. package/client/ui/StudioDock.vue +45 -0
  71. package/client/ui/StudioFile.vue +76 -0
  72. package/client/ui/StudioLibrary.vue +32 -0
  73. package/client/ui/StudioNotes.vue +23 -0
  74. package/client/ui/StudioRoot.vue +278 -0
  75. package/client/ui/StudioToolbar.vue +218 -0
  76. package/client/ui/panels/PanelAnimate.vue +288 -0
  77. package/client/ui/panels/PanelAssets.vue +105 -0
  78. package/client/ui/panels/PanelComponents.vue +157 -0
  79. package/client/ui/panels/PanelInspect.vue +298 -0
  80. package/client/ui/panels/PanelLayers.vue +85 -0
  81. package/client/ui/panels/PanelLayout.vue +145 -0
  82. package/client/ui/panels/PanelPagePresets.vue +42 -0
  83. package/client/ui/panels/PanelSlides.vue +106 -0
  84. package/client/ui/panels/PanelTransition.vue +32 -0
  85. package/client/ui/parts/ArrangeSelection.vue +31 -0
  86. package/client/ui/parts/ColorSwatch.vue +97 -0
  87. package/client/ui/parts/ComponentPreview.vue +86 -0
  88. package/client/ui/parts/ImageElementFields.vue +37 -0
  89. package/client/ui/parts/InteractionFields.vue +128 -0
  90. package/client/ui/parts/ListField.vue +85 -0
  91. package/client/ui/parts/MediaFields.vue +41 -0
  92. package/client/ui/parts/ObjectListField.vue +128 -0
  93. package/client/ui/parts/ProjectTree.vue +22 -0
  94. package/client/ui/parts/PropField.vue +220 -0
  95. package/client/ui/parts/ShapeFields.vue +28 -0
  96. package/client/ui/parts/ShapePicker.vue +30 -0
  97. package/client/ui/parts/SlideThumbnail.vue +55 -0
  98. package/client/ui/parts/StudioField.vue +10 -0
  99. package/client/ui/parts/StudioIcon.vue +78 -0
  100. package/client/ui/parts/StudioSegmented.vue +23 -0
  101. package/client/ui/parts/TextElementFields.vue +99 -0
  102. package/components/StudioButton.vue +104 -0
  103. package/components/StudioCorrectCount.vue +31 -0
  104. package/components/StudioFeedback.vue +45 -0
  105. package/components/StudioMedia.vue +125 -0
  106. package/components/StudioQuestion.vue +44 -0
  107. package/components/StudioShape.vue +53 -0
  108. package/custom-nav-controls.vue +22 -0
  109. package/docs/custom-code/agent-guide.md +61 -0
  110. package/docs/custom-code/components.md +158 -0
  111. package/docs/custom-code/conventions.md +119 -0
  112. package/docs/custom-code/media.md +28 -0
  113. package/docs/releases/0.4.0-renko.1.md +35 -0
  114. package/examples/human-agent/AGENTS.md +20 -0
  115. package/examples/human-agent/README.md +16 -0
  116. package/examples/human-agent/components/GuestSpotlight.vue +59 -0
  117. package/examples/human-agent/package.json +18 -0
  118. package/examples/human-agent/public/chime.wav +0 -0
  119. package/examples/human-agent/public/intro.mp4 +0 -0
  120. package/examples/human-agent/public/portrait.svg +5 -0
  121. package/examples/human-agent/slides.md +56 -0
  122. package/global-top.vue +28 -0
  123. package/index.d.ts +15 -0
  124. package/node/assets.ts +134 -0
  125. package/node/builtin-meta.ts +108 -0
  126. package/node/catalog.ts +700 -0
  127. package/node/deck.ts +130 -0
  128. package/node/markdown-source.ts +232 -0
  129. package/node/metadata.ts +261 -0
  130. package/node/palette.ts +87 -0
  131. package/node/plugin.ts +215 -0
  132. package/node/presentation-drag.ts +25 -0
  133. package/node/project.ts +97 -0
  134. package/node/slide-source.ts +148 -0
  135. package/package.json +82 -4
  136. package/runtime/app.ts +99 -0
  137. package/runtime/composables/useInteractionPage.ts +33 -0
  138. package/runtime/composables/useQuiz.ts +16 -0
  139. package/runtime/composables/useStudioContext.ts +41 -0
  140. package/runtime/index.ts +6 -0
  141. package/runtime/interactions.ts +51 -0
  142. package/runtime/preview.ts +28 -0
  143. package/runtime/stores/quiz.ts +55 -0
  144. package/runtime/types.ts +28 -0
  145. package/setup/context-menu.ts +106 -0
  146. package/setup/main.ts +6 -0
  147. package/setup/root.ts +32 -0
  148. package/setup/shortcuts.ts +63 -0
  149. package/setup/vite-plugins.ts +13 -0
  150. package/shared/assets.ts +15 -0
  151. package/shared/catalog.ts +79 -0
  152. package/shared/editor-mode.ts +10 -0
  153. package/shared/errors.ts +37 -0
  154. package/shared/html-scan.ts +118 -0
  155. package/shared/project.ts +15 -0
  156. package/shared/quiz.ts +50 -0
  157. package/shared/shapes.ts +120 -0
  158. package/shared/signature.ts +40 -0
  159. package/skills/studio-authoring/SKILL.md +61 -0
  160. package/styles/layers.css +4 -0
  161. package/styles/studio.css +977 -0
  162. package/types/slidev-client.d.ts +101 -0
  163. package/vite.config.ts +27 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daniel Christensen
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 CHANGED
@@ -1,3 +1,370 @@
1
- # Temporary Holding Version
1
+ # Slidev Studio — Renko fork
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A visual editor for [Slidev](https://sli.dev), with a persistent slide filmstrip,
4
+ a grouped ribbon, a real slide canvas and an inspector. Create text boxes, insert
5
+ and replace pictures, edit component properties, configure animations and copy
6
+ objects between slides. Single- and multiple-choice question templates add
7
+ repeatable answers and feedback. Changes are written back to your Markdown and local assets.
8
+
9
+ ![Studio editing workspace](docs/images/workspace.png)
10
+
11
+ Studio is an ordinary Slidev addon. It works with a local project and has no
12
+ account, Git service or workbench dependency. The editor is available in the dev
13
+ server; authored content also renders in presentations and static builds.
14
+
15
+ [中文使用指南](docs/usage.zh-CN.md) | [Documentation](docs/README.md) | [Current status](docs/status.md)
16
+
17
+ ## Version and installation
18
+
19
+ The current fork version is **0.4.0-renko.1**. It includes the current editor,
20
+ component fields and runtime, the bundled human–agent authoring skill and example,
21
+ and native audio/video assets. Publication status and validation are recorded in
22
+ [the release notes](docs/releases/0.4.0-renko.1.md). Existing projects keep their
23
+ installed versions until explicitly upgraded.
24
+
25
+ To try the current source:
26
+
27
+ ```bash
28
+ git clone https://github.com/Renko6626/slidev-addon-studio.git
29
+ cd slidev-addon-studio
30
+ pnpm install --frozen-lockfile
31
+ pnpm play
32
+ ```
33
+
34
+ To use this checkout in another local Slidev project, run from that project:
35
+
36
+ ```bash
37
+ pnpm add -D "link:../slidev-addon-studio"
38
+ ```
39
+
40
+ Install the fork from npm:
41
+
42
+ ```bash
43
+ pnpm add -D slidev-addon-studio@npm:@renko_1055/slidev-addon-studio@0.4.0-renko.1
44
+ ```
45
+
46
+ The alias keeps the addon name `slidev-addon-studio`. Installing that name without
47
+ the alias installs upstream. Enable the addon in your deck's headmatter:
48
+
49
+ ```yaml
50
+ ---
51
+ addons:
52
+ - slidev-addon-studio
53
+ ---
54
+ ```
55
+
56
+ Or enable it for every deck in your project's `package.json`:
57
+
58
+ ```json
59
+ {
60
+ "slidev": {
61
+ "addons": ["slidev-addon-studio"]
62
+ }
63
+ }
64
+ ```
65
+
66
+ ## Enter, preview and present
67
+
68
+ Press **E**, use the pencil button in Slidev's navigation, or open the Studio item
69
+ in the context menu. Add `?studio=1` to a slide URL to enter directly, for example
70
+ `http://localhost:3030/1?studio=1`. `?studio=0` explicitly opens without the editor;
71
+ ordinary URLs follow the previous editor preference. Vite base paths are supported.
72
+
73
+ - **Preview** restores normal Slidev interaction and shows Return to editor.
74
+ - **Present** starts fullscreen from the current slide. Leaving a fullscreen
75
+ session started by Studio returns to the editor.
76
+ - Closing Studio in development retains its pencil, context-menu and E entry
77
+ points. Static builds have no Studio editing UI or entry points.
78
+
79
+ Apply the current text edit before switching modes. Applied edits write to the
80
+ Markdown file automatically. **File → Save**, the title-bar save button, and
81
+ **Ctrl/Cmd+S** also apply the active text edit and speaker notes, then wait for
82
+ the writes to finish. The status bar reports pending edits and failed writes.
83
+
84
+ ## Projects and File
85
+
86
+ **File** opens the current project's name, directory, slide entry, save status
87
+ and a read-only directory tree. A project is an ordinary Slidev directory; Git,
88
+ a workbench account and `project.yaml` are not required. For nested slide entries,
89
+ the nearest parent `package.json` determines the project directory; without one,
90
+ Studio uses the entry's directory. In a web workspace this is a server directory.
91
+
92
+ **Download project ZIP** applies active edits first and archives the current
93
+ files, including new and uncommitted content, local assets, components, lockfiles
94
+ and patches. Dependencies, Git history, build output, caches, `.env` values and
95
+ local credential configuration such as `.npmrc` are excluded; `.env.example`,
96
+ `.env.sample` and `.env.template` remain. The file tree uses the same exclusions.
97
+ Unzip the archive to continue with the project's usual Slidev commands; install
98
+ its dependencies first if necessary. The ZIP does not fetch external assets,
99
+ copy outside dependencies, or replace machine-specific `link:` dependencies.
100
+
101
+ Linked source files and imported Markdown outside the project must be moved
102
+ inside before export; Studio reports the path rather than silently omitting it.
103
+ New/open/save-copy operations belong to the workspace or desktop application and
104
+ are not supplied by this standalone addon. The companion [Windows desktop preview](desktop/README.md)
105
+ provides these operations through the same File page and native menus. This File page exports editable
106
+ projects; PDF, PowerPoint and built presentation exports are not included.
107
+
108
+ ## Workspace
109
+
110
+ | Area | Purpose |
111
+ | --- | --- |
112
+ | Left filmstrip | Browse, add, duplicate, delete and reorder slides |
113
+ | Ribbon | Home, Insert, Design, Transitions, Animate, View and contextual Object commands |
114
+ | Canvas | Select, move, resize, rotate and edit the real slide |
115
+ | Inspector | Current object or slide settings, with source and classes under Advanced |
116
+ | Component and asset libraries | Insert existing project content without replacing the filmstrip |
117
+ | Notes and status bar | Speaker notes, current page, view scale and Fit to window |
118
+
119
+ The canvas fits the space left by the panels. Its display percentage does not
120
+ change the slide's frontmatter `zoom`. The properties pane collapses on narrow
121
+ windows and can be reopened from View.
122
+
123
+ ## New slides and layouts
124
+
125
+ **Home → New slide** and the filmstrip's **New slide** open the same gallery:
126
+ Blank, Title slide, Title and text, Two columns, Picture on the left, Picture on
127
+ the right, and Full-page picture. Choosing one inserts a page after the current
128
+ slide. Previews and inserted pages share object geometry and placeholder text.
129
+ Text uses editable Studio text boxes; select a picture placeholder and use
130
+ **Replace picture** in its properties. Placeholders are embedded images and need
131
+ no external files. **Design → Page settings** edits the page name and parameters
132
+ used by its existing layout. The layout gallery and switcher have been removed;
133
+ existing layouts keep rendering unchanged. Layout selection and generic Slidev
134
+ configuration remain available in Markdown source.
135
+
136
+ **Insert → Heading** creates a larger text box. Use paragraph formatting for
137
+ lists and the dedicated picture/shape tools for visual objects. The component
138
+ library keeps quotes, dividers and code under **More content**.
139
+
140
+ ## Text boxes and pictures
141
+
142
+ **Insert → Text box** creates a positioned box with its placeholder selected.
143
+ Double-click or press F2 to edit; use the side handles to change its width.
144
+ Height follows the text. Home keeps its Font and Paragraph groups visible, with
145
+ font, size (canvas CSS pixels), colour, bold/italic/underline/strike, alignment,
146
+ list, indent and line spacing controls. They are disabled when no supported
147
+ heading, paragraph or Studio text box is selected. Entering text editing opens Home; the inspector
148
+ retains position, dimensions and other detailed properties. A text selection changes only those characters; a caret sets
149
+ the format of subsequent typing; selecting the box applies formatting to all its
150
+ text. Mixed values are shown as Mixed. Font names use fonts available in the
151
+ browser, with normal CSS fallback; fonts are not installed or downloaded.
152
+
153
+ Format controls keep the active text selection. Enter starts a paragraph,
154
+ Shift+Enter inserts a line break, and Tab/Shift+Tab changes list levels. During
155
+ text editing, undo/redo handles typing and formatting in the current session.
156
+ After applying, the deck history treats that session as one edit. Clear character
157
+ formatting restores the box's defaults. Supported formatting is retained on
158
+ paste; use the browser's plain-text paste shortcut when needed.
159
+
160
+ Studio text boxes use Tiptap/ProseMirror internally and still save native HTML
161
+ inside the existing positioned box. Opening and closing without changes does
162
+ not rewrite it. Custom markup outside the supported text schema opens as source
163
+ to preserve it. Ordinary Markdown ATX headings (`#` through `######`), paragraphs
164
+ and standalone HTML headings/paragraphs share the same rich-text controls.
165
+ Simple marks keep Markdown; fonts, sizes and colours save standard HTML while
166
+ preserving the heading level, document flow and existing root attributes.
167
+ Enter adds sibling paragraphs; list controls can convert the selected block
168
+ to a standard HTML list, which remains editable. Other Markdown structures and complex HTML open as source. Frontmatter text and
169
+ question labels use plain-text editing. Properties and the context menu offer
170
+ Edit HTML, Edit Markdown and Edit component tag; source editing preserves the
171
+ authored markup and provides Apply and Cancel. Mixed containers are no longer
172
+ edited visually across existing blocks.
173
+
174
+ Press and drag a movable object directly, without selecting it first. A light
175
+ click only selects it. Clicking another canvas object while editing text applies
176
+ the text and selects that object in the same click; clicking blank slide space
177
+ applies the text and clears the selection. This also works from source editing.
178
+ Dragging is disabled while a write is in progress.
179
+
180
+ **Insert → Picture** offers a file picker and the asset library. The image is
181
+ inserted and selected immediately, at a size that keeps its original proportions
182
+ and fits the slide. Pictures lock their frame ratio by default. The inspector
183
+ supports alternative text, replacement, and two display modes:
184
+
185
+ | Mode | Result |
186
+ | --- | --- |
187
+ | Show entire image | Preserves the whole image, with empty space when frame ratios differ |
188
+ | Fill frame | Fills the frame, hiding the excess; adjust horizontal and vertical position to keep the subject visible |
189
+
190
+ Replacement keeps position, frame dimensions, rotation, alternative text,
191
+ display mode and image position. Image positioning saves standard CSS
192
+ `object-position` percentages and leaves the frame unchanged. In Fill frame mode,
193
+ set horizontal and vertical position from 0 to 100: 0 aligns the left or top edge,
194
+ 100 the right or bottom edge. **Centre image** resets both to 50%. These controls
195
+ adjust the visible part of the image; there is no draggable crop tool. Deleting
196
+ an object or undoing replacement changes the Markdown reference; it does not delete the asset file.
197
+
198
+ ![Picture display modes in a static presentation](docs/images/picture-frames.png)
199
+
200
+ New text boxes and pictures are native HTML with `v-drag` and readable
201
+ `data-studio-element` attributes. Existing unmarked content retains its original
202
+ editing paths. SVG files can be used as complete pictures; editable SVG paths and
203
+ pixel editing are outside the current feature set.
204
+
205
+ On blank free-canvas pages and pages made of independently positioned objects,
206
+ **Page settings → Background** chooses a page colour or picture. Choosing one
207
+ replaces the other; Remove background returns to the deck's own paint. Pictures
208
+ fill the page from the centre. The background is a native, non-interactive
209
+ `data-studio-background` element at the start of the slide body, below the
210
+ positioned objects. An effective background change, including removal, clears the
211
+ current object selection. It uses the normal save and undo history, and renders in
212
+ thumbnails, presentations and static builds. Background controls stay disabled
213
+ on pages containing document-flow content; existing layout parameters retain
214
+ their own background options.
215
+
216
+ ## Select and arrange multiple objects
217
+
218
+ Hold **Shift** and click objects to add or remove them from the selection. Drag
219
+ from empty slide space to box-select; Shift-box-selection adds to the current
220
+ selection. This supports independently positioned Studio text boxes, pictures,
221
+ shapes and components with a definite source range and position on the current
222
+ slide. Backgrounds are excluded.
223
+
224
+ Drag any selected object to move the selection. Create copy, Ctrl/Cmd+D,
225
+ Ctrl/Cmd+C/V and Delete/Backspace act on all selected objects. Home, Object and
226
+ the object inspector offer left/right/top/bottom alignment, horizontal/vertical
227
+ centring and equal horizontal/vertical gaps. Alignment uses the selection's
228
+ visual bounds; distribution needs at least three objects and keeps the outer
229
+ objects fixed. Each batch action is one undo step.
230
+
231
+ Font and Paragraph controls are disabled during multiple selection. Text editing
232
+ and detailed object properties use single selection. Permanent grouping, batch
233
+ resizing/rotation and selection across slides are not provided.
234
+
235
+ ## Layers
236
+
237
+ Open **Layers** from View, the contextual Object tab or the right-hand inspector.
238
+ The list runs from front to back; click a row to select that object. Supported
239
+ text boxes, pictures and shapes can move forward/backward or to the front/back
240
+ within the same parent container. The order is saved as CSS stacking order in
241
+ the source and is retained in presentations and static builds.
242
+
243
+ Unknown components can be selected in the list but cannot be reordered. Objects
244
+ in different containers cannot exchange layer order; this is not a page-wide
245
+ stack across layouts or nested components. Backgrounds are excluded from the
246
+ list and stay below the page objects.
247
+
248
+ ## Questions and buttons
249
+
250
+ **Insert → Single-choice page / Multiple-choice page** creates a page with a
251
+ question control, a separate prompt, four independent option buttons and feedback.
252
+ Select the control to configure its name and correct option IDs. Edit the prompt
253
+ as an ordinary text box, option text/images on each button, and messages on the
254
+ feedback object. Dashed lines show its connections; selecting a child shows only that
255
+ child's connection. Objects remain independently positioned. The control is
256
+ hidden when presenting by default; **Show question name when presenting** displays
257
+ its name while the question keeps running in either mode. Removing a prompt keeps
258
+ the question; removing the control warns and leaves the display objects in place.
259
+ The prompt is an ordinary Studio text box linked by `data-studio-question-ref`.
260
+
261
+ Multiple-choice pages also have Confirm answer and Clear selection buttons. This version keeps
262
+ four options and does not offer changing the question type. Double-click or F2
263
+ opens rich-text editing for the prompt and button content. Each button also
264
+ offers an image field. Feedback messages belong to the feedback object; its idle
265
+ message supports plain-text editing and all three messages appear in properties.
266
+
267
+ **Insert → Button** adds a button bound to a question on the current page. Its
268
+ properties set the question, purpose, option and appearance. Normal, Selected,
269
+ Correct and Incorrect previews show styles without answering.
270
+
271
+ Answers run in Preview and Present, including static presentations. Single
272
+ choice judges each selection; multiple choice requires the exact correct set
273
+ and ignores empty submissions. Changing the selection clears an old judgement;
274
+ Clear selection removes choices and results. Switching slides retains answers
275
+ within a trial; returning to editing or starting a new trial resets them.
276
+
277
+ Copying a selection that includes a question assigns a fresh question id and
278
+ updates its copied prompt/buttons/feedback. Copying a child alone keeps its question
279
+ binding on the same page. See [the working example](playground/interactions.md)
280
+ and [the advanced signal API](docs/components.md#question-interactions).
281
+
282
+ ## Copy, paste and keyboard
283
+
284
+ | Shortcut | Action |
285
+ | --- | --- |
286
+ | E | Toggle Studio |
287
+ | Ctrl/Cmd+C | Copy the selected complete object or multiple independent objects |
288
+ | Ctrl/Cmd+V | Paste into the current slide |
289
+ | Ctrl/Cmd+D | Create copies of the selection immediately |
290
+ | Delete / Backspace | Delete the selection when not typing |
291
+ | Ctrl/Cmd+Z / Ctrl/Cmd+Shift+Z | Undo / redo |
292
+ | F2 | Enter or finish editing supported text |
293
+ | Ctrl/Cmd+Enter or Esc while editing text | Apply the text edit; use the floating Cancel button to discard it |
294
+ | Arrow keys / Shift+Arrow | Move a positioned selection by 1 / 10 canvas units |
295
+ | Alt while dragging | Bypass snapping |
296
+ | Shift during ordinary resizing / rotation | Keep ratio / snap rotation to 15 degrees; new pictures also have a ratio lock |
297
+
298
+ Object clipboard copying works across slides at the same presentation entry
299
+ (origin and Vite base). It retains source, local asset references and
300
+ each object's position/animation wrappers. Metadata travels on the native
301
+ clipboard, including across a page reload. Same-page pastes and immediate copies
302
+ are offset by 20 units; the first cross-page paste keeps the original coordinates.
303
+ The new objects are selected after insertion.
304
+
305
+ Text inputs retain native text clipboard behaviour. External text is not treated
306
+ as an object. Nested sub-elements, individual list items and frontmatter-only
307
+ text are not standalone clipboard objects. If another application strips the
308
+ Studio clipboard format, copy the object again in Studio.
309
+
310
+ ## Boundaries
311
+
312
+ - Adding, duplicating, deleting or reordering slides reloads the page and clears
313
+ undo history. The first entry slide cannot be moved/deleted, and slides cannot
314
+ be dragged across Markdown files.
315
+ - The source remains Markdown. Complex content may require the source editor;
316
+ not every rendered element can be traced to an independently editable block.
317
+ - Permanent grouping, batch resizing/rotation, selection across slides, manual
318
+ viewport zoom, font installation and interactive crop handles remain future work.
319
+ Layer ordering is limited to supported objects in the same parent container.
320
+ - Return to flow and source-order controls are temporarily hidden throughout
321
+ the editor. Unpositioned content still offers Free position. Editing context
322
+ menus show object actions and Close Studio; presentation menus remain in preview.
323
+
324
+ See [all limitations](docs/limitations.md) and the [stage status](docs/status.md)
325
+ for validation scope. Native clipboard, IME, file-picker, dragging and fullscreen
326
+ interaction are not claimed as browser-automated acceptance tests.
327
+
328
+ ## Human–agent authoring and media
329
+
330
+ Let the agent build the effects, interaction rules and first layout. Keep titles,
331
+ copy and replaceable pictures editable so a person can finish in Studio. The
332
+ bundled `skills/studio-authoring/SKILL.md` describes this handoff; read it directly
333
+ or copy its folder into your agent's skill directory. Studio does not install it
334
+ into machine-wide agent settings automatically.
335
+
336
+ Copy `examples/human-agent/` to a writable directory, install dependencies and run
337
+ `pnpm dev`. It contains a configurable animated guest card, independent text boxes
338
+ and shared quiz state, using public addon imports. See its README for edit points.
339
+
340
+ **Insert → Assets** accepts images, audio and video. New audio/video objects use
341
+ `StudioMedia`, with file replacement, poster, autoplay, controls, loop, mute,
342
+ volume and start-time settings. Editing and thumbnail views do not play; leaving
343
+ the active slide pauses and resets to the start time. Autoplay is opt-in, and a
344
+ blocked autoplay offers a manual Play button.
345
+
346
+ Images keep a 32 MiB upload limit; audio/video allow 128 MiB. The original file is
347
+ retained without transcoding. HEIC/TIFF images require conversion; media container
348
+ extensions alone do not guarantee codec support. Larger files can be placed in
349
+ `public/` directly. See [formats and playback](docs/custom-code/media.md).
350
+
351
+ ## Language, extensions and development
352
+
353
+ The UI supports English and Simplified Chinese, follows the browser initially,
354
+ and remembers the language selected in the title bar. Component names, existing
355
+ user content and third-party metadata keep their authored form.
356
+
357
+ - [Detailed editing reference](docs/editor-reference.md)
358
+ - [Component and layout metadata](docs/components.md)
359
+ - [Configuration, source modules, verification and distribution](docs/development.md)
360
+ - [Current capabilities and historical plans](docs/status.md)
361
+
362
+ ```bash
363
+ pnpm test
364
+ pnpm typecheck
365
+ pnpm exec slidev build playground/slides.md --out /tmp/studio-build
366
+ ```
367
+
368
+ ## License
369
+
370
+ MIT. Fork of [BobTheShoplifter/slidev-addon-studio](https://github.com/BobTheShoplifter/slidev-addon-studio).
@@ -0,0 +1,232 @@
1
+ import { action, t, targetLabel, targetName } from './i18n'
2
+ import type { StudioContext } from './context'
3
+ import type { SourceRange, StudioTarget } from './types'
4
+ import { positionedUnit, readDrag, removeDrag, writeDrag } from './md/drag'
5
+ import { duplicateListItem, listItemUnit, moveBlock, moveListItem, removeBlock } from './md/lines'
6
+ import { captureBlock, insertCopiedBlock } from './md/clipboard'
7
+ import { activePanel, busy, editing, editSourceRequested, reportError, selection, selectedTargets } from './state'
8
+ import { captureBlocks, insertCopiedBlocks, movePositions, removePositions, writePositions } from './md/batch'
9
+ import { alignDeltas, distributeDeltas } from './selection-geometry'
10
+ import type { Align } from './selection-geometry'
11
+ import { readInteraction } from './md/interactions'
12
+
13
+ /**
14
+ * What can be done to the selected block, in one place.
15
+ *
16
+ * The Element panel and the right-click menu offer the same handful of actions,
17
+ * and an action that behaves differently depending on where it was invoked from
18
+ * is a bug waiting to happen, so both call these.
19
+ */
20
+
21
+ /**
22
+ * The lines an arrange action owns.
23
+ *
24
+ * A block given a free position lives inside a `<v-drag>` wrapper, and the
25
+ * wrapper is part of the thing on screen: reordering only the block moved it
26
+ * out and left an empty wrapper behind, holding a position and nothing to
27
+ * position. Moving, duplicating or deleting takes the whole wrapper.
28
+ */
29
+ export { positionedUnit } from './md/drag'
30
+
31
+ /** Whether the block already carries a position of its own. */
32
+ export function isPositioned(content: string, range: SourceRange): boolean {
33
+ return !!readDrag(content, range)?.pos
34
+ }
35
+
36
+ export function editText() {
37
+ if (selection.value?.el.hasAttribute('data-studio-question-control')) return
38
+ if (selectedTargets.value.length === 1 && (selection.value?.range || selection.value?.prop) && selection.value.element !== 'image' && selection.value.element !== 'shape')
39
+ editing.value = true
40
+ }
41
+
42
+ export function editSource() {
43
+ if (busy.value || editing.value || selectedTargets.value.length !== 1 || !selection.value?.range) return
44
+ editSourceRequested.value = true
45
+ editing.value = true
46
+ }
47
+
48
+ /** Removing a control intentionally leaves independently authored display objects. */
49
+ export function confirmQuestionRemoval(content: string, ranges: SourceRange[]): boolean {
50
+ const removesControl = ranges.some(range => {
51
+ const source = readInteraction(content, range)
52
+ return source?.kind === 'question'
53
+ })
54
+ return !removesControl || window.confirm(t('quizDeleteControl'))
55
+ }
56
+
57
+ /**
58
+ * Lifts the block out of the document flow, where it is standing.
59
+ *
60
+ * Measured from what is on screen rather than from a guess, so the block does
61
+ * not jump the moment it becomes free.
62
+ */
63
+ export async function freePosition(studio: StudioContext, target: StudioTarget) {
64
+ if (!target.range)
65
+ return
66
+
67
+ /*
68
+ * A block that shares its Markdown block with siblings cannot be lifted out
69
+ * of it.
70
+ *
71
+ * The position is written by wrapping the block's lines in `<v-drag>`, and
72
+ * for one item of a list those lines sit in the middle of the list. Wrapping
73
+ * them splices an HTML block into it, which ends the list above and starts a
74
+ * new one below: the item is orphaned and its neighbours quietly change which
75
+ * list, and which level, they belong to. Refusing is the only honest answer
76
+ * until the item can be promoted out of its list first.
77
+ */
78
+ if (target.nested) {
79
+ reportError(new Error(
80
+ t('errorListPosition', { name: targetLabel(target) }),
81
+ ))
82
+ return
83
+ }
84
+ const box = studio.canvas.boxOf(target.el)
85
+ // Written in the coordinates Slidev will read it in, which are the block's
86
+ // own containing block rather than the slide when a layout positions its
87
+ // panes. Without this the block jumps by the pane's offset the moment it is
88
+ // given a position.
89
+ const origin = studio.canvas.originOf(target.el)
90
+ await studio.commit(
91
+ writeDrag(studio.content(), target.range, { x: box.x - origin.x, y: box.y - origin.y, w: box.w, h: null, rotate: 0 }),
92
+ action('actionFreePosition'),
93
+ )
94
+ }
95
+
96
+ export async function returnToFlow(studio: StudioContext, target: StudioTarget) {
97
+ if (!target.range)
98
+ return
99
+ await studio.commit(removeDrag(studio.content(), target.range), action('actionReturnFlow'))
100
+ }
101
+
102
+ /**
103
+ * Whether reordering and duplicating apply.
104
+ *
105
+ * A block that shares its Markdown with siblings usually cannot be moved on its
106
+ * own. A list item is the exception: it has its own line, and its siblings are
107
+ * the other lines of the same list, so the two operations mean something
108
+ * precise there. They are written by the list aware functions rather than the
109
+ * block ones, which is what stopped an item jumping over its siblings or
110
+ * breaking the list in two around a copy.
111
+ */
112
+ export function canReorder(target: StudioTarget): boolean {
113
+ return !target.nested || target.kind === 'list-item'
114
+ }
115
+
116
+ export async function duplicateBlock(studio: StudioContext, target: StudioTarget) {
117
+ if (selectedTargets.value.length > 1) {
118
+ if (editing.value || busy.value) return
119
+ const no = studio.no()
120
+ const copied = captureBlocks(studio.content(), selectedTargets.value.map(item => ({ range: item.range!, tag: item.tag })), { deck: '', page: no })
121
+ const result = insertCopiedBlocks(studio.content(), copied, 20)
122
+ await studio.commit(result.content, action('actionDuplicateBlock'))
123
+ if (studio.no() === no) await studio.selectInsertedMany?.(result.inserted)
124
+ return
125
+ }
126
+ if (!target.range || !canReorder(target) || editing.value || busy.value)
127
+ return
128
+
129
+ if (target.kind === 'list-item') {
130
+ const unit = listItemUnit(studio.content(), target.range[0])
131
+ const next = duplicateListItem(studio.content(), target.range[0])
132
+ if (next && unit) {
133
+ const no = studio.no()
134
+ await studio.commit(next, action('actionDuplicateItem'))
135
+ if (studio.no() === no)
136
+ await studio.selectInserted(target.tag, [unit[1], unit[1] + target.range[1] - target.range[0]])
137
+ }
138
+ return
139
+ }
140
+ const no = studio.no()
141
+ const copied = captureBlock(studio.content(), target.range, { deck: '', page: no, tag: target.tag })
142
+ const start = target.range[0] - copied.range[0]
143
+ const unit: SourceRange = [start, start + copied.source.split('\n').length]
144
+ const inserted = insertCopiedBlock(studio.content(), copied, 20, unit)
145
+ await studio.commit(inserted.content, action('actionDuplicateBlock'))
146
+ if (studio.no() === no && await studio.selectInserted(target.tag, inserted.range))
147
+ activePanel.value = 'inspect'
148
+ }
149
+
150
+ export async function deleteBlock(studio: StudioContext, target: StudioTarget) {
151
+ if (!target.range)
152
+ return
153
+ const targets = selectedTargets.value
154
+ if (!confirmQuestionRemoval(studio.content(), targets.length > 1 ? targets.map(item => item.range!) : [target.range])) return
155
+ const unit = positionedUnit(studio.content(), target.range)
156
+ const next = targets.length > 1 ? removePositions(studio.content(), targets.map(item => item.range!)) : removeBlock(studio.content(), unit)
157
+ selection.value = null
158
+ await studio.commit(next, action('actionDelete', { name: targetName(target) }))
159
+ }
160
+
161
+ /**
162
+ * Moves a positioned block by a few pixels, from the keyboard.
163
+ *
164
+ * A block still in the flow has no position to change: where it sits is decided
165
+ * by the text around it, and an arrow key there means the deck's own navigation,
166
+ * which is what it keeps doing. Only a block that has been given a position of
167
+ * its own can be nudged, which is also the only one where a pixel means
168
+ * anything.
169
+ */
170
+ export async function nudgeBlock(
171
+ studio: StudioContext,
172
+ target: StudioTarget,
173
+ dx: number,
174
+ dy: number,
175
+ ): Promise<boolean> {
176
+ if (!target.range)
177
+ return false
178
+
179
+ const content = studio.content()
180
+ if (selectedTargets.value.length > 1) {
181
+ await studio.commit(movePositions(content, selectedTargets.value.map(item => item.range!), dx, dy), action('actionNudge'))
182
+ return true
183
+ }
184
+ const unit = positionedUnit(content, target.range)
185
+ const drag = readDrag(content, unit)
186
+ if (!drag?.pos)
187
+ return false
188
+
189
+ const pos = drag.pos
190
+ await studio.commit(
191
+ writeDrag(content, unit, { ...pos, x: pos.x + dx, y: pos.y + dy }),
192
+ action('actionNudge'),
193
+ // The numbers change, nothing else does, and rebuilding the slide for an
194
+ // arrow key would make holding one down unusable.
195
+ { keepSelection: true },
196
+ )
197
+ return true
198
+ }
199
+
200
+ export async function moveBlockBy(studio: StudioContext, target: StudioTarget, direction: -1 | 1) {
201
+ if (!target.range)
202
+ return
203
+
204
+ if (target.kind === 'list-item') {
205
+ const next = moveListItem(studio.content(), target.range[0], direction)
206
+ // Null means there is no sibling that way, so there is nothing to do.
207
+ if (next)
208
+ await studio.commit(next, action('actionReorderItem'))
209
+ return
210
+ }
211
+ const unit = positionedUnit(studio.content(), target.range)
212
+ await studio.commit(moveBlock(studio.content(), unit, direction), action('actionReorderBlock'))
213
+ }
214
+
215
+ /** Align in slide coordinates; write only position deltas in each object's own context. */
216
+ export async function arrangeSelection(studio: StudioContext, operation: Align | 'distributeX' | 'distributeY') {
217
+ const targets = selectedTargets.value
218
+ if (targets.length < (operation.startsWith('distribute') ? 3 : 2) || busy.value || editing.value) return
219
+ const scale = studio.canvas.scale.value
220
+ const boxes = targets.map(target => {
221
+ const box = target.el.getBoundingClientRect()
222
+ return { x: box.left / scale, y: box.top / scale, w: box.width / scale, h: box.height / scale }
223
+ })
224
+ const deltas = operation === 'distributeX' || operation === 'distributeY'
225
+ ? distributeDeltas(boxes, operation === 'distributeX' ? 'x' : 'y') : alignDeltas(boxes, operation)
226
+ const content = studio.content()
227
+ const changes = targets.flatMap((target, index) => {
228
+ const pos = target.range && readDrag(content, target.range)?.pos
229
+ return pos && target.range ? [{ range: target.range, pos: { ...pos, x: pos.x + deltas[index].x, y: pos.y + deltas[index].y } }] : []
230
+ })
231
+ await studio.commit(writePositions(content, changes), action('actionArrangeObjects'))
232
+ }