Skip to main content
@reductoai/docx-editor/model: the headless editor. Guide: Headless editor.

EditorModel

@reductoai/docx-editor/model: the headless layer. No Svelte, no DOM chrome; the model, its observable protocol, input binding, clipboard, palette commands and export helpers. A host that draws its own UI needs only this. Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

new EditorModel()

EditorModel properties

answerModify()

Resolves false, and marks the prompt wrong, when the password does not match.

applyCollabChange()

Applies change after the edits before it, as this writer’s own: sent, and one undo step.

applyCollabChanges()

Applies steps in order after the edits before them: one layout, one undo step; each is sent and observed with its tag.

applyRunFormat()

attach()

bindInput()

cancelUnlock()

changePicture()

Change Picture: a picked file takes the selected picture’s place in the same frame.

clearHover()

collabAck()

collabPeers()

The other writers and their last reported selections; replaces the previous set.

collabPending()

After the edits before this call: true while the server has not confirmed one; undefined off a session.

collabRemote()

Server messages, in the order the server sent them.

collabResend()

collabSnapshot()

The bytes as of the last sequenced change, after every queued edit; undefined while one is unconfirmed.

collabTokens()

The body’s tokens, or a story stream’s, after the edits before this call.

collapse()

compareWith()

Word’s Compare: this document is the original, revised the later copy. The result, revised with every difference as a tracked change, opens in its place.

copy()

copyFormat()

Copy Format (Ctrl+Shift+C): remember the caret’s character formatting.

destroy()

drawOverlay()

dropCaret()

Where a picture drag would drop, without disturbing the live selection.

editShapeText()

Word’s Add Text / Edit Text: open the selected shape’s text, making it when there is none.

enterHeaderFooter()

Word’s Edit Header / Edit Footer: the caret moves into the band on the caret’s page, else the page in view. The caret’s section gets an empty one first when it shows none, as Word’s Insert > Header does. False when read-only or still not found.

enterStory()

exitStory()

fail()

Show a message (or an error’s) as a transient toast.

floatHover()

Whether a press here grabs a float, so the pointer can say so before the click.

focusInput()

goBack()

Shift+F5: the caret visits the last few places an edit was made, newest first.

goToPage()

Word’s Go To page; false leaves the dialog open on input that names no page.

hitTest()

The page, text position and link under a viewport point; null off the pages.

hoverAt()

Track the closed story under the pointer; the hint repaints only when it changes.

insertChart()

Insert Chart; a selected picture keeps its place and the chart lands after it.

insertImageFile()

insertNote()

A note mark after the selection (mark: Word’s Custom mark); the caret goes into the new note, and Escape comes back.

insertTextBox()

Float a new text box off the caret and start typing in it, as Word does.

layerFor()

linkAt()

The address a link under the point goes to: a URL, or #bookmark.
The link under a page point and its text’s box on that line in client pixels.

move()

observes()

open()

keepView takes new bytes for the document already on screen (another writer saved it): the old pages stay up until the new layout is ready, and scroll, caret and open panels survive where they still resolve. Resolves true once the document is on screen.

openBlank()

File > New: Word’s blank document, opened in place of the current one.

openGoTo()

pasteFormat()

Paste Format (Ctrl+Shift+V): lay the copied formatting over the selection.

pickImage()

placeAt()

placeCaret()

redo()

redoOrRepeat()

Word’s Ctrl+Y and F4: redo while there is something to redo, else repeat the last edit.

refreshFromHost()

The session changed under the editor (an agent edited it). Relayout from the host, repaint every page and keep the caret where it still resolves. A failure is toasted and rethrown: the caller must not report a repaint that never reached the page.

resizeFont()

run()

runImage()

runOnChart()

A data pane commits on blur, often after a click moved the caret: the edit goes to the chart it came from, and the pane keeps the keyboard.

runTable()

saveBytes()

The bytes a Save writes: encrypted when openPassword is set.

scaleFor()

Display px per hmm on one page.

scrollCaretIntoView()

top is Word’s jump (a heading, Go To): the caret’s line goes to the top of the window. center puts a selection that is out of view in the middle of the window.

seedRevisionAuthor()

The author a live session joined as, unless the host set one with setRevisionAuthor.

select()

selectAll()

selectCollabRange()

Selects tokens from..to of the body, or of story stream stream, and scrolls to them.

selectFloat()

A click landing on a floating picture selects the character that anchors it.

selectionBox()

The selection’s box in client pixels, for chrome that floats beside it; null when it is off screen.

selectionRects()

One box per selected line in client pixels; empty for a caret.

selectionText()

The selection as plain text, as Copy puts it on the clipboard.

selectShape()

Select a shape by its anchoring character, moving to the story that holds it.

setAlignment()

setDrawingGrid()

Word’s View > Gridlines: the document’s drawing grid over each page.

setGridlines()

Word’s View Gridlines: dashed rules where a table cell has no border.

setMarkup()

Simple and No Markup show the document as if accepted; Original as if every change were rejected.

setOpenPassword()

File > Passwords: "" or null saves without a password to open.

setOutline()

Opens, changes (Show Level, collapsed headings) or, with null, closes Outline view.

setRevisionAuthor()

The name this writer’s tracked changes and comments carry, in this and every later document.

setScheme()

setSuggesting()

Under a policy other than “allow” the policy wins over on.

setTablePosition()

setTableWrap()

setZoom()

Zoom the pages: a scale (1 is 100%), “fit” for the window’s width or “page” for a whole page.

snapTargets()

The guides a float dragged on page may line up with, itself left out.

stampOf()

startCollab()

Joins a shared session; with no send, a session of one that confirms its own changes.

startComment()

subscribe()

Listen to one key, or to every change (including adopted children) when key is omitted.

tab()

The host settles Tab against the document as it is then, not the format shown now.

tapChart()

toBytes()

The current edit state as .docx bytes, carrying its Session for the next open.

toggleBold()

toggleItalic()

toggleList()

toggleStrike()

toggleUnderline()

toPdf()

toPng()

typeIntoShape()

Keys typed on a selected shape go into its text, as in Word; a new story is made first. False when none takes text.

undo()

unlock()

Retries the encrypted file open stopped on.

whenLicensed()

Resolves once npm.reducto.ai trusts this install; else sets licenseError and rethrows.

EditorModelOptions

@reductoai/docx-editor/model: the headless layer. No Svelte, no DOM chrome; the model, its observable protocol, input binding, clipboard, palette commands and export helpers. A host that draws its own UI needs only this. Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

EditorTransport

How the model reaches a session. spawnWorker is the bundler’s business (new Worker(new URL("./host-worker.ts", import.meta.url), { type: "module" })); without one, or when the worker fails to load, createHost runs in the page. Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

attachEditorInput()

Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

serveEditorHost()

Answer editor requests on scope until it is terminated. scope is the worker’s self, or a MessagePort when the worker also serves other traffic. Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

ServeEditorHostOptions

Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

createDefaultHost()

Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

portableFonts()

Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

formatCommands()

Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

WorkerConfig

Sent to the worker before its first request, so it builds the same provider as the page. Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

ProgressView

Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

Phase

Import from @reductoai/docx-editor, @reductoai/docx-editor/model.

ZoomMode

Import from @reductoai/docx-editor, @reductoai/docx-editor/model.