@nutrient-sdk/document-authoring 1.7.1 → 1.8.0-preview.202507151230.e2f50a717d658a927bf4a773479bbf4c53603889

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
@@ -78,7 +78,7 @@ the SDK via `npm`).
78
78
 
79
79
  ### Example
80
80
 
81
- You can download an example project demoing both TypeScript and JavaScript integration from [here](https://document-authoring.cdn.nutrient.io/releases/document-authoring-1.7.1-example.zip), unzip it and run:
81
+ You can download an example project demoing both TypeScript and JavaScript integration from [here](https://document-authoring.cdn.staging.nutrient.io/releases/document-authoring-1.8.0-preview.202507151230.e2f50a717d658a927bf4a773479bbf4c53603889-example.zip), unzip it and run:
82
82
 
83
83
  ```bash
84
84
  npm install
@@ -92,7 +92,7 @@ By default, the Document Authoring SDK will fetch the required files (fonts, emo
92
92
 
93
93
  ### Self-hosting the assets
94
94
 
95
- To host the assets on your own infrastructure you can download them from [here](https://document-authoring.cdn.nutrient.io/releases/document-authoring-1.7.1-assets.zip) and deploy them to a suitable location.
95
+ To host the assets on your own infrastructure you can download them from [here](https://document-authoring.cdn.staging.nutrient.io/releases/document-authoring-1.8.0-preview.202507151230.e2f50a717d658a927bf4a773479bbf4c53603889-assets.zip) and deploy them to a suitable location.
96
96
  Provide an appropriate base path when initializing the Document Authoring SDK.
97
97
 
98
98
  #### Example:
package/lib/docauth.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const t={type:"default-index"},e=async t=>(await(async t=>{const e=new URL(t??"https://document-authoring.cdn.nutrient.io/2025/1/",window.location.href).href,a=new URL("docauth-impl-bb7a265a8ccdb134.js",e).href;return import(
1
+ const t={type:"default-index"},e=async t=>(await(async t=>{const e=new URL(t??"https://document-authoring.cdn.staging.nutrient.io/2025/1/",window.location.href).href,a=new URL("docauth-impl-d7a44870346ca907.js",e).href;return import(
2
2
  /*webpackIgnore: true*/
3
3
  /* @vite-ignore */
4
4
  a)})(t?.assets?.base)).createDocAuthSystem(t);var a={createDocAuthSystem:e,defaultFontIndex:t};export{e as createDocAuthSystem,a as default,t as defaultFontIndex};
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).DocAuth={})}(this,(function(e){"use strict";const t={type:"default-index"},n=async e=>(await(async e=>{const t=new URL(e??"https://document-authoring.cdn.nutrient.io/2025/1/",window.location.href).href,n=new URL("docauth-impl-bb7a265a8ccdb134.js",t).href;return import(
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).DocAuth={})}(this,(function(e){"use strict";const t={type:"default-index"},n=async e=>(await(async e=>{const t=new URL(e??"https://document-authoring.cdn.staging.nutrient.io/2025/1/",window.location.href).href,n=new URL("docauth-impl-d7a44870346ca907.js",t).href;return import(
2
2
  /*webpackIgnore: true*/
3
3
  /* @vite-ignore */
4
4
  n)})(e?.assets?.base)).createDocAuthSystem(e);var o={createDocAuthSystem:n,defaultFontIndex:t};e.createDocAuthSystem=n,e.default=o,e.defaultFontIndex=t,Object.defineProperty(e,"__esModule",{value:!0})}));
package/lib/index.d.cts CHANGED
@@ -80,8 +80,14 @@ export declare type CreateEditorOptions = {
80
80
  * See {@link UIOptions}
81
81
  */
82
82
  ui?: UIOptions;
83
-
84
-
83
+ /**
84
+ * @internal
85
+ */
86
+ __hideDOCXDownload?: boolean;
87
+ /**
88
+ * @internal
89
+ */
90
+ __hidePDFDownload?: boolean;
85
91
  };
86
92
 
87
93
  /**
@@ -136,7 +142,10 @@ export declare type DocAuthDocument = {
136
142
  * Exports a snapshot of the current document as a DOCX file.
137
143
  */
138
144
  exportDOCX(options?: ExportDOCXOptions): Promise<ArrayBuffer>;
139
-
145
+ /**
146
+ * @alpha
147
+ */
148
+ transaction<T = void>(callback: TransactionCallback<T>): Promise<T>;
140
149
  /**
141
150
  * The `DocAuthSystem` this document is bound to.
142
151
  */
@@ -343,6 +352,190 @@ export declare type ImportDOCXOptions = {
343
352
  */
344
353
  export declare type Locale = 'en' | 'fr' | 'de';
345
354
 
355
+ /**
356
+ * @alpha
357
+ */
358
+ export declare namespace Programmatic {
359
+ export type Range = {
360
+ begin: number;
361
+ end?: number;
362
+ };
363
+ export type Formatting = {
364
+ font: string | null;
365
+ fontSize: number | null;
366
+ bold: boolean | null;
367
+ italic: boolean | null;
368
+ color: string | null;
369
+ highlight: string | null;
370
+ strikeout: boolean | null;
371
+ underline: boolean | null;
372
+ };
373
+ export type SearchFor = string | RegExp;
374
+ export type Replacement = {
375
+ text?: string;
376
+ formatting?: Partial<Formatting>;
377
+ };
378
+ export type ReplaceFn = (value: string) => Replacement | string;
379
+ export type ReplacementOrReplaceFn = Replacement | ReplaceFn | string;
380
+ export type ReplaceTextSignature = (searchFor: SearchFor, replace: ReplacementOrReplaceFn) => number;
381
+ export type SearchResult = {
382
+ range: Range;
383
+ text: string;
384
+ };
385
+ export type TextView = {
386
+ getPlainText(range?: Range): string;
387
+ searchText(searchFor: SearchFor, after?: Range): SearchResult | undefined;
388
+ replaceText: ReplaceTextSignature;
389
+ setText(value: string, range?: Range): Range;
390
+ setFormatting(formatting: Partial<Formatting>, range?: Range): void;
391
+ inlines(): RangeInline[];
392
+ addLineBreak(insertionPoint?: {
393
+ placement: 'before' | 'after';
394
+ range: Range;
395
+ }): LineBreak;
396
+ addInlineText(text: string, insertionPoint?: {
397
+ placement: 'before' | 'after';
398
+ range: Range;
399
+ }): InlineText;
400
+ removeInline(index?: number): Inline | undefined;
401
+ };
402
+ export type Extent = {
403
+ width: number;
404
+ height: number;
405
+ };
406
+ export type Image = {
407
+ type: 'image';
408
+ extent(): Extent;
409
+ setExtent(extent: Partial<Extent>): void;
410
+ };
411
+ export type Field = {
412
+ type: 'field';
413
+ };
414
+ export type Footnote = {
415
+ type: 'footnote';
416
+ };
417
+ export type FootnoteRef = {
418
+ type: 'footnote/ref';
419
+ };
420
+ export type Endnote = {
421
+ type: 'endnote';
422
+ };
423
+ export type EndnoteRef = {
424
+ type: 'endnote/ref';
425
+ };
426
+ export type LineBreak = {
427
+ type: 'line-break';
428
+ };
429
+ export type PageBreak = {
430
+ type: 'page-break';
431
+ };
432
+ export type Tab = {
433
+ type: 'tab';
434
+ };
435
+ export type Separator = {
436
+ type: 'sep';
437
+ };
438
+ export type InlineText = {
439
+ type: 'text';
440
+ plainText(): string;
441
+ formatting(): Formatting;
442
+ };
443
+ export type Inline = InlineText | Tab | Separator | LineBreak | PageBreak | Image | Field | Footnote | FootnoteRef | Endnote | EndnoteRef;
444
+ export type RangeInline = {
445
+ range: Range;
446
+ inline: Inline;
447
+ };
448
+ export type Paragraph = {
449
+ type: 'paragraph';
450
+ asTextView(): TextView;
451
+ replaceText: ReplaceTextSignature;
452
+ };
453
+ export type TableCell = BlockLevelContainer;
454
+ export type TableRow = {
455
+ cells(): TableCell[];
456
+ addCell(index?: number): TableCell;
457
+ removeCell(index: number): TableCell | undefined;
458
+ replaceText: ReplaceTextSignature;
459
+ };
460
+ export type Table = {
461
+ type: 'table';
462
+ rows(): TableRow[];
463
+ addRow(index?: number): TableRow;
464
+ removeRow(index: number): TableRow | undefined;
465
+ replaceText: ReplaceTextSignature;
466
+ };
467
+ export type BlockLevel = Paragraph | Table;
468
+ export type BlockLevelContainer = {
469
+ blocklevels(): BlockLevel[];
470
+ addParagraph(index?: number): Paragraph;
471
+ addTable(index?: number): Table;
472
+ removeElement(index: number): BlockLevel | undefined;
473
+ replaceText: ReplaceTextSignature;
474
+ };
475
+ export type PageSize = {
476
+ width: number;
477
+ height: number;
478
+ };
479
+ export type PageMargins = {
480
+ left: number;
481
+ right: number;
482
+ top: number;
483
+ bottom: number;
484
+ };
485
+ export type PageSetup = {
486
+ setPageSize(size: Partial<PageSize>): void;
487
+ setPageMargins(margins: Partial<PageMargins>): void;
488
+ pageSize(): PageSize;
489
+ pageMargins(): PageMargins;
490
+ };
491
+ export type HeaderFooter = BlockLevelContainer;
492
+ export type HeadersFooters = {
493
+ default(): HeaderFooter | null;
494
+ first(): HeaderFooter | null;
495
+ even(): HeaderFooter | null;
496
+ replaceText: ReplaceTextSignature;
497
+ };
498
+ export type HeadersAndFooters = {
499
+ headers(): HeadersFooters;
500
+ footers(): HeadersFooters;
501
+ replaceText: ReplaceTextSignature;
502
+ };
503
+ export type Section = {
504
+ pageSetup(): PageSetup;
505
+ headersAndFooters(): HeadersAndFooters;
506
+ content(): BlockLevelContainer;
507
+ };
508
+ export type Body = {
509
+ sections(): Section[];
510
+ addSection(index?: number): Section;
511
+ removeSection(index: number): Section | undefined;
512
+ replaceText: ReplaceTextSignature;
513
+ };
514
+ export type Document = {
515
+ body(): Body;
516
+ replaceText: ReplaceTextSignature;
517
+ };
518
+ {};
519
+ }
520
+
521
+ /**
522
+ * @alpha
523
+ */
524
+ export declare type TransactionCallback<T = void> = (context: {
525
+ draft: Programmatic.Document;
526
+ }) => Promise<TransactionResult<T>>;
527
+
528
+ /**
529
+ * @alpha
530
+ */
531
+ export declare type TransactionResult<T = void> = undefined | boolean | {
532
+ commit: boolean;
533
+ result: T;
534
+ } | Promise<undefined | boolean | {
535
+ commit: boolean;
536
+ result: T;
537
+ }>;
538
+
346
539
  /**
347
540
  * Configuration options for the user interface.
348
541
  *
@@ -374,6 +567,16 @@ export declare type UIOptions = {
374
567
  */
375
568
  enabled: boolean;
376
569
  };
570
+ /**
571
+ * @internal
572
+ *
573
+ * Initial zoom level for the editor.
574
+ *
575
+ * Valid range is 0.5 to 4.0.
576
+ *
577
+ * @defaultValue `1`
578
+ */
579
+ initialZoom?: number;
377
580
  };
378
581
 
379
582
  /**
package/lib/index.d.mts CHANGED
@@ -80,8 +80,14 @@ export declare type CreateEditorOptions = {
80
80
  * See {@link UIOptions}
81
81
  */
82
82
  ui?: UIOptions;
83
-
84
-
83
+ /**
84
+ * @internal
85
+ */
86
+ __hideDOCXDownload?: boolean;
87
+ /**
88
+ * @internal
89
+ */
90
+ __hidePDFDownload?: boolean;
85
91
  };
86
92
 
87
93
  /**
@@ -136,7 +142,10 @@ export declare type DocAuthDocument = {
136
142
  * Exports a snapshot of the current document as a DOCX file.
137
143
  */
138
144
  exportDOCX(options?: ExportDOCXOptions): Promise<ArrayBuffer>;
139
-
145
+ /**
146
+ * @alpha
147
+ */
148
+ transaction<T = void>(callback: TransactionCallback<T>): Promise<T>;
140
149
  /**
141
150
  * The `DocAuthSystem` this document is bound to.
142
151
  */
@@ -343,6 +352,190 @@ export declare type ImportDOCXOptions = {
343
352
  */
344
353
  export declare type Locale = 'en' | 'fr' | 'de';
345
354
 
355
+ /**
356
+ * @alpha
357
+ */
358
+ export declare namespace Programmatic {
359
+ export type Range = {
360
+ begin: number;
361
+ end?: number;
362
+ };
363
+ export type Formatting = {
364
+ font: string | null;
365
+ fontSize: number | null;
366
+ bold: boolean | null;
367
+ italic: boolean | null;
368
+ color: string | null;
369
+ highlight: string | null;
370
+ strikeout: boolean | null;
371
+ underline: boolean | null;
372
+ };
373
+ export type SearchFor = string | RegExp;
374
+ export type Replacement = {
375
+ text?: string;
376
+ formatting?: Partial<Formatting>;
377
+ };
378
+ export type ReplaceFn = (value: string) => Replacement | string;
379
+ export type ReplacementOrReplaceFn = Replacement | ReplaceFn | string;
380
+ export type ReplaceTextSignature = (searchFor: SearchFor, replace: ReplacementOrReplaceFn) => number;
381
+ export type SearchResult = {
382
+ range: Range;
383
+ text: string;
384
+ };
385
+ export type TextView = {
386
+ getPlainText(range?: Range): string;
387
+ searchText(searchFor: SearchFor, after?: Range): SearchResult | undefined;
388
+ replaceText: ReplaceTextSignature;
389
+ setText(value: string, range?: Range): Range;
390
+ setFormatting(formatting: Partial<Formatting>, range?: Range): void;
391
+ inlines(): RangeInline[];
392
+ addLineBreak(insertionPoint?: {
393
+ placement: 'before' | 'after';
394
+ range: Range;
395
+ }): LineBreak;
396
+ addInlineText(text: string, insertionPoint?: {
397
+ placement: 'before' | 'after';
398
+ range: Range;
399
+ }): InlineText;
400
+ removeInline(index?: number): Inline | undefined;
401
+ };
402
+ export type Extent = {
403
+ width: number;
404
+ height: number;
405
+ };
406
+ export type Image = {
407
+ type: 'image';
408
+ extent(): Extent;
409
+ setExtent(extent: Partial<Extent>): void;
410
+ };
411
+ export type Field = {
412
+ type: 'field';
413
+ };
414
+ export type Footnote = {
415
+ type: 'footnote';
416
+ };
417
+ export type FootnoteRef = {
418
+ type: 'footnote/ref';
419
+ };
420
+ export type Endnote = {
421
+ type: 'endnote';
422
+ };
423
+ export type EndnoteRef = {
424
+ type: 'endnote/ref';
425
+ };
426
+ export type LineBreak = {
427
+ type: 'line-break';
428
+ };
429
+ export type PageBreak = {
430
+ type: 'page-break';
431
+ };
432
+ export type Tab = {
433
+ type: 'tab';
434
+ };
435
+ export type Separator = {
436
+ type: 'sep';
437
+ };
438
+ export type InlineText = {
439
+ type: 'text';
440
+ plainText(): string;
441
+ formatting(): Formatting;
442
+ };
443
+ export type Inline = InlineText | Tab | Separator | LineBreak | PageBreak | Image | Field | Footnote | FootnoteRef | Endnote | EndnoteRef;
444
+ export type RangeInline = {
445
+ range: Range;
446
+ inline: Inline;
447
+ };
448
+ export type Paragraph = {
449
+ type: 'paragraph';
450
+ asTextView(): TextView;
451
+ replaceText: ReplaceTextSignature;
452
+ };
453
+ export type TableCell = BlockLevelContainer;
454
+ export type TableRow = {
455
+ cells(): TableCell[];
456
+ addCell(index?: number): TableCell;
457
+ removeCell(index: number): TableCell | undefined;
458
+ replaceText: ReplaceTextSignature;
459
+ };
460
+ export type Table = {
461
+ type: 'table';
462
+ rows(): TableRow[];
463
+ addRow(index?: number): TableRow;
464
+ removeRow(index: number): TableRow | undefined;
465
+ replaceText: ReplaceTextSignature;
466
+ };
467
+ export type BlockLevel = Paragraph | Table;
468
+ export type BlockLevelContainer = {
469
+ blocklevels(): BlockLevel[];
470
+ addParagraph(index?: number): Paragraph;
471
+ addTable(index?: number): Table;
472
+ removeElement(index: number): BlockLevel | undefined;
473
+ replaceText: ReplaceTextSignature;
474
+ };
475
+ export type PageSize = {
476
+ width: number;
477
+ height: number;
478
+ };
479
+ export type PageMargins = {
480
+ left: number;
481
+ right: number;
482
+ top: number;
483
+ bottom: number;
484
+ };
485
+ export type PageSetup = {
486
+ setPageSize(size: Partial<PageSize>): void;
487
+ setPageMargins(margins: Partial<PageMargins>): void;
488
+ pageSize(): PageSize;
489
+ pageMargins(): PageMargins;
490
+ };
491
+ export type HeaderFooter = BlockLevelContainer;
492
+ export type HeadersFooters = {
493
+ default(): HeaderFooter | null;
494
+ first(): HeaderFooter | null;
495
+ even(): HeaderFooter | null;
496
+ replaceText: ReplaceTextSignature;
497
+ };
498
+ export type HeadersAndFooters = {
499
+ headers(): HeadersFooters;
500
+ footers(): HeadersFooters;
501
+ replaceText: ReplaceTextSignature;
502
+ };
503
+ export type Section = {
504
+ pageSetup(): PageSetup;
505
+ headersAndFooters(): HeadersAndFooters;
506
+ content(): BlockLevelContainer;
507
+ };
508
+ export type Body = {
509
+ sections(): Section[];
510
+ addSection(index?: number): Section;
511
+ removeSection(index: number): Section | undefined;
512
+ replaceText: ReplaceTextSignature;
513
+ };
514
+ export type Document = {
515
+ body(): Body;
516
+ replaceText: ReplaceTextSignature;
517
+ };
518
+ {};
519
+ }
520
+
521
+ /**
522
+ * @alpha
523
+ */
524
+ export declare type TransactionCallback<T = void> = (context: {
525
+ draft: Programmatic.Document;
526
+ }) => Promise<TransactionResult<T>>;
527
+
528
+ /**
529
+ * @alpha
530
+ */
531
+ export declare type TransactionResult<T = void> = undefined | boolean | {
532
+ commit: boolean;
533
+ result: T;
534
+ } | Promise<undefined | boolean | {
535
+ commit: boolean;
536
+ result: T;
537
+ }>;
538
+
346
539
  /**
347
540
  * Configuration options for the user interface.
348
541
  *
@@ -374,6 +567,16 @@ export declare type UIOptions = {
374
567
  */
375
568
  enabled: boolean;
376
569
  };
570
+ /**
571
+ * @internal
572
+ *
573
+ * Initial zoom level for the editor.
574
+ *
575
+ * Valid range is 0.5 to 4.0.
576
+ *
577
+ * @defaultValue `1`
578
+ */
579
+ initialZoom?: number;
377
580
  };
378
581
 
379
582
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nutrient-sdk/document-authoring",
3
- "version": "1.7.1",
3
+ "version": "1.8.0-preview.202507151230.e2f50a717d658a927bf4a773479bbf4c53603889",
4
4
  "description": "A web SDK for word processing and rich text capabilities.",
5
5
  "type": "commonjs",
6
6
  "main": "lib/docauth.umd.js",