Skip to content

Element API and events ​

Every framework adapter wraps the same <docx-editor> custom element. The adapters forward these properties and re-emit these events in their framework's idiom (see framework bindings).

Attributes and properties ​

PropertyAttributeDescription
documentModelThe DocumentModel shown. Assigning it is an external replacement, not an edit event.
readOnlyread-onlyBlocks local edits. Remote collaboration batches still apply.
localelocaleInterface language: en, fr, de, es or zh-CN. Document content is never translated.
fileNamefile-nameName of the open document (default Document1.docx).
reviewAuthorreview-authorAuthor recorded on tracked changes and comments (default Author).
themethemelight, dark or auto. See theming.
themeColorsPartial token overrides applied as --dve-* custom properties.
showThumbnailsshow-thumbnailsLeft rail of page thumbnails (Print Layout only).
showToolbarshow-toolbarfalse hides the ribbon; the title bar and status bar remain.
hiddenActionsRibbon controls to hide by stable id; see the table in bindings.
dirty (read)True after an edit, false after save, load or markClean().

Methods ​

MethodDescription
load(bytes)Load DOCX or legacy DOC bytes. Rejects and emits document-error on failure.
save()Resolves to a Blob of the serialized document.
saveBytes()Resolves to the raw Uint8Array.
download(fileName?)Saves and starts a browser download.
markClean()Clears the dirty flag after the host persisted the document.
startCollaboration(config)Join a collaboration session; see collaboration.
getPendingCollaboration()The pending step batch, or null.
receiveCollaboration(batch)Apply an accepted batch from the authority.
stopCollaboration(discardPending?)Leave the session; pending edits must be acknowledged or explicitly discarded.
publishPresence, receivePresence, leavePresenceTransient presence channel; see collaboration.

Events ​

All events bubble and are composed, so they cross the shadow boundary.

EventDetailMeaning
document-changeDocumentModelThe document changed through editing or review actions.
document-errorErrorLoading, saving, printing or an edit failed.
document-warningstringNon-fatal notice.
readonly-changebooleanThe user toggled Editing/Viewing in the chrome.
file-command{ command }Cancelable. command is new, open, save, export or print.
dirty-changebooleanUnsaved-changes state flipped.
page-change{ page, pageCount }Print Layout page or page count changed (approximate pagination).
ribbon-actionRibbonActionA ribbon control was activated.
ribbon-customizereadonly string[]The user changed which ribbon commands are shown; persist the ids if wanted.
presence-sendPresenceMessageLocal presence changed; transport it to other clients.
collaboration-sendStepBatchLocal steps are pending; transport them to the authority.

The package exports the typed event map (DocxEditorEventMap) and the runtime list DOCX_EDITOR_EVENTS.

Released under the Apache-2.0 License.