@nutrient-sdk/document-authoring 1.8.0 → 1.9.0-preview.202508262146.00d4b4b113b716d41439d1b4930563b2d82f1465

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.8.0-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.9.0-preview.202508262146.00d4b4b113b716d41439d1b4930563b2d82f1465-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.8.0-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.9.0-preview.202508262146.00d4b4b113b716d41439d1b4930563b2d82f1465-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-2e14989b0a9b1796.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,n=new URL("docauth-impl-189f1c547985c1c6.js",e).href;return import(
2
2
  /*webpackIgnore: true*/
3
3
  /* @vite-ignore */
4
- a)})(t?.assets?.base)).createDocAuthSystem(t);var a={createDocAuthSystem:e,defaultFontIndex:t};export{e as createDocAuthSystem,a as default,t as defaultFontIndex};
4
+ n)})(t?.assets?.base)).createDocAuthSystem(t);var n={createDocAuthSystem:e,defaultFontIndex:t};export{e as createDocAuthSystem,n 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-2e14989b0a9b1796.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-189f1c547985c1c6.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
@@ -1,3 +1,5 @@
1
+ import * as JsonDiffTs from 'json-diff-ts';
2
+
1
3
  /**
2
4
  * @public
3
5
  */
@@ -80,8 +82,14 @@ export declare type CreateEditorOptions = {
80
82
  * See {@link UIOptions}
81
83
  */
82
84
  ui?: UIOptions;
83
-
84
-
85
+ /**
86
+ * @internal
87
+ */
88
+ __hideDOCXDownload?: boolean;
89
+ /**
90
+ * @internal
91
+ */
92
+ __hidePDFDownload?: boolean;
85
93
  };
86
94
 
87
95
  /**
@@ -136,7 +144,12 @@ export declare type DocAuthDocument = {
136
144
  * Exports a snapshot of the current document as a DOCX file.
137
145
  */
138
146
  exportDOCX(options?: ExportDOCXOptions): Promise<ArrayBuffer>;
139
-
147
+ __athenaSetJSONDiffHandler(handler: (diff: JsonDiffTs.IChange[]) => void): void;
148
+ __athenaApplyJSONDiff(diffGetter: () => JsonDiffTs.IChange[]): void;
149
+ /**
150
+ * @alpha
151
+ */
152
+ transaction<T = void>(callback: TransactionCallback<T>): Promise<T>;
140
153
  /**
141
154
  * The `DocAuthSystem` this document is bound to.
142
155
  */
@@ -173,7 +186,15 @@ export declare type DocAuthEditor = {
173
186
  * Retrieves the `DocAuthSystem` instance this editor is bound to.
174
187
  */
175
188
  docAuthSystem(): DocAuthSystem;
176
-
189
+ /**
190
+ * Inserts text at the current cursor position.
191
+ * If there's a selection, it will be replaced with the provided text.
192
+ *
193
+ * @param text - The text to insert at the cursor position
194
+ *
195
+ * @internal
196
+ */
197
+ insertTextAtCursor(text: string): void;
177
198
  /**
178
199
  * Adds an event listener that will be called every time the specified event is emitted.
179
200
  *
@@ -420,6 +441,190 @@ export declare type ImportDOCXOptions = {
420
441
  */
421
442
  export declare type Locale = 'en' | 'fr' | 'de';
422
443
 
444
+ /**
445
+ * @alpha
446
+ */
447
+ export declare namespace Programmatic {
448
+ export type Range = {
449
+ begin: number;
450
+ end?: number;
451
+ };
452
+ export type Formatting = {
453
+ font: string | null;
454
+ fontSize: number | null;
455
+ bold: boolean | null;
456
+ italic: boolean | null;
457
+ color: string | null;
458
+ highlight: string | null;
459
+ strikeout: boolean | null;
460
+ underline: boolean | null;
461
+ };
462
+ export type SearchFor = string | RegExp;
463
+ export type Replacement = {
464
+ text?: string;
465
+ formatting?: Partial<Formatting>;
466
+ };
467
+ export type ReplaceFn = (value: string) => Replacement | string;
468
+ export type ReplacementOrReplaceFn = Replacement | ReplaceFn | string;
469
+ export type ReplaceTextSignature = (searchFor: SearchFor, replace: ReplacementOrReplaceFn) => number;
470
+ export type SearchResult = {
471
+ range: Range;
472
+ text: string;
473
+ };
474
+ export type TextView = {
475
+ getPlainText(range?: Range): string;
476
+ searchText(searchFor: SearchFor, after?: Range): SearchResult | undefined;
477
+ replaceText: ReplaceTextSignature;
478
+ setText(value: string, range?: Range): Range;
479
+ setFormatting(formatting: Partial<Formatting>, range?: Range): void;
480
+ inlines(): RangeInline[];
481
+ addLineBreak(insertionPoint?: {
482
+ placement: 'before' | 'after';
483
+ range: Range;
484
+ }): LineBreak;
485
+ addInlineText(text: string, insertionPoint?: {
486
+ placement: 'before' | 'after';
487
+ range: Range;
488
+ }): InlineText;
489
+ removeInline(index?: number): Inline | undefined;
490
+ };
491
+ export type Extent = {
492
+ width: number;
493
+ height: number;
494
+ };
495
+ export type Image = {
496
+ type: 'image';
497
+ extent(): Extent;
498
+ setExtent(extent: Partial<Extent>): void;
499
+ };
500
+ export type Field = {
501
+ type: 'field';
502
+ };
503
+ export type Footnote = {
504
+ type: 'footnote';
505
+ };
506
+ export type FootnoteRef = {
507
+ type: 'footnote/ref';
508
+ };
509
+ export type Endnote = {
510
+ type: 'endnote';
511
+ };
512
+ export type EndnoteRef = {
513
+ type: 'endnote/ref';
514
+ };
515
+ export type LineBreak = {
516
+ type: 'line-break';
517
+ };
518
+ export type PageBreak = {
519
+ type: 'page-break';
520
+ };
521
+ export type Tab = {
522
+ type: 'tab';
523
+ };
524
+ export type Separator = {
525
+ type: 'sep';
526
+ };
527
+ export type InlineText = {
528
+ type: 'text';
529
+ plainText(): string;
530
+ formatting(): Formatting;
531
+ };
532
+ export type Inline = InlineText | Tab | Separator | LineBreak | PageBreak | Image | Field | Footnote | FootnoteRef | Endnote | EndnoteRef;
533
+ export type RangeInline = {
534
+ range: Range;
535
+ inline: Inline;
536
+ };
537
+ export type Paragraph = {
538
+ type: 'paragraph';
539
+ asTextView(): TextView;
540
+ replaceText: ReplaceTextSignature;
541
+ };
542
+ export type TableCell = BlockLevelContainer;
543
+ export type TableRow = {
544
+ cells(): TableCell[];
545
+ addCell(index?: number): TableCell;
546
+ removeCell(index: number): TableCell | undefined;
547
+ replaceText: ReplaceTextSignature;
548
+ };
549
+ export type Table = {
550
+ type: 'table';
551
+ rows(): TableRow[];
552
+ addRow(index?: number): TableRow;
553
+ removeRow(index: number): TableRow | undefined;
554
+ replaceText: ReplaceTextSignature;
555
+ };
556
+ export type BlockLevel = Paragraph | Table;
557
+ export type BlockLevelContainer = {
558
+ blocklevels(): BlockLevel[];
559
+ addParagraph(index?: number): Paragraph;
560
+ addTable(index?: number): Table;
561
+ removeElement(index: number): BlockLevel | undefined;
562
+ replaceText: ReplaceTextSignature;
563
+ };
564
+ export type PageSize = {
565
+ width: number;
566
+ height: number;
567
+ };
568
+ export type PageMargins = {
569
+ left: number;
570
+ right: number;
571
+ top: number;
572
+ bottom: number;
573
+ };
574
+ export type PageSetup = {
575
+ setPageSize(size: Partial<PageSize>): void;
576
+ setPageMargins(margins: Partial<PageMargins>): void;
577
+ pageSize(): PageSize;
578
+ pageMargins(): PageMargins;
579
+ };
580
+ export type HeaderFooter = BlockLevelContainer;
581
+ export type HeadersFooters = {
582
+ default(): HeaderFooter | null;
583
+ first(): HeaderFooter | null;
584
+ even(): HeaderFooter | null;
585
+ replaceText: ReplaceTextSignature;
586
+ };
587
+ export type HeadersAndFooters = {
588
+ headers(): HeadersFooters;
589
+ footers(): HeadersFooters;
590
+ replaceText: ReplaceTextSignature;
591
+ };
592
+ export type Section = {
593
+ pageSetup(): PageSetup;
594
+ headersAndFooters(): HeadersAndFooters;
595
+ content(): BlockLevelContainer;
596
+ };
597
+ export type Body = {
598
+ sections(): Section[];
599
+ addSection(index?: number): Section;
600
+ removeSection(index: number): Section | undefined;
601
+ replaceText: ReplaceTextSignature;
602
+ };
603
+ export type Document = {
604
+ body(): Body;
605
+ replaceText: ReplaceTextSignature;
606
+ };
607
+ {};
608
+ }
609
+
610
+ /**
611
+ * @alpha
612
+ */
613
+ export declare type TransactionCallback<T = void> = (context: {
614
+ draft: Programmatic.Document;
615
+ }) => Promise<TransactionResult<T>>;
616
+
617
+ /**
618
+ * @alpha
619
+ */
620
+ export declare type TransactionResult<T = void> = undefined | boolean | {
621
+ commit: boolean;
622
+ result: T;
623
+ } | Promise<undefined | boolean | {
624
+ commit: boolean;
625
+ result: T;
626
+ }>;
627
+
423
628
  /**
424
629
  * Configuration options for the user interface.
425
630
  *
@@ -451,7 +656,16 @@ export declare type UIOptions = {
451
656
  */
452
657
  enabled: boolean;
453
658
  };
454
-
659
+ /**
660
+ * @internal
661
+ *
662
+ * Initial zoom level for the editor.
663
+ *
664
+ * Valid range is 0.5 to 4.0.
665
+ *
666
+ * @defaultValue `1`
667
+ */
668
+ initialZoom?: number;
455
669
  };
456
670
 
457
671
  /**
package/lib/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as JsonDiffTs from 'json-diff-ts';
2
+
1
3
  /**
2
4
  * @public
3
5
  */
@@ -80,8 +82,14 @@ export declare type CreateEditorOptions = {
80
82
  * See {@link UIOptions}
81
83
  */
82
84
  ui?: UIOptions;
83
-
84
-
85
+ /**
86
+ * @internal
87
+ */
88
+ __hideDOCXDownload?: boolean;
89
+ /**
90
+ * @internal
91
+ */
92
+ __hidePDFDownload?: boolean;
85
93
  };
86
94
 
87
95
  /**
@@ -136,7 +144,12 @@ export declare type DocAuthDocument = {
136
144
  * Exports a snapshot of the current document as a DOCX file.
137
145
  */
138
146
  exportDOCX(options?: ExportDOCXOptions): Promise<ArrayBuffer>;
139
-
147
+ __athenaSetJSONDiffHandler(handler: (diff: JsonDiffTs.IChange[]) => void): void;
148
+ __athenaApplyJSONDiff(diffGetter: () => JsonDiffTs.IChange[]): void;
149
+ /**
150
+ * @alpha
151
+ */
152
+ transaction<T = void>(callback: TransactionCallback<T>): Promise<T>;
140
153
  /**
141
154
  * The `DocAuthSystem` this document is bound to.
142
155
  */
@@ -173,7 +186,15 @@ export declare type DocAuthEditor = {
173
186
  * Retrieves the `DocAuthSystem` instance this editor is bound to.
174
187
  */
175
188
  docAuthSystem(): DocAuthSystem;
176
-
189
+ /**
190
+ * Inserts text at the current cursor position.
191
+ * If there's a selection, it will be replaced with the provided text.
192
+ *
193
+ * @param text - The text to insert at the cursor position
194
+ *
195
+ * @internal
196
+ */
197
+ insertTextAtCursor(text: string): void;
177
198
  /**
178
199
  * Adds an event listener that will be called every time the specified event is emitted.
179
200
  *
@@ -420,6 +441,190 @@ export declare type ImportDOCXOptions = {
420
441
  */
421
442
  export declare type Locale = 'en' | 'fr' | 'de';
422
443
 
444
+ /**
445
+ * @alpha
446
+ */
447
+ export declare namespace Programmatic {
448
+ export type Range = {
449
+ begin: number;
450
+ end?: number;
451
+ };
452
+ export type Formatting = {
453
+ font: string | null;
454
+ fontSize: number | null;
455
+ bold: boolean | null;
456
+ italic: boolean | null;
457
+ color: string | null;
458
+ highlight: string | null;
459
+ strikeout: boolean | null;
460
+ underline: boolean | null;
461
+ };
462
+ export type SearchFor = string | RegExp;
463
+ export type Replacement = {
464
+ text?: string;
465
+ formatting?: Partial<Formatting>;
466
+ };
467
+ export type ReplaceFn = (value: string) => Replacement | string;
468
+ export type ReplacementOrReplaceFn = Replacement | ReplaceFn | string;
469
+ export type ReplaceTextSignature = (searchFor: SearchFor, replace: ReplacementOrReplaceFn) => number;
470
+ export type SearchResult = {
471
+ range: Range;
472
+ text: string;
473
+ };
474
+ export type TextView = {
475
+ getPlainText(range?: Range): string;
476
+ searchText(searchFor: SearchFor, after?: Range): SearchResult | undefined;
477
+ replaceText: ReplaceTextSignature;
478
+ setText(value: string, range?: Range): Range;
479
+ setFormatting(formatting: Partial<Formatting>, range?: Range): void;
480
+ inlines(): RangeInline[];
481
+ addLineBreak(insertionPoint?: {
482
+ placement: 'before' | 'after';
483
+ range: Range;
484
+ }): LineBreak;
485
+ addInlineText(text: string, insertionPoint?: {
486
+ placement: 'before' | 'after';
487
+ range: Range;
488
+ }): InlineText;
489
+ removeInline(index?: number): Inline | undefined;
490
+ };
491
+ export type Extent = {
492
+ width: number;
493
+ height: number;
494
+ };
495
+ export type Image = {
496
+ type: 'image';
497
+ extent(): Extent;
498
+ setExtent(extent: Partial<Extent>): void;
499
+ };
500
+ export type Field = {
501
+ type: 'field';
502
+ };
503
+ export type Footnote = {
504
+ type: 'footnote';
505
+ };
506
+ export type FootnoteRef = {
507
+ type: 'footnote/ref';
508
+ };
509
+ export type Endnote = {
510
+ type: 'endnote';
511
+ };
512
+ export type EndnoteRef = {
513
+ type: 'endnote/ref';
514
+ };
515
+ export type LineBreak = {
516
+ type: 'line-break';
517
+ };
518
+ export type PageBreak = {
519
+ type: 'page-break';
520
+ };
521
+ export type Tab = {
522
+ type: 'tab';
523
+ };
524
+ export type Separator = {
525
+ type: 'sep';
526
+ };
527
+ export type InlineText = {
528
+ type: 'text';
529
+ plainText(): string;
530
+ formatting(): Formatting;
531
+ };
532
+ export type Inline = InlineText | Tab | Separator | LineBreak | PageBreak | Image | Field | Footnote | FootnoteRef | Endnote | EndnoteRef;
533
+ export type RangeInline = {
534
+ range: Range;
535
+ inline: Inline;
536
+ };
537
+ export type Paragraph = {
538
+ type: 'paragraph';
539
+ asTextView(): TextView;
540
+ replaceText: ReplaceTextSignature;
541
+ };
542
+ export type TableCell = BlockLevelContainer;
543
+ export type TableRow = {
544
+ cells(): TableCell[];
545
+ addCell(index?: number): TableCell;
546
+ removeCell(index: number): TableCell | undefined;
547
+ replaceText: ReplaceTextSignature;
548
+ };
549
+ export type Table = {
550
+ type: 'table';
551
+ rows(): TableRow[];
552
+ addRow(index?: number): TableRow;
553
+ removeRow(index: number): TableRow | undefined;
554
+ replaceText: ReplaceTextSignature;
555
+ };
556
+ export type BlockLevel = Paragraph | Table;
557
+ export type BlockLevelContainer = {
558
+ blocklevels(): BlockLevel[];
559
+ addParagraph(index?: number): Paragraph;
560
+ addTable(index?: number): Table;
561
+ removeElement(index: number): BlockLevel | undefined;
562
+ replaceText: ReplaceTextSignature;
563
+ };
564
+ export type PageSize = {
565
+ width: number;
566
+ height: number;
567
+ };
568
+ export type PageMargins = {
569
+ left: number;
570
+ right: number;
571
+ top: number;
572
+ bottom: number;
573
+ };
574
+ export type PageSetup = {
575
+ setPageSize(size: Partial<PageSize>): void;
576
+ setPageMargins(margins: Partial<PageMargins>): void;
577
+ pageSize(): PageSize;
578
+ pageMargins(): PageMargins;
579
+ };
580
+ export type HeaderFooter = BlockLevelContainer;
581
+ export type HeadersFooters = {
582
+ default(): HeaderFooter | null;
583
+ first(): HeaderFooter | null;
584
+ even(): HeaderFooter | null;
585
+ replaceText: ReplaceTextSignature;
586
+ };
587
+ export type HeadersAndFooters = {
588
+ headers(): HeadersFooters;
589
+ footers(): HeadersFooters;
590
+ replaceText: ReplaceTextSignature;
591
+ };
592
+ export type Section = {
593
+ pageSetup(): PageSetup;
594
+ headersAndFooters(): HeadersAndFooters;
595
+ content(): BlockLevelContainer;
596
+ };
597
+ export type Body = {
598
+ sections(): Section[];
599
+ addSection(index?: number): Section;
600
+ removeSection(index: number): Section | undefined;
601
+ replaceText: ReplaceTextSignature;
602
+ };
603
+ export type Document = {
604
+ body(): Body;
605
+ replaceText: ReplaceTextSignature;
606
+ };
607
+ {};
608
+ }
609
+
610
+ /**
611
+ * @alpha
612
+ */
613
+ export declare type TransactionCallback<T = void> = (context: {
614
+ draft: Programmatic.Document;
615
+ }) => Promise<TransactionResult<T>>;
616
+
617
+ /**
618
+ * @alpha
619
+ */
620
+ export declare type TransactionResult<T = void> = undefined | boolean | {
621
+ commit: boolean;
622
+ result: T;
623
+ } | Promise<undefined | boolean | {
624
+ commit: boolean;
625
+ result: T;
626
+ }>;
627
+
423
628
  /**
424
629
  * Configuration options for the user interface.
425
630
  *
@@ -451,7 +656,16 @@ export declare type UIOptions = {
451
656
  */
452
657
  enabled: boolean;
453
658
  };
454
-
659
+ /**
660
+ * @internal
661
+ *
662
+ * Initial zoom level for the editor.
663
+ *
664
+ * Valid range is 0.5 to 4.0.
665
+ *
666
+ * @defaultValue `1`
667
+ */
668
+ initialZoom?: number;
455
669
  };
456
670
 
457
671
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nutrient-sdk/document-authoring",
3
- "version": "1.8.0",
3
+ "version": "1.9.0-preview.202508262146.00d4b4b113b716d41439d1b4930563b2d82f1465",
4
4
  "description": "A web SDK for word processing and rich text capabilities.",
5
5
  "type": "commonjs",
6
6
  "main": "lib/docauth.umd.js",