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

UIOptions>= v1.5.0

UIOptions:

{
locale?: Locale | "auto";
ruler?: { enabled: boolean };
}

Configuration options for the user interface.

CreateEditorOptions for all available options when creating an editor.

optional locale: Locale | "auto"

The locale to use for displaying text, formatting numbers etc.

auto will automatically detect the user’s locale based on their browser settings. If this doesn’t match a supported locale, it will fall back to en.

auto


optional unit: Unit

The unit system for measurements shown in the UI.

pt


optional ruler: object

Configuration for the ruler feature.

enabled: boolean

Controls whether the ruler is shown by default when the editor loads.

true


optional toolbar: ToolbarConfig

Initial toolbar configuration.

The toolbar can also be customized at runtime using editor.setToolbarConfig().

import { defaultToolbarConfig, defaultActions } from '@nutrient-sdk/document-authoring';
// Add a separator and custom action to the default toolbar
const editor = await system.createEditor(target, {
ui: {
actions: [...defaultActions, { id: 'custom.hello', label: 'Say Hello', handler: () => alert('Hello!') }],
toolbar: {
items: [
{ type: 'separator', id: 'sep-custom' },
{ type: 'action', id: 'custom-action', actionId: 'custom.hello' },
],
},
},
});
// Create a minimal toolbar with just undo/redo and bold/italic
const editor = await system.createEditor(target, {
ui: {
toolbar: {
items: [
{ type: 'built-in', id: 'undo', builtInType: 'undo' },
{ type: 'built-in', id: 'redo', builtInType: 'redo' },
{ type: 'separator', id: 'sep-1' },
{ type: 'built-in', id: 'bold', builtInType: 'bold' },
{ type: 'built-in', id: 'italic', builtInType: 'italic' },
],
},
},
});
// Mix built-in items with custom actions
const editor = await system.createEditor(target, {
ui: {
toolbar: {
items: [
{ type: 'built-in', id: 'undo', builtInType: 'undo' },
{ type: 'action', id: 'custom-btn', actionId: 'custom.my-action' },
],
},
actions: [
{
id: 'custom.my-action',
label: 'My Action',
handler: () => console.log('clicked!'),
},
],
},
});

optional actions: Action[]

Initial actions configuration.

Actions can also be customized at runtime using editor.setActions().

import { defaultActions } from '@nutrient-sdk/document-authoring';
const editor = await system.createEditor(target, {
ui: {
actions: [
{
id: 'custom.hello',
label: 'Say Hello',
handler: () => alert('Hello!'),
},
],
},
});