Nutrient Web SDK
    Preparing search index...

    Interface ContentEditor

    The instance.contentEditor namespace exposes the headless APIs that let a custom toolbar read state from and write state to the live UI content editor session.

    Session save/discard/dirty-flag/export and starting a programmatic session stay on Instance itself — see Instance#saveContentEditingSession, Instance#discardContentEditingSession, Instance#hasUnsavedContentEditingChanges, Instance#exportContentEditorPDF, and Instance#beginContentEditingSession. This namespace fills the gaps those methods do not cover.

    The read methods expose the live session — UI or programmatic, whichever is currently active. UI state methods such as selection, focus, text styling, undo, redo, and layout changes require an active UI session. Programmatic sessions should use the ContentEditing.Session returned by Instance#beginContentEditingSession for mutations.

    Subscribe to "contentEditor.stateChange" to keep a custom toolbar in sync with state changes.

    interface ContentEditor {
        focusBlock(id: string | null): void;
        getActiveBlock(): string | null;
        getAvailableFonts(): readonly AvailableFontFace[];
        getBlock(id: string): TextBlockSummary | null;
        getBlocks(pageIndex?: number): readonly TextBlockSummary[];
        getCurrentStyle(): CurrentStyle | null;
        getSelectedBlock(): string | null;
        isActive(): boolean;
        redo(): void;
        selectBlock(id: string | null): void;
        setLayout(id: string, layout: LayoutInput): Promise<void>;
        setTextStyle(style: TextStyle): void;
        undo(): void;
    }
    Index

    Methods

    • Put the given block into Active state (cursor inside, edit mode). Pass null to clear.

      Parameters

      • id: string | null

      Returns void

    • Returns string | null

    • Synchronous read of a single block by id. Narrow on block.type.

      Parameters

      • id: string

      Returns TextBlockSummary | null

    • Synchronous read of all blocks (or the blocks on one page). Narrow on block.type.

      Parameters

      • OptionalpageIndex: number

      Returns readonly TextBlockSummary[]

    • Style at the cursor / selection inside the active block, or null if no block is active.

      Returns CurrentStyle | null

    • Returns string | null

    • Redo the last undone change in the active text block.

      Returns void

    • Put the given block into Selected state (clicked, but not in edit mode). Pass null to clear.

      Parameters

      • id: string | null

      Returns void

    • Apply layout properties to a specific text block in the active UI session.

      Parameters

      Returns Promise<void>

    • Apply style to the current UI selection (or to the cursor for next-typed text).

      Parameters

      Returns void

    • Undo the last change in the active text block (text-input scoped today).

      Returns void