@zumer/snapdom 3.2.1-dev.5 → 3.3.1-dev.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 +28 -6
- package/dist/snapdom.js +10 -10
- package/dist/snapdom.mjs +9 -9
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<img src="https://raw.githubusercontent.com/zumerlab/snapdom/main/docs/assets/newhero.png" width="80%">
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
|
-
|
|
7
6
|
<p align="center">
|
|
8
7
|
<a href="https://snapdom.dev">
|
|
9
8
|
<img alt="Website" src="https://img.shields.io/badge/Website-snapdom.dev-2ea44f?style=flat-square">
|
|
@@ -42,7 +41,7 @@ Export images and canvas with the core. Use plugins for self-contained HTML, pag
|
|
|
42
41
|
|
|
43
42
|
[Documentation and demos](https://snapdom.dev/) · [Technical features](FEATURES.md) · [Official plugins](packages/plugins/README.md) · [简体中文](README_CN.md)
|
|
44
43
|
|
|
45
|
-
This checkout documents **v3.x.x**. The migration guide below compares it with **v2.x.x**. The [v2 source](https://github.com/zumerlab/snapdom/tree/v2)
|
|
44
|
+
This checkout documents **v3.x.x**. The migration guide below compares it with **v2.x.x**. The [v2 source](https://github.com/zumerlab/snapdom/tree/v2) remains available.
|
|
46
45
|
|
|
47
46
|
## What you can build
|
|
48
47
|
|
|
@@ -52,7 +51,8 @@ This checkout documents **v3.x.x**. The migration guide below compares it with *
|
|
|
52
51
|
| Reuse a capture in a texture, overlay or transition | Canvas plus capture geometry | Core |
|
|
53
52
|
| Save a page fragment for later display | HTML with captured styles and fonts | `html-export` plugin |
|
|
54
53
|
| Give an agent or a log a view of page content | Text/JSON context, or an image with an element map | `context-export` / `agent-map` plugins |
|
|
55
|
-
| Download a document or record changing content |
|
|
54
|
+
| Download a document or record changing content | Searchable, paginated PDF, animated GIF or browser-encoded video | `pdf` / `gif-export` / `video-export` plugins |
|
|
55
|
+
| Export editable artwork or paste into Figma | Native SVG shapes and text, or a Figma clipboard payload | `vector` plugin |
|
|
56
56
|
|
|
57
57
|
Image, HTML and context exports use the captured state. GIF and video plugins record the live element over time.
|
|
58
58
|
|
|
@@ -81,12 +81,14 @@ The result keeps that capture even if the source element later changes. Call `sn
|
|
|
81
81
|
|
|
82
82
|
## Installation
|
|
83
83
|
|
|
84
|
-
Install the core and, when you need them, the official plugins;
|
|
84
|
+
Install the core and, when you need them, the official plugins; choose a core supported by the plugins’ peer dependency:
|
|
85
85
|
|
|
86
86
|
```sh
|
|
87
87
|
npm i @zumer/snapdom@latest @zumer/snapdom-plugins@latest
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
+
Plugins 4.x in this checkout require core 3.x. The full PDF and Vector exporters are open source under MIT here, but have not been published to npm; the `@latest` command above does not install these new exporters. Run `npm run compile` and `npm run site` to try them against the local build.
|
|
91
|
+
|
|
90
92
|
Or load it in a browser:
|
|
91
93
|
|
|
92
94
|
```html
|
|
@@ -213,7 +215,7 @@ for (let y = 0; y < h0; y += pieceHeight) {
|
|
|
213
215
|
|
|
214
216
|
### Export HTML or structured context
|
|
215
217
|
|
|
216
|
-
Official plugins are published separately as `@zumer/snapdom-plugins
|
|
218
|
+
Official plugins are published separately as `@zumer/snapdom-plugins`. Plugins 4.x in this checkout require core 3.x and include the full PDF and Vector exporters under MIT. Their sources live in `packages/plugins/`.
|
|
217
219
|
|
|
218
220
|
```js
|
|
219
221
|
import { htmlExport, contextExport } from '@zumer/snapdom-plugins';
|
|
@@ -228,6 +230,25 @@ const context = await result.toContext();
|
|
|
228
230
|
|
|
229
231
|
The same plugin system supports overlays, redaction and custom exporters. Local plugins override global plugins by name. See the [official plugin reference](packages/plugins/README.md) and [plugin specification](PLUGIN_SPEC.md).
|
|
230
232
|
|
|
233
|
+
### Export PDF and editable vectors
|
|
234
|
+
|
|
235
|
+
These examples use plugins 4.x from this checkout. PDF returns a `Blob` with searchable, selectable text, links, pagination and optional form fields. Vector returns an SVG string without `<foreignObject>`, preserving supported shapes and editable text.
|
|
236
|
+
|
|
237
|
+
```js
|
|
238
|
+
import { snapdom } from '@zumer/snapdom';
|
|
239
|
+
import { pdf } from '@zumer/snapdom-plugins/pdf';
|
|
240
|
+
import { vector } from '@zumer/snapdom-plugins/vector';
|
|
241
|
+
|
|
242
|
+
const documentCapture = await snapdom(element, { plugins: [pdf()] });
|
|
243
|
+
const blob = await documentCapture.toPdf({ page: 'a4', margin: 36 });
|
|
244
|
+
|
|
245
|
+
const artwork = await snapdom(element, { plugins: [vector()] });
|
|
246
|
+
const svg = await artwork.toVector();
|
|
247
|
+
copyButton.addEventListener('click', () => artwork.toFigma());
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Pass PDF capture settings to `pdf()` and paper, margin and download settings to `toPdf()`. `toFigma()` returns `Promise<void>` and needs the async clipboard API on HTTPS or localhost, called from a user action. Vector requires a connected source element; unsupported paint is diagnosed by the engine. See the [PDF reference](packages/plugins/pdf/REFERENCE.md) and [Vector contract](packages/plugins/vector/CONTRACT.md).
|
|
251
|
+
|
|
231
252
|
### Capture HTML strings
|
|
232
253
|
|
|
233
254
|
```js
|
|
@@ -347,7 +368,8 @@ For a useful comparison, use the same scene, output format, scale and DPR. Compa
|
|
|
347
368
|
|
|
348
369
|
## Documentation
|
|
349
370
|
|
|
350
|
-
- [
|
|
371
|
+
- [Interactive Playground](https://snapdom.dev/playground/), [PDF demos](https://snapdom.dev/pro/pdf/) and [Vector demos](https://snapdom.dev/pro/vector/)
|
|
372
|
+
- [v2 source](https://github.com/zumerlab/snapdom/tree/v2)
|
|
351
373
|
- [API](https://snapdom.dev/docs/api/) and [options](https://snapdom.dev/docs/options/)
|
|
352
374
|
- [Framework guides](https://snapdom.dev/guides/) and [how-to examples](https://snapdom.dev/how-to/)
|
|
353
375
|
- [Official plugins](packages/plugins/README.md), [plugin specification](PLUGIN_SPEC.md) and [contributing plugins](CONTRIBUTING_PLUGINS.md)
|