@powerhousedao/codegen 0.49.4-dev.1 → 0.49.5-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 +11 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EditorContainer.esm.t +21 -26
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editor.esm.t +3 -9
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/document-models.esm.t +0 -44
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useDocumentModels.esm.t +0 -41
|
@@ -144,6 +144,14 @@ export function DriveExplorer({
|
|
|
144
144
|
? files.find((file) => file.id === activeDocumentId)
|
|
145
145
|
: undefined;
|
|
146
146
|
|
|
147
|
+
const documentModelModule = activeDocument
|
|
148
|
+
? context.getDocumentModelModule(activeDocument.documentType)
|
|
149
|
+
: null;
|
|
150
|
+
|
|
151
|
+
const editorModule = activeDocument
|
|
152
|
+
? context.getEditor(activeDocument.documentType)
|
|
153
|
+
: null;
|
|
154
|
+
|
|
147
155
|
return (
|
|
148
156
|
<div className="flex h-full">
|
|
149
157
|
{/* Sidebar */}
|
|
@@ -158,7 +166,7 @@ export function DriveExplorer({
|
|
|
158
166
|
|
|
159
167
|
{/* Main Content */}
|
|
160
168
|
<div className="flex-1 p-4 overflow-y-auto">
|
|
161
|
-
{activeDocument ? (
|
|
169
|
+
{activeDocument && documentModelModule && editorModule ? (
|
|
162
170
|
<EditorContainer
|
|
163
171
|
context={{
|
|
164
172
|
...context,
|
|
@@ -169,6 +177,8 @@ export function DriveExplorer({
|
|
|
169
177
|
driveId={driveId}
|
|
170
178
|
onClose={handleEditorClose}
|
|
171
179
|
title={activeDocument.name}
|
|
180
|
+
documentModelModule={documentModelModule}
|
|
181
|
+
editorModule={editorModule}
|
|
172
182
|
/>
|
|
173
183
|
) : (
|
|
174
184
|
<>
|
|
@@ -6,12 +6,13 @@ import {
|
|
|
6
6
|
useDriveContext,
|
|
7
7
|
exportDocument,
|
|
8
8
|
type User,
|
|
9
|
+
type DriveEditorContext,
|
|
9
10
|
} from "@powerhousedao/reactor-browser";
|
|
10
11
|
import {
|
|
11
|
-
documentModelDocumentModelModule,
|
|
12
|
-
type EditorModule,
|
|
13
|
-
type DocumentModelModule,
|
|
14
12
|
type EditorContext,
|
|
13
|
+
type DocumentModelModule,
|
|
14
|
+
type EditorModule,
|
|
15
|
+
type EditorProps,
|
|
15
16
|
type PHDocument,
|
|
16
17
|
} from "document-model";
|
|
17
18
|
import {
|
|
@@ -21,8 +22,7 @@ import {
|
|
|
21
22
|
type TimelineItem,
|
|
22
23
|
} from "@powerhousedao/design-system";
|
|
23
24
|
import { useTimelineItems, getRevisionFromDate } from "@powerhousedao/common";
|
|
24
|
-
import { useState, Suspense, type FC, useCallback
|
|
25
|
-
import { useDocumentModel, useDocumentEditorModule } from "../hooks/useDocumentModels.js";
|
|
25
|
+
import { useState, Suspense, type FC, useCallback } from "react";
|
|
26
26
|
|
|
27
27
|
export interface EditorContainerProps {
|
|
28
28
|
driveId: string;
|
|
@@ -30,11 +30,22 @@ export interface EditorContainerProps {
|
|
|
30
30
|
documentType: string;
|
|
31
31
|
onClose: () => void;
|
|
32
32
|
title: string;
|
|
33
|
-
context: EditorContext
|
|
33
|
+
context: Omit<DriveEditorContext, "getDocumentRevision"> & Pick<EditorContext, "getDocumentRevision">;
|
|
34
|
+
documentModelModule: DocumentModelModule<PHDocument>;
|
|
35
|
+
editorModule: EditorModule;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export const EditorContainer: React.FC<EditorContainerProps> = (props) => {
|
|
37
|
-
const {
|
|
39
|
+
const {
|
|
40
|
+
title,
|
|
41
|
+
driveId,
|
|
42
|
+
context,
|
|
43
|
+
onClose,
|
|
44
|
+
documentId,
|
|
45
|
+
documentType,
|
|
46
|
+
editorModule,
|
|
47
|
+
documentModelModule,
|
|
48
|
+
} = props;
|
|
38
49
|
|
|
39
50
|
const [selectedTimelineItem, setSelectedTimelineItem] = useState<TimelineItem | null>(null);
|
|
40
51
|
const [showRevisionHistory, setShowRevisionHistory] = useState(false);
|
|
@@ -43,12 +54,6 @@ export const EditorContainer: React.FC<EditorContainerProps> = (props) => {
|
|
|
43
54
|
|
|
44
55
|
const user = context.user as User | undefined;
|
|
45
56
|
|
|
46
|
-
const documentModelModule = useDocumentModel(
|
|
47
|
-
documentType,
|
|
48
|
-
) as DocumentModelModule<PHDocument>;
|
|
49
|
-
|
|
50
|
-
const { editorModule, isLoading } = useDocumentEditorModule(documentType);
|
|
51
|
-
|
|
52
57
|
const { dispatch, error, document } = useDocumentEditorProps({
|
|
53
58
|
documentId,
|
|
54
59
|
documentType,
|
|
@@ -70,19 +75,9 @@ export const EditorContainer: React.FC<EditorContainerProps> = (props) => {
|
|
|
70
75
|
</div>
|
|
71
76
|
);
|
|
72
77
|
|
|
73
|
-
if (!document
|
|
74
|
-
|
|
75
|
-
if (!editorModule) {
|
|
76
|
-
console.error("No editor found for document type:", documentType);
|
|
77
|
-
return (
|
|
78
|
-
<div className="flex-1">
|
|
79
|
-
No editor found for document type: {documentType}
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
78
|
+
if (!document) return loadingContent;
|
|
83
79
|
|
|
84
|
-
const
|
|
85
|
-
const EditorComponent = moduleWithComponent.Component;
|
|
80
|
+
const EditorComponent = editorModule.Component as FC<EditorProps<PHDocument>>;
|
|
86
81
|
|
|
87
82
|
return showRevisionHistory ? (
|
|
88
83
|
<RevisionHistory
|
|
@@ -101,7 +96,7 @@ export const EditorContainer: React.FC<EditorContainerProps> = (props) => {
|
|
|
101
96
|
onShowRevisionHistory={() => setShowRevisionHistory(true)}
|
|
102
97
|
onSwitchboardLinkClick={() => {}}
|
|
103
98
|
title={title}
|
|
104
|
-
timelineButtonVisible={
|
|
99
|
+
timelineButtonVisible={editorModule.config.timelineEnabled}
|
|
105
100
|
timelineItems={timelineItems.data}
|
|
106
101
|
onTimelineItemClick={setSelectedTimelineItem}
|
|
107
102
|
/>
|
|
@@ -67,18 +67,12 @@ export function BaseEditor(props: IProps) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export default function Editor(props: IProps) {
|
|
70
|
-
const baseEditor = props.context.analyticsStore ? (
|
|
71
|
-
<AnalyticsProvider store={props.context.analyticsStore}>
|
|
72
|
-
<BaseEditor {...props} />
|
|
73
|
-
</AnalyticsProvider>
|
|
74
|
-
) : (
|
|
75
|
-
<BaseEditor {...props} />
|
|
76
|
-
);
|
|
77
|
-
|
|
78
70
|
return (
|
|
79
71
|
<DriveContextProvider value={props.context}>
|
|
80
72
|
<WagmiContext>
|
|
81
|
-
{
|
|
73
|
+
<AnalyticsProvider databaseName={props.context.analyticsDatabaseName}>
|
|
74
|
+
<BaseEditor {...props} />
|
|
75
|
+
</AnalyticsProvider>
|
|
82
76
|
</WagmiContext>
|
|
83
77
|
</DriveContextProvider>
|
|
84
78
|
);
|