@powerhousedao/academy 5.0.10 → 5.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1059 -42
- package/docs/academy/04-APIReferences/01-ReactHooks.md +289 -499
- package/package.json +1 -1
|
@@ -44,705 +44,495 @@ Learn more about the [Drive Editors](/academy/MasteryTrack/BuildingUserExperienc
|
|
|
44
44
|
### Reactor
|
|
45
45
|
|
|
46
46
|
All of the data used by these hooks is ultimately derived from the `Reactor`, which manages the asynchronous eventually consistent state of drives and documents. Learn more about the [Reactor](/academy/Architecture/WorkingWithTheReactor)
|
|
47
|
+
# Reactor Browser Hooks API Documentation
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
<summary>useReactor</summary>
|
|
49
|
+
This document contains all documentation comments for the hooks exported from `packages/reactor-browser/src/hooks/index.ts`.
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
function useReactor(): Reactor | undefined;
|
|
53
|
-
```
|
|
51
|
+
## Table of Contents
|
|
54
52
|
|
|
55
|
-
|
|
53
|
+
- [Allowed Document Model Modules](#allowed-document-model-modules)
|
|
54
|
+
- [Child Nodes](#child-nodes)
|
|
55
|
+
- [Config: Editor](#config-editor)
|
|
56
|
+
- [Config: Set Config by Object](#config-set-config-by-object)
|
|
57
|
+
- [Config: Use Value by Key](#config-use-value-by-key)
|
|
58
|
+
- [Document by ID](#document-by-id)
|
|
59
|
+
- [Document Cache](#document-cache)
|
|
60
|
+
- [Document of Type](#document-of-type)
|
|
61
|
+
- [Document Types](#document-types)
|
|
62
|
+
- [Drives](#drives)
|
|
63
|
+
- [Items in Selected Drive](#items-in-selected-drive)
|
|
64
|
+
- [Items in Selected Folder](#items-in-selected-folder)
|
|
65
|
+
- [Modals](#modals)
|
|
66
|
+
- [Node by ID](#node-by-id)
|
|
67
|
+
- [Node Path](#node-path)
|
|
68
|
+
- [Revision History](#revision-history)
|
|
69
|
+
- [Selected Document](#selected-document)
|
|
70
|
+
- [Selected Drive](#selected-drive)
|
|
71
|
+
- [Selected Folder](#selected-folder)
|
|
72
|
+
- [Selected Node](#selected-node)
|
|
73
|
+
- [Selected Timeline Item](#selected-timeline-item)
|
|
74
|
+
- [Supported Document Types](#supported-document-types)
|
|
75
|
+
- [Timeline Revision](#timeline-revision)
|
|
76
|
+
- [Use Get Switchboard Link](#use-get-switchboard-link)
|
|
77
|
+
- [Vetra Packages](#vetra-packages)
|
|
56
78
|
|
|
57
|
-
|
|
79
|
+
---
|
|
58
80
|
|
|
59
|
-
|
|
60
|
-
import { useReactor } from "@powerhousedao/state";
|
|
81
|
+
## Allowed Document Model Modules
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
const reactor = useReactor();
|
|
64
|
-
}
|
|
65
|
-
```
|
|
83
|
+
### `useAllowedDocumentModelModules`
|
|
66
84
|
|
|
67
|
-
|
|
85
|
+
No documentation available.
|
|
68
86
|
|
|
69
|
-
|
|
87
|
+
---
|
|
70
88
|
|
|
71
|
-
|
|
72
|
-
<summary>useDrives</summary>
|
|
89
|
+
## Child Nodes
|
|
73
90
|
|
|
74
|
-
|
|
75
|
-
function useDrives(): DocumentDriveDocument[] | undefined;
|
|
76
|
-
```
|
|
91
|
+
### `useNodesInSelectedDriveOrFolder`
|
|
77
92
|
|
|
78
|
-
Returns the
|
|
93
|
+
Returns the child nodes for the selected drive or folder.
|
|
79
94
|
|
|
80
|
-
|
|
95
|
+
---
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
import { useDrives } from "@powerhousedao/state";
|
|
97
|
+
## Document by ID
|
|
84
98
|
|
|
85
|
-
|
|
86
|
-
const drives = useDrives();
|
|
87
|
-
}
|
|
88
|
-
```
|
|
99
|
+
### `useDocumentById`
|
|
89
100
|
|
|
90
|
-
|
|
101
|
+
Returns a document by id.
|
|
91
102
|
|
|
92
|
-
|
|
93
|
-
<summary>useDriveById</summary>
|
|
103
|
+
### `useDocumentsByIds`
|
|
94
104
|
|
|
95
|
-
|
|
96
|
-
function useDriveById(
|
|
97
|
-
id: string | null | undefined,
|
|
98
|
-
): DocumentDriveDocument | undefined;
|
|
99
|
-
```
|
|
105
|
+
Returns documents by ids.
|
|
100
106
|
|
|
101
|
-
|
|
107
|
+
---
|
|
102
108
|
|
|
103
|
-
|
|
109
|
+
## Document Cache
|
|
104
110
|
|
|
105
|
-
|
|
106
|
-
import { useDriveById } from "@powerhousedao/state";
|
|
111
|
+
### `useDocumentCache`
|
|
107
112
|
|
|
108
|
-
|
|
109
|
-
const driveById = useDriveById("some-id");
|
|
110
|
-
}
|
|
111
|
-
```
|
|
113
|
+
Returns all documents in the reactor.
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
### `setDocumentCache`
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
<summary>useSelectedDrive</summary>
|
|
117
|
+
Sets all of the documents in the reactor.
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
function useSelectedDrive(): DocumentDriveDocument | undefined;
|
|
120
|
-
```
|
|
119
|
+
### `addDocumentCacheEventHandler`
|
|
121
120
|
|
|
122
|
-
|
|
121
|
+
Adds an event handler for all of the documents in the reactor.
|
|
123
122
|
|
|
124
|
-
|
|
123
|
+
### `useGetDocument`
|
|
125
124
|
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
Retrieves a document from the reactor and subscribes to changes using React Suspense.
|
|
126
|
+
This hook will suspend rendering while the document is loading.
|
|
128
127
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
```
|
|
128
|
+
**Parameters:**
|
|
129
|
+
- `id` - The document ID to retrieve, or null/undefined to skip retrieval
|
|
133
130
|
|
|
134
|
-
|
|
131
|
+
**Returns:** The document if found, or undefined if id is null/undefined
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
<summary>Drive Properties Convenience Hooks</summary>
|
|
138
|
-
|
|
139
|
-
We provide hooks for accessing various properties on the drive object for your convenience. These use the above hooks to get a drive and then return properties in the object.
|
|
140
|
-
|
|
141
|
-
```ts
|
|
142
|
-
/** Returns the remote URL for a drive. */
|
|
143
|
-
function useDriveRemoteUrl(
|
|
144
|
-
driveId: string | null | undefined,
|
|
145
|
-
): string | undefined;
|
|
146
|
-
|
|
147
|
-
/** Returns the pull responder trigger for a drive. */
|
|
148
|
-
function useDrivePullResponderTrigger(
|
|
149
|
-
driveId: string | null | undefined,
|
|
150
|
-
): Trigger | undefined;
|
|
151
|
-
|
|
152
|
-
/** Returns the pull responder URL for a drive. */
|
|
153
|
-
function useDrivePullResponderUrl(
|
|
154
|
-
driveId: string | null | undefined,
|
|
155
|
-
): string | undefined;
|
|
156
|
-
|
|
157
|
-
/** Returns whether a drive is remote. */
|
|
158
|
-
function useDriveIsRemote(driveId: string | null | undefined): boolean;
|
|
159
|
-
|
|
160
|
-
/** Returns the sharing type for a drive. */
|
|
161
|
-
function useDriveSharingType(
|
|
162
|
-
driveId: string | null | undefined,
|
|
163
|
-
): SharingType | undefined;
|
|
164
|
-
|
|
165
|
-
/** Returns whether a drive is available offline. */
|
|
166
|
-
function useDriveAvailableOffline(driveId: string | null | undefined): boolean;
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Usage
|
|
170
|
-
|
|
171
|
-
```jsx
|
|
172
|
-
import {
|
|
173
|
-
useDriveRemoteUrl,
|
|
174
|
-
useDrivePullResponderTrigger,
|
|
175
|
-
useDrivePullResponderUrl,
|
|
176
|
-
useDriveIsRemote,
|
|
177
|
-
useDriveSharingType,
|
|
178
|
-
useDriveAvailableOffline,
|
|
179
|
-
} from "@powerhousedao/state";
|
|
180
|
-
|
|
181
|
-
function MyEditorComponent() {
|
|
182
|
-
const myDriveId = "some-drive-id";
|
|
183
|
-
const driveRemoteUrl = useDriveRemoteUrl(myDriveId);
|
|
184
|
-
const drivePullResponderTrigger = useDrivePullResponderTrigger(myDriveId);
|
|
185
|
-
const drivePullResponderUrl = useDrivePullResponderUrl(myDriveId);
|
|
186
|
-
const driveIsRemote = useDriveIsRemote(myDriveId);
|
|
187
|
-
const driveSharingType = useDriveSharingType(myDriveId);
|
|
188
|
-
const driveAvailableOffline = useDriveAvailableOffline(myDriveId);
|
|
189
|
-
|
|
190
|
-
console.log({
|
|
191
|
-
driveRemoteUrl,
|
|
192
|
-
drivePullResponderTrigger,
|
|
193
|
-
drivePullResponderUrl,
|
|
194
|
-
driveIsRemote,
|
|
195
|
-
driveSharingType,
|
|
196
|
-
driveAvailableOffline,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
```
|
|
133
|
+
### `useGetDocuments`
|
|
200
134
|
|
|
201
|
-
|
|
135
|
+
Retrieves multiple documents from the reactor using React Suspense.
|
|
136
|
+
This hook will suspend rendering while any of the documents are loading.
|
|
202
137
|
|
|
203
|
-
|
|
138
|
+
**Parameters:**
|
|
139
|
+
- `ids` - Array of document IDs to retrieve, or null/undefined to skip retrieval
|
|
204
140
|
|
|
205
|
-
|
|
206
|
-
<summary>useAllDocuments/useSelectedDriveDocuments</summary>
|
|
141
|
+
**Returns:** An array of documents if found, or undefined if ids is null/undefined
|
|
207
142
|
|
|
208
|
-
|
|
209
|
-
function useAllDocuments(): PHDocument[] | undefined;
|
|
210
|
-
```
|
|
143
|
+
### `useGetDocumentAsync`
|
|
211
144
|
|
|
212
|
-
|
|
145
|
+
Retrieves a document from the reactor without suspending rendering.
|
|
146
|
+
Returns the current state of the document loading operation.
|
|
213
147
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
```
|
|
148
|
+
**Parameters:**
|
|
149
|
+
- `id` - The document ID to retrieve, or null/undefined to skip retrieval
|
|
217
150
|
|
|
218
|
-
Returns
|
|
151
|
+
**Returns:** An object containing:
|
|
152
|
+
- `status`: "initial" | "pending" | "success" | "error"
|
|
153
|
+
- `data`: The document if successfully loaded
|
|
154
|
+
- `isPending`: Boolean indicating if the document is currently loading
|
|
155
|
+
- `error`: Any error that occurred during loading
|
|
156
|
+
- `reload`: Function to force reload the document from cache
|
|
219
157
|
|
|
220
|
-
|
|
158
|
+
---
|
|
221
159
|
|
|
222
|
-
|
|
223
|
-
import {
|
|
224
|
-
useAllDocuments,
|
|
225
|
-
useSelectedDriveDocuments,
|
|
226
|
-
} from "@powerhousedao/state";
|
|
160
|
+
## Document of Type
|
|
227
161
|
|
|
228
|
-
|
|
229
|
-
const allDocuments = useAllDocuments();
|
|
230
|
-
const selectedDriveDocuments = useSelectedDriveDocuments();
|
|
231
|
-
}
|
|
232
|
-
```
|
|
162
|
+
### `useDocumentOfType`
|
|
233
163
|
|
|
234
|
-
|
|
164
|
+
Returns a document of a specific type, throws an error if the found document has a different type.
|
|
235
165
|
|
|
236
|
-
|
|
237
|
-
<summary>useSelectedDocument</summary>
|
|
166
|
+
---
|
|
238
167
|
|
|
239
|
-
|
|
240
|
-
function useSelectedDocument(): PHDocument | undefined;
|
|
241
|
-
```
|
|
168
|
+
## Document Types
|
|
242
169
|
|
|
243
|
-
|
|
170
|
+
### `useDocumentTypes`
|
|
244
171
|
|
|
245
|
-
|
|
172
|
+
Returns the document types a drive editor supports.
|
|
246
173
|
|
|
247
|
-
|
|
248
|
-
|
|
174
|
+
If present, uses the `allowedDocumentTypes` config value.
|
|
175
|
+
Otherwise, uses the supported document types from the reactor.
|
|
249
176
|
|
|
250
|
-
|
|
251
|
-
const selectedDocument = useSelectedDocument();
|
|
252
|
-
}
|
|
253
|
-
```
|
|
177
|
+
---
|
|
254
178
|
|
|
255
|
-
|
|
179
|
+
## Drives
|
|
256
180
|
|
|
257
|
-
|
|
258
|
-
<summary>useDocumentById</summary>
|
|
181
|
+
### `useDrives`
|
|
259
182
|
|
|
260
|
-
|
|
261
|
-
function useDocumentById(id: string | null | undefined): PHDocument | undefined;
|
|
262
|
-
```
|
|
183
|
+
Returns all of the drives in the reactor.
|
|
263
184
|
|
|
264
|
-
|
|
185
|
+
### `setDrives`
|
|
265
186
|
|
|
266
|
-
|
|
187
|
+
Sets the drives in the reactor.
|
|
267
188
|
|
|
268
|
-
|
|
269
|
-
import { useDocumentById } from "@powerhousedao/state";
|
|
189
|
+
### `addDrivesEventHandler`
|
|
270
190
|
|
|
271
|
-
|
|
272
|
-
const myDocumentId = "some-document-id";
|
|
273
|
-
const documentById = useDocumentById(myDocumentId);
|
|
274
|
-
}
|
|
275
|
-
```
|
|
191
|
+
Adds an event handler for the drives.
|
|
276
192
|
|
|
277
|
-
|
|
193
|
+
---
|
|
278
194
|
|
|
279
|
-
|
|
195
|
+
## Items in Selected Drive
|
|
280
196
|
|
|
281
|
-
|
|
197
|
+
### `useNodesInSelectedDrive`
|
|
282
198
|
|
|
283
|
-
|
|
199
|
+
Returns the nodes in the selected drive.
|
|
284
200
|
|
|
285
|
-
|
|
201
|
+
### `useFileNodesInSelectedDrive`
|
|
286
202
|
|
|
287
|
-
|
|
203
|
+
Returns the file nodes in the selected drive.
|
|
288
204
|
|
|
289
|
-
|
|
290
|
-
type FileNode = {
|
|
291
|
-
documentType: string;
|
|
292
|
-
id: string;
|
|
293
|
-
kind: string;
|
|
294
|
-
name: string;
|
|
295
|
-
parentFolder: string | null | undefined;
|
|
296
|
-
};
|
|
205
|
+
### `useFolderNodesInSelectedDrive`
|
|
297
206
|
|
|
298
|
-
|
|
299
|
-
id: string;
|
|
300
|
-
kind: string;
|
|
301
|
-
name: string;
|
|
302
|
-
parentFolder: string | null | undefined;
|
|
303
|
-
};
|
|
207
|
+
Returns the folder nodes in the selected drive.
|
|
304
208
|
|
|
305
|
-
|
|
306
|
-
```
|
|
209
|
+
### `useDocumentsInSelectedDrive`
|
|
307
210
|
|
|
308
|
-
|
|
309
|
-
<summary>useNodes</summary>
|
|
211
|
+
Returns the documents in the selected drive.
|
|
310
212
|
|
|
311
|
-
|
|
213
|
+
### `useDocumentTypesInSelectedDrive`
|
|
312
214
|
|
|
313
|
-
|
|
314
|
-
function useNodes(): Node[] | undefined;
|
|
315
|
-
```
|
|
215
|
+
Returns the document types supported by the selected drive, as defined by the document model documents present in the drive.
|
|
316
216
|
|
|
317
|
-
|
|
217
|
+
---
|
|
318
218
|
|
|
319
|
-
|
|
219
|
+
## Items in Selected Folder
|
|
320
220
|
|
|
321
|
-
|
|
322
|
-
import { useNodes } from "@powerhousedao/state";
|
|
221
|
+
### `useNodesInSelectedFolder`
|
|
323
222
|
|
|
324
|
-
|
|
325
|
-
const nodes = useNodes();
|
|
326
|
-
}
|
|
327
|
-
```
|
|
223
|
+
Returns the nodes in the selected folder.
|
|
328
224
|
|
|
329
|
-
|
|
225
|
+
### `useFileNodesInSelectedFolder`
|
|
330
226
|
|
|
331
|
-
|
|
332
|
-
|
|
227
|
+
Returns the file nodes in the selected folder.
|
|
228
|
+
|
|
229
|
+
### `useFolderNodesInSelectedFolder`
|
|
230
|
+
|
|
231
|
+
Returns the folder nodes in the selected folder.
|
|
232
|
+
|
|
233
|
+
### `useDocumentsInSelectedFolder`
|
|
234
|
+
|
|
235
|
+
Returns the documents in the selected folder.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Modals
|
|
240
|
+
|
|
241
|
+
### `usePHModal`
|
|
242
|
+
|
|
243
|
+
Returns the current modal.
|
|
244
|
+
|
|
245
|
+
### `setPHModal`
|
|
246
|
+
|
|
247
|
+
Sets the current modal.
|
|
248
|
+
|
|
249
|
+
### `addModalEventHandler`
|
|
250
|
+
|
|
251
|
+
Adds an event handler for the modal.
|
|
252
|
+
|
|
253
|
+
### `showPHModal`
|
|
254
|
+
|
|
255
|
+
Shows a modal.
|
|
256
|
+
|
|
257
|
+
### `closePHModal`
|
|
333
258
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
259
|
+
Closes the current modal.
|
|
260
|
+
|
|
261
|
+
### `showCreateDocumentModal`
|
|
262
|
+
|
|
263
|
+
Shows the create document modal.
|
|
264
|
+
|
|
265
|
+
### `showDeleteNodeModal`
|
|
266
|
+
|
|
267
|
+
Shows the delete node modal.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Node by ID
|
|
272
|
+
|
|
273
|
+
### `useNodeById`
|
|
337
274
|
|
|
338
275
|
Returns a node in the selected drive by id.
|
|
339
276
|
|
|
340
|
-
|
|
277
|
+
---
|
|
341
278
|
|
|
342
|
-
|
|
343
|
-
import { useNodeById } from "@powerhousedao/state";
|
|
279
|
+
## Node Path
|
|
344
280
|
|
|
345
|
-
|
|
346
|
-
const myFolderId = "some-folder-id";
|
|
347
|
-
const myDocumentId = "some-document-id";
|
|
348
|
-
const myFolderNode = useNodeById(myFolderId);
|
|
349
|
-
const myFileNode = useNodeById(myDocumentId);
|
|
350
|
-
}
|
|
351
|
-
```
|
|
281
|
+
### `useNodePathById`
|
|
352
282
|
|
|
353
|
-
|
|
283
|
+
Returns the path to a node in the selected drive.
|
|
354
284
|
|
|
355
|
-
|
|
356
|
-
<summary>useSelectedFolder</summary>
|
|
285
|
+
### `useSelectedNodePath`
|
|
357
286
|
|
|
358
|
-
|
|
359
|
-
function useSelectedFolder(): FolderNode | undefined;
|
|
360
|
-
```
|
|
287
|
+
Returns the path to the currently selected node in the selected drive.
|
|
361
288
|
|
|
362
|
-
|
|
289
|
+
---
|
|
363
290
|
|
|
364
|
-
|
|
291
|
+
## Revision History
|
|
365
292
|
|
|
366
|
-
|
|
367
|
-
import { useSelectedFolder } from "@powerhousedao/state";
|
|
293
|
+
### `useRevisionHistoryVisible`
|
|
368
294
|
|
|
369
|
-
|
|
370
|
-
const selectedFolder = useSelectedFolder();
|
|
371
|
-
}
|
|
372
|
-
```
|
|
295
|
+
Returns whether revision history is visible.
|
|
373
296
|
|
|
374
|
-
|
|
297
|
+
### `setRevisionHistoryVisible`
|
|
375
298
|
|
|
376
|
-
|
|
377
|
-
<summary>useSelectedNodePath</summary>
|
|
299
|
+
Sets revision history visibility.
|
|
378
300
|
|
|
379
|
-
|
|
380
|
-
function useSelectedNodePath(): Node[];
|
|
381
|
-
```
|
|
301
|
+
### `addRevisionHistoryVisibleEventHandler`
|
|
382
302
|
|
|
383
|
-
|
|
303
|
+
Adds event handler for revision history visibility.
|
|
384
304
|
|
|
385
|
-
|
|
305
|
+
### `showRevisionHistory`
|
|
386
306
|
|
|
387
|
-
|
|
388
|
-
import { useSelectedNodePath } from "@powerhousedao/state";
|
|
307
|
+
Shows the revision history.
|
|
389
308
|
|
|
390
|
-
|
|
391
|
-
const nodes = useSelectedNodePath();
|
|
309
|
+
### `hideRevisionHistory`
|
|
392
310
|
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
```
|
|
311
|
+
Hides the revision history.
|
|
396
312
|
|
|
397
|
-
|
|
313
|
+
---
|
|
398
314
|
|
|
399
|
-
|
|
400
|
-
<summary>useChildNodes/useFolderChildNodes/useFileChildNodes</summary>
|
|
315
|
+
## Selected Document
|
|
401
316
|
|
|
402
|
-
|
|
403
|
-
function useChildNodes(): Node[];
|
|
404
|
-
```
|
|
317
|
+
### `useSelectedDocumentId`
|
|
405
318
|
|
|
406
|
-
Returns the
|
|
319
|
+
Returns the selected document id.
|
|
407
320
|
|
|
408
|
-
|
|
409
|
-
function useFolderChildNodes(): FolderNode[];
|
|
410
|
-
```
|
|
321
|
+
### `useSelectedDocument`
|
|
411
322
|
|
|
412
|
-
Returns the
|
|
323
|
+
Returns the selected document.
|
|
413
324
|
|
|
414
|
-
|
|
415
|
-
function useFileChildNodes(): FileNode[];
|
|
416
|
-
```
|
|
325
|
+
### `useSelectedDocumentOfType`
|
|
417
326
|
|
|
418
|
-
Returns the
|
|
327
|
+
Returns the selected document of a specific type, throws an error if the found document has a different type.
|
|
419
328
|
|
|
420
|
-
|
|
329
|
+
---
|
|
421
330
|
|
|
422
|
-
|
|
423
|
-
import {
|
|
424
|
-
useChildNodes,
|
|
425
|
-
useFolderChildNodes,
|
|
426
|
-
useFileChildNodes,
|
|
427
|
-
} from "@powerhousedao/state";
|
|
331
|
+
## Selected Drive
|
|
428
332
|
|
|
429
|
-
|
|
430
|
-
const nodes = useChildNodes();
|
|
431
|
-
const fileNodes = useFileChildNodes();
|
|
432
|
-
const folderNodes = useFolderChildNodes();
|
|
333
|
+
### `useSelectedDriveId`
|
|
433
334
|
|
|
434
|
-
|
|
435
|
-
<div>
|
|
436
|
-
<FilesAndFolders nodes={nodes} />
|
|
437
|
-
<Files fileNodes={fileNodes} />
|
|
438
|
-
<Folders folderNodes={folderNodes} />
|
|
439
|
-
</div>
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
```
|
|
335
|
+
Returns the selected drive id.
|
|
443
336
|
|
|
444
|
-
|
|
337
|
+
### `setSelectedDriveId`
|
|
445
338
|
|
|
446
|
-
|
|
447
|
-
<summary>useChildNodesForId/useFolderChildNodesForId/useFileChildNodesForId</summary>
|
|
339
|
+
Sets the selected drive id.
|
|
448
340
|
|
|
449
|
-
|
|
450
|
-
function useChildNodesForId(id: string | null | undefined): Node[];
|
|
451
|
-
```
|
|
341
|
+
### `addSelectedDriveIdEventHandler`
|
|
452
342
|
|
|
453
|
-
|
|
343
|
+
Adds an event handler for the selected drive id.
|
|
454
344
|
|
|
455
|
-
|
|
456
|
-
function useFolderChildNodesForId(id: string | null | undefined): FolderNode[];
|
|
457
|
-
```
|
|
345
|
+
### `useSelectedDrive`
|
|
458
346
|
|
|
459
|
-
Returns the
|
|
347
|
+
Returns the selected drive.
|
|
460
348
|
|
|
461
|
-
|
|
462
|
-
function useFileChildNodesForId(id: string | null | undefined): FileNode[];
|
|
463
|
-
```
|
|
349
|
+
### `useSelectedDriveSafe`
|
|
464
350
|
|
|
465
|
-
Returns the
|
|
351
|
+
Returns the selected drive, or undefined if no drive is selected.
|
|
466
352
|
|
|
467
|
-
|
|
353
|
+
---
|
|
468
354
|
|
|
469
|
-
|
|
470
|
-
import {
|
|
471
|
-
useChildNodesForId,
|
|
472
|
-
useFolderChildNodesForId,
|
|
473
|
-
useFileChildNodesForId,
|
|
474
|
-
} from "@powerhousedao/state";
|
|
355
|
+
## Selected Folder
|
|
475
356
|
|
|
476
|
-
|
|
477
|
-
const driveOrFolderId = "some-drive-or-folder-id";
|
|
478
|
-
const nodes = useChildNodesForId(driveOrFolderId);
|
|
479
|
-
const fileNodes = useFileChildNodesForId(driveOrFolderId);
|
|
480
|
-
const folderNodes = useFolderChildNodesForId(driveOrFolderId);
|
|
357
|
+
### `useSelectedFolder`
|
|
481
358
|
|
|
482
|
-
|
|
483
|
-
<div>
|
|
484
|
-
<FilesAndFolders nodes={nodes} />
|
|
485
|
-
<Files fileNodes={fileNodes} />
|
|
486
|
-
<Folders folderNodes={folderNodes} />
|
|
487
|
-
</div>
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
```
|
|
359
|
+
Returns the selected folder.
|
|
491
360
|
|
|
492
|
-
|
|
361
|
+
---
|
|
493
362
|
|
|
494
|
-
|
|
495
|
-
<summary>useNodeName/useNodeKind</summary>
|
|
363
|
+
## Selected Node
|
|
496
364
|
|
|
497
|
-
|
|
498
|
-
function useNodeName(id: string | null | undefined): string | undefined;
|
|
499
|
-
```
|
|
365
|
+
### `useSelectedNode`
|
|
500
366
|
|
|
501
|
-
Returns the
|
|
367
|
+
Returns the selected node.
|
|
502
368
|
|
|
503
|
-
|
|
504
|
-
function useNodeKind(id: string | null | undefined): NodeKind | undefined;
|
|
505
|
-
```
|
|
369
|
+
### `setSelectedNode`
|
|
506
370
|
|
|
507
|
-
|
|
371
|
+
Sets the selected node (file or folder).
|
|
508
372
|
|
|
509
|
-
|
|
373
|
+
---
|
|
510
374
|
|
|
511
|
-
|
|
512
|
-
import { useNodeName, useNodeKind } from "@powerhousedao/state";
|
|
375
|
+
## Selected Timeline Item
|
|
513
376
|
|
|
514
|
-
|
|
515
|
-
const nodeId = "some-node-id";
|
|
516
|
-
const nodeName = useNodeName(nodeId);
|
|
517
|
-
const nodeKind = useNodeKind(nodeId);
|
|
377
|
+
### `useSelectedTimelineItem`
|
|
518
378
|
|
|
519
|
-
|
|
520
|
-
return <File name={nodeName} />;
|
|
521
|
-
}
|
|
379
|
+
Returns the selected timeline item.
|
|
522
380
|
|
|
523
|
-
|
|
524
|
-
return <Folder name={nodeName} />;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
```
|
|
381
|
+
### `setSelectedTimelineItem`
|
|
528
382
|
|
|
529
|
-
|
|
383
|
+
Sets the selected timeline item.
|
|
530
384
|
|
|
531
|
-
###
|
|
385
|
+
### `addSelectedTimelineItemEventHandler`
|
|
532
386
|
|
|
533
|
-
|
|
387
|
+
Adds event handler for selected timeline item.
|
|
534
388
|
|
|
535
|
-
|
|
389
|
+
---
|
|
536
390
|
|
|
537
|
-
|
|
538
|
-
- editors
|
|
539
|
-
- subgraphs
|
|
540
|
-
- import scripts
|
|
541
|
-
- processors
|
|
391
|
+
## Supported Document Types
|
|
542
392
|
|
|
543
|
-
|
|
393
|
+
### `useSupportedDocumentTypesInReactor`
|
|
544
394
|
|
|
545
|
-
|
|
546
|
-
<summary>useVetraPackages</summary>
|
|
395
|
+
Returns the supported document types for the reactor (derived from the document model modules).
|
|
547
396
|
|
|
548
|
-
|
|
549
|
-
function useVetraPackages(): VetraPackage[] | undefined;
|
|
550
|
-
```
|
|
397
|
+
---
|
|
551
398
|
|
|
552
|
-
|
|
399
|
+
## Timeline Revision
|
|
553
400
|
|
|
554
|
-
|
|
401
|
+
### `useSelectedTimelineRevision`
|
|
555
402
|
|
|
556
|
-
|
|
557
|
-
import { useVetraPackages } from "@powerhousedao/state";
|
|
403
|
+
Returns the selected timeline revision.
|
|
558
404
|
|
|
559
|
-
|
|
560
|
-
const vetraPackages = useVetraPackages();
|
|
561
|
-
}
|
|
562
|
-
```
|
|
405
|
+
### `setSelectedTimelineRevision`
|
|
563
406
|
|
|
564
|
-
|
|
407
|
+
Sets the selected timeline revision.
|
|
565
408
|
|
|
566
|
-
|
|
567
|
-
<summary>useDocumentModelModules</summary>
|
|
409
|
+
### `addSelectedTimelineRevisionEventHandler`
|
|
568
410
|
|
|
569
|
-
|
|
570
|
-
function useDocumentModelModules(): DocumentModelModule[] | undefined;
|
|
571
|
-
```
|
|
411
|
+
Adds an event handler for the selected timeline revision.
|
|
572
412
|
|
|
573
|
-
|
|
413
|
+
---
|
|
574
414
|
|
|
575
|
-
|
|
415
|
+
## Use Get Switchboard Link
|
|
576
416
|
|
|
577
|
-
|
|
578
|
-
import { useDocumentModelModules } from "@powerhousedao/state";
|
|
417
|
+
### `useGetSwitchboardLink`
|
|
579
418
|
|
|
580
|
-
function
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
```
|
|
419
|
+
Hook that returns a function to generate a document's switchboard URL.
|
|
420
|
+
Only returns a function for documents in remote drives.
|
|
421
|
+
Returns null for local drives or when the document/drive cannot be determined.
|
|
584
422
|
|
|
585
|
-
|
|
423
|
+
The returned function generates a fresh bearer token and builds the switchboard URL
|
|
424
|
+
with authentication when called.
|
|
586
425
|
|
|
587
|
-
|
|
588
|
-
|
|
426
|
+
**Parameters:**
|
|
427
|
+
- `document` - The document to create a switchboard URL generator for
|
|
589
428
|
|
|
590
|
-
|
|
591
|
-
function useDocumentModelModuleById(): DocumentModelModule[] | undefined;
|
|
592
|
-
```
|
|
429
|
+
**Returns:** An async function that returns the switchboard URL, or null if not applicable
|
|
593
430
|
|
|
594
|
-
|
|
595
|
-
_NOTE_ What we call here an id is really the value in the "document type" field in the document model editor
|
|
596
|
-
_NOTE_ Connect assumes that these document types (ids) are unique. It is your responsibility to enforce this.
|
|
431
|
+
---
|
|
597
432
|
|
|
598
|
-
|
|
433
|
+
## Vetra Packages
|
|
599
434
|
|
|
600
|
-
|
|
601
|
-
import { useDocumentModelModuleById } from "@powerhousedao/state";
|
|
435
|
+
### `useVetraPackages`
|
|
602
436
|
|
|
603
|
-
|
|
604
|
-
const documentType = "my-org/my-document";
|
|
605
|
-
const documentModelModuleById = useDocumentModelModuleById(documentType);
|
|
606
|
-
}
|
|
607
|
-
```
|
|
437
|
+
Returns all of the Vetra packages loaded by the Connect instance.
|
|
608
438
|
|
|
609
|
-
|
|
439
|
+
### `addVetraPackagesEventHandler`
|
|
610
440
|
|
|
611
|
-
|
|
612
|
-
<summary>useEditorModules</summary>
|
|
441
|
+
Adds the Vetra packages event handler.
|
|
613
442
|
|
|
614
|
-
|
|
615
|
-
function useEditorModules(): EditorModule[] | undefined;
|
|
616
|
-
```
|
|
443
|
+
### `setVetraPackages`
|
|
617
444
|
|
|
618
|
-
|
|
445
|
+
Sets the Vetra packages for the Connect instance.
|
|
619
446
|
|
|
620
|
-
|
|
447
|
+
---
|
|
621
448
|
|
|
622
|
-
```jsx
|
|
623
|
-
import { useEditorModules } from "@powerhousedao/state";
|
|
624
449
|
|
|
625
|
-
|
|
626
|
-
const editorModules = useEditorModules();
|
|
627
|
-
}
|
|
628
|
-
```
|
|
450
|
+
## Config: Editor
|
|
629
451
|
|
|
630
|
-
|
|
452
|
+
### `setIsExternalControlsEnabled`
|
|
631
453
|
|
|
632
|
-
|
|
633
|
-
<summary>useDriveEditorModules</summary>
|
|
454
|
+
Sets whether external controls are enabled for a given editor.
|
|
634
455
|
|
|
635
|
-
|
|
636
|
-
function useDriveEditorModules(): DriveEditorModule[] | undefined;
|
|
637
|
-
```
|
|
456
|
+
### `useIsExternalControlsEnabled`
|
|
638
457
|
|
|
639
|
-
|
|
458
|
+
Gets whether external controls are enabled for a given editor.
|
|
640
459
|
|
|
641
|
-
|
|
460
|
+
### `addIsExternalControlsEnabledEventHandler`
|
|
642
461
|
|
|
643
|
-
|
|
644
|
-
import { useDriveEditorModules } from "@powerhousedao/state";
|
|
462
|
+
Adds an event handler for when the external controls enabled state changes.
|
|
645
463
|
|
|
646
|
-
|
|
647
|
-
const driveEditorModules = useDriveEditorModules();
|
|
648
|
-
}
|
|
649
|
-
```
|
|
464
|
+
### `setIsDragAndDropEnabled`
|
|
650
465
|
|
|
651
|
-
|
|
466
|
+
Sets whether drag and drop is enabled for a given drive editor.
|
|
652
467
|
|
|
653
|
-
|
|
654
|
-
<summary>useProcessorModules</summary>
|
|
468
|
+
### `useIsDragAndDropEnabled`
|
|
655
469
|
|
|
656
|
-
|
|
657
|
-
function useProcessorModules(): ProcessorModule[] | undefined;
|
|
658
|
-
```
|
|
470
|
+
Gets whether drag and drop is enabled for a given drive editor.
|
|
659
471
|
|
|
660
|
-
|
|
472
|
+
### `addIsDragAndDropEnabledEventHandler`
|
|
661
473
|
|
|
662
|
-
|
|
474
|
+
Adds an event handler for when the drag and drop enabled state changes.
|
|
663
475
|
|
|
664
|
-
|
|
665
|
-
import { useProcessorModules } from "@powerhousedao/state";
|
|
476
|
+
### `setAllowedDocumentTypes`
|
|
666
477
|
|
|
667
|
-
|
|
668
|
-
const processorModules = useProcessorModules();
|
|
669
|
-
}
|
|
670
|
-
```
|
|
478
|
+
Sets the allowed document types for a given drive editor.
|
|
671
479
|
|
|
672
|
-
|
|
480
|
+
### `useAllowedDocumentTypes`
|
|
673
481
|
|
|
674
|
-
|
|
675
|
-
<summary>useSubgraphModules</summary>
|
|
482
|
+
Defines the document types a drive supports.
|
|
676
483
|
|
|
677
|
-
|
|
678
|
-
function useSubgraphModules(): SubgraphModule[] | undefined;
|
|
679
|
-
```
|
|
484
|
+
Defaults to all of the document types registered in the reactor.
|
|
680
485
|
|
|
681
|
-
|
|
486
|
+
### `addAllowedDocumentTypesEventHandler`
|
|
682
487
|
|
|
683
|
-
|
|
488
|
+
Adds an event handler for when the allowed document types for a given drive editor changes.
|
|
684
489
|
|
|
685
|
-
|
|
686
|
-
import { useSubgraphModules } from "@powerhousedao/state";
|
|
490
|
+
---
|
|
687
491
|
|
|
688
|
-
|
|
689
|
-
const subgraphModules = useSubgraphModules();
|
|
690
|
-
}
|
|
691
|
-
```
|
|
492
|
+
## Config: Set Config by Object
|
|
692
493
|
|
|
693
|
-
|
|
494
|
+
### `setPHDriveEditorConfig`
|
|
694
495
|
|
|
695
|
-
|
|
696
|
-
<summary>useImportScriptModules</summary>
|
|
496
|
+
Sets the global drive config.
|
|
697
497
|
|
|
698
|
-
|
|
699
|
-
function useImportScriptModules(): ImportScriptModule[] | undefined;
|
|
700
|
-
```
|
|
498
|
+
Pass in a partial object of the global drive config to set.
|
|
701
499
|
|
|
702
|
-
|
|
500
|
+
### `setPHDocumentEditorConfig`
|
|
703
501
|
|
|
704
|
-
|
|
502
|
+
Sets the global document config.
|
|
705
503
|
|
|
706
|
-
|
|
707
|
-
import { useImportScriptModules } from "@powerhousedao/state";
|
|
504
|
+
Pass in a partial object of the global document config to set.
|
|
708
505
|
|
|
709
|
-
|
|
710
|
-
const importScriptModules = useImportScriptModules();
|
|
711
|
-
}
|
|
712
|
-
```
|
|
506
|
+
### `useSetPHDriveEditorConfig`
|
|
713
507
|
|
|
714
|
-
|
|
508
|
+
Wrapper hook for setting the global drive editor config.
|
|
509
|
+
|
|
510
|
+
Automatically sets the global drive editor config when the component mounts.
|
|
511
|
+
|
|
512
|
+
Pass in a partial object of the global drive editor config to set.
|
|
715
513
|
|
|
716
|
-
|
|
514
|
+
### `useSetPHDocumentEditorConfig`
|
|
717
515
|
|
|
718
|
-
|
|
516
|
+
Wrapper hook for setting the global document editor config.
|
|
719
517
|
|
|
720
|
-
|
|
518
|
+
Automatically sets the global document editor config when the component mounts.
|
|
721
519
|
|
|
722
|
-
|
|
520
|
+
Pass in a partial object of the global document editor config to set.
|
|
723
521
|
|
|
724
|
-
|
|
725
|
-
- useReadDocumentField
|
|
726
|
-
- useUpdateDocumentField
|
|
727
|
-
- useDocumentDispatch(docId): updateX, delete, ...
|
|
522
|
+
---
|
|
728
523
|
|
|
729
|
-
|
|
524
|
+
## Config: Use Value by Key
|
|
730
525
|
|
|
731
|
-
|
|
732
|
-
- How to inspect children from parent context
|
|
733
|
-
- Tree traversal utilities (if any)
|
|
526
|
+
### `usePHDriveEditorConfigByKey`
|
|
734
527
|
|
|
735
|
-
|
|
528
|
+
Gets the value of an item in the global drive config for a given key.
|
|
736
529
|
|
|
737
|
-
|
|
738
|
-
- "Quick Start" to manipulate any document like a pro
|
|
530
|
+
Strongly typed, inferred from type definition for the key.
|
|
739
531
|
|
|
740
|
-
###
|
|
532
|
+
### `usePHDocumentEditorConfigByKey`
|
|
741
533
|
|
|
742
|
-
|
|
743
|
-
- Example: using context to get current doc, sibling docs
|
|
534
|
+
Gets the value of an item in the global document config for a given key.
|
|
744
535
|
|
|
745
|
-
|
|
536
|
+
Strongly typed, inferred from type definition for the key.
|
|
746
537
|
|
|
747
|
-
|
|
748
|
-
- Composing document fields into custom logic
|
|
538
|
+
---
|