Skip to main content

Control Office with JavaScript

Editor SDK (@thinkfree.dev/tfo-sdk) connects a host web page to a Thinkfree Office editor running in an iframe. Your application can read and edit Word, Spreadsheet, and Presentation documents, run the editor's document tools from your own AI agent, or send low-level commands.

Public npm package · Preview

What you can build

  • A document editor embedded in your web application
  • Deterministic Word, Spreadsheet, and Presentation automation
  • A Playground for finding and running document APIs
  • An AI agent that uses the same document tools

One integration surface

Host applicationOffice.word(iframe)Office.cell(iframe)Office.show(iframe)Editor SDK@thinkfree.dev/tfo-sdkgetDocument() / getWorkbook()deterministic document APIdocument methods via app.getDocument()getTools()executable document tools for your LLMframeworkexecute()low-level command channelexact-originpostMessageThinkfree OfficeiframeWordSpreadsheetPresentation

The SDK supports three modules. The module value is the identifier used in code; the product names are Word, Spreadsheet, and Presentation.

ProductmoduleEntry pointRoot handleCurrent generated catalog
WordwordOffice.word(iframe)Word.WordDocument14 types, 259 methods
SpreadsheetcellOffice.cell(iframe)Cell.Workbook6 types, 156 methods
PresentationshowOffice.show(iframe)Show.Document10 types, 586 methods

The method totals come from the API catalog shipped with the current Playground artifact. Treat them as versioned preview data rather than a permanent compatibility promise.

Choose an API level

APIUse it when…Entry point
Document handlesYou want predictable application codeapp.getDocument() and the handles it returns
Document toolsYou want your own agent to call editor capabilitiesapp.getTools()
Low-level commandsYou are integrating a documented editor commandapp.execute(method, params)

Start with document handles. Low-level command names are more tightly coupled to the editor protocol.

Two ways to connect

  • Office.word(iframe) / Office.cell(iframe) / Office.show(iframe) - recommended. Pass the iframe element; the SDK derives the editor origin from iframe.src, offers whenReady() to wait for the editor to boot, and returns the same app handle for the same iframe (get-or-create).
  • createOffice({ module, frameworkOrigin, iframeEl | targetWindow, timeoutMs }) - low level. Use it when you need explicit options, for example a non-iframe targetWindow topology.

Both connect to an editor that is already loaded in the page. Neither creates a document, and disconnect() only releases the connection.

Distribution

Install @thinkfree.dev/tfo-sdk from the public npm registry. Pin the package version you have verified for production.

npm install @thinkfree.dev/tfo-sdk

Requirements: a browser environment (DOM), ESM (import), and TypeScript 4.9 or later if you use the bundled types.

Next steps