polotno-node 2.12.30 → 2.13.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 +51 -15
- package/dist/assets/html2canvas.esm-Ge7aVWlp.js +5 -0
- package/dist/assets/index-vFr48NCL.js +520 -0
- package/dist/assets/{index.es-CWfYjgqJ.js → index.es-Bm4liNaR.js} +2 -15
- package/dist/assets/purify.es-C65SP4u9.js +2 -0
- package/dist/index.html +1 -1
- package/instance.js +10 -13
- package/package.json +9 -8
- package/dist/assets/html2canvas.esm-B0tyYwQk.js +0 -22
- package/dist/assets/index-l_QMGoMi.js +0 -603
- package/dist/assets/purify.es-B6FQ9oRL.js +0 -2
package/README.md
CHANGED
|
@@ -230,14 +230,30 @@ Timeout for loading fonts. By default it is 6000ms.
|
|
|
230
230
|
const url = await instance.jsonToPDFDataURL(json, { fontLoadTimeout: 10000 });
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
### `attrs.
|
|
233
|
+
### `attrs.richTextEnabled`
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
Enable rich text renderin. By default it is `false`.
|
|
236
236
|
|
|
237
237
|
```js
|
|
238
|
+
const url = await instance.jsonToPDFDataURL(json, {
|
|
239
|
+
richTextEnabled: true,
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### `attrs.htmlTextRenderEnabled` (deprecated)
|
|
244
|
+
|
|
245
|
+
⚠️ **Deprecated:** Use `richTextEnabled` instead. This property is maintained for backward compatibility and works as a fallback.
|
|
246
|
+
|
|
247
|
+
```js
|
|
248
|
+
// Old (deprecated)
|
|
238
249
|
const url = await instance.jsonToPDFDataURL(json, {
|
|
239
250
|
htmlTextRenderEnabled: true,
|
|
240
251
|
});
|
|
252
|
+
|
|
253
|
+
// New (recommended)
|
|
254
|
+
const url = await instance.jsonToPDFDataURL(json, {
|
|
255
|
+
richTextEnabled: true,
|
|
256
|
+
});
|
|
241
257
|
```
|
|
242
258
|
|
|
243
259
|
### `attrs.textVerticalResizeEnabled`
|
|
@@ -326,7 +342,7 @@ You should be able to change config before you call `store.loadJSON` function an
|
|
|
326
342
|
```js
|
|
327
343
|
const url = await instance.run(async (json) => {
|
|
328
344
|
// you can use global "config" object that has some functions from "polotno/config" module
|
|
329
|
-
window.config.
|
|
345
|
+
window.config.setTextVerticalResizeEnabled(true);
|
|
330
346
|
// you can use global "store" object
|
|
331
347
|
store.loadJSON(json);
|
|
332
348
|
return store.toDataURL();
|
|
@@ -347,19 +363,25 @@ console.log(args);
|
|
|
347
363
|
// ['--disable-web-security', '--allow-file-access-from-files', '--disable-gpu', ...]
|
|
348
364
|
```
|
|
349
365
|
|
|
366
|
+
**Platform compatibility:** Using `@sparticuz/chromium` args works best on **Linux** and **macOS**. On **Windows**, these args may not work as expected, so the library automatically skips them on Windows. When manually combining args, be aware of platform differences.
|
|
367
|
+
|
|
350
368
|
### Using with custom browser
|
|
351
369
|
|
|
352
|
-
When you want to use your own browser instance (e.g., with browserless.io or custom puppeteer configuration), you
|
|
370
|
+
When you want to use your own browser instance (e.g., with browserless.io or custom puppeteer configuration), you should combine `chrome.args` (the base defaults) with polotno-node's `args` (additional optimizations):
|
|
353
371
|
|
|
354
372
|
```js
|
|
355
373
|
const { createInstance, args } = require('polotno-node');
|
|
374
|
+
const chromium = require('@sparticuz/chromium');
|
|
356
375
|
const puppeteer = require('puppeteer-core');
|
|
357
376
|
|
|
358
|
-
//
|
|
377
|
+
// Combine chrome.args (base defaults) with polotno-node's args (optimizations)
|
|
378
|
+
// This works best on Linux/macOS
|
|
359
379
|
const browser = await puppeteer.launch({
|
|
360
|
-
args: args,
|
|
380
|
+
args: [...chromium.args, ...args],
|
|
381
|
+
defaultViewport: chromium.defaultViewport,
|
|
382
|
+
executablePath: await chromium.executablePath(),
|
|
361
383
|
headless: true,
|
|
362
|
-
|
|
384
|
+
ignoreHTTPSErrors: true,
|
|
363
385
|
});
|
|
364
386
|
|
|
365
387
|
const instance = await createInstance({
|
|
@@ -368,37 +390,48 @@ const instance = await createInstance({
|
|
|
368
390
|
});
|
|
369
391
|
```
|
|
370
392
|
|
|
393
|
+
**Note:** `polotno-node`'s `args` are designed to work on top of `@sparticuz/chromium`'s args for optimal server-side rendering on Linux/macOS environments.
|
|
394
|
+
|
|
371
395
|
### Modifying default arguments
|
|
372
396
|
|
|
373
|
-
If you need to add or
|
|
397
|
+
If you need to add, remove, or replace specific arguments (Linux/macOS):
|
|
374
398
|
|
|
375
399
|
```js
|
|
376
400
|
const { createInstance, args } = require('polotno-node');
|
|
401
|
+
const chromium = require('@sparticuz/chromium');
|
|
377
402
|
const puppeteer = require('puppeteer-core');
|
|
378
403
|
|
|
379
|
-
// Add custom arguments
|
|
404
|
+
// Add custom arguments on top of chrome.args and polotno args
|
|
380
405
|
const browser = await puppeteer.launch({
|
|
381
|
-
args: [...args, '--custom-arg', '--another-custom-arg'],
|
|
406
|
+
args: [...chromium.args, ...args, '--custom-arg', '--another-custom-arg'],
|
|
407
|
+
defaultViewport: chromium.defaultViewport,
|
|
408
|
+
executablePath: await chromium.executablePath(),
|
|
382
409
|
});
|
|
383
410
|
|
|
384
|
-
// Remove specific arguments
|
|
411
|
+
// Remove specific arguments from polotno args
|
|
385
412
|
const filteredArgs = args.filter((arg) => arg !== '--disable-gpu');
|
|
386
413
|
const browser2 = await puppeteer.launch({
|
|
387
|
-
args: filteredArgs,
|
|
414
|
+
args: [...chromium.args, ...filteredArgs],
|
|
415
|
+
defaultViewport: chromium.defaultViewport,
|
|
416
|
+
executablePath: await chromium.executablePath(),
|
|
388
417
|
});
|
|
389
418
|
|
|
390
|
-
// Replace specific arguments
|
|
419
|
+
// Replace specific arguments in polotno args
|
|
391
420
|
const customArgs = args.map((arg) =>
|
|
392
421
|
arg === '--disable-web-security' ? '--enable-web-security' : arg
|
|
393
422
|
);
|
|
394
423
|
const browser3 = await puppeteer.launch({
|
|
395
|
-
args: customArgs,
|
|
424
|
+
args: [...chromium.args, ...customArgs],
|
|
425
|
+
defaultViewport: chromium.defaultViewport,
|
|
426
|
+
executablePath: await chromium.executablePath(),
|
|
396
427
|
});
|
|
397
428
|
```
|
|
398
429
|
|
|
430
|
+
**Note:** These examples assume Linux/macOS environment where `chromium.args` work properly.
|
|
431
|
+
|
|
399
432
|
### Combining with `browserArgs` option
|
|
400
433
|
|
|
401
|
-
When using `createInstance()` or `createBrowser()`, you can provide additional arguments via `browserArgs` option.
|
|
434
|
+
When using `createInstance()` or `createBrowser()`, you can provide additional arguments via `browserArgs` option. Internally, this automatically combines `chrome.args` + `args` + your custom `browserArgs`:
|
|
402
435
|
|
|
403
436
|
```js
|
|
404
437
|
const { createInstance } = require('polotno-node');
|
|
@@ -407,6 +440,7 @@ const instance = await createInstance({
|
|
|
407
440
|
key: 'your-key',
|
|
408
441
|
browserArgs: ['--custom-arg', '--another-arg'],
|
|
409
442
|
});
|
|
443
|
+
// Internally merges: chrome.args + polotno args + browserArgs
|
|
410
444
|
```
|
|
411
445
|
|
|
412
446
|
## Your own client
|
|
@@ -514,6 +548,7 @@ import { createInstance, args } from 'polotno-node';
|
|
|
514
548
|
export const handler = async (event) => {
|
|
515
549
|
const browser = await puppeteer.launch({
|
|
516
550
|
// Combine chromium args with polotno-node's optimized args
|
|
551
|
+
// Works well on AWS Lambda (Linux environment)
|
|
517
552
|
args: [...chromium.args, ...args],
|
|
518
553
|
defaultViewport: chromium.defaultViewport,
|
|
519
554
|
executablePath: await chromium.executablePath(),
|
|
@@ -632,6 +667,7 @@ const puppeteer = require('puppeteer-core');
|
|
|
632
667
|
const makeInstance = async () => {
|
|
633
668
|
const browser = await puppeteer.launch({
|
|
634
669
|
// Combine chromium args with polotno-node's optimized args
|
|
670
|
+
// Best for Linux/macOS environments
|
|
635
671
|
args: [...chromium.args, ...args],
|
|
636
672
|
defaultViewport: chromium.defaultViewport,
|
|
637
673
|
executablePath: await chromium.executablePath(
|