Skip to content
Document Authoring DA  API Docs v1.21.0
npmGitHub

CreateEditorOptions

CreateEditorOptions:

{
canPerformTrackedChange?: (operation: "create" | "accept" | "reject", revisionId?: string) => boolean;
}

Options for creating an editor instance.

// Create editor with empty document
const editor = await system.createEditor(targetElement);
// Create editor with existing document
const doc = await system.loadDocument(docJSON);
const editor = await system.createEditor(targetElement, { document: doc });
// Create editor with custom UI settings
const editor = await system.createEditor(targetElement, {
ui: {
locale: 'de',
unit: 'cm',
ruler: { enabled: false },
},
});
import { defaultToolbarConfig } from '@nutrient-sdk/document-authoring';
// Create editor with custom actions and toolbar
const editor = await system.createEditor(targetElement, {
ui: {
actions: [
{
id: 'custom.save',
label: 'Save',
shortcuts: ['Mod+S'],
handler: async () => {
const doc = await editor.currentDocument().saveDocument();
await fetch('/api/save', { method: 'POST', body: JSON.stringify(doc) });
},
},
],
toolbar: {
items: [
{ type: 'built-in', id: 'undo', builtInType: 'undo' },
{ type: 'built-in', id: 'redo', builtInType: 'redo' },
{ type: 'separator', id: 'sep-1' },
{ type: 'action', id: 'save-btn', actionId: 'custom.save' },
],
},
},
});

optional document: DocAuthDocument

The document to attach to this editor. If no document is provided, an empty document will be created.

DocAuthEditor.setCurrentDocument for setting the document after the editor is created.


optional canPerformTrackedChange: (operation, revisionId?) => boolean

Decides whether this editor may create, accept, or reject a tracked change.

Return false, or throw, to deny the operation. revisionId is provided for accept and reject operations. This callback applies only to editor-originated operations; document transactions remain under host control.

"create" | "accept" | "reject"

string

boolean


optional ui: UIOptions