@nutrient-sdk/document-authoring 1.9.0-preview.202510241936.9f989d53d54c916f7857a572a63625d636359767 → 1.9.0-preview.202511030843.fde7b7ea0cd1beee611ebc75b37f110193857a94
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 +2 -2
- package/lib/docauth.mjs +18 -2
- package/lib/docauth.umd.js +18 -2
- package/lib/index.d.cts +276 -1
- package/lib/index.d.mts +276 -1
- package/package.json +1 -1
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.staging.nutrient.io/releases/document-authoring-1.9.0-preview.
|
|
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.202511030843.fde7b7ea0cd1beee611ebc75b37f110193857a94-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.staging.nutrient.io/releases/document-authoring-1.9.0-preview.
|
|
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.202511030843.fde7b7ea0cd1beee611ebc75b37f110193857a94-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,20 @@
|
|
|
1
|
-
|
|
1
|
+
var e=[
|
|
2
|
+
// Document actions
|
|
3
|
+
{id:"document.undo",label:"Undo",description:"Undo the last action",shortcuts:["Cmd+Z"]},{id:"document.redo",label:"Redo",description:"Redo the last undone action",shortcuts:["Cmd+Y","Cmd+Shift+Z"]},{id:"document.export-pdf",label:"Download PDF",description:"Export document as PDF"},{id:"document.export-docx",label:"Download DOCX",description:"Export document as DOCX"},
|
|
4
|
+
// Formatting actions
|
|
5
|
+
{id:"formatting.bold",label:"Bold",description:"Apply bold formatting",shortcuts:["Cmd+B"]},{id:"formatting.italic",label:"Italic",description:"Apply italic formatting",shortcuts:["Cmd+I"]},{id:"formatting.underline",label:"Underline",description:"Apply underline formatting",shortcuts:["Cmd+U"]},{id:"formatting.strikethrough",label:"Strikethrough",description:"Apply strikethrough formatting"},{id:"formatting.subscript",label:"Subscript",description:"Apply subscript formatting"},{id:"formatting.superscript",label:"Superscript",description:"Apply superscript formatting"},{id:"formatting.clear",label:"Clear Formatting",description:"Remove all formatting"},
|
|
6
|
+
// Insert actions
|
|
7
|
+
{id:"insert.page-break",label:"Page Break",description:"Insert a page break"},{id:"insert.section-break-next-page",label:"Section Break (Next Page)",description:"Insert a section break on next page"},{id:"insert.section-break-continuous",label:"Section Break (Continuous)",description:"Insert a continuous section break"},{id:"insert.column-break",label:"Column Break",description:"Insert a column break"},{id:"insert.image",label:"Image",description:"Insert an image"},{id:"insert.link",label:"Link",description:"Insert a hyperlink",shortcuts:["Cmd+K"]},
|
|
8
|
+
// Table actions
|
|
9
|
+
{id:"table.insert",label:"Insert Table",description:"Insert a new table"},{id:"table.delete",label:"Delete Table",description:"Delete the current table"},{id:"table.insert-row-above",label:"Insert Row Above",description:"Insert a row above current row"},{id:"table.insert-row-below",label:"Insert Row Below",description:"Insert a row below current row"},{id:"table.insert-column-left",label:"Insert Column Left",description:"Insert a column to the left"},{id:"table.insert-column-right",label:"Insert Column Right",description:"Insert a column to the right"},{id:"table.delete-row",label:"Delete Row",description:"Delete the current row"},{id:"table.delete-column",label:"Delete Column",description:"Delete the current column"},{id:"table.merge-cells",label:"Merge Cells",description:"Merge selected cells"},{id:"table.split-cells",label:"Split Cells",description:"Split merged cells"},
|
|
10
|
+
// View actions
|
|
11
|
+
{id:"view.zoom-in",label:"Zoom In",description:"Increase zoom level",shortcuts:["Cmd+="]},{id:"view.zoom-out",label:"Zoom Out",description:"Decrease zoom level",shortcuts:["Cmd+-"]},{id:"view.zoom-reset",label:"Reset Zoom",description:"Reset zoom to 100%",shortcuts:["Cmd+0"]},{id:"view.toggle-ruler",label:"Toggle Ruler",description:"Show or hide the ruler"},{id:"view.toggle-formatting-marks",label:"Toggle Formatting Marks",description:"Show or hide formatting marks"},
|
|
12
|
+
// Layout actions
|
|
13
|
+
{id:"layout.align-left",label:"Align Left",description:"Align text to the left",shortcuts:["Cmd+Shift+L"]},{id:"layout.align-center",label:"Align Center",description:"Center align text",shortcuts:["Cmd+Shift+E"]},{id:"layout.align-right",label:"Align Right",description:"Align text to the right",shortcuts:["Cmd+Shift+R"]},{id:"layout.align-justify",label:"Justify",description:"Justify text",shortcuts:["Cmd+Shift+J"]},{id:"layout.increase-indent",label:"Increase Indent",description:"Increase paragraph indent",shortcuts:["Cmd+]"]},{id:"layout.decrease-indent",label:"Decrease Indent",description:"Decrease paragraph indent",shortcuts:["Cmd+["]},{id:"layout.bulleted-list",label:"Bulleted List",description:"Create a bulleted list"},{id:"layout.numbered-list",label:"Numbered List",description:"Create a numbered list"},
|
|
14
|
+
// Style actions
|
|
15
|
+
{id:"style.apply",label:"Apply Style",description:"Apply a style to the selection"}],t={items:[{type:"built-in",id:"zoom-select",builtInType:"zoom"},{type:"separator",id:"sep-after-zoom"},{type:"built-in",id:"mobile-lock",builtInType:"mobile-lock"},{type:"built-in",id:"undo-btn",builtInType:"undo"},{type:"built-in",id:"redo-btn",builtInType:"redo"},{type:"separator",id:"sep-after-undo-redo"},{type:"built-in",id:"style-menu",builtInType:"style-menu"},{type:"separator",id:"sep-after-style"},{type:"built-in",id:"font-family-select",builtInType:"font-family"},{type:"built-in",id:"font-size-input",builtInType:"font-size"},{type:"separator",id:"sep-after-font"},{type:"built-in",id:"bold-btn",builtInType:"bold"},{type:"built-in",id:"italic-btn",builtInType:"italic"},{type:"built-in",id:"underline-btn",builtInType:"underline"},{type:"built-in",id:"strikethrough-btn",builtInType:"strikethrough"},{type:"built-in",id:"subscript-btn",builtInType:"subscript"},{type:"built-in",id:"superscript-btn",builtInType:"superscript"},{type:"separator",id:"sep-after-character-formatting"},{type:"built-in",id:"text-color-picker",builtInType:"text-color"},{type:"built-in",id:"highlight-color-picker",builtInType:"highlight-color"},{type:"separator",id:"sep-after-colors"},{type:"built-in",id:"align-left-btn",builtInType:"align-left"},{type:"built-in",id:"align-center-btn",builtInType:"align-center"},{type:"built-in",id:"align-right-btn",builtInType:"align-right"},{type:"built-in",id:"align-justify-btn",builtInType:"align-justify"},{type:"separator",id:"sep-after-alignment"},{type:"built-in",id:"line-spacing-menu",builtInType:"line-spacing-menu"},{type:"separator",id:"sep-after-line-spacing"},{type:"built-in",id:"bulleted-list",builtInType:"bulleted-list"},{type:"built-in",id:"numbered-list",builtInType:"numbered-list"},{type:"separator",id:"sep-after-lists"},{type:"built-in",id:"decrease-indent-btn",builtInType:"decrease-indent"},{type:"built-in",id:"increase-indent-btn",builtInType:"increase-indent"},{type:"separator",id:"sep-after-indentation"},{type:"built-in",id:"clear-formatting-btn",builtInType:"clear-formatting"},{type:"built-in",id:"formatting-marks-btn",builtInType:"formatting-marks"},{type:"separator",id:"sep-after-formatting-marks"},{type:"built-in",id:"page-setup-menu",builtInType:"page-setup-menu"},{type:"separator",id:"sep-after-page-setup"},{type:"built-in",id:"insert-menu",builtInType:"insert-menu"},{type:"separator",id:"sep-after-insert"},{type:"built-in",id:"table-menu",builtInType:"table-menu"},{type:"separator",id:"sep-after-table"},{type:"built-in",id:"download-menu",builtInType:"download-menu"},{type:"separator",id:"sep-before-ui-settings"},{type:"built-in",id:"ui-settings-menu",builtInType:"ui-settings-menu",visible:e=>!e.mobile},{type:"separator",id:"sep-after-ui-settings"}]};
|
|
16
|
+
// ../packages/ui/src/actions/default-actions-standalone.ts
|
|
17
|
+
const i={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,i=new URL("docauth-impl-4fcda3e4741df97d.js",t).href;return import(
|
|
2
18
|
/*webpackIgnore: true*/
|
|
3
19
|
/* @vite-ignore */
|
|
4
|
-
|
|
20
|
+
i)})(e?.assets?.base)).createDocAuthSystem(e);var l={createDocAuthSystem:n,defaultFontIndex:i,defaultActions:e,defaultToolbarConfig:t};export{n as createDocAuthSystem,l as default,e as defaultActions,i as defaultFontIndex,t as defaultToolbarConfig};
|
package/lib/docauth.umd.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
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";
|
|
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";var t=[
|
|
2
|
+
// Document actions
|
|
3
|
+
{id:"document.undo",label:"Undo",description:"Undo the last action",shortcuts:["Cmd+Z"]},{id:"document.redo",label:"Redo",description:"Redo the last undone action",shortcuts:["Cmd+Y","Cmd+Shift+Z"]},{id:"document.export-pdf",label:"Download PDF",description:"Export document as PDF"},{id:"document.export-docx",label:"Download DOCX",description:"Export document as DOCX"},
|
|
4
|
+
// Formatting actions
|
|
5
|
+
{id:"formatting.bold",label:"Bold",description:"Apply bold formatting",shortcuts:["Cmd+B"]},{id:"formatting.italic",label:"Italic",description:"Apply italic formatting",shortcuts:["Cmd+I"]},{id:"formatting.underline",label:"Underline",description:"Apply underline formatting",shortcuts:["Cmd+U"]},{id:"formatting.strikethrough",label:"Strikethrough",description:"Apply strikethrough formatting"},{id:"formatting.subscript",label:"Subscript",description:"Apply subscript formatting"},{id:"formatting.superscript",label:"Superscript",description:"Apply superscript formatting"},{id:"formatting.clear",label:"Clear Formatting",description:"Remove all formatting"},
|
|
6
|
+
// Insert actions
|
|
7
|
+
{id:"insert.page-break",label:"Page Break",description:"Insert a page break"},{id:"insert.section-break-next-page",label:"Section Break (Next Page)",description:"Insert a section break on next page"},{id:"insert.section-break-continuous",label:"Section Break (Continuous)",description:"Insert a continuous section break"},{id:"insert.column-break",label:"Column Break",description:"Insert a column break"},{id:"insert.image",label:"Image",description:"Insert an image"},{id:"insert.link",label:"Link",description:"Insert a hyperlink",shortcuts:["Cmd+K"]},
|
|
8
|
+
// Table actions
|
|
9
|
+
{id:"table.insert",label:"Insert Table",description:"Insert a new table"},{id:"table.delete",label:"Delete Table",description:"Delete the current table"},{id:"table.insert-row-above",label:"Insert Row Above",description:"Insert a row above current row"},{id:"table.insert-row-below",label:"Insert Row Below",description:"Insert a row below current row"},{id:"table.insert-column-left",label:"Insert Column Left",description:"Insert a column to the left"},{id:"table.insert-column-right",label:"Insert Column Right",description:"Insert a column to the right"},{id:"table.delete-row",label:"Delete Row",description:"Delete the current row"},{id:"table.delete-column",label:"Delete Column",description:"Delete the current column"},{id:"table.merge-cells",label:"Merge Cells",description:"Merge selected cells"},{id:"table.split-cells",label:"Split Cells",description:"Split merged cells"},
|
|
10
|
+
// View actions
|
|
11
|
+
{id:"view.zoom-in",label:"Zoom In",description:"Increase zoom level",shortcuts:["Cmd+="]},{id:"view.zoom-out",label:"Zoom Out",description:"Decrease zoom level",shortcuts:["Cmd+-"]},{id:"view.zoom-reset",label:"Reset Zoom",description:"Reset zoom to 100%",shortcuts:["Cmd+0"]},{id:"view.toggle-ruler",label:"Toggle Ruler",description:"Show or hide the ruler"},{id:"view.toggle-formatting-marks",label:"Toggle Formatting Marks",description:"Show or hide formatting marks"},
|
|
12
|
+
// Layout actions
|
|
13
|
+
{id:"layout.align-left",label:"Align Left",description:"Align text to the left",shortcuts:["Cmd+Shift+L"]},{id:"layout.align-center",label:"Align Center",description:"Center align text",shortcuts:["Cmd+Shift+E"]},{id:"layout.align-right",label:"Align Right",description:"Align text to the right",shortcuts:["Cmd+Shift+R"]},{id:"layout.align-justify",label:"Justify",description:"Justify text",shortcuts:["Cmd+Shift+J"]},{id:"layout.increase-indent",label:"Increase Indent",description:"Increase paragraph indent",shortcuts:["Cmd+]"]},{id:"layout.decrease-indent",label:"Decrease Indent",description:"Decrease paragraph indent",shortcuts:["Cmd+["]},{id:"layout.bulleted-list",label:"Bulleted List",description:"Create a bulleted list"},{id:"layout.numbered-list",label:"Numbered List",description:"Create a numbered list"},
|
|
14
|
+
// Style actions
|
|
15
|
+
{id:"style.apply",label:"Apply Style",description:"Apply a style to the selection"}],i={items:[{type:"built-in",id:"zoom-select",builtInType:"zoom"},{type:"separator",id:"sep-after-zoom"},{type:"built-in",id:"mobile-lock",builtInType:"mobile-lock"},{type:"built-in",id:"undo-btn",builtInType:"undo"},{type:"built-in",id:"redo-btn",builtInType:"redo"},{type:"separator",id:"sep-after-undo-redo"},{type:"built-in",id:"style-menu",builtInType:"style-menu"},{type:"separator",id:"sep-after-style"},{type:"built-in",id:"font-family-select",builtInType:"font-family"},{type:"built-in",id:"font-size-input",builtInType:"font-size"},{type:"separator",id:"sep-after-font"},{type:"built-in",id:"bold-btn",builtInType:"bold"},{type:"built-in",id:"italic-btn",builtInType:"italic"},{type:"built-in",id:"underline-btn",builtInType:"underline"},{type:"built-in",id:"strikethrough-btn",builtInType:"strikethrough"},{type:"built-in",id:"subscript-btn",builtInType:"subscript"},{type:"built-in",id:"superscript-btn",builtInType:"superscript"},{type:"separator",id:"sep-after-character-formatting"},{type:"built-in",id:"text-color-picker",builtInType:"text-color"},{type:"built-in",id:"highlight-color-picker",builtInType:"highlight-color"},{type:"separator",id:"sep-after-colors"},{type:"built-in",id:"align-left-btn",builtInType:"align-left"},{type:"built-in",id:"align-center-btn",builtInType:"align-center"},{type:"built-in",id:"align-right-btn",builtInType:"align-right"},{type:"built-in",id:"align-justify-btn",builtInType:"align-justify"},{type:"separator",id:"sep-after-alignment"},{type:"built-in",id:"line-spacing-menu",builtInType:"line-spacing-menu"},{type:"separator",id:"sep-after-line-spacing"},{type:"built-in",id:"bulleted-list",builtInType:"bulleted-list"},{type:"built-in",id:"numbered-list",builtInType:"numbered-list"},{type:"separator",id:"sep-after-lists"},{type:"built-in",id:"decrease-indent-btn",builtInType:"decrease-indent"},{type:"built-in",id:"increase-indent-btn",builtInType:"increase-indent"},{type:"separator",id:"sep-after-indentation"},{type:"built-in",id:"clear-formatting-btn",builtInType:"clear-formatting"},{type:"built-in",id:"formatting-marks-btn",builtInType:"formatting-marks"},{type:"separator",id:"sep-after-formatting-marks"},{type:"built-in",id:"page-setup-menu",builtInType:"page-setup-menu"},{type:"separator",id:"sep-after-page-setup"},{type:"built-in",id:"insert-menu",builtInType:"insert-menu"},{type:"separator",id:"sep-after-insert"},{type:"built-in",id:"table-menu",builtInType:"table-menu"},{type:"separator",id:"sep-after-table"},{type:"built-in",id:"download-menu",builtInType:"download-menu"},{type:"separator",id:"sep-before-ui-settings"},{type:"built-in",id:"ui-settings-menu",builtInType:"ui-settings-menu",visible:e=>!e.mobile},{type:"separator",id:"sep-after-ui-settings"}]};
|
|
16
|
+
// ../packages/ui/src/actions/default-actions-standalone.ts
|
|
17
|
+
const n={type:"default-index"},l=async e=>(await(async e=>{const t=new URL(e??"https://document-authoring.cdn.staging.nutrient.io/2025/1/",window.location.href).href,i=new URL("docauth-impl-4fcda3e4741df97d.js",t).href;return import(
|
|
2
18
|
/*webpackIgnore: true*/
|
|
3
19
|
/* @vite-ignore */
|
|
4
|
-
|
|
20
|
+
i)})(e?.assets?.base)).createDocAuthSystem(e);var r={createDocAuthSystem:l,defaultFontIndex:n,defaultActions:t,defaultToolbarConfig:i};e.createDocAuthSystem=l,e.default=r,e.defaultActions=t,e.defaultFontIndex=n,e.defaultToolbarConfig=i,Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/lib/index.d.cts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action definition that users can register
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export declare type Action = BuiltInAction | CustomAction;
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* @public
|
|
3
9
|
*/
|
|
@@ -15,6 +21,42 @@ export declare type Assets = {
|
|
|
15
21
|
*/
|
|
16
22
|
export declare type BlobInput = Promise<Response | Blob | ArrayBuffer> | Response | Blob | ArrayBuffer;
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Built-in action - can omit handler, will use default implementation
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare type BuiltInAction = {
|
|
29
|
+
readonly id: BuiltInActionId;
|
|
30
|
+
readonly label: string;
|
|
31
|
+
readonly description?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Keyboard shortcuts for the action.
|
|
34
|
+
* Use "Mod" as the primary modifier key - it will be automatically resolved to:
|
|
35
|
+
* - "Ctrl" on Windows/Linux
|
|
36
|
+
* - "⌘" (Command) on Mac
|
|
37
|
+
*
|
|
38
|
+
* Examples:
|
|
39
|
+
* - "Mod+B" becomes "Ctrl+B" on Windows, "⌘B" on Mac
|
|
40
|
+
* - "Mod+Shift+P" becomes "Ctrl+Shift+P" on Windows, "⌘⇧P" on Mac
|
|
41
|
+
*/
|
|
42
|
+
readonly shortcuts?: string[];
|
|
43
|
+
/** Icon as data URI (e.g., data:image/svg+xml;base64,... or data:image/png;base64,...). Only data:image/ URIs are allowed for security. */
|
|
44
|
+
readonly icon?: string;
|
|
45
|
+
readonly isEnabled?: () => boolean;
|
|
46
|
+
readonly order?: number;
|
|
47
|
+
readonly handler?: (...args: unknown[]) => void | Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Actions API - Type definitions for registering and executing editor actions
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* Built-in action IDs that have default implementations
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare type BuiltInActionId = 'document.undo' | 'document.redo' | 'document.export-pdf' | 'document.export-docx' | 'formatting.bold' | 'formatting.italic' | 'formatting.underline' | 'formatting.strikethrough' | 'formatting.subscript' | 'formatting.superscript' | 'formatting.clear' | 'insert.page-break' | 'insert.section-break-next-page' | 'insert.section-break-continuous' | 'insert.column-break' | 'insert.image' | 'insert.link' | 'table.insert' | 'table.delete' | 'table.insert-row-above' | 'table.insert-row-below' | 'table.insert-column-left' | 'table.insert-column-right' | 'table.delete-row' | 'table.delete-column' | 'table.merge-cells' | 'table.split-cells' | 'view.zoom-in' | 'view.zoom-out' | 'view.zoom-reset' | 'view.toggle-ruler' | 'view.toggle-formatting-marks' | 'layout.align-left' | 'layout.align-center' | 'layout.align-right' | 'layout.align-justify' | 'layout.increase-indent' | 'layout.decrease-indent' | 'layout.bulleted-list' | 'layout.numbered-list' | 'style.apply';
|
|
59
|
+
|
|
18
60
|
/**
|
|
19
61
|
* Creates an instance of the Document Authoring system which can be shared between different tasks
|
|
20
62
|
* like creating editors, importing Word documents or creating PDFs.
|
|
@@ -90,15 +132,83 @@ export declare type CreateEditorOptions = {
|
|
|
90
132
|
__hidePDFDownload?: boolean;
|
|
91
133
|
};
|
|
92
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Custom action - must provide handler
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export declare type CustomAction = {
|
|
140
|
+
readonly id: string;
|
|
141
|
+
readonly label: string;
|
|
142
|
+
readonly description?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Keyboard shortcuts for the action.
|
|
145
|
+
* Use "Cmd" as the modifier key - it will be resolved to:
|
|
146
|
+
* - "Ctrl" on Windows/Linux (for keyboard handling)
|
|
147
|
+
* - "⌘" on Mac (for keyboard handling)
|
|
148
|
+
* - "Ctrl" or "⌘" for display based on platform
|
|
149
|
+
*
|
|
150
|
+
* Examples:
|
|
151
|
+
* - "Cmd+B" becomes "Ctrl+B" on Windows, "⌘B" on Mac
|
|
152
|
+
* - "Cmd+Shift+P" becomes "Ctrl+Shift+P" on Windows, "⌘⇧P" on Mac
|
|
153
|
+
*/
|
|
154
|
+
readonly shortcuts?: string[];
|
|
155
|
+
/** Icon as data URI (e.g., data:image/svg+xml;base64,... or data:image/png;base64,...). Only data:image/ URIs are allowed for security. */
|
|
156
|
+
readonly icon?: string;
|
|
157
|
+
readonly isEnabled?: () => boolean;
|
|
158
|
+
readonly order?: number;
|
|
159
|
+
readonly handler: (...args: unknown[]) => void | Promise<void>;
|
|
160
|
+
};
|
|
161
|
+
|
|
93
162
|
/**
|
|
94
163
|
* @hidden
|
|
95
164
|
*/
|
|
96
165
|
declare const _default: {
|
|
97
166
|
createDocAuthSystem: (options?: CreateDocAuthSystemOptions) => Promise<DocAuthSystem>;
|
|
98
167
|
defaultFontIndex: DefaultFontIndex;
|
|
168
|
+
defaultActions: BuiltInAction[];
|
|
169
|
+
defaultToolbarConfig: ToolbarConfig;
|
|
99
170
|
};
|
|
100
171
|
export default _default;
|
|
101
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Get the default set of actions available in the editor.
|
|
175
|
+
* Can be combined with custom actions using spread operator.
|
|
176
|
+
*
|
|
177
|
+
* Note: Built-in actions (those with IDs from {@link BuiltInActionId}) can omit handlers -
|
|
178
|
+
* they will be automatically populated with default implementations when passed to
|
|
179
|
+
* `editor.setActions()`. This allows you to customize labels, shortcuts, and order
|
|
180
|
+
* without needing to implement the behavior yourself. Built-in handlers can also be
|
|
181
|
+
* overridden by providing your own handler function.
|
|
182
|
+
*
|
|
183
|
+
* Custom actions (those with any other string ID) must provide a handler function.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* import { defaultActions } from '@nutrient-sdk/document-authoring';
|
|
188
|
+
*
|
|
189
|
+
* // Customize a built-in action's metadata (handlers auto-populate for built-in actions)
|
|
190
|
+
* editor.setActions([
|
|
191
|
+
* ...defaultActions,
|
|
192
|
+
* { id: 'formatting.bold', label: 'Make Bold', shortcuts: ['Ctrl+B'] }
|
|
193
|
+
* ]);
|
|
194
|
+
*
|
|
195
|
+
* // Override a built-in action's behavior
|
|
196
|
+
* editor.setActions([
|
|
197
|
+
* ...defaultActions,
|
|
198
|
+
* { id: 'formatting.bold', label: 'Bold', handler: () => console.log('custom bold!') }
|
|
199
|
+
* ]);
|
|
200
|
+
*
|
|
201
|
+
* // Add custom actions (must provide handler)
|
|
202
|
+
* editor.setActions([
|
|
203
|
+
* ...defaultActions.filter(a => a.id !== 'document.export-pdf'),
|
|
204
|
+
* { id: 'custom.my-action', label: 'My Action', handler: () => console.log('clicked') }
|
|
205
|
+
* ]);
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
210
|
+
export declare const defaultActions: BuiltInAction[];
|
|
211
|
+
|
|
102
212
|
/**
|
|
103
213
|
* The default font index that is part of the Document Authoring SDK bundle.
|
|
104
214
|
*
|
|
@@ -119,6 +229,25 @@ export declare type DefaultFontIndex = {
|
|
|
119
229
|
*/
|
|
120
230
|
export declare const defaultFontIndex: DefaultFontIndex;
|
|
121
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Get the default toolbar configuration.
|
|
234
|
+
* Can be used as-is or customized.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* import { defaultToolbarConfig } from '@nutrient-sdk/document-authoring';
|
|
239
|
+
*
|
|
240
|
+
* editor.setToolbarConfig(defaultToolbarConfig);
|
|
241
|
+
* // or customize:
|
|
242
|
+
* editor.setToolbarConfig({
|
|
243
|
+
* items: [...defaultToolbarConfig.items, myCustomItem]
|
|
244
|
+
* });
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* @public
|
|
248
|
+
*/
|
|
249
|
+
export declare const defaultToolbarConfig: ToolbarConfig;
|
|
250
|
+
|
|
122
251
|
/**
|
|
123
252
|
* @public
|
|
124
253
|
*/
|
|
@@ -189,6 +318,15 @@ export declare type DocAuthEditor = {
|
|
|
189
318
|
* @param text - The text to insert at the cursor position
|
|
190
319
|
*/
|
|
191
320
|
insertTextAtCursor(text: string): void;
|
|
321
|
+
/**
|
|
322
|
+
* Checks if the editor has an active cursor/insertion point.
|
|
323
|
+
* This is useful for custom actions to determine if they should be enabled.
|
|
324
|
+
*
|
|
325
|
+
* @returns true if cursor is active and insertion is possible, false otherwise
|
|
326
|
+
*
|
|
327
|
+
* @internal
|
|
328
|
+
*/
|
|
329
|
+
hasActiveCursor(): boolean;
|
|
192
330
|
/**
|
|
193
331
|
* Adds an event listener that will be called every time the specified event is emitted.
|
|
194
332
|
*
|
|
@@ -242,6 +380,62 @@ export declare type DocAuthEditor = {
|
|
|
242
380
|
* @eventMap DocAuthEditorEvents
|
|
243
381
|
*/
|
|
244
382
|
once: <EventName extends keyof DocAuthEditorEvents>(event: EventName, handler: DocAuthEditorEventHandler<EventName>) => DocAuthEditor;
|
|
383
|
+
/**
|
|
384
|
+
* Set all actions (replaces any existing actions).
|
|
385
|
+
* Allows setting and executing editor actions programmatically.
|
|
386
|
+
*
|
|
387
|
+
* @param actions - Array of actions to register
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* import { defaultActions } from '@nutrient-sdk/document-authoring';
|
|
392
|
+
*
|
|
393
|
+
* // Register custom actions alongside default actions
|
|
394
|
+
* editor.setActions([
|
|
395
|
+
* ...defaultActions, // Keep default actions
|
|
396
|
+
* {
|
|
397
|
+
* id: 'custom.insert-signature',
|
|
398
|
+
* label: 'Insert Signature',
|
|
399
|
+
* handler: () => {
|
|
400
|
+
* editor.insertTextAtCursor('\n\nBest regards,\nJohn Doe');
|
|
401
|
+
* },
|
|
402
|
+
* shortcuts: [{ mac: '⌘⇧S', windows: 'Ctrl+Shift+S' }]
|
|
403
|
+
* }
|
|
404
|
+
* ]);
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @public
|
|
408
|
+
*/
|
|
409
|
+
setActions(actions: Action[]): void;
|
|
410
|
+
/**
|
|
411
|
+
* Set the toolbar configuration.
|
|
412
|
+
* Use this to customize the editor's toolbar.
|
|
413
|
+
*
|
|
414
|
+
* @param config - Toolbar configuration object
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```typescript
|
|
418
|
+
* import { defaultToolbarConfig } from '@nutrient-sdk/document-authoring';
|
|
419
|
+
*
|
|
420
|
+
* // Use default toolbar
|
|
421
|
+
* editor.setToolbarConfig(defaultToolbarConfig);
|
|
422
|
+
*
|
|
423
|
+
* // Or create a minimal toolbar
|
|
424
|
+
* editor.setToolbarConfig({
|
|
425
|
+
* items: [
|
|
426
|
+
* { type: 'built-in', id: 'undo', builtInType: 'undo' },
|
|
427
|
+
* { type: 'built-in', id: 'redo', builtInType: 'redo' },
|
|
428
|
+
* { type: 'separator', id: 'sep-1' },
|
|
429
|
+
* { type: 'built-in', id: 'bold', builtInType: 'bold' },
|
|
430
|
+
* { type: 'built-in', id: 'italic', builtInType: 'italic' },
|
|
431
|
+
* { type: 'action', id: 'custom', actionId: 'custom.insert-signature' }
|
|
432
|
+
* ]
|
|
433
|
+
* });
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @public
|
|
437
|
+
*/
|
|
438
|
+
setToolbarConfig(config: ToolbarConfig): void;
|
|
245
439
|
};
|
|
246
440
|
|
|
247
441
|
/**
|
|
@@ -601,6 +795,57 @@ export declare namespace Programmatic {
|
|
|
601
795
|
{};
|
|
602
796
|
}
|
|
603
797
|
|
|
798
|
+
/**
|
|
799
|
+
* Toolbar API - Type definitions for customizing the editor toolbar
|
|
800
|
+
* @public
|
|
801
|
+
*/
|
|
802
|
+
/**
|
|
803
|
+
* Action toolbar item - references an action by ID
|
|
804
|
+
* @public
|
|
805
|
+
*/
|
|
806
|
+
export declare type ToolbarActionItem = {
|
|
807
|
+
type: 'action';
|
|
808
|
+
id: string;
|
|
809
|
+
actionId: string;
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Built-in toolbar item - uses original toolbar components directly
|
|
814
|
+
* Self-contained with no external configuration properties
|
|
815
|
+
* @public
|
|
816
|
+
*/
|
|
817
|
+
export declare type ToolbarBuiltInItem = {
|
|
818
|
+
type: 'built-in';
|
|
819
|
+
id: string;
|
|
820
|
+
builtInType: 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'subscript' | 'superscript' | 'text-color' | 'highlight-color' | 'align-left' | 'align-center' | 'align-right' | 'align-justify' | 'bulleted-list' | 'numbered-list' | 'decrease-indent' | 'increase-indent' | 'clear-formatting' | 'formatting-marks' | 'zoom' | 'mobile-lock' | 'font-family' | 'font-size' | 'style-menu' | 'line-spacing-menu' | 'page-setup-menu' | 'insert-menu' | 'table-menu' | 'download-menu' | 'ui-settings-menu';
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Toolbar configuration
|
|
825
|
+
* @public
|
|
826
|
+
*/
|
|
827
|
+
export declare type ToolbarConfig = {
|
|
828
|
+
/**
|
|
829
|
+
* Array of toolbar items to display
|
|
830
|
+
*/
|
|
831
|
+
items?: ToolbarItem[];
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Union type for all toolbar items
|
|
836
|
+
* @public
|
|
837
|
+
*/
|
|
838
|
+
export declare type ToolbarItem = ToolbarActionItem | ToolbarBuiltInItem | ToolbarSeparatorItem;
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Visual separator
|
|
842
|
+
* @public
|
|
843
|
+
*/
|
|
844
|
+
export declare type ToolbarSeparatorItem = {
|
|
845
|
+
type: 'separator';
|
|
846
|
+
id: string;
|
|
847
|
+
};
|
|
848
|
+
|
|
604
849
|
/**
|
|
605
850
|
* @alpha
|
|
606
851
|
*/
|
|
@@ -655,11 +900,41 @@ export declare type UIOptions = {
|
|
|
655
900
|
*
|
|
656
901
|
* Initial zoom level for the editor.
|
|
657
902
|
*
|
|
658
|
-
* Valid range is 0.5 to 4.0.
|
|
903
|
+
* Valid range is 0.5 to 4.0, which any values provided will be clamped to.
|
|
659
904
|
*
|
|
660
905
|
* @defaultValue `1`
|
|
661
906
|
*/
|
|
662
907
|
initialZoom?: number;
|
|
908
|
+
/**
|
|
909
|
+
* Initial toolbar configuration.
|
|
910
|
+
*
|
|
911
|
+
* The toolbar can also be customized at runtime using `editor.setToolbarConfig()`.
|
|
912
|
+
*/
|
|
913
|
+
toolbar?: ToolbarConfig;
|
|
914
|
+
/**
|
|
915
|
+
* Initial actions configuration.
|
|
916
|
+
*
|
|
917
|
+
* Actions can also be customized at runtime using `editor.setActions()`.
|
|
918
|
+
*
|
|
919
|
+
* @example
|
|
920
|
+
* ```typescript
|
|
921
|
+
* import { defaultActions } from '@nutrient-sdk/document-authoring';
|
|
922
|
+
*
|
|
923
|
+
* const editor = await system.createEditor(target, {
|
|
924
|
+
* ui: {
|
|
925
|
+
* actions: [
|
|
926
|
+
* ...defaultActions,
|
|
927
|
+
* {
|
|
928
|
+
* id: 'custom.hello',
|
|
929
|
+
* label: 'Say Hello',
|
|
930
|
+
* handler: () => alert('Hello!'),
|
|
931
|
+
* }
|
|
932
|
+
* ]
|
|
933
|
+
* }
|
|
934
|
+
* });
|
|
935
|
+
* ```
|
|
936
|
+
*/
|
|
937
|
+
actions?: Action[];
|
|
663
938
|
};
|
|
664
939
|
|
|
665
940
|
/**
|
package/lib/index.d.mts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action definition that users can register
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export declare type Action = BuiltInAction | CustomAction;
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* @public
|
|
3
9
|
*/
|
|
@@ -15,6 +21,42 @@ export declare type Assets = {
|
|
|
15
21
|
*/
|
|
16
22
|
export declare type BlobInput = Promise<Response | Blob | ArrayBuffer> | Response | Blob | ArrayBuffer;
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Built-in action - can omit handler, will use default implementation
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare type BuiltInAction = {
|
|
29
|
+
readonly id: BuiltInActionId;
|
|
30
|
+
readonly label: string;
|
|
31
|
+
readonly description?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Keyboard shortcuts for the action.
|
|
34
|
+
* Use "Mod" as the primary modifier key - it will be automatically resolved to:
|
|
35
|
+
* - "Ctrl" on Windows/Linux
|
|
36
|
+
* - "⌘" (Command) on Mac
|
|
37
|
+
*
|
|
38
|
+
* Examples:
|
|
39
|
+
* - "Mod+B" becomes "Ctrl+B" on Windows, "⌘B" on Mac
|
|
40
|
+
* - "Mod+Shift+P" becomes "Ctrl+Shift+P" on Windows, "⌘⇧P" on Mac
|
|
41
|
+
*/
|
|
42
|
+
readonly shortcuts?: string[];
|
|
43
|
+
/** Icon as data URI (e.g., data:image/svg+xml;base64,... or data:image/png;base64,...). Only data:image/ URIs are allowed for security. */
|
|
44
|
+
readonly icon?: string;
|
|
45
|
+
readonly isEnabled?: () => boolean;
|
|
46
|
+
readonly order?: number;
|
|
47
|
+
readonly handler?: (...args: unknown[]) => void | Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Actions API - Type definitions for registering and executing editor actions
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* Built-in action IDs that have default implementations
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare type BuiltInActionId = 'document.undo' | 'document.redo' | 'document.export-pdf' | 'document.export-docx' | 'formatting.bold' | 'formatting.italic' | 'formatting.underline' | 'formatting.strikethrough' | 'formatting.subscript' | 'formatting.superscript' | 'formatting.clear' | 'insert.page-break' | 'insert.section-break-next-page' | 'insert.section-break-continuous' | 'insert.column-break' | 'insert.image' | 'insert.link' | 'table.insert' | 'table.delete' | 'table.insert-row-above' | 'table.insert-row-below' | 'table.insert-column-left' | 'table.insert-column-right' | 'table.delete-row' | 'table.delete-column' | 'table.merge-cells' | 'table.split-cells' | 'view.zoom-in' | 'view.zoom-out' | 'view.zoom-reset' | 'view.toggle-ruler' | 'view.toggle-formatting-marks' | 'layout.align-left' | 'layout.align-center' | 'layout.align-right' | 'layout.align-justify' | 'layout.increase-indent' | 'layout.decrease-indent' | 'layout.bulleted-list' | 'layout.numbered-list' | 'style.apply';
|
|
59
|
+
|
|
18
60
|
/**
|
|
19
61
|
* Creates an instance of the Document Authoring system which can be shared between different tasks
|
|
20
62
|
* like creating editors, importing Word documents or creating PDFs.
|
|
@@ -90,15 +132,83 @@ export declare type CreateEditorOptions = {
|
|
|
90
132
|
__hidePDFDownload?: boolean;
|
|
91
133
|
};
|
|
92
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Custom action - must provide handler
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export declare type CustomAction = {
|
|
140
|
+
readonly id: string;
|
|
141
|
+
readonly label: string;
|
|
142
|
+
readonly description?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Keyboard shortcuts for the action.
|
|
145
|
+
* Use "Cmd" as the modifier key - it will be resolved to:
|
|
146
|
+
* - "Ctrl" on Windows/Linux (for keyboard handling)
|
|
147
|
+
* - "⌘" on Mac (for keyboard handling)
|
|
148
|
+
* - "Ctrl" or "⌘" for display based on platform
|
|
149
|
+
*
|
|
150
|
+
* Examples:
|
|
151
|
+
* - "Cmd+B" becomes "Ctrl+B" on Windows, "⌘B" on Mac
|
|
152
|
+
* - "Cmd+Shift+P" becomes "Ctrl+Shift+P" on Windows, "⌘⇧P" on Mac
|
|
153
|
+
*/
|
|
154
|
+
readonly shortcuts?: string[];
|
|
155
|
+
/** Icon as data URI (e.g., data:image/svg+xml;base64,... or data:image/png;base64,...). Only data:image/ URIs are allowed for security. */
|
|
156
|
+
readonly icon?: string;
|
|
157
|
+
readonly isEnabled?: () => boolean;
|
|
158
|
+
readonly order?: number;
|
|
159
|
+
readonly handler: (...args: unknown[]) => void | Promise<void>;
|
|
160
|
+
};
|
|
161
|
+
|
|
93
162
|
/**
|
|
94
163
|
* @hidden
|
|
95
164
|
*/
|
|
96
165
|
declare const _default: {
|
|
97
166
|
createDocAuthSystem: (options?: CreateDocAuthSystemOptions) => Promise<DocAuthSystem>;
|
|
98
167
|
defaultFontIndex: DefaultFontIndex;
|
|
168
|
+
defaultActions: BuiltInAction[];
|
|
169
|
+
defaultToolbarConfig: ToolbarConfig;
|
|
99
170
|
};
|
|
100
171
|
export default _default;
|
|
101
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Get the default set of actions available in the editor.
|
|
175
|
+
* Can be combined with custom actions using spread operator.
|
|
176
|
+
*
|
|
177
|
+
* Note: Built-in actions (those with IDs from {@link BuiltInActionId}) can omit handlers -
|
|
178
|
+
* they will be automatically populated with default implementations when passed to
|
|
179
|
+
* `editor.setActions()`. This allows you to customize labels, shortcuts, and order
|
|
180
|
+
* without needing to implement the behavior yourself. Built-in handlers can also be
|
|
181
|
+
* overridden by providing your own handler function.
|
|
182
|
+
*
|
|
183
|
+
* Custom actions (those with any other string ID) must provide a handler function.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* import { defaultActions } from '@nutrient-sdk/document-authoring';
|
|
188
|
+
*
|
|
189
|
+
* // Customize a built-in action's metadata (handlers auto-populate for built-in actions)
|
|
190
|
+
* editor.setActions([
|
|
191
|
+
* ...defaultActions,
|
|
192
|
+
* { id: 'formatting.bold', label: 'Make Bold', shortcuts: ['Ctrl+B'] }
|
|
193
|
+
* ]);
|
|
194
|
+
*
|
|
195
|
+
* // Override a built-in action's behavior
|
|
196
|
+
* editor.setActions([
|
|
197
|
+
* ...defaultActions,
|
|
198
|
+
* { id: 'formatting.bold', label: 'Bold', handler: () => console.log('custom bold!') }
|
|
199
|
+
* ]);
|
|
200
|
+
*
|
|
201
|
+
* // Add custom actions (must provide handler)
|
|
202
|
+
* editor.setActions([
|
|
203
|
+
* ...defaultActions.filter(a => a.id !== 'document.export-pdf'),
|
|
204
|
+
* { id: 'custom.my-action', label: 'My Action', handler: () => console.log('clicked') }
|
|
205
|
+
* ]);
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
210
|
+
export declare const defaultActions: BuiltInAction[];
|
|
211
|
+
|
|
102
212
|
/**
|
|
103
213
|
* The default font index that is part of the Document Authoring SDK bundle.
|
|
104
214
|
*
|
|
@@ -119,6 +229,25 @@ export declare type DefaultFontIndex = {
|
|
|
119
229
|
*/
|
|
120
230
|
export declare const defaultFontIndex: DefaultFontIndex;
|
|
121
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Get the default toolbar configuration.
|
|
234
|
+
* Can be used as-is or customized.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* import { defaultToolbarConfig } from '@nutrient-sdk/document-authoring';
|
|
239
|
+
*
|
|
240
|
+
* editor.setToolbarConfig(defaultToolbarConfig);
|
|
241
|
+
* // or customize:
|
|
242
|
+
* editor.setToolbarConfig({
|
|
243
|
+
* items: [...defaultToolbarConfig.items, myCustomItem]
|
|
244
|
+
* });
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* @public
|
|
248
|
+
*/
|
|
249
|
+
export declare const defaultToolbarConfig: ToolbarConfig;
|
|
250
|
+
|
|
122
251
|
/**
|
|
123
252
|
* @public
|
|
124
253
|
*/
|
|
@@ -189,6 +318,15 @@ export declare type DocAuthEditor = {
|
|
|
189
318
|
* @param text - The text to insert at the cursor position
|
|
190
319
|
*/
|
|
191
320
|
insertTextAtCursor(text: string): void;
|
|
321
|
+
/**
|
|
322
|
+
* Checks if the editor has an active cursor/insertion point.
|
|
323
|
+
* This is useful for custom actions to determine if they should be enabled.
|
|
324
|
+
*
|
|
325
|
+
* @returns true if cursor is active and insertion is possible, false otherwise
|
|
326
|
+
*
|
|
327
|
+
* @internal
|
|
328
|
+
*/
|
|
329
|
+
hasActiveCursor(): boolean;
|
|
192
330
|
/**
|
|
193
331
|
* Adds an event listener that will be called every time the specified event is emitted.
|
|
194
332
|
*
|
|
@@ -242,6 +380,62 @@ export declare type DocAuthEditor = {
|
|
|
242
380
|
* @eventMap DocAuthEditorEvents
|
|
243
381
|
*/
|
|
244
382
|
once: <EventName extends keyof DocAuthEditorEvents>(event: EventName, handler: DocAuthEditorEventHandler<EventName>) => DocAuthEditor;
|
|
383
|
+
/**
|
|
384
|
+
* Set all actions (replaces any existing actions).
|
|
385
|
+
* Allows setting and executing editor actions programmatically.
|
|
386
|
+
*
|
|
387
|
+
* @param actions - Array of actions to register
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* import { defaultActions } from '@nutrient-sdk/document-authoring';
|
|
392
|
+
*
|
|
393
|
+
* // Register custom actions alongside default actions
|
|
394
|
+
* editor.setActions([
|
|
395
|
+
* ...defaultActions, // Keep default actions
|
|
396
|
+
* {
|
|
397
|
+
* id: 'custom.insert-signature',
|
|
398
|
+
* label: 'Insert Signature',
|
|
399
|
+
* handler: () => {
|
|
400
|
+
* editor.insertTextAtCursor('\n\nBest regards,\nJohn Doe');
|
|
401
|
+
* },
|
|
402
|
+
* shortcuts: [{ mac: '⌘⇧S', windows: 'Ctrl+Shift+S' }]
|
|
403
|
+
* }
|
|
404
|
+
* ]);
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @public
|
|
408
|
+
*/
|
|
409
|
+
setActions(actions: Action[]): void;
|
|
410
|
+
/**
|
|
411
|
+
* Set the toolbar configuration.
|
|
412
|
+
* Use this to customize the editor's toolbar.
|
|
413
|
+
*
|
|
414
|
+
* @param config - Toolbar configuration object
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```typescript
|
|
418
|
+
* import { defaultToolbarConfig } from '@nutrient-sdk/document-authoring';
|
|
419
|
+
*
|
|
420
|
+
* // Use default toolbar
|
|
421
|
+
* editor.setToolbarConfig(defaultToolbarConfig);
|
|
422
|
+
*
|
|
423
|
+
* // Or create a minimal toolbar
|
|
424
|
+
* editor.setToolbarConfig({
|
|
425
|
+
* items: [
|
|
426
|
+
* { type: 'built-in', id: 'undo', builtInType: 'undo' },
|
|
427
|
+
* { type: 'built-in', id: 'redo', builtInType: 'redo' },
|
|
428
|
+
* { type: 'separator', id: 'sep-1' },
|
|
429
|
+
* { type: 'built-in', id: 'bold', builtInType: 'bold' },
|
|
430
|
+
* { type: 'built-in', id: 'italic', builtInType: 'italic' },
|
|
431
|
+
* { type: 'action', id: 'custom', actionId: 'custom.insert-signature' }
|
|
432
|
+
* ]
|
|
433
|
+
* });
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @public
|
|
437
|
+
*/
|
|
438
|
+
setToolbarConfig(config: ToolbarConfig): void;
|
|
245
439
|
};
|
|
246
440
|
|
|
247
441
|
/**
|
|
@@ -601,6 +795,57 @@ export declare namespace Programmatic {
|
|
|
601
795
|
{};
|
|
602
796
|
}
|
|
603
797
|
|
|
798
|
+
/**
|
|
799
|
+
* Toolbar API - Type definitions for customizing the editor toolbar
|
|
800
|
+
* @public
|
|
801
|
+
*/
|
|
802
|
+
/**
|
|
803
|
+
* Action toolbar item - references an action by ID
|
|
804
|
+
* @public
|
|
805
|
+
*/
|
|
806
|
+
export declare type ToolbarActionItem = {
|
|
807
|
+
type: 'action';
|
|
808
|
+
id: string;
|
|
809
|
+
actionId: string;
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Built-in toolbar item - uses original toolbar components directly
|
|
814
|
+
* Self-contained with no external configuration properties
|
|
815
|
+
* @public
|
|
816
|
+
*/
|
|
817
|
+
export declare type ToolbarBuiltInItem = {
|
|
818
|
+
type: 'built-in';
|
|
819
|
+
id: string;
|
|
820
|
+
builtInType: 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'subscript' | 'superscript' | 'text-color' | 'highlight-color' | 'align-left' | 'align-center' | 'align-right' | 'align-justify' | 'bulleted-list' | 'numbered-list' | 'decrease-indent' | 'increase-indent' | 'clear-formatting' | 'formatting-marks' | 'zoom' | 'mobile-lock' | 'font-family' | 'font-size' | 'style-menu' | 'line-spacing-menu' | 'page-setup-menu' | 'insert-menu' | 'table-menu' | 'download-menu' | 'ui-settings-menu';
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Toolbar configuration
|
|
825
|
+
* @public
|
|
826
|
+
*/
|
|
827
|
+
export declare type ToolbarConfig = {
|
|
828
|
+
/**
|
|
829
|
+
* Array of toolbar items to display
|
|
830
|
+
*/
|
|
831
|
+
items?: ToolbarItem[];
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Union type for all toolbar items
|
|
836
|
+
* @public
|
|
837
|
+
*/
|
|
838
|
+
export declare type ToolbarItem = ToolbarActionItem | ToolbarBuiltInItem | ToolbarSeparatorItem;
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Visual separator
|
|
842
|
+
* @public
|
|
843
|
+
*/
|
|
844
|
+
export declare type ToolbarSeparatorItem = {
|
|
845
|
+
type: 'separator';
|
|
846
|
+
id: string;
|
|
847
|
+
};
|
|
848
|
+
|
|
604
849
|
/**
|
|
605
850
|
* @alpha
|
|
606
851
|
*/
|
|
@@ -655,11 +900,41 @@ export declare type UIOptions = {
|
|
|
655
900
|
*
|
|
656
901
|
* Initial zoom level for the editor.
|
|
657
902
|
*
|
|
658
|
-
* Valid range is 0.5 to 4.0.
|
|
903
|
+
* Valid range is 0.5 to 4.0, which any values provided will be clamped to.
|
|
659
904
|
*
|
|
660
905
|
* @defaultValue `1`
|
|
661
906
|
*/
|
|
662
907
|
initialZoom?: number;
|
|
908
|
+
/**
|
|
909
|
+
* Initial toolbar configuration.
|
|
910
|
+
*
|
|
911
|
+
* The toolbar can also be customized at runtime using `editor.setToolbarConfig()`.
|
|
912
|
+
*/
|
|
913
|
+
toolbar?: ToolbarConfig;
|
|
914
|
+
/**
|
|
915
|
+
* Initial actions configuration.
|
|
916
|
+
*
|
|
917
|
+
* Actions can also be customized at runtime using `editor.setActions()`.
|
|
918
|
+
*
|
|
919
|
+
* @example
|
|
920
|
+
* ```typescript
|
|
921
|
+
* import { defaultActions } from '@nutrient-sdk/document-authoring';
|
|
922
|
+
*
|
|
923
|
+
* const editor = await system.createEditor(target, {
|
|
924
|
+
* ui: {
|
|
925
|
+
* actions: [
|
|
926
|
+
* ...defaultActions,
|
|
927
|
+
* {
|
|
928
|
+
* id: 'custom.hello',
|
|
929
|
+
* label: 'Say Hello',
|
|
930
|
+
* handler: () => alert('Hello!'),
|
|
931
|
+
* }
|
|
932
|
+
* ]
|
|
933
|
+
* }
|
|
934
|
+
* });
|
|
935
|
+
* ```
|
|
936
|
+
*/
|
|
937
|
+
actions?: Action[];
|
|
663
938
|
};
|
|
664
939
|
|
|
665
940
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nutrient-sdk/document-authoring",
|
|
3
|
-
"version": "1.9.0-preview.
|
|
3
|
+
"version": "1.9.0-preview.202511030843.fde7b7ea0cd1beee611ebc75b37f110193857a94",
|
|
4
4
|
"description": "A web SDK for word processing and rich text capabilities.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "lib/docauth.umd.js",
|