This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/web/headless/content-editor.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Headless content editor | Nutrient Web SDK

The instance.contentEditor namespace exposes the headless surface for content editor integrations. Use it when you want to react to editor state in your own UI or respond to content editing changes without relying on the built-in chrome.

Looking for the visual editing experience? Refer to the PDF content editing API and edit PDF text using our JavaScript content editor guides. This page covers the headless state surface you can use alongside those guides.

When to use this

Reach for the headless content editor surface when you want to:

  • Watch the content editor state from a custom toolbar or side panel.
  • React to state changes in your own UI without polling.
  • Keep host-app controls in sync with the current content editing session.

API reference

SymbolNotes
instance.contentEditorHeadless namespace for content editor integrations.
contentEditor.stateChangeEvent fired when the content editor state changes.

Example: Listen for content editor state changes

The following example shows how to listen for content editor state changes using the contentEditor.stateChange event. This event is fired whenever the content editor state changes, such as when a new editing session starts, when a user makes changes to the content, or when the editing session ends.

const instance = await NutrientViewer.load({
container: "#viewer",
document: "contract.pdf"
});
instance.addEventListener("contentEditor.stateChange", (event) => {
console.log("Content editor state changed:", event);
});

Use this event to update your own buttons, menus, or status text when the editor changes state.