Word JavaScript preview APIs

New Word JavaScript APIs are first introduced in "preview" and later become part of a specific, numbered requirement set after sufficient testing occurs and user feedback is acquired.

Important

Note that the following Word preview APIs may be available on the following platforms.

  • Word on Windows
  • Word on Mac

Word preview APIs are currently not supported on iPad. However, bookmark feature APIs are also available in Word on the web. For APIs available only in Word on the web, see the Web-only API list.

Note

Preview APIs are subject to change and are not intended for use in a production environment. We recommend that you try them out in test and development environments only. Do not use preview APIs in a production environment or within business-critical documents.

To use preview APIs:

  • You must use the preview version of the Office JavaScript API library from the Office.js content delivery network (CDN). The type definition file for TypeScript compilation and IntelliSense is found at the CDN and DefinitelyTyped. You can install these types with npm install --save-dev @types/office-js-preview (be sure to remove the types for @types/office-js if you've previously installed them).
  • You may need to join the Office Insider program for access to more recent Office builds.

API list

The following table lists the Word JavaScript APIs currently in preview, except those that are available only in Word on the web. To see a complete list of all Word JavaScript APIs (including preview APIs and previously released APIs), see all Word JavaScript APIs.

Class Fields Description
ContentControl onDataChanged Occurs when data within the content control are changed.
onDeleted Occurs when the content control is deleted.
onSelectionChanged Occurs when selection within the content control is changed.
ContentControlEventArgs contentControl The object that raised the event.
eventType The event type.
Document onContentControlAdded Occurs when a content control is added.
InlinePicture imageFormat Gets the format of the inline image.
List getLevelFont(level: number) Gets the font of the bullet, number, or picture at the specified level in the list.
getLevelPicture(level: number) Gets the base64 encoded string representation of the picture at the specified level in the list.
resetLevelFont(level: number, resetFontName?: boolean) Resets the font of the bullet, number, or picture at the specified level in the list.
setLevelPicture(level: number, base64EncodedImage?: string) Sets the picture at the specified level in the list.
TableRow insertContentControl() Inserts a content control on the row.

Web-only API list

The following table lists the Word JavaScript APIs currently in preview only in Word on the web. To see a complete list of all Word JavaScript APIs (including preview APIs and previously released APIs), see all Word JavaScript APIs.

Class Fields Description
CommentCollection onCommentAdded Occurs when new comments are added.
onCommentChanged Occurs when a comment or its reply is changed.
onCommentDeleted Occurs when comments are deleted.
onCommentDeselected Occurs when a comment is deselected.
onCommentSelected Occurs when a comment is selected.
CommentDetail id Represents the ID of this comment.
replyIds Represents the IDs of the replies to this comment.
CommentEventArgs changeType Represents how the comment changed event is triggered.
commentDetails Gets the CommentDetail array which contains the IDs and reply IDs of the involved comments.
source The source of the event.
type The event type.
Field delete() Deletes the field.

See also