편집

다음을 통해 공유


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, several APIs may also be 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:

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
Body shapes Gets the collection of shape objects in the body, including both inline and floating shapes.
type Gets the type of the body.
ContentControl resetState() Resets the state of the content control.
setState(contentControlState: Word.ContentControlState) Sets the state of the content control.
ContentControlAddedEventArgs eventType The event type.
ContentControlDataChangedEventArgs eventType The event type.
ContentControlDeletedEventArgs eventType The event type.
ContentControlEnteredEventArgs eventType The event type.
ContentControlExitedEventArgs eventType The event type.
ContentControlSelectionChangedEventArgs eventType The event type.
Document compareFromBase64(base64File: string, documentCompareOptions?: Word.DocumentCompareOptions) Displays revision marks that indicate where the specified document differs from another document.
Font hidden Specifies a value that indicates whether the font is tagged as hidden.
InsertShapeOptions height Represents the height of the shape being inserted.
left Represents the left position of the shape being inserted.
top Represents the top position of the shape being inserted.
width Represents the width of the shape being inserted.
Paragraph insertGeometricShape(geometricShapeType: Word.GeometricShapeType, insertShapeOptions?: Word.InsertShapeOptions) Inserts a geometric shape with its anchor at the beginning of the paragraph.
insertPictureFromBase64(base64EncodedImage: string, insertShapeOptions?: Word.InsertShapeOptions) Inserts a floating picture with its anchor at the beginning of the paragraph.
insertTextBox(text?: string, insertShapeOptions?: Word.InsertShapeOptions) Inserts a floating text box with its anchor at the beginning of the paragraph.
shapes Gets the collection of shape objects anchored in the paragraph, including both inline and floating shapes.
ParagraphAddedEventArgs type The event type.
ParagraphChangedEventArgs type The event type.
ParagraphDeletedEventArgs type The event type.
Range insertGeometricShape(geometricShapeType: Word.GeometricShapeType, insertShapeOptions?: Word.InsertShapeOptions) Inserts a geometric shape with its anchor at the beginning of the range.
insertPictureFromBase64(base64EncodedImage: string, insertShapeOptions?: Word.InsertShapeOptions) Inserts a floating picture with its anchor at the beginning of the range.
insertTextBox(text?: string, insertShapeOptions?: Word.InsertShapeOptions) Inserts a floating text box with its anchor at the beginning of the range.
shapes Gets the collection of shape objects anchored in the range, including both inline and floating shapes.
Shape body Represents the body object of the shape.
delete() Deletes the shape and its content.
geometricShapeType The geometric shape type of the shape.
height The height, in points, of the shape.
id Gets an integer that represents the shape identifier.
left The distance, in points, from the left side of the shape to the horizontal relative position, see Word.RelativeHorizontalPosition.
moveHorizontally(distance: number) Moves the shape horizontally by the number of points.
moveVertically(distance: number) Moves the shape vertically by the number of points.
name The name of the shape.
relativeHorizontalPosition The relative horizontal position of the shape.
relativeVerticalPosition The relative vertical position of the shape.
select(selectMultipleShapes?: boolean) Selects the shape.
shapeGroup Gets the shape group associated with the shape.
top The distance, in points, from the top edge of the shape to the vertical relative position, see Word.RelativeVerticalPosition.
type Gets the shape type.
width The width, in points, of the shape.
ShapeCollection getByGeometricTypes(types: Word.GeometricShapeType[]) Gets the shapes that have the specified geometric types.
getById(id: number) Gets a shape by its identifier.
getByIdOrNullObject(id: number) Gets a shape by its identifier.
getByIds(ids: number[]) Gets the shapes by the identifiers.
getByTypes(types: Word.ShapeType[]) Gets the shapes that have the specified types.
getFirst() Gets the first shape in this collection.
getFirstOrNullObject() Gets the first shape in this collection.
group() Groups floating shapes in this collection, inline shapes will be skipped.
items Gets the loaded child items in this collection.
ShapeGroup id Gets an integer that represents the shape group identifier.
shape Gets the Shape object associated with the group.
shapes Gets the collection of Shape objects.
unGroup() Ungroups any grouped shapes in the specified shape group.
Style description Gets the description of the specified style.

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
Body 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.
ContentControl onCommentAdded Occurs when new comments are added.
onCommentChanged Occurs when a comment or its reply is changed.
onCommentDeselected Occurs when a comment is deselected.
onCommentSelected Occurs when a comment is selected.
Paragraph 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.
Range onCommentAdded Occurs when new comments are added.
onCommentChanged Occurs when a comment or its reply is changed.
onCommentDeselected Occurs when a comment is deselected.
onCommentSelected Occurs when a comment is selected.

See also