Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Word.EventSource enum
- Package:
- word
An enum that specifies an event's source. It can be local or remote (through coauthoring).
Remarks
Used by
- Word.CommentEventArgs: source
- Word.ContentControlAddedEventArgs: source
- Word.ContentControlDataChangedEventArgs: source
- Word.ContentControlDeletedEventArgs: source
- Word.ContentControlEnteredEventArgs: source
- Word.ContentControlExitedEventArgs: source
- Word.ContentControlSelectionChangedEventArgs: source
- Word.ParagraphAddedEventArgs: source
- Word.ParagraphChangedEventArgs: source
- Word.ParagraphDeletedEventArgs: source
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml
// Registers event handlers.
await Word.run(async (context) => {
const body: Word.Body = context.document.body;
body.track();
await context.sync();
eventContexts[0] = body.onCommentAdded.add(onEventHandler);
eventContexts[1] = body.onCommentChanged.add(onChangedHandler);
eventContexts[2] = body.onCommentDeleted.add(onEventHandler);
eventContexts[3] = body.onCommentDeselected.add(onEventHandler);
eventContexts[4] = body.onCommentSelected.add(onEventHandler);
await context.sync();
console.log("Event handlers registered.");
});
...
async function onEventHandler(event: Word.CommentEventArgs) {
// Handler for all events except onCommentChanged.
await Word.run(async (context) => {
console.log(`${event.type} event detected. Event source: ${event.source}. Comment info:`, event.commentDetails);
});
}
Fields
| local = "Local" | Local source. |
| remote = "Remote" | Remote source. |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Add-ins
Feedback
Was this page helpful?
