@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.
@@ -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
- <details>
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
- ```ts
52
- function useReactor(): Reactor | undefined;
53
- ```
51
+ ## Table of Contents
54
52
 
55
- Returns the reactor instance.
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
- Usage
79
+ ---
58
80
 
59
- ```jsx
60
- import { useReactor } from "@powerhousedao/state";
81
+ ## Allowed Document Model Modules
61
82
 
62
- function MyEditorComponent() {
63
- const reactor = useReactor();
64
- }
65
- ```
83
+ ### `useAllowedDocumentModelModules`
66
84
 
67
- </details>
85
+ No documentation available.
68
86
 
69
- ### Drives
87
+ ---
70
88
 
71
- <details>
72
- <summary>useDrives</summary>
89
+ ## Child Nodes
73
90
 
74
- ```ts
75
- function useDrives(): DocumentDriveDocument[] | undefined;
76
- ```
91
+ ### `useNodesInSelectedDriveOrFolder`
77
92
 
78
- Returns the drives for a reactor.
93
+ Returns the child nodes for the selected drive or folder.
79
94
 
80
- Usage
95
+ ---
81
96
 
82
- ```jsx
83
- import { useDrives } from "@powerhousedao/state";
97
+ ## Document by ID
84
98
 
85
- function MyEditorComponent() {
86
- const drives = useDrives();
87
- }
88
- ```
99
+ ### `useDocumentById`
89
100
 
90
- </details>
101
+ Returns a document by id.
91
102
 
92
- <details>
93
- <summary>useDriveById</summary>
103
+ ### `useDocumentsByIds`
94
104
 
95
- ```ts
96
- function useDriveById(
97
- id: string | null | undefined,
98
- ): DocumentDriveDocument | undefined;
99
- ```
105
+ Returns documents by ids.
100
106
 
101
- Returns a drive by id.
107
+ ---
102
108
 
103
- Usage
109
+ ## Document Cache
104
110
 
105
- ```jsx
106
- import { useDriveById } from "@powerhousedao/state";
111
+ ### `useDocumentCache`
107
112
 
108
- function MyEditorComponent() {
109
- const driveById = useDriveById("some-id");
110
- }
111
- ```
113
+ Returns all documents in the reactor.
112
114
 
113
- </details>
115
+ ### `setDocumentCache`
114
116
 
115
- <details>
116
- <summary>useSelectedDrive</summary>
117
+ Sets all of the documents in the reactor.
117
118
 
118
- ```ts
119
- function useSelectedDrive(): DocumentDriveDocument | undefined;
120
- ```
119
+ ### `addDocumentCacheEventHandler`
121
120
 
122
- Returns the selected drive. You can set the selected drive with `setSelectedDrive`.
121
+ Adds an event handler for all of the documents in the reactor.
123
122
 
124
- Usage
123
+ ### `useGetDocument`
125
124
 
126
- ```jsx
127
- import { useSelectedDrive } from "@powerhousedao/state";
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
- function MyEditorComponent() {
130
- const selectedDrive = useSelectedDrive();
131
- }
132
- ```
128
+ **Parameters:**
129
+ - `id` - The document ID to retrieve, or null/undefined to skip retrieval
133
130
 
134
- </details>
131
+ **Returns:** The document if found, or undefined if id is null/undefined
135
132
 
136
- <details>
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
- </details>
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
- ### Documents
138
+ **Parameters:**
139
+ - `ids` - Array of document IDs to retrieve, or null/undefined to skip retrieval
204
140
 
205
- <details>
206
- <summary>useAllDocuments/useSelectedDriveDocuments</summary>
141
+ **Returns:** An array of documents if found, or undefined if ids is null/undefined
207
142
 
208
- ```ts
209
- function useAllDocuments(): PHDocument[] | undefined;
210
- ```
143
+ ### `useGetDocumentAsync`
211
144
 
212
- Returns all of the documents in the reactor.
145
+ Retrieves a document from the reactor without suspending rendering.
146
+ Returns the current state of the document loading operation.
213
147
 
214
- ```ts
215
- function useSelectedDriveDocuments(): PHDocument[] | undefined;
216
- ```
148
+ **Parameters:**
149
+ - `id` - The document ID to retrieve, or null/undefined to skip retrieval
217
150
 
218
- Returns the documents in the reactor for the selected drive.
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
- Usage
158
+ ---
221
159
 
222
- ```jsx
223
- import {
224
- useAllDocuments,
225
- useSelectedDriveDocuments,
226
- } from "@powerhousedao/state";
160
+ ## Document of Type
227
161
 
228
- function MyEditorComponent() {
229
- const allDocuments = useAllDocuments();
230
- const selectedDriveDocuments = useSelectedDriveDocuments();
231
- }
232
- ```
162
+ ### `useDocumentOfType`
233
163
 
234
- </details>
164
+ Returns a document of a specific type, throws an error if the found document has a different type.
235
165
 
236
- <details>
237
- <summary>useSelectedDocument</summary>
166
+ ---
238
167
 
239
- ```ts
240
- function useSelectedDocument(): PHDocument | undefined;
241
- ```
168
+ ## Document Types
242
169
 
243
- Returns the selected document. You can set the selected document with `setSelectedNode`.
170
+ ### `useDocumentTypes`
244
171
 
245
- Usage
172
+ Returns the document types a drive editor supports.
246
173
 
247
- ```jsx
248
- import { useSelectedDocument } from "@powerhousedao/state";
174
+ If present, uses the `allowedDocumentTypes` config value.
175
+ Otherwise, uses the supported document types from the reactor.
249
176
 
250
- function MyEditorComponent() {
251
- const selectedDocument = useSelectedDocument();
252
- }
253
- ```
177
+ ---
254
178
 
255
- </details>
179
+ ## Drives
256
180
 
257
- <details>
258
- <summary>useDocumentById</summary>
181
+ ### `useDrives`
259
182
 
260
- ```ts
261
- function useDocumentById(id: string | null | undefined): PHDocument | undefined;
262
- ```
183
+ Returns all of the drives in the reactor.
263
184
 
264
- Returns a document by id.
185
+ ### `setDrives`
265
186
 
266
- Usage
187
+ Sets the drives in the reactor.
267
188
 
268
- ```jsx
269
- import { useDocumentById } from "@powerhousedao/state";
189
+ ### `addDrivesEventHandler`
270
190
 
271
- function MyEditorComponent() {
272
- const myDocumentId = "some-document-id";
273
- const documentById = useDocumentById(myDocumentId);
274
- }
275
- ```
191
+ Adds an event handler for the drives.
276
192
 
277
- </details>
193
+ ---
278
194
 
279
- ### Nodes
195
+ ## Items in Selected Drive
280
196
 
281
- "Nodes" refers to the items found in a given drive's `state.global.nodes` array. Nodes can represent both files (documents) and folders.
197
+ ### `useNodesInSelectedDrive`
282
198
 
283
- A document in a drive will have a node in the drive's node list which has the same id as the document.
199
+ Returns the nodes in the selected drive.
284
200
 
285
- Nodes have an optional `parentFolder` field, which is the id of a folder node in the drive when it is defined. If it is undefined, the node is a direct child of the drive.
201
+ ### `useFileNodesInSelectedDrive`
286
202
 
287
- A given folder node's children are the nodes in the drive's node list which have their parent folder set to the folder node's id.
203
+ Returns the file nodes in the selected drive.
288
204
 
289
- ```ts
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
- type FolderNode = {
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
- type Node = FileNode | FolderNode;
306
- ```
209
+ ### `useDocumentsInSelectedDrive`
307
210
 
308
- <details>
309
- <summary>useNodes</summary>
211
+ Returns the documents in the selected drive.
310
212
 
311
- Ideally you should not need to handle the list of nodes directly, since we already provide documents and folders. But these hooks are provided just in case.
213
+ ### `useDocumentTypesInSelectedDrive`
312
214
 
313
- ```ts
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
- Returns the nodes for a drive.
217
+ ---
318
218
 
319
- Usage
219
+ ## Items in Selected Folder
320
220
 
321
- ```jsx
322
- import { useNodes } from "@powerhousedao/state";
221
+ ### `useNodesInSelectedFolder`
323
222
 
324
- function MyEditorComponent() {
325
- const nodes = useNodes();
326
- }
327
- ```
223
+ Returns the nodes in the selected folder.
328
224
 
329
- </details>
225
+ ### `useFileNodesInSelectedFolder`
330
226
 
331
- <details>
332
- <summary>useNodeById</summary>
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
- ```ts
335
- function useNodeById(id: string | null | undefined): Node | undefined;
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
- Usage
277
+ ---
341
278
 
342
- ```jsx
343
- import { useNodeById } from "@powerhousedao/state";
279
+ ## Node Path
344
280
 
345
- function MyEditorComponent() {
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
- </details>
283
+ Returns the path to a node in the selected drive.
354
284
 
355
- <details>
356
- <summary>useSelectedFolder</summary>
285
+ ### `useSelectedNodePath`
357
286
 
358
- ```ts
359
- function useSelectedFolder(): FolderNode | undefined;
360
- ```
287
+ Returns the path to the currently selected node in the selected drive.
361
288
 
362
- Returns the selected folder. You can set the selected folder with `setSelectedNode`
289
+ ---
363
290
 
364
- Usage
291
+ ## Revision History
365
292
 
366
- ```jsx
367
- import { useSelectedFolder } from "@powerhousedao/state";
293
+ ### `useRevisionHistoryVisible`
368
294
 
369
- function MyEditorComponent() {
370
- const selectedFolder = useSelectedFolder();
371
- }
372
- ```
295
+ Returns whether revision history is visible.
373
296
 
374
- </details>
297
+ ### `setRevisionHistoryVisible`
375
298
 
376
- <details>
377
- <summary>useSelectedNodePath</summary>
299
+ Sets revision history visibility.
378
300
 
379
- ```ts
380
- function useSelectedNodePath(): Node[];
381
- ```
301
+ ### `addRevisionHistoryVisibleEventHandler`
382
302
 
383
- Returns the path to the selected node. Useful for navigational components like breadcrumbs.
303
+ Adds event handler for revision history visibility.
384
304
 
385
- Usage
305
+ ### `showRevisionHistory`
386
306
 
387
- ```jsx
388
- import { useSelectedNodePath } from "@powerhousedao/state";
307
+ Shows the revision history.
389
308
 
390
- function MyEditorComponent() {
391
- const nodes = useSelectedNodePath();
309
+ ### `hideRevisionHistory`
392
310
 
393
- return <Breadcrumbs nodes={nodes} />;
394
- }
395
- ```
311
+ Hides the revision history.
396
312
 
397
- </details>
313
+ ---
398
314
 
399
- <details>
400
- <summary>useChildNodes/useFolderChildNodes/useFileChildNodes</summary>
315
+ ## Selected Document
401
316
 
402
- ```ts
403
- function useChildNodes(): Node[];
404
- ```
317
+ ### `useSelectedDocumentId`
405
318
 
406
- Returns the child nodes for the selected drive or folder.
319
+ Returns the selected document id.
407
320
 
408
- ```ts
409
- function useFolderChildNodes(): FolderNode[];
410
- ```
321
+ ### `useSelectedDocument`
411
322
 
412
- Returns the folder child nodes for the selected drive or folder.
323
+ Returns the selected document.
413
324
 
414
- ```ts
415
- function useFileChildNodes(): FileNode[];
416
- ```
325
+ ### `useSelectedDocumentOfType`
417
326
 
418
- Returns the file (document) child nodes for the selected drive or folder.
327
+ Returns the selected document of a specific type, throws an error if the found document has a different type.
419
328
 
420
- Usage
329
+ ---
421
330
 
422
- ```jsx
423
- import {
424
- useChildNodes,
425
- useFolderChildNodes,
426
- useFileChildNodes,
427
- } from "@powerhousedao/state";
331
+ ## Selected Drive
428
332
 
429
- function MyEditorComponent() {
430
- const nodes = useChildNodes();
431
- const fileNodes = useFileChildNodes();
432
- const folderNodes = useFolderChildNodes();
333
+ ### `useSelectedDriveId`
433
334
 
434
- return (
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
- </details>
337
+ ### `setSelectedDriveId`
445
338
 
446
- <details>
447
- <summary>useChildNodesForId/useFolderChildNodesForId/useFileChildNodesForId</summary>
339
+ Sets the selected drive id.
448
340
 
449
- ```ts
450
- function useChildNodesForId(id: string | null | undefined): Node[];
451
- ```
341
+ ### `addSelectedDriveIdEventHandler`
452
342
 
453
- Returns the child nodes for a drive or folder by id.
343
+ Adds an event handler for the selected drive id.
454
344
 
455
- ```ts
456
- function useFolderChildNodesForId(id: string | null | undefined): FolderNode[];
457
- ```
345
+ ### `useSelectedDrive`
458
346
 
459
- Returns the folder child nodes for a drive or folder by id.
347
+ Returns the selected drive.
460
348
 
461
- ```ts
462
- function useFileChildNodesForId(id: string | null | undefined): FileNode[];
463
- ```
349
+ ### `useSelectedDriveSafe`
464
350
 
465
- Returns the file (document) child nodes for a drive or folder by id.
351
+ Returns the selected drive, or undefined if no drive is selected.
466
352
 
467
- Usage
353
+ ---
468
354
 
469
- ```jsx
470
- import {
471
- useChildNodesForId,
472
- useFolderChildNodesForId,
473
- useFileChildNodesForId,
474
- } from "@powerhousedao/state";
355
+ ## Selected Folder
475
356
 
476
- function MyEditorComponent() {
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
- return (
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
- </details>
361
+ ---
493
362
 
494
- <details>
495
- <summary>useNodeName/useNodeKind</summary>
363
+ ## Selected Node
496
364
 
497
- ```ts
498
- function useNodeName(id: string | null | undefined): string | undefined;
499
- ```
365
+ ### `useSelectedNode`
500
366
 
501
- Returns the name of a node.
367
+ Returns the selected node.
502
368
 
503
- ```ts
504
- function useNodeKind(id: string | null | undefined): NodeKind | undefined;
505
- ```
369
+ ### `setSelectedNode`
506
370
 
507
- Returns the kind of a node.
371
+ Sets the selected node (file or folder).
508
372
 
509
- Usage
373
+ ---
510
374
 
511
- ```jsx
512
- import { useNodeName, useNodeKind } from "@powerhousedao/state";
375
+ ## Selected Timeline Item
513
376
 
514
- function MyEditorComponent() {
515
- const nodeId = "some-node-id";
516
- const nodeName = useNodeName(nodeId);
517
- const nodeKind = useNodeKind(nodeId);
377
+ ### `useSelectedTimelineItem`
518
378
 
519
- if (nodeKind === "file") {
520
- return <File name={nodeName} />;
521
- }
379
+ Returns the selected timeline item.
522
380
 
523
- if (nodeKind === "folder") {
524
- return <Folder name={nodeName} />;
525
- }
526
- }
527
- ```
381
+ ### `setSelectedTimelineItem`
528
382
 
529
- </details>
383
+ Sets the selected timeline item.
530
384
 
531
- ### Vetra Packages and Modules
385
+ ### `addSelectedTimelineItemEventHandler`
532
386
 
533
- Vetra packages hold code which can plug into your Connect application. This includes common default modules like the document model document model editor and document drive document model, as well as the modules from your local project and the various packages you have installed.
387
+ Adds event handler for selected timeline item.
534
388
 
535
- These modules can be for:
389
+ ---
536
390
 
537
- - document models
538
- - editors
539
- - subgraphs
540
- - import scripts
541
- - processors
391
+ ## Supported Document Types
542
392
 
543
- Each Vetra package contains a `modules` field which optionally contains lists of these modules.
393
+ ### `useSupportedDocumentTypesInReactor`
544
394
 
545
- <details>
546
- <summary>useVetraPackages</summary>
395
+ Returns the supported document types for the reactor (derived from the document model modules).
547
396
 
548
- ```ts
549
- function useVetraPackages(): VetraPackage[] | undefined;
550
- ```
397
+ ---
551
398
 
552
- Returns all of the Vetra packages in your Connect app.
399
+ ## Timeline Revision
553
400
 
554
- Usage
401
+ ### `useSelectedTimelineRevision`
555
402
 
556
- ```jsx
557
- import { useVetraPackages } from "@powerhousedao/state";
403
+ Returns the selected timeline revision.
558
404
 
559
- function MyEditorComponent() {
560
- const vetraPackages = useVetraPackages();
561
- }
562
- ```
405
+ ### `setSelectedTimelineRevision`
563
406
 
564
- </details>
407
+ Sets the selected timeline revision.
565
408
 
566
- <details>
567
- <summary>useDocumentModelModules</summary>
409
+ ### `addSelectedTimelineRevisionEventHandler`
568
410
 
569
- ```ts
570
- function useDocumentModelModules(): DocumentModelModule[] | undefined;
571
- ```
411
+ Adds an event handler for the selected timeline revision.
572
412
 
573
- Returns the document model modules from your Vetra packages.
413
+ ---
574
414
 
575
- Usage
415
+ ## Use Get Switchboard Link
576
416
 
577
- ```jsx
578
- import { useDocumentModelModules } from "@powerhousedao/state";
417
+ ### `useGetSwitchboardLink`
579
418
 
580
- function MyEditorComponent() {
581
- const documentModelModules = useDocumentModelModules();
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
- </details>
423
+ The returned function generates a fresh bearer token and builds the switchboard URL
424
+ with authentication when called.
586
425
 
587
- <details>
588
- <summary>useDocumentModelModuleById</summary>
426
+ **Parameters:**
427
+ - `document` - The document to create a switchboard URL generator for
589
428
 
590
- ```ts
591
- function useDocumentModelModuleById(): DocumentModelModule[] | undefined;
592
- ```
429
+ **Returns:** An async function that returns the switchboard URL, or null if not applicable
593
430
 
594
- Returns the document model for a given id (document type).
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
- Usage
433
+ ## Vetra Packages
599
434
 
600
- ```jsx
601
- import { useDocumentModelModuleById } from "@powerhousedao/state";
435
+ ### `useVetraPackages`
602
436
 
603
- function MyEditorComponent() {
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
- </details>
439
+ ### `addVetraPackagesEventHandler`
610
440
 
611
- <details>
612
- <summary>useEditorModules</summary>
441
+ Adds the Vetra packages event handler.
613
442
 
614
- ```ts
615
- function useEditorModules(): EditorModule[] | undefined;
616
- ```
443
+ ### `setVetraPackages`
617
444
 
618
- Returns the editor modules from your Vetra packages.
445
+ Sets the Vetra packages for the Connect instance.
619
446
 
620
- Usage
447
+ ---
621
448
 
622
- ```jsx
623
- import { useEditorModules } from "@powerhousedao/state";
624
449
 
625
- function MyEditorComponent() {
626
- const editorModules = useEditorModules();
627
- }
628
- ```
450
+ ## Config: Editor
629
451
 
630
- </details>
452
+ ### `setIsExternalControlsEnabled`
631
453
 
632
- <details>
633
- <summary>useDriveEditorModules</summary>
454
+ Sets whether external controls are enabled for a given editor.
634
455
 
635
- ```ts
636
- function useDriveEditorModules(): DriveEditorModule[] | undefined;
637
- ```
456
+ ### `useIsExternalControlsEnabled`
638
457
 
639
- Returns the drive editor modules from your Vetra packages.
458
+ Gets whether external controls are enabled for a given editor.
640
459
 
641
- Usage
460
+ ### `addIsExternalControlsEnabledEventHandler`
642
461
 
643
- ```jsx
644
- import { useDriveEditorModules } from "@powerhousedao/state";
462
+ Adds an event handler for when the external controls enabled state changes.
645
463
 
646
- function MyDriveEditorComponent() {
647
- const driveEditorModules = useDriveEditorModules();
648
- }
649
- ```
464
+ ### `setIsDragAndDropEnabled`
650
465
 
651
- </details>
466
+ Sets whether drag and drop is enabled for a given drive editor.
652
467
 
653
- <details>
654
- <summary>useProcessorModules</summary>
468
+ ### `useIsDragAndDropEnabled`
655
469
 
656
- ```ts
657
- function useProcessorModules(): ProcessorModule[] | undefined;
658
- ```
470
+ Gets whether drag and drop is enabled for a given drive editor.
659
471
 
660
- Returns the processor modules from your Vetra packages.
472
+ ### `addIsDragAndDropEnabledEventHandler`
661
473
 
662
- Usage
474
+ Adds an event handler for when the drag and drop enabled state changes.
663
475
 
664
- ```jsx
665
- import { useProcessorModules } from "@powerhousedao/state";
476
+ ### `setAllowedDocumentTypes`
666
477
 
667
- function MyProcessorComponent() {
668
- const processorModules = useProcessorModules();
669
- }
670
- ```
478
+ Sets the allowed document types for a given drive editor.
671
479
 
672
- </details>
480
+ ### `useAllowedDocumentTypes`
673
481
 
674
- <details>
675
- <summary>useSubgraphModules</summary>
482
+ Defines the document types a drive supports.
676
483
 
677
- ```ts
678
- function useSubgraphModules(): SubgraphModule[] | undefined;
679
- ```
484
+ Defaults to all of the document types registered in the reactor.
680
485
 
681
- Returns the subgraph modules from your Vetra packages.
486
+ ### `addAllowedDocumentTypesEventHandler`
682
487
 
683
- Usage
488
+ Adds an event handler for when the allowed document types for a given drive editor changes.
684
489
 
685
- ```jsx
686
- import { useSubgraphModules } from "@powerhousedao/state";
490
+ ---
687
491
 
688
- function MySubgraphComponent() {
689
- const subgraphModules = useSubgraphModules();
690
- }
691
- ```
492
+ ## Config: Set Config by Object
692
493
 
693
- </details>
494
+ ### `setPHDriveEditorConfig`
694
495
 
695
- <details>
696
- <summary>useImportScriptModules</summary>
496
+ Sets the global drive config.
697
497
 
698
- ```ts
699
- function useImportScriptModules(): ImportScriptModule[] | undefined;
700
- ```
498
+ Pass in a partial object of the global drive config to set.
701
499
 
702
- Returns the import script modules from your Vetra packages.
500
+ ### `setPHDocumentEditorConfig`
703
501
 
704
- Usage
502
+ Sets the global document config.
705
503
 
706
- ```jsx
707
- import { useImportScriptModules } from "@powerhousedao/state";
504
+ Pass in a partial object of the global document config to set.
708
505
 
709
- function MyImportScriptComponent() {
710
- const importScriptModules = useImportScriptModules();
711
- }
712
- ```
506
+ ### `useSetPHDriveEditorConfig`
713
507
 
714
- </details>
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
- ## More documentation coming soon!
514
+ ### `useSetPHDocumentEditorConfig`
717
515
 
718
- Global access to drive state: A top-level, possibly context-based, way to introspect and interact with any document and its state tree without manually passing things around.
516
+ Wrapper hook for setting the global document editor config.
719
517
 
720
- Global dispatcher access: A utility or API (probably a hook or service function) where they give a document ID and get back all the relevant dispatch functions — kind of like a command palette for document ops.
518
+ Automatically sets the global document editor config when the component mounts.
721
519
 
722
- ### Core Hooks & Patterns
520
+ Pass in a partial object of the global document editor config to set.
723
521
 
724
- - useDocumentField
725
- - useReadDocumentField
726
- - useUpdateDocumentField
727
- - useDocumentDispatch(docId): updateX, delete, ...
522
+ ---
728
523
 
729
- ### Global Drive Access
524
+ ## Config: Use Value by Key
730
525
 
731
- - How to access and manipulate the global document tree
732
- - How to inspect children from parent context
733
- - Tree traversal utilities (if any)
526
+ ### `usePHDriveEditorConfigByKey`
734
527
 
735
- ### Convenience APIs
528
+ Gets the value of an item in the global drive config for a given key.
736
529
 
737
- - Utility functions like getDispatchFunctions(docId)
738
- - "Quick Start" to manipulate any document like a pro
530
+ Strongly typed, inferred from type definition for the key.
739
531
 
740
- ### Working with Context
532
+ ### `usePHDocumentEditorConfigByKey`
741
533
 
742
- - DriveContext: what lives there, how to use it
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
- ### Best Practices & Patterns
536
+ Strongly typed, inferred from type definition for the key.
746
537
 
747
- - When to use useDocumentField vs getDispatch
748
- - Composing document fields into custom logic
538
+ ---