-
Notifications
You must be signed in to change notification settings - Fork 63
/
word.eventsource.yml
61 lines (46 loc) · 1.83 KB
/
word.eventsource.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
### YamlMime:TSEnum
name: Word.EventSource
uid: 'word!Word.EventSource:enum'
package: word!
fullName: Word.EventSource
summary: An enum that specifies an event's source. It can be local or remote (through coauthoring).
remarks: >-
\[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
#### Examples
```TypeScript
// 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);
});
}
```
isPreview: false
isDeprecated: false
fields:
- name: local
uid: 'word!Word.EventSource.local:member'
package: word!
summary: '* \[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
value: '"Local"'
- name: remote
uid: 'word!Word.EventSource.remote:member'
package: word!
summary: '* \[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
value: '"Remote"'