@mdzip/editor-vue 2.4.2 → 2.5.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/README.md CHANGED
@@ -1,229 +1,226 @@
1
- [![MDZip logo][mdzip-logo]][mdzip-url]
2
-
3
- [mdzip-logo]: https://raw.githubusercontent.com/mdzip-project/mdzip-editor/main/resources/mdzip-mark.svg
4
- [mdzip-url]: https://mdzip.org
5
-
6
- # @mdzip/editor-vue
7
-
8
- [![npm](https://img.shields.io/npm/v/@mdzip/editor-vue?logo=npm)](https://www.npmjs.com/package/@mdzip/editor-vue)
9
- [![license](https://img.shields.io/npm/l/@mdzip/editor-vue)](https://github.com/mdzip-project/mdzip-editor/blob/main/LICENSE)
10
-
11
- Vue 3 component wrapper for the MDZip workspace editor.
12
-
13
- `@mdzip/editor-vue` provides a `MdzipWorkspace` component that embeds the full MDZip workspace UI — document preview, editor, package navigator, and asset manager — as a native Vue 3 component.
14
-
15
- ## Install
16
-
17
- ```sh
18
- npm install @mdzip/editor-vue
19
- ```
20
-
21
- Peer dependency: `vue` >=3.
22
-
23
- ## Basic Usage
24
-
25
- ```vue
26
- <script setup lang="ts">
27
- import { MdzipWorkspace } from '@mdzip/editor-vue';
28
-
29
- const props = defineProps<{ bytes: Uint8Array }>();
30
- </script>
31
-
32
- <template>
33
- <div style="height: 600px">
34
- <MdzipWorkspace
35
- :bytes="props.bytes"
36
- file-name="document.mdz"
37
- mode="read-only"
38
- controls="viewer"
39
- @failed="console.error"
40
- />
41
- </div>
42
- </template>
43
- ```
44
-
45
- The parent element must have an explicit height. The component expands to fill it.
46
-
47
- ## Archive Diff
48
-
49
- ```vue
50
- <script setup lang="ts">
51
- import { MdzipDiff } from '@mdzip/editor-vue/diff-view';
52
- </script>
53
-
54
- <template>
55
- <div style="height: 600px">
56
- <MdzipDiff
57
- :before="{ bytes: baseBytes, label: 'Git base' }"
58
- :after="{ bytes: workingBytes, label: 'Working tree' }"
59
- initial-path="index.md"
60
- :toolbar-actions="[{ id: 'refresh', label: 'Refresh', icon: 'refresh', run: refresh }]"
61
- />
62
- </div>
63
- </template>
64
- ```
65
-
66
- The component emits `selectionChanged` and `failed`. Its exposed handle
67
- provides `openPath`, `openPreviousChange`, `openNextChange`, `setShowUnchanged`,
68
- `setNavigationVisible`, and `setToolbarActions`. The built-in toolbar adds
69
- Previous/Next change buttons and a Show-unchanged toggle; pass a `controls`
70
- prop (`{ navigation?, changeTraversal?, showUnchanged? }`) to opt any out.
71
-
72
- ## Editor Mode
73
-
74
- ```vue
75
- <MdzipWorkspace
76
- :bytes="bytes"
77
- file-name="document.mdz"
78
- mode="editable"
79
- controls="standalone-editor"
80
- @saved="onSaved"
81
- @changed="onChanged"
82
- />
83
- ```
84
-
85
- ## Props
86
-
87
- | Prop | Type | Default | Description |
88
- |------|------|---------|-------------|
89
- | `bytes` | `Uint8Array \| null` | `null` | Raw archive bytes to open |
90
- | `workspace` | `MdzWorkspace \| null` | `null` | Pre-built workspace object |
91
- | `fileName` | `string` | `'document.mdz'` | Filename used for format detection and Save dialogs |
92
- | `mode` | `MdzipWorkspaceMode` | `'read-only'` | `'read-only'` or `'editable'` |
93
- | `sourceFormat` | `MdzipSourceFormat` | — | Override format detection: `'mdz'` or `'markdown'` |
94
- | `controls` | `MdzipControlPreset \| MdzipControlPolicy` | `'viewer'` | `'preview'`, `'viewer'`, `'standalone-editor'`, `'hosted-editor'`, or a policy object |
95
- | `toolbarDensity` | `'comfortable' \| 'compact' \| 'dense'` | `'comfortable'` | Semantic sizing preset for built-in toolbar controls |
96
- | `contentDensity` | `'comfortable' \| 'compact'` | `'comfortable'` | Semantic padding preset for editor and preview content |
97
- | `imageHydrationAnimation` | `'auto' \| 'initial' \| 'off'` | `'auto'` | Control preview image reveal animation: every render, first render per document path, or never |
98
- | `initialLayout` | `MdzipWorkspaceLayout` | — | Starting layout: `'preview'`, `'editor'`, `'split'` |
99
- | `initialColorScheme` | `MdzipColorSchemePreference` | `'system'` | `'light'`, `'dark'` or `'system'` (follows the OS setting live) |
100
- | `systemColorScheme` | `MdzipSystemColorScheme` | — | Makes the color scheme menu's System choice follow the host's theme instead of the OS setting, with its own `label` and `icon`, e.g. `{ colorScheme: 'dark', label: 'VS Code theme', icon: '<svg…>' }`; changes apply live |
101
- | `previewMaxWidth` | `MdzipPreviewMaxWidth` | `'default'` | Preview reading-column width: `'narrow'`, `'default'`, `'wide'`, `'full'` or a pixel number; the user can change it from the toolbar's page-width menu |
102
- | `navigationMode` | `MdzipNavigationMode` | `'editor'` | Package navigation mode |
103
- | `navigationButtonActive` | `boolean` | `true` | Whether the navigation button is shown |
104
- | `inlineSvgLinks` | `boolean` | `true` | Shows archive SVGs that contain links inline, so the links can be clicked (draw.io `.drawio.svg` diagrams, for example); other SVGs stay images. Read when the view is created |
105
- | `hostFileActions` | `readonly MdzipFileAction[]` | — | The host's own items in the file tree's right-click menu on files (`{ id, label, appliesTo?, run }`), e.g. "Open in Another Editor". Also shown as buttons on the card that stands in for a `.drawio` image. Read when the view is created |
106
- | `markdownRenderer` | `MdzipMarkdownRenderer \| null` | `null` | Custom markdown renderer (keep the reference stable) |
107
- | `markdownExtensions` | `readonly MdzipMarkdownRenderExtension[]` | `[]` | Markdown pipeline extensions, diffed by `name` — inline arrays are safe |
108
- | `entryRenderers` | `readonly MdzipEntryRenderer[]` | `[]` | Entry renderers claiming the content area for matching entries, diffed by `id` — inline arrays are safe |
109
- | `entrySlotPriority` | `number` | `0` | Matching priority of the `#entry` slot relative to `entryRenderers` |
110
- | `frontMatter` | `MdzipFrontMatterOptions` | `{}` | Front matter panel config (`enabled`, `display`, `collapsible`, `label`) — always registered, diffed by deep equality; inline objects are safe |
111
- | `externalLinks` | `MdzipExternalLinkPolicy` | — | External-link policy, e.g. `{ target: '_blank' }` (adds `rel="noopener noreferrer"`); optional `rel` and `predicate(href)`. Re-applies without a re-render only when `target`, `rel` or `predicate` change; inline objects are safe |
112
-
113
- `controls`, density, `imageHydrationAnimation`, and rendering prop changes apply in
114
- place — they never recreate the workspace view. Line-number visibility changes
115
- preserve the current CodeMirror document and selection. See the `@mdzip/editor`
116
- Rendering Extensibility docs for the contracts and lifecycle rules.
117
-
118
- ### Native entry rendering (`#entry` slot)
119
-
120
- ```vue
121
- <MdzipWorkspace :bytes="bytes">
122
- <template #entry="{ context }">
123
- <ManifestEditor
124
- v-if="context.path.toLowerCase() === 'manifest.json'"
125
- :manifest="context.manifest"
126
- :editable="context.mode === 'editable'"
127
- @manifest-change="context.updateManifest"
128
- />
129
- </template>
130
- </MdzipWorkspace>
131
- ```
132
-
133
- A slot render that produces no content (its `v-if` is false) delegates to
134
- `entryRenderers` and the built-in rendering. The slot mounts in a detached
135
- tree sharing the host app context (plugins, provide/inject); the context is
136
- reactive, and the tree unmounts on selection change.
137
-
138
- ## Events
139
-
140
- | Event | Payload | Description |
141
- |-------|---------|-------------|
142
- | `changed` | `MdzipWorkspaceChange` | Emitted when archive bytes change |
143
- | `saved` | `MdzipWorkspaceSave` | Emitted on Save |
144
- | `snapshotChanged` | `MdzipWorkspaceSnapshot` | Emitted on any state change |
145
- | `selectionChanged` | `MdzipWorkspaceSnapshot` | Emitted when the editor selection changes |
146
- | `dirtyChanged` | `MdzipWorkspaceSnapshot` | Emitted when the dirty flag changes |
147
- | `validationChanged` | `MdzipWorkspaceSnapshot` | Emitted when validation state changes |
148
- | `colorSchemeChanged` | `MdzipColorScheme` | Emitted when the color scheme changes |
149
- | `colorSchemePreferenceChanged` | `MdzipColorSchemePreference` | Emitted when the user picks Light, Dark or System in the toolbar menu |
150
- | `previewWidthChanged` | `MdzipPreviewWidthChoice` | Emitted when the user picks a width in the toolbar's page-width menu |
151
- | `previewRendered` | `MdzipWorkspaceSnapshot` | Emitted when the preview HTML is mounted |
152
- | `assetsHydrated` | `MdzipWorkspaceSnapshot` | Emitted once the mounted preview's images have loaded |
153
- | `linkActivated` | `MdzipLinkActivatedEvent` | Emitted for every preview link click before built-in handling; call `event.preventDefault()` to take over |
154
- | `failed` | `unknown` | Emitted on unrecoverable errors |
155
-
156
- ## Conversion hook
157
-
158
- `onConversionRequested` is a **function prop** (not an emit, because it must return a value):
159
- pass `(action: MdzipConversionAction) => boolean | Promise<boolean>`. It fires when the user
160
- triggers the markdown→MDZ conversion flow (nav button, Insert Image, or image paste on a
161
- plain `.md`). Return/resolve `true` to take over and suppress the built-in conversion dialog.
162
-
163
- `onPackRequested` is the same kind of function prop for the folder→.mdz packing
164
- decision surfaced by the exposed `packFilesAsWorkspace(files, options)` method — fires
165
- only when the file list contains more than one Markdown file, with the same
166
- return contract as `onConversionRequested`.
167
-
168
- ## Image insertion
169
-
170
- Pass `image-insert-mode="markdown"`, `"ask"`, or `"html"` for the built-in
171
- image markup flow. Pass `:image-insert-handler="handler"` for host-owned image
172
- UI; the handler can return Markdown or HTML sizing/alignment settings, return
173
- `null` to cancel, or return `undefined` to fall back to `imageInsertMode`.
174
-
175
- Pass `:image-edit-handler="handler"` to let users edit an *existing* image by
176
- clicking it. Fully opt-in — with no handler, clicking an image does nothing
177
- and no edit affordance appears; there is no built-in fallback dialog.
178
-
179
- ## File management (nav pane)
180
-
181
- With `controls="standalone-editor"` or `"hosted-editor"` (or `fileActions: true` in a custom
182
- policy), the navigation pane offers a right-click context menu: new `.md` file, new folder,
183
- rename/move, duplicate, replace, download, copy markdown link, set entry point, set cover
184
- image, and delete. Files can also be dragged between folders, and OS files can be dropped
185
- onto the pane. Copy and Download remain available in read-only mode. The same operations are
186
- exposed on the handle: `removeFile`, `renameFile`, `setEntryPoint`, and `setCoverImage`.
187
-
188
- ## Imperative API
189
-
190
- Use a template ref to access the exposed handle:
191
-
192
- ```vue
193
- <script setup lang="ts">
194
- import { ref } from 'vue';
195
- import { MdzipWorkspace, type MdzipWorkspaceExposed } from '@mdzip/editor-vue';
196
-
197
- const workspace = ref<MdzipWorkspaceExposed>();
198
-
199
- async function save() {
200
- const snapshot = await workspace.value?.flush();
201
- if (snapshot) {
202
- await persist(snapshot.bytes);
203
- workspace.value?.markPersisted();
204
- }
205
- }
206
- </script>
207
-
208
- <template>
209
- <MdzipWorkspace ref="workspace" ... />
210
- </template>
211
- ```
212
-
213
- The handle also exposes `whenRendered()`, which resolves once the current preview (including
214
- its images) is mounted — useful for revealing or animating read-only preview content.
215
-
216
- ## Links and anchors
217
-
218
- The `linkActivated` event fires for every preview link click, before the view's own handling, with the
219
- parsed link (`kind`: `'anchor' | 'document' | 'relative' | 'external'`, plus `path`,
220
- `anchor`, `targetPath`, `sourcePath`, modifier keys). Call `event.preventDefault()` in the
221
- handler to route the link yourself; unprevented clicks keep the built-in behavior.
222
- The handle also exposes `scrollToAnchor(anchor)` (waits for the preview to mount, resolves whether it
223
- scrolled; safe straight after load), `getAvailableAnchors()`, `openPath(path, { anchor })` (opens another
224
- file, optionally at an anchor) and `getCurrentPath()`. Changing only `fileName` (e.g. after Save As)
225
- renames in place without reopening; set `preserveSelectionOnReopen` to stay on the current file when
226
- the archive content changes. See the
227
- [`@mdzip/editor` README](https://www.npmjs.com/package/@mdzip/editor#links-and-anchors).
228
-
229
- See the [`@mdzip/editor`](https://www.npmjs.com/package/@mdzip/editor) package for the full API reference, theming guide, and framework-agnostic usage.
1
+ <a href="https://mdzip.org"><img src="https://mdzip.org/assets/images/mdzip-mark-square.svg" alt="MDZip logo" width="64" height="64"></a>
2
+
3
+ # @mdzip/editor-vue
4
+
5
+ [![npm](https://img.shields.io/npm/v/@mdzip/editor-vue?logo=npm)](https://www.npmjs.com/package/@mdzip/editor-vue)
6
+ [![license](https://img.shields.io/npm/l/@mdzip/editor-vue)](https://github.com/mdzip-project/mdzip-editor/blob/main/LICENSE)
7
+
8
+ Vue 3 component wrapper for the MDZip workspace editor.
9
+
10
+ `@mdzip/editor-vue` provides a `MdzipWorkspace` component that embeds the full MDZip workspace UI — document preview, editor, package navigator, and asset manager — as a native Vue 3 component.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install @mdzip/editor-vue
16
+ ```
17
+
18
+ Peer dependency: `vue` >=3.
19
+
20
+ ## Basic Usage
21
+
22
+ ```vue
23
+ <script setup lang="ts">
24
+ import { MdzipWorkspace } from '@mdzip/editor-vue';
25
+
26
+ const props = defineProps<{ bytes: Uint8Array }>();
27
+ </script>
28
+
29
+ <template>
30
+ <div style="height: 600px">
31
+ <MdzipWorkspace
32
+ :bytes="props.bytes"
33
+ file-name="document.mdz"
34
+ mode="read-only"
35
+ controls="viewer"
36
+ @failed="console.error"
37
+ />
38
+ </div>
39
+ </template>
40
+ ```
41
+
42
+ The parent element must have an explicit height. The component expands to fill it.
43
+
44
+ ## Archive Diff
45
+
46
+ ```vue
47
+ <script setup lang="ts">
48
+ import { MdzipDiff } from '@mdzip/editor-vue/diff-view';
49
+ </script>
50
+
51
+ <template>
52
+ <div style="height: 600px">
53
+ <MdzipDiff
54
+ :before="{ bytes: baseBytes, label: 'Git base' }"
55
+ :after="{ bytes: workingBytes, label: 'Working tree' }"
56
+ initial-path="index.md"
57
+ :toolbar-actions="[{ id: 'refresh', label: 'Refresh', icon: 'refresh', run: refresh }]"
58
+ />
59
+ </div>
60
+ </template>
61
+ ```
62
+
63
+ The component emits `selectionChanged` and `failed`. Its exposed handle
64
+ provides `openPath`, `openPreviousChange`, `openNextChange`, `setShowUnchanged`,
65
+ `setNavigationVisible`, and `setToolbarActions`. The built-in toolbar adds
66
+ Previous/Next change buttons and a Show-unchanged toggle; pass a `controls`
67
+ prop (`{ navigation?, changeTraversal?, showUnchanged? }`) to opt any out.
68
+
69
+ ## Editor Mode
70
+
71
+ ```vue
72
+ <MdzipWorkspace
73
+ :bytes="bytes"
74
+ file-name="document.mdz"
75
+ mode="editable"
76
+ controls="standalone-editor"
77
+ @saved="onSaved"
78
+ @changed="onChanged"
79
+ />
80
+ ```
81
+
82
+ ## Props
83
+
84
+ | Prop | Type | Default | Description |
85
+ |------|------|---------|-------------|
86
+ | `bytes` | `Uint8Array \| null` | `null` | Raw archive bytes to open |
87
+ | `workspace` | `MdzWorkspace \| null` | `null` | Pre-built workspace object |
88
+ | `fileName` | `string` | `'document.mdz'` | Filename used for format detection and Save dialogs |
89
+ | `mode` | `MdzipWorkspaceMode` | `'read-only'` | `'read-only'` or `'editable'` |
90
+ | `sourceFormat` | `MdzipSourceFormat` | — | Override format detection: `'mdz'` or `'markdown'` |
91
+ | `controls` | `MdzipControlPreset \| MdzipControlPolicy` | `'viewer'` | `'preview'`, `'viewer'`, `'standalone-editor'`, `'hosted-editor'`, or a policy object |
92
+ | `toolbarDensity` | `'comfortable' \| 'compact' \| 'dense'` | `'comfortable'` | Semantic sizing preset for built-in toolbar controls |
93
+ | `contentDensity` | `'comfortable' \| 'compact'` | `'comfortable'` | Semantic padding preset for editor and preview content |
94
+ | `imageHydrationAnimation` | `'auto' \| 'initial' \| 'off'` | `'auto'` | Control preview image reveal animation: every render, first render per document path, or never |
95
+ | `initialLayout` | `MdzipWorkspaceLayout` | — | Starting layout: `'preview'`, `'editor'`, `'split'` |
96
+ | `initialColorScheme` | `MdzipColorSchemePreference` | `'system'` | `'light'`, `'dark'` or `'system'` (follows the OS setting live) |
97
+ | `systemColorScheme` | `MdzipSystemColorScheme` | — | Makes the color scheme menu's System choice follow the host's theme instead of the OS setting, with its own `label` and `icon`, e.g. `{ colorScheme: 'dark', label: 'VS Code theme', icon: '<svg…>' }`; changes apply live |
98
+ | `previewMaxWidth` | `MdzipPreviewMaxWidth` | `'default'` | Preview reading-column width: `'narrow'`, `'default'`, `'wide'`, `'full'` or a pixel number; the user can change it from the toolbar's page-width menu |
99
+ | `navigationMode` | `MdzipNavigationMode` | `'editor'` | Package navigation mode |
100
+ | `navigationButtonActive` | `boolean` | `true` | Whether the navigation button is shown |
101
+ | `inlineSvgLinks` | `boolean` | `true` | Shows archive SVGs that contain links inline, so the links can be clicked (draw.io `.drawio.svg` diagrams, for example); other SVGs stay images. Read when the view is created |
102
+ | `hostFileActions` | `readonly MdzipFileAction[]` | — | The host's own items in the file tree's right-click menu on files (`{ id, label, appliesTo?, run }`), e.g. "Open in Another Editor". Also shown as buttons on the card that stands in for a `.drawio` image. Read when the view is created |
103
+ | `markdownRenderer` | `MdzipMarkdownRenderer \| null` | `null` | Custom markdown renderer (keep the reference stable) |
104
+ | `markdownExtensions` | `readonly MdzipMarkdownRenderExtension[]` | `[]` | Markdown pipeline extensions, diffed by `name` — inline arrays are safe |
105
+ | `entryRenderers` | `readonly MdzipEntryRenderer[]` | `[]` | Entry renderers claiming the content area for matching entries, diffed by `id` — inline arrays are safe |
106
+ | `entrySlotPriority` | `number` | `0` | Matching priority of the `#entry` slot relative to `entryRenderers` |
107
+ | `frontMatter` | `MdzipFrontMatterOptions` | `{}` | Front matter panel config (`enabled`, `display`, `collapsible`, `label`) — always registered, diffed by deep equality; inline objects are safe |
108
+ | `externalLinks` | `MdzipExternalLinkPolicy` | — | External-link policy, e.g. `{ target: '_blank' }` (adds `rel="noopener noreferrer"`); optional `rel` and `predicate(href)`. Re-applies without a re-render only when `target`, `rel` or `predicate` change; inline objects are safe |
109
+
110
+ `controls`, density, `imageHydrationAnimation`, and rendering prop changes apply in
111
+ place — they never recreate the workspace view. Line-number visibility changes
112
+ preserve the current CodeMirror document and selection. See the `@mdzip/editor`
113
+ Rendering Extensibility docs for the contracts and lifecycle rules.
114
+
115
+ ### Native entry rendering (`#entry` slot)
116
+
117
+ ```vue
118
+ <MdzipWorkspace :bytes="bytes">
119
+ <template #entry="{ context }">
120
+ <ManifestEditor
121
+ v-if="context.path.toLowerCase() === 'manifest.json'"
122
+ :manifest="context.manifest"
123
+ :editable="context.mode === 'editable'"
124
+ @manifest-change="context.updateManifest"
125
+ />
126
+ </template>
127
+ </MdzipWorkspace>
128
+ ```
129
+
130
+ A slot render that produces no content (its `v-if` is false) delegates to
131
+ `entryRenderers` and the built-in rendering. The slot mounts in a detached
132
+ tree sharing the host app context (plugins, provide/inject); the context is
133
+ reactive, and the tree unmounts on selection change.
134
+
135
+ ## Events
136
+
137
+ | Event | Payload | Description |
138
+ |-------|---------|-------------|
139
+ | `changed` | `MdzipWorkspaceChange` | Emitted when archive bytes change |
140
+ | `saved` | `MdzipWorkspaceSave` | Emitted on Save |
141
+ | `snapshotChanged` | `MdzipWorkspaceSnapshot` | Emitted on any state change |
142
+ | `selectionChanged` | `MdzipWorkspaceSnapshot` | Emitted when the editor selection changes |
143
+ | `dirtyChanged` | `MdzipWorkspaceSnapshot` | Emitted when the dirty flag changes |
144
+ | `validationChanged` | `MdzipWorkspaceSnapshot` | Emitted when validation state changes |
145
+ | `colorSchemeChanged` | `MdzipColorScheme` | Emitted when the color scheme changes |
146
+ | `colorSchemePreferenceChanged` | `MdzipColorSchemePreference` | Emitted when the user picks Light, Dark or System in the toolbar menu |
147
+ | `previewWidthChanged` | `MdzipPreviewWidthChoice` | Emitted when the user picks a width in the toolbar's page-width menu |
148
+ | `previewRendered` | `MdzipWorkspaceSnapshot` | Emitted when the preview HTML is mounted |
149
+ | `assetsHydrated` | `MdzipWorkspaceSnapshot` | Emitted once the mounted preview's images have loaded |
150
+ | `linkActivated` | `MdzipLinkActivatedEvent` | Emitted for every preview link click before built-in handling; call `event.preventDefault()` to take over |
151
+ | `failed` | `unknown` | Emitted on unrecoverable errors |
152
+
153
+ ## Conversion hook
154
+
155
+ `onConversionRequested` is a **function prop** (not an emit, because it must return a value):
156
+ pass `(action: MdzipConversionAction) => boolean | Promise<boolean>`. It fires when the user
157
+ triggers the markdown→MDZ conversion flow (nav button, Insert Image, or image paste on a
158
+ plain `.md`). Return/resolve `true` to take over and suppress the built-in conversion dialog.
159
+
160
+ `onPackRequested` is the same kind of function prop for the folder→.mdz packing
161
+ decision surfaced by the exposed `packFilesAsWorkspace(files, options)` method — fires
162
+ only when the file list contains more than one Markdown file, with the same
163
+ return contract as `onConversionRequested`.
164
+
165
+ ## Image insertion
166
+
167
+ Pass `image-insert-mode="markdown"`, `"ask"`, or `"html"` for the built-in
168
+ image markup flow. Pass `:image-insert-handler="handler"` for host-owned image
169
+ UI; the handler can return Markdown or HTML sizing/alignment settings, return
170
+ `null` to cancel, or return `undefined` to fall back to `imageInsertMode`.
171
+
172
+ Pass `:image-edit-handler="handler"` to let users edit an *existing* image by
173
+ clicking it. Fully opt-in — with no handler, clicking an image does nothing
174
+ and no edit affordance appears; there is no built-in fallback dialog.
175
+
176
+ ## File management (nav pane)
177
+
178
+ With `controls="standalone-editor"` or `"hosted-editor"` (or `fileActions: true` in a custom
179
+ policy), the navigation pane offers a right-click context menu: new `.md` file, new folder,
180
+ rename/move, duplicate, replace, download, copy markdown link, set entry point, set cover
181
+ image, and delete. Files can also be dragged between folders, and OS files can be dropped
182
+ onto the pane. Copy and Download remain available in read-only mode. The same operations are
183
+ exposed on the handle: `removeFile`, `renameFile`, `setEntryPoint`, and `setCoverImage`.
184
+
185
+ ## Imperative API
186
+
187
+ Use a template ref to access the exposed handle:
188
+
189
+ ```vue
190
+ <script setup lang="ts">
191
+ import { ref } from 'vue';
192
+ import { MdzipWorkspace, type MdzipWorkspaceExposed } from '@mdzip/editor-vue';
193
+
194
+ const workspace = ref<MdzipWorkspaceExposed>();
195
+
196
+ async function save() {
197
+ const snapshot = await workspace.value?.flush();
198
+ if (snapshot) {
199
+ await persist(snapshot.bytes);
200
+ workspace.value?.markPersisted();
201
+ }
202
+ }
203
+ </script>
204
+
205
+ <template>
206
+ <MdzipWorkspace ref="workspace" ... />
207
+ </template>
208
+ ```
209
+
210
+ The handle also exposes `whenRendered()`, which resolves once the current preview (including
211
+ its images) is mounted — useful for revealing or animating read-only preview content.
212
+
213
+ ## Links and anchors
214
+
215
+ The `linkActivated` event fires for every preview link click, before the view's own handling, with the
216
+ parsed link (`kind`: `'anchor' | 'document' | 'relative' | 'external'`, plus `path`,
217
+ `anchor`, `targetPath`, `sourcePath`, modifier keys). Call `event.preventDefault()` in the
218
+ handler to route the link yourself; unprevented clicks keep the built-in behavior.
219
+ The handle also exposes `scrollToAnchor(anchor)` (waits for the preview to mount, resolves whether it
220
+ scrolled; safe straight after load), `getAvailableAnchors()`, `openPath(path, { anchor })` (opens another
221
+ file, optionally at an anchor) and `getCurrentPath()`. Changing only `fileName` (e.g. after Save As)
222
+ renames in place without reopening; set `preserveSelectionOnReopen` to stay on the current file when
223
+ the archive content changes. See the
224
+ [`@mdzip/editor` README](https://www.npmjs.com/package/@mdzip/editor#links-and-anchors).
225
+
226
+ See the [`@mdzip/editor`](https://www.npmjs.com/package/@mdzip/editor) package for the full API reference, theming guide, and framework-agnostic usage.
@@ -1,6 +1,6 @@
1
1
  export declare const PACKAGE_INFO: {
2
2
  readonly name: "@mdzip/editor-vue";
3
- readonly version: "2.4.2";
3
+ readonly version: "2.5.0";
4
4
  readonly repositoryUrl: "https://github.com/mdzip-project/mdzip-editor/tree/main/packages/editor-vue";
5
5
  readonly description: "Vue wrapper for the MDZip workspace editor.";
6
6
  };
@@ -1,7 +1,7 @@
1
1
  // Generated from package.json. Do not edit by hand.
2
2
  export const PACKAGE_INFO = {
3
3
  "name": "@mdzip/editor-vue",
4
- "version": "2.4.2",
4
+ "version": "2.5.0",
5
5
  "repositoryUrl": "https://github.com/mdzip-project/mdzip-editor/tree/main/packages/editor-vue",
6
6
  "description": "Vue wrapper for the MDZip workspace editor."
7
7
  };
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "name": "@mdzip/editor-vue",
3
- "version": "2.4.2",
4
- "description": "Vue wrapper for the MDZip workspace editor.",
5
- "license": "Apache-2.0",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/mdzip-project/mdzip-editor.git",
9
- "directory": "packages/editor-vue"
10
- },
11
- "homepage": "https://mdzip.org",
12
- "bugs": {
13
- "url": "https://github.com/mdzip-project/mdzip-editor/issues"
14
- },
15
- "type": "module",
16
- "main": "dist/index.js",
17
- "types": "dist/index.d.ts",
18
- "exports": {
19
- ".": {
20
- "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js"
22
- },
23
- "./diff-view": {
24
- "types": "./dist/diff-view.d.ts",
25
- "import": "./dist/diff-view.js"
26
- }
27
- },
28
- "files": [
29
- "dist"
30
- ],
31
- "scripts": {
32
- "generate:package-info": "node ../../scripts/generate-package-info.mjs",
33
- "prebuild": "npm run generate:package-info",
34
- "build": "tsc -p tsconfig.json",
35
- "test": "vitest run"
36
- },
37
- "dependencies": {
38
- "@mdzip/editor": "^2.4.2"
39
- },
40
- "peerDependencies": {
41
- "vue": ">=3.0.0"
42
- },
43
- "publishConfig": {
44
- "access": "public"
45
- }
46
- }
1
+ {
2
+ "name": "@mdzip/editor-vue",
3
+ "version": "2.5.0",
4
+ "description": "Vue wrapper for the MDZip workspace editor.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/mdzip-project/mdzip-editor.git",
9
+ "directory": "packages/editor-vue"
10
+ },
11
+ "homepage": "https://mdzip.org",
12
+ "bugs": {
13
+ "url": "https://github.com/mdzip-project/mdzip-editor/issues"
14
+ },
15
+ "type": "module",
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./diff-view": {
24
+ "types": "./dist/diff-view.d.ts",
25
+ "import": "./dist/diff-view.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "scripts": {
32
+ "generate:package-info": "node ../../scripts/generate-package-info.mjs",
33
+ "prebuild": "npm run generate:package-info",
34
+ "build": "tsc -p tsconfig.json",
35
+ "test": "vitest run"
36
+ },
37
+ "dependencies": {
38
+ "@mdzip/editor": "^2.5.0"
39
+ },
40
+ "peerDependencies": {
41
+ "vue": ">=3.0.0"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ }
46
+ }