@mdzip/editor 1.4.4 → 1.4.6
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/AGENTS.md +48 -46
- package/README.md +554 -547
- package/dist/library-info.d.ts +1 -1
- package/dist/library-info.js +1 -1
- package/dist/rendering.d.ts +23 -0
- package/dist/rendering.d.ts.map +1 -1
- package/dist/rendering.js +112 -4
- package/dist/rendering.js.map +1 -1
- package/dist/view.d.ts +63 -0
- package/dist/view.d.ts.map +1 -1
- package/dist/view.js +501 -352
- package/dist/view.js.map +1 -1
- package/dist/workspace-view.d.ts +1 -0
- package/dist/workspace-view.d.ts.map +1 -1
- package/dist/workspace-view.js +14 -3
- package/dist/workspace-view.js.map +1 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
# Notes for AI Agents
|
|
2
|
-
|
|
3
|
-
Read `README.md` before looking at source or type files.
|
|
4
|
-
|
|
5
|
-
## Key facts that are easy to miss
|
|
6
|
-
|
|
7
|
-
**`open()` vs `openWorkspace()`**
|
|
8
|
-
|
|
9
|
-
`open(bytes)` parses the ZIP archive in the browser and is slow for large files.
|
|
10
|
-
`openWorkspace(workspace)` skips the parse entirely. Use it when the host has already parsed the archive on the native side.
|
|
11
|
-
|
|
12
|
-
**Paste in markdown source files**
|
|
13
|
-
|
|
14
|
-
`workspace.pasteImage()` returns `null` for `sourceFormat === 'markdown'` — it does not throw. The paste event handler automatically shows the conversion dialog by calling `executeCommand('insert-image')`.
|
|
15
|
-
|
|
16
|
-
**`MdzWorkspace` runtime shape**
|
|
17
|
-
|
|
18
|
-
The runtime workspace object has fields not in the TypeScript type: `validation`, `orphanedAssets`, and `asset.kind`. Serialise by spreading the full runtime value, not just declared fields.
|
|
19
|
-
|
|
20
|
-
**VS Code preset**
|
|
21
|
-
|
|
22
|
-
Use `controls: { preset: 'hosted-editor' }` for VS Code and other native hosts.
|
|
23
|
-
|
|
24
|
-
**Performance**
|
|
25
|
-
|
|
26
|
-
`archiveBytesWithPendingText()` skips redundant ZIP rebuilds when pending text has not changed. This optimization is critical for large documents during paste operations and similar workflows that trigger multiple rebuild cycles.
|
|
27
|
-
|
|
28
|
-
**Documents vs assets (since 1.3.0)**
|
|
29
|
-
|
|
30
|
-
Markdown files live in `workspace.documents`; everything else lives in `workspace.assets`. `removeAsset()` only removes assets — use `removeFile()` to delete either kind (it refuses the entry-point document and `manifest.json`). `renameFile()` also moves files and rewrites markdown references. `setEntryPoint()` and `setCoverImage()` update the manifest through `updateManifest`.
|
|
31
|
-
|
|
32
|
-
**Nav-pane file management gating (since 1.3.0)**
|
|
33
|
-
|
|
34
|
-
The context menu's mutating items and drag-and-drop are gated by the `fileActions` control-policy flag (true in `standalone-editor`/`hosted-editor`), not by `orphanActions`. Copy/Download items are non-mutating and appear even in read-only mode. Files are draggable whenever the workspace is editable — dragging onto the editor inserts a markdown link and does not require `fileActions`.
|
|
35
|
-
|
|
36
|
-
**`onConversionRequested` hook (since 1.3.0)**
|
|
37
|
-
|
|
38
|
-
Hosts intercept the markdown→MDZ conversion flow by returning/resolving `true` from `onConversionRequested(action)`. This replaces the old capture-phase paste workaround in VS Code-style hosts. A rejecting hook reports to `onFailed` and falls back to the built-in dialog.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
# Notes for AI Agents
|
|
2
|
+
|
|
3
|
+
Read `README.md` before looking at source or type files.
|
|
4
|
+
|
|
5
|
+
## Key facts that are easy to miss
|
|
6
|
+
|
|
7
|
+
**`open()` vs `openWorkspace()`**
|
|
8
|
+
|
|
9
|
+
`open(bytes)` parses the ZIP archive in the browser and is slow for large files.
|
|
10
|
+
`openWorkspace(workspace)` skips the parse entirely. Use it when the host has already parsed the archive on the native side.
|
|
11
|
+
|
|
12
|
+
**Paste in markdown source files**
|
|
13
|
+
|
|
14
|
+
`workspace.pasteImage()` returns `null` for `sourceFormat === 'markdown'` — it does not throw. The paste event handler automatically shows the conversion dialog by calling `executeCommand('insert-image')`.
|
|
15
|
+
|
|
16
|
+
**`MdzWorkspace` runtime shape**
|
|
17
|
+
|
|
18
|
+
The runtime workspace object has fields not in the TypeScript type: `validation`, `orphanedAssets`, and `asset.kind`. Serialise by spreading the full runtime value, not just declared fields.
|
|
19
|
+
|
|
20
|
+
**VS Code preset**
|
|
21
|
+
|
|
22
|
+
Use `controls: { preset: 'hosted-editor' }` for VS Code and other native hosts.
|
|
23
|
+
|
|
24
|
+
**Performance**
|
|
25
|
+
|
|
26
|
+
`archiveBytesWithPendingText()` skips redundant ZIP rebuilds when pending text has not changed. This optimization is critical for large documents during paste operations and similar workflows that trigger multiple rebuild cycles.
|
|
27
|
+
|
|
28
|
+
**Documents vs assets (since 1.3.0)**
|
|
29
|
+
|
|
30
|
+
Markdown files live in `workspace.documents`; everything else lives in `workspace.assets`. `removeAsset()` only removes assets — use `removeFile()` to delete either kind (it refuses the entry-point document and `manifest.json`). `renameFile()` also moves files and rewrites markdown references. `setEntryPoint()` and `setCoverImage()` update the manifest through `updateManifest`.
|
|
31
|
+
|
|
32
|
+
**Nav-pane file management gating (since 1.3.0)**
|
|
33
|
+
|
|
34
|
+
The context menu's mutating items and drag-and-drop are gated by the `fileActions` control-policy flag (true in `standalone-editor`/`hosted-editor`), not by `orphanActions`. Copy/Download items are non-mutating and appear even in read-only mode. Files are draggable whenever the workspace is editable — dragging onto the editor inserts a markdown link and does not require `fileActions`.
|
|
35
|
+
|
|
36
|
+
**`onConversionRequested` hook (since 1.3.0)**
|
|
37
|
+
|
|
38
|
+
Hosts intercept the markdown→MDZ conversion flow by returning/resolving `true` from `onConversionRequested(action)`. This replaces the old capture-phase paste workaround in VS Code-style hosts. A rejecting hook reports to `onFailed` and falls back to the built-in dialog.
|
|
39
|
+
|
|
40
|
+
A host that writes a linked image file itself (plain `.md`) can reuse the editor's insert flow (`imageInsertHandler`, or the `'ask'` Markdown/HTML + alt text + size + alignment dialog): `await context.promptImageInsert({ bytes, fileName, altText })` resolves the decision (`null` = cancelled, write nothing), then `context.formatImageInsert(src, decision)` returns the text for `context.insertMarkdown()`. `src` is used as given — URL-encode it. Ask before writing the file so cancel leaves nothing behind. Since 1.4.6.
|
|
41
|
+
|
|
42
|
+
**`packFilesAsWorkspace` / `onPackRequested` hook**
|
|
43
|
+
|
|
44
|
+
`view.packFilesAsWorkspace(files, options)` packs a host-collected file list (e.g. from a folder picker) into a new archive. The hook is only consulted when `files` contains more than one Markdown file — the zero/one-Markdown fast path always packs Document mode directly, no hook call, no dialog. Document mode opens the packed archive in the view; Project mode does **not** auto-open — it returns `archiveBytes` for the host to save first, since only the host knows where a project archive belongs. Same `true`/`false`/throw contract as `onConversionRequested`.
|
|
45
|
+
|
|
46
|
+
**Preview code-block chrome (since 1.3.16)**
|
|
47
|
+
|
|
48
|
+
Rendered code blocks get a language header, a copy button, and (past 15 lines) a collapse toggle, gated by the `codeBlockTools` control-policy flag (default `true` everywhere, including `preview`). This is wired into `mountPreviewHtml`/`mountProgressivePreview` directly, not a `markdownExtensions` entry — don't confuse it with `formatting.codeBlock`, which is the unrelated editor-toolbar insert-code-block control.
|