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.
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
The SDK supports three modules. The module value is the identifier used in code; the product names are Word,
Spreadsheet, and Presentation.
| Product | module | Entry point | Root handle | Current generated catalog |
|---|---|---|---|---|
| Word | word | Office.word(iframe) | Word.WordDocument | 14 types, 259 methods |
| Spreadsheet | cell | Office.cell(iframe) | Cell.Workbook | 6 types, 156 methods |
| Presentation | show | Office.show(iframe) | Show.Document | 10 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
| API | Use it when… | Entry point |
|---|---|---|
| Document handles | You want predictable application code | app.getDocument() and the handles it returns |
| Document tools | You want your own agent to call editor capabilities | app.getTools() |
| Low-level commands | You are integrating a documented editor command | app.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 fromiframe.src, offerswhenReady()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-iframetargetWindowtopology.
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
- Complete the quickstart
- Explore the module guides: Word API, Spreadsheet API, Presentation API
- Use document tools and handle errors
- Understand the iframe protocol and lifecycle
- For exact method names, parameters, and return types, see the Word, Spreadsheet, Presentation API references.
- Open the Editor SDK Playground