You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/components/dispatch.md
+31-19Lines changed: 31 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Join to get access to the Beacon SDK, the community sheet repo for Beacon sheet,
24
24
25
25
The dispatch is returned by the `initRelay` and provides methods for sending commands from the character sheet back to the host. Except when specified every method below will return a promise.
26
26
27
-
####update
27
+
## update
28
28
```javascript
29
29
dispatch.update({
30
30
options: { overwrite?: boolean }
@@ -35,7 +35,7 @@ The `update` method sends character changes to the host (Roll20 Tabletop or Roll
35
35
36
36
The partial character passed in here must contain the character's id, and can contain any combination of the attributes, bio, and gmNotes properties. When updating a character’s attributes, only include those attributes that have changed.
37
37
38
-
####updateCharacter
38
+
## updateCharacter
39
39
```javascript
40
40
dispatch.updateCharacter({
41
41
character: Partial<Character>
@@ -45,7 +45,7 @@ Like the `update` method, `updateCharacter` sends character changes to the host
45
45
46
46
However, this method takes a full set of character attributes as the character argument, and automatically computes the diff with existing character attributes, so that only changed attributes are sent to the data store.
@@ -58,7 +58,7 @@ If messageId is omitted, the roll will be associated with a new chat message and
58
58
59
59
The method returns a promise that resolves with an object containing the messageId and the RollResult (see Types). The roll result is returned in the same format as in the non-beacon dice rolls computed roll system.
60
60
61
-
####post
61
+
## post
62
62
```javascript
63
63
dispatch.post({
64
64
characterId: string,
@@ -78,7 +78,7 @@ The secret option is ignored unless whisper is also set, toggling to true will c
78
78
79
79
Like roll, messageId can be provided to update an existing chat message, but if omitted the method will generate a new messageId and post a new chat message. The method returns the messageId.
80
80
81
-
####query
81
+
## query
82
82
```javascript
83
83
dispatch.query(options: Swal2Options): {
84
84
isConfirmed: boolean,
@@ -102,7 +102,7 @@ The `query` method takes an options object and uses them to display a [SweetAler
`perform` executes the specified action on behalf of the character (designated by the character id), passing in args to the action method. This method can perform actions on behalf of any character, even a character that the sheet does not have data for.
114
114
115
-
####getComputed
115
+
## getComputed
116
116
```javascript
117
117
dispatch.getComputed({
118
118
characterId: string,
@@ -132,7 +132,7 @@ dispatch.setComputed({
132
132
```
133
133
`getComputed` and `setComputed` are both nearly identical in how they are called, taking a character id and a property with the name of the computed property you wish to get or set, and an array of string args. Both methods return a promise that resolves with the computed value.
134
134
135
-
####compendiumRequest
135
+
## compendiumRequest
136
136
```javascript
137
137
dispatch.compendiumRequest({
138
138
query: string
@@ -144,7 +144,7 @@ dispatch.compendiumRequest({
144
144
```
145
145
`compendiumRequest` executes an AJAX request to the compendium service’s graphQL endpoint. It takes in a graphQL query string written according to the Compendium service’s schema. The query string does not need to include the ruleSystem shortName as this is set automatically according to the campaign override or sheet.json value in the Roll20 Tabletop.
Like `compendiumRequest`, except that calls to this method are automatically debounced (at 100ms) and grouped together into a single request to the compendium service. Note that this method will only return the requested data, it does not return errors or extensions.
156
156
157
-
####getTokens
157
+
## getTokens
158
158
```javascript
159
159
dispatch.getTokens({
160
160
characterId: string
@@ -168,7 +168,7 @@ dispatch.getTokens({
168
168
```
169
169
`getTokens` requires a character id string and returns information about tokens on the user’s current page. The return value contains two arrays of tokens. The tokens array contains all tokens on the current page that represent the character whose id was provided to the method. The selected array contains any tokens that are currently selected, regardless of which character they represent. The returned token objects contain all of the token attributes available to the API, you can find documentation here and here.
170
170
171
-
####addToTracker
171
+
## addToTracker
172
172
```javascript
173
173
dispatch.addToTracker({
174
174
tokenId?: string,
@@ -182,7 +182,7 @@ dispatch.addToTracker({
182
182
```
183
183
`addToTracker` adds or updates a single item in the turn tracker. Passing in a tokenId will add the specified token to the tracker, while passing in custom with a name and an optional image url (img) will add a custom item, not connected to any character or token. A round calculation string can be added via the optional formula parameter. value is the initiative number for the item.
184
184
185
-
####addMacrosToHost
185
+
## addMacrosToHost
186
186
```javascript
187
187
dispatch.addMacrosToHost({
188
188
macro: {
@@ -206,7 +206,7 @@ Passing in a `location` will add it either to the player's macroBar, the charact
206
206
207
207
[See Actions page for examples on the usuage of `addMacrosToHost`](/beacon-docs/docs/components/actions)
208
208
209
-
####getCharacterMacros
209
+
## getCharacterMacros
210
210
```javascript
211
211
dispatch.getCharacterMacros({
212
212
args: {
@@ -224,7 +224,7 @@ dispatch.getCharacterMacros({
224
224
```
225
225
`getCharacterMacros` gets a specific character’s macros. The `ids` returned from this list can be used in conjuction with `addMacrosToHost` update their locations. In jumpgate games, character macros can also be found in the `Advanced Tools -> Characters Macros` tab.
226
226
227
-
####setContainerSize
227
+
## setContainerSize
228
228
```javascript
229
229
dispatch.setContainerSize({
230
230
args: {
@@ -235,7 +235,7 @@ dispatch.setContainerSize({
235
235
```
236
236
`setContainerSize` updates the size of the container which holds the sheet shared settings. Returns a promise that can be awaited. This can be used in conjunction with something like the ResizeSensor event listener from npm: css-element-queries to automatically resize the container on the host.
`updateTokensByCharacter` updates a particular character’s default token as well as all existing tokens representing that character. Returns a promise that can be awaited.
248
248
249
-
####updateTokensByIds
249
+
## updateTokensByIds
250
250
```javascript
251
251
dispatch.updateTokensByIds({
252
252
args: {
@@ -257,7 +257,7 @@ dispatch.updateTokensByIds({
257
257
```
258
258
`updateTokensByIds` updates a single or several tokens. Returns a promise that can be awaited.
259
259
260
-
####autoLinkText
260
+
## autoLinkText
261
261
```javascript
262
262
dispatch.autoLinkText({
263
263
args: {
@@ -267,7 +267,7 @@ dispatch.autoLinkText({
267
267
```
268
268
`autoLinkText` goes through the text to find handout names between square brackets and converts them into links with the handoutID. For example in a game with a handout named `Dragon`, passing in the text string of `this is a [Dragon]` to autoLinkText returns something similar to this is a `<a href="https://journal.roll20.net/8je02j0kd02k">Dragon</a>`.
`openDialogFromLink` opens the supplied urlString through the Roll20 Tabletop.
279
279
- If the url is for a handout, it will open the corresponding handout in the campaign. This will also check if the user opening the link has access to the handout.
280
280
- If the url is for a compendium, it will open a pop up to the compendium page, it will also check to ensure the user has access to view the page.
281
-
- If the url is for an external page, a confirmation pop up will display to warn the user that the link is for an external site and open a new tab in their main window if confirmed.
281
+
- If the url is for an external page, a confirmation pop up will display to warn the user that the link is for an external site and open a new tab in their main window if confirmed.
282
+
283
+
## writeToClipboard
284
+
```javascript
285
+
dispatch.writeToClipboard(text)
286
+
```
287
+
`writeToClipboard` allows writing text such as macro commands or roll templates from the sheet to the player's OS clipboard.
288
+
289
+
This command will trigger a dialog model to pop up in the host, the dialog will include a warning urging the player to fully understand what their copying to their clipboard; The dialog will also include a preview of the text.
290
+
291
+
Clicking `allow` will copy the text to the player's clipboard, while clicking `deny` will prevent it and log `"user refused copy action"`
0 commit comments