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

CreateEditorOptions

CreateEditorOptions:

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 },
},
});
// 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 ui: UIOptions