@powerhousedao/codegen 0.49.3-dev.0 → 0.49.3-dev.1
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/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveExplorer.esm.t +18 -5
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EditorContainer.esm.t +17 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editor.esm.t +11 -1
- package/package.json +1 -1
|
@@ -11,17 +11,17 @@ import {
|
|
|
11
11
|
type UiNode,
|
|
12
12
|
} from "@powerhousedao/design-system";
|
|
13
13
|
import { useCallback, useState, useRef, useEffect } from "react";
|
|
14
|
-
import type { FileNode, Node } from "document-drive";
|
|
14
|
+
import type { FileNode, GetDocumentOptions, Node } from "document-drive";
|
|
15
15
|
import { FileItemsGrid } from "./FileItemsGrid.js";
|
|
16
16
|
import { FolderItemsGrid } from "./FolderItemsGrid.js";
|
|
17
17
|
import { FolderTree } from "./FolderTree.js";
|
|
18
18
|
import { useTransformedNodes } from "../hooks/useTransformedNodes.js";
|
|
19
19
|
import { useSelectedFolderChildren } from "../hooks/useSelectedFolderChildren.js";
|
|
20
20
|
import { EditorContainer } from "./EditorContainer.js";
|
|
21
|
-
import type {
|
|
21
|
+
import type { DocumentModelModule } from "document-model";
|
|
22
22
|
import { CreateDocumentModal } from "@powerhousedao/design-system";
|
|
23
23
|
import { CreateDocument } from "./CreateDocument.js";
|
|
24
|
-
import { useDriveContext } from "@powerhousedao/reactor-browser";
|
|
24
|
+
import { type DriveEditorContext, useDriveContext } from "@powerhousedao/reactor-browser";
|
|
25
25
|
|
|
26
26
|
interface DriveExplorerProps {
|
|
27
27
|
driveId: string;
|
|
@@ -30,7 +30,7 @@ interface DriveExplorerProps {
|
|
|
30
30
|
onDeleteNode: (nodeId: string) => void;
|
|
31
31
|
renameNode: (nodeId: string, name: string) => void;
|
|
32
32
|
onCopyNode: (nodeId: string, targetName: string, parentId?: string) => void;
|
|
33
|
-
context:
|
|
33
|
+
context: DriveEditorContext;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function DriveExplorer({
|
|
@@ -42,6 +42,8 @@ export function DriveExplorer({
|
|
|
42
42
|
onCopyNode,
|
|
43
43
|
context,
|
|
44
44
|
}: DriveExplorerProps) {
|
|
45
|
+
const { getDocumentRevision } = context;
|
|
46
|
+
|
|
45
47
|
const [selectedNodeId, setSelectedNodeId] = useState<string | undefined>();
|
|
46
48
|
const [activeDocumentId, setActiveDocumentId] = useState<
|
|
47
49
|
string | undefined
|
|
@@ -109,6 +111,14 @@ export function DriveExplorer({
|
|
|
109
111
|
[]
|
|
110
112
|
);
|
|
111
113
|
|
|
114
|
+
const onGetDocumentRevision = useCallback(
|
|
115
|
+
(options?: GetDocumentOptions) => {
|
|
116
|
+
if (!activeDocumentId) return;
|
|
117
|
+
return getDocumentRevision?.(activeDocumentId, options);
|
|
118
|
+
},
|
|
119
|
+
[getDocumentRevision, activeDocumentId],
|
|
120
|
+
);
|
|
121
|
+
|
|
112
122
|
const filteredDocumentModels = documentModels;
|
|
113
123
|
|
|
114
124
|
// Transform nodes using the custom hook
|
|
@@ -150,7 +160,10 @@ export function DriveExplorer({
|
|
|
150
160
|
<div className="flex-1 p-4 overflow-y-auto">
|
|
151
161
|
{activeDocument ? (
|
|
152
162
|
<EditorContainer
|
|
153
|
-
context={
|
|
163
|
+
context={{
|
|
164
|
+
...context,
|
|
165
|
+
getDocumentRevision: onGetDocumentRevision,
|
|
166
|
+
}}
|
|
154
167
|
documentId={activeDocumentId!}
|
|
155
168
|
documentType={activeDocument.documentType}
|
|
156
169
|
driveId={driveId}
|
|
@@ -18,7 +18,9 @@ import {
|
|
|
18
18
|
DocumentToolbar,
|
|
19
19
|
RevisionHistory,
|
|
20
20
|
DefaultEditorLoader,
|
|
21
|
+
type TimelineItem,
|
|
21
22
|
} from "@powerhousedao/design-system";
|
|
23
|
+
import { useTimelineItems, getRevisionFromDate } from "@powerhousedao/common";
|
|
22
24
|
import { useState, Suspense, type FC, useCallback, lazy } from "react";
|
|
23
25
|
|
|
24
26
|
export interface EditorContainerProps {
|
|
@@ -55,8 +57,11 @@ function getDocumentEditor(documentType: string) {
|
|
|
55
57
|
export const EditorContainer: React.FC<EditorContainerProps> = (props) => {
|
|
56
58
|
const { driveId, documentId, documentType, onClose, title, context } = props;
|
|
57
59
|
|
|
60
|
+
const [selectedTimelineItem, setSelectedTimelineItem] = useState<TimelineItem | null>(null);
|
|
58
61
|
const [showRevisionHistory, setShowRevisionHistory] = useState(false);
|
|
59
62
|
const { useDocumentEditorProps } = useDriveContext();
|
|
63
|
+
const timelineItems = useTimelineItems(documentId);
|
|
64
|
+
|
|
60
65
|
const user = context.user as User | undefined;
|
|
61
66
|
|
|
62
67
|
const documentModelModule = getDocumentModel(
|
|
@@ -115,9 +120,20 @@ export const EditorContainer: React.FC<EditorContainerProps> = (props) => {
|
|
|
115
120
|
onShowRevisionHistory={() => setShowRevisionHistory(true)}
|
|
116
121
|
onSwitchboardLinkClick={() => {}}
|
|
117
122
|
title={title}
|
|
123
|
+
timelineButtonVisible
|
|
124
|
+
timelineItems={timelineItems.data}
|
|
125
|
+
onTimelineItemClick={setSelectedTimelineItem}
|
|
118
126
|
/>
|
|
119
127
|
<EditorComponent
|
|
120
|
-
context={
|
|
128
|
+
context={{
|
|
129
|
+
...context,
|
|
130
|
+
readMode: !!selectedTimelineItem,
|
|
131
|
+
selectedTimelineRevision: getRevisionFromDate(
|
|
132
|
+
selectedTimelineItem?.startDate,
|
|
133
|
+
selectedTimelineItem?.endDate,
|
|
134
|
+
document.operations.global,
|
|
135
|
+
),
|
|
136
|
+
}}
|
|
121
137
|
dispatch={dispatch}
|
|
122
138
|
document={document}
|
|
123
139
|
error={error}
|
|
@@ -3,11 +3,13 @@ to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/editor.tsx"
|
|
|
3
3
|
unless_exists: true
|
|
4
4
|
---
|
|
5
5
|
import { type DriveEditorProps } from "@powerhousedao/reactor-browser";
|
|
6
|
+
import { AnalyticsProvider } from '@powerhousedao/reactor-browser/analytics/context';
|
|
6
7
|
import { DriveContextProvider } from "@powerhousedao/reactor-browser/hooks/useDriveContext";
|
|
7
8
|
import { type DocumentDriveDocument, addFolder, deleteNode, updateNode, generateNodesCopy, copyNode } from "document-drive";
|
|
8
9
|
import { WagmiContext } from "@powerhousedao/design-system";
|
|
9
10
|
import { DriveExplorer } from "./components/DriveExplorer.js";
|
|
10
11
|
import { useCallback } from "react";
|
|
12
|
+
import { hashKey } from "document-model";
|
|
11
13
|
|
|
12
14
|
export type IProps = DriveEditorProps<DocumentDriveDocument>;
|
|
13
15
|
|
|
@@ -67,10 +69,18 @@ export function BaseEditor(props: IProps) {
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
export default function Editor(props: IProps) {
|
|
72
|
+
const baseEditor = props.context.analyticsStore ? (
|
|
73
|
+
<AnalyticsProvider store={props.context.analyticsStore}>
|
|
74
|
+
<BaseEditor {...props} />
|
|
75
|
+
</AnalyticsProvider>
|
|
76
|
+
) : (
|
|
77
|
+
<BaseEditor {...props} />
|
|
78
|
+
);
|
|
79
|
+
|
|
70
80
|
return (
|
|
71
81
|
<DriveContextProvider value={props.context}>
|
|
72
82
|
<WagmiContext>
|
|
73
|
-
|
|
83
|
+
{baseEditor}
|
|
74
84
|
</WagmiContext>
|
|
75
85
|
</DriveContextProvider>
|
|
76
86
|
);
|