Office.js API Request: Context-Anchored Sandboxed Web Surfaces for Excel, Word, and PowerPoint
Office Add-ins currently provide cross-platform task panes, dialogs, and add-in commands. However, developers cannot display sandboxed and interactive web content anchored to a selected document object without inserting a native shape, image, text box, content control, or other persistent Office object.
I propose a cross-platform Context-Anchored Web Surface API for Excel, Word, and PowerPoint.
The API should allow an Office Add-in to attach a sandboxed web card to the current selection or to a supported document object, including:
- Excel ranges, table cells, charts, images, or shapes
- Word text ranges, paragraphs, table cells, images, or content controls
- PowerPoint text ranges, shapes, images, table cells, or slides
The surface should not become part of the native document drawing layer unless the developer explicitly requests conversion to a document object.
Office should manage:
- Position relative to the anchor
- Focus and keyboard interaction
- Security boundaries
- Z-order and clipping
- Scrolling and zoom behavior
- Word document reflow
- PowerPoint editing and presentation modes
- Surface lifetime and restoration
- Cross-platform behavior
The proposed API should provide:
- A unified cross-host anchor abstraction
- Persistent anchor identifiers
- Selection, session, document, and manual lifetime modes
- Preview, interactive, and editor interaction modes
- Sandboxed iframe or WebView content
- Automatic viewport-aware placement
- Host-managed repositioning during scrolling, zooming, layout changes, or document reflow
- Explicit print, PDF export, image export, and presentation rendering policies
- Message passing between the Office Add-in runtime and the contextual surface
- Requirement-set detection across Windows, macOS, Office on the web, and supported mobile clients
An example API could look like:
Office.context.ui.contextualSurfaces.create({
anchor: Office.context.document.getSelectionAnchor(),
source: {
url: “https://example.com/context-card”
},
placement: {
preferred: “right”,
keepInViewport: true,
followAnchor: true
},
interaction: {
mode: “interactive”,
dismissOnEscape: true
},
lifetime: {
mode: “document”,
restoreOnOpen: true
},
rendering: {
mode: “authoringOnly”,
includeInPrint: false,
includeInExport: false
}
});
This would enable contextual experiences such as:
- Chemical compound and molecular structure cards
- Biomedical annotations
- Citation and literature tools
- Translation and terminology previews
- Financial and company data cards
- Educational explanations
- AI-assisted review tools
- Domain-specific document annotations
Today, developers must choose between a fixed task pane and native document objects. A host-managed contextual web surface would provide a secure and consistent middle layer while preserving document integrity and cross-platform compatibility.