@powerhousedao/network-admin 0.0.3 → 0.0.5
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/editors/network-admin/components/DriveExplorer.d.ts.map +1 -1
- package/dist/editors/network-admin/components/DriveExplorer.js +51 -12
- package/dist/editors/network-admin/components/EditorContainer.d.ts.map +1 -1
- package/dist/editors/network-admin/components/EditorContainer.js +19 -1
- package/dist/editors/request-for-proposals/markdown-editor.d.ts.map +1 -1
- package/dist/editors/request-for-proposals/markdown-editor.js +21 -7
- package/dist/style.css +1299 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"AAwCA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,2CAklCvC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, CreateDocumentModal, } from "@powerhousedao/design-system";
|
|
2
|
+
import { Button, CreateDocumentModal, useDrop, } from "@powerhousedao/design-system";
|
|
3
3
|
import { addDocument, setSelectedNode, useAllFolderNodes, useDocumentModelModules, useDriveContext, useDriveSharingType, useEditorModules, useFileChildNodes, useFolderChildNodes, useSelectedDrive, useSelectedFolder, useSelectedNodePath, useUserPermissions, useAllDocuments, } from "@powerhousedao/reactor-browser";
|
|
4
|
+
import { twMerge } from "tailwind-merge";
|
|
4
5
|
import { useCallback, useRef, useState, useMemo } from "react";
|
|
5
6
|
import { EditorContainer } from "./EditorContainer.js";
|
|
6
7
|
import { getNewDocumentObject } from "../utils.js";
|
|
@@ -19,6 +20,8 @@ export function DriveExplorer(props) {
|
|
|
19
20
|
const [modalDocumentType, setModalDocumentType] = useState("powerhouse/workstream");
|
|
20
21
|
const selectedDocumentModel = useRef(null);
|
|
21
22
|
const editorModules = useEditorModules();
|
|
23
|
+
// Track the last created folder for drag and drop targeting
|
|
24
|
+
const [lastCreatedFolder, setLastCreatedFolder] = useState(undefined);
|
|
22
25
|
// === DRIVE CONTEXT HOOKS ===
|
|
23
26
|
// Core drive operations and document models
|
|
24
27
|
const { onAddFile, onAddFolder, onCopyNode, onDuplicateNode, onMoveNode, onRenameNode, showDeleteNodeModal, } = useDriveContext();
|
|
@@ -30,13 +33,8 @@ export function DriveExplorer(props) {
|
|
|
30
33
|
const selectedNodePath = useSelectedNodePath();
|
|
31
34
|
const sharingType = useDriveSharingType(selectedDrive?.header.id);
|
|
32
35
|
const allDocuments = useAllDocuments();
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
// const { breadcrumbs, onBreadcrumbSelected } = useBreadcrumbs({
|
|
36
|
-
// selectedNodePath: selectedNodePath as any,
|
|
37
|
-
// setSelectedNode: (node) => setSelectedNode(node as any),
|
|
38
|
-
// getNodeById: (id: string) => (allFolders.find(node => node.id === id) || fileChildren.find(node => node.id === id)) as any || null,
|
|
39
|
-
// });
|
|
36
|
+
// All folders for the sidebar tree view
|
|
37
|
+
const allFolders = useAllFolderNodes();
|
|
40
38
|
const folderChildren = useFolderChildNodes();
|
|
41
39
|
const fileChildren = useFileChildNodes();
|
|
42
40
|
const filesWithDocuments = fileChildren.map((file) => {
|
|
@@ -47,12 +45,45 @@ export function DriveExplorer(props) {
|
|
|
47
45
|
state,
|
|
48
46
|
};
|
|
49
47
|
});
|
|
48
|
+
// Find the folder containing the most recent workstream document
|
|
49
|
+
const getMostRecentWorkstreamFolder = useCallback(() => {
|
|
50
|
+
const workstreamFiles = fileChildren.filter((file) => file.documentType === "powerhouse/workstream");
|
|
51
|
+
if (workstreamFiles.length === 0)
|
|
52
|
+
return undefined;
|
|
53
|
+
// Sort by creation time (assuming newer files have higher IDs or we can use a different method)
|
|
54
|
+
const mostRecentWorkstream = workstreamFiles[workstreamFiles.length - 1];
|
|
55
|
+
// Find the folder that contains this workstream
|
|
56
|
+
if (mostRecentWorkstream.parentFolder) {
|
|
57
|
+
return allFolders.find((folder) => folder.id === mostRecentWorkstream.parentFolder);
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}, [fileChildren, allFolders]);
|
|
61
|
+
// === DROP HOOKS ===
|
|
62
|
+
const mostRecentWorkstreamFolder = getMostRecentWorkstreamFolder();
|
|
63
|
+
const dropTargetNode = lastCreatedFolder ||
|
|
64
|
+
mostRecentWorkstreamFolder ||
|
|
65
|
+
selectedFolder ||
|
|
66
|
+
undefined;
|
|
67
|
+
// Create a custom onAddFile wrapper that ensures the correct folder is used
|
|
68
|
+
const onAddFileWithTarget = useCallback((file, targetFolder) => {
|
|
69
|
+
console.log("onAddFileWithTarget called with:", {
|
|
70
|
+
file,
|
|
71
|
+
targetFolder,
|
|
72
|
+
dropTargetNode,
|
|
73
|
+
});
|
|
74
|
+
// Use the dropTargetNode as the folder, not the targetFolder parameter
|
|
75
|
+
return onAddFile(file, dropTargetNode);
|
|
76
|
+
}, [onAddFile, dropTargetNode]);
|
|
77
|
+
const { isDropTarget, dropProps } = useDrop({
|
|
78
|
+
node: dropTargetNode,
|
|
79
|
+
onAddFile: onAddFileWithTarget,
|
|
80
|
+
onCopyNode,
|
|
81
|
+
onMoveNode,
|
|
82
|
+
});
|
|
50
83
|
// check if workstream doc is created, set isWorkstreamCreated to true
|
|
51
84
|
const isWorkstreamCreated = fileChildren.some((file) => file.documentType === "powerhouse/workstream");
|
|
52
85
|
//check if network profile doc is created, set isNetworkProfileCreated to true
|
|
53
86
|
const isNetworkProfileCreated = fileChildren.some((file) => file.documentType === "powerhouse/network-profile");
|
|
54
|
-
// All folders for the sidebar tree view
|
|
55
|
-
const allFolders = useAllFolderNodes();
|
|
56
87
|
// Convert folders and files to SidebarNode format
|
|
57
88
|
const sidebarNodes = useMemo(() => {
|
|
58
89
|
const workstreamsNode = {
|
|
@@ -177,6 +208,8 @@ export function DriveExplorer(props) {
|
|
|
177
208
|
// Handle sidebar node selection
|
|
178
209
|
const handleActiveNodeChange = useCallback((nodeId) => {
|
|
179
210
|
console.log("nodeId", nodeId);
|
|
211
|
+
// Clear the last created folder when navigating to a different node
|
|
212
|
+
setLastCreatedFolder(undefined);
|
|
180
213
|
// Find the node by ID
|
|
181
214
|
const findNodeById = (nodes, id) => {
|
|
182
215
|
for (const node of nodes) {
|
|
@@ -392,7 +425,10 @@ export function DriveExplorer(props) {
|
|
|
392
425
|
}
|
|
393
426
|
if (name?.trim()) {
|
|
394
427
|
try {
|
|
395
|
-
await onAddFolder(name.trim(), selectedFolder);
|
|
428
|
+
const createdFolder = await onAddFolder(name.trim(), selectedFolder);
|
|
429
|
+
// Track the created folder for drag and drop targeting
|
|
430
|
+
console.log("Created manual folder:", createdFolder);
|
|
431
|
+
setLastCreatedFolder(createdFolder);
|
|
396
432
|
}
|
|
397
433
|
catch (error) {
|
|
398
434
|
console.error("Failed to create folder:", error);
|
|
@@ -413,6 +449,9 @@ export function DriveExplorer(props) {
|
|
|
413
449
|
let folder = undefined;
|
|
414
450
|
if (documentType === "powerhouse/workstream") {
|
|
415
451
|
folder = await onAddFolder(fileName, undefined);
|
|
452
|
+
// Track the created folder for drag and drop targeting
|
|
453
|
+
console.log("Created workstream folder:", folder);
|
|
454
|
+
setLastCreatedFolder(folder);
|
|
416
455
|
}
|
|
417
456
|
const node = await addDocument(selectedDrive?.header.id || "", fileName, documentType, folder?.id, getNewDocumentObject(fileName, documentType), undefined, editorType);
|
|
418
457
|
selectedDocumentModel.current = null;
|
|
@@ -456,5 +495,5 @@ export function DriveExplorer(props) {
|
|
|
456
495
|
return (_jsx(IsolatedSidebarProvider, { nodes: sidebarNodes, children: _jsxs("div", { className: "flex h-full", children: [_jsx(IsolatedSidebar, { nodes: sidebarNodes, activeNodeId: selectedFolder?.id || activeDocumentId, onActiveNodeChange: handleActiveNodeChange, sidebarTitle: "Network Admin", showSearchBar: true, allowPinning: true, resizable: true, initialWidth: 300, maxWidth: 500, enableMacros: 2, handleOnTitleClick: () => {
|
|
457
496
|
setActiveDocumentId(undefined);
|
|
458
497
|
setSelectedRootNode("workstreams");
|
|
459
|
-
} }), _jsx("div", { className: "flex-1 overflow-y-auto", children: activeDocumentId ? (_jsx(EditorContainer, { handleClose: () => setActiveDocumentId(undefined), hideToolbar: false, activeDocumentId: activeDocumentId, setActiveDocumentId: setActiveDocumentId })) : (displayActiveNode(selectedFolder?.id || selectedRootNode)) }), _jsx(CreateDocumentModal, { onContinue: onCreateDocument, onOpenChange: (open) => setOpenModal(open), open: openModal })] }) }));
|
|
498
|
+
} }), _jsx("div", { className: "flex-1 overflow-y-auto", children: _jsx("div", { ...dropProps, className: twMerge("rounded-md border-2 border-transparent ", isDropTarget && "border-dashed border-blue-100"), children: activeDocumentId ? (_jsx(EditorContainer, { handleClose: () => setActiveDocumentId(undefined), hideToolbar: false, activeDocumentId: activeDocumentId, setActiveDocumentId: setActiveDocumentId })) : (displayActiveNode(selectedFolder?.id || selectedRootNode)) }) }), _jsx(CreateDocumentModal, { onContinue: onCreateDocument, onOpenChange: (open) => setOpenModal(open), open: openModal })] }) }));
|
|
460
499
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/EditorContainer.tsx"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO;IACrC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,
|
|
1
|
+
{"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/EditorContainer.tsx"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO;IACrC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,4CAqLA,CAAC"}
|
|
@@ -55,7 +55,25 @@ export const EditorContainer = (props) => {
|
|
|
55
55
|
}, [selectedDrive, (selectedDocument?.state).global, folderId]);
|
|
56
56
|
// Timeline data for revision history
|
|
57
57
|
const timelineItems = useTimelineItems(selectedDocument?.header.id, selectedDocument?.header.createdAtUtcIso, selectedDrive?.header.id);
|
|
58
|
-
|
|
58
|
+
let preferredEditor = selectedDocument?.header.meta?.preferredEditor;
|
|
59
|
+
if (!preferredEditor) {
|
|
60
|
+
if (selectedDocument?.header.documentType === "powerhouse/workstream") {
|
|
61
|
+
preferredEditor = "workstream-editor";
|
|
62
|
+
}
|
|
63
|
+
else if (selectedDocument?.header.documentType === "powerhouse/rfp") {
|
|
64
|
+
preferredEditor = "request-for-proposals-editor";
|
|
65
|
+
}
|
|
66
|
+
else if (selectedDocument?.header.documentType === "payment-terms") {
|
|
67
|
+
preferredEditor = "payment-terms-editor";
|
|
68
|
+
}
|
|
69
|
+
else if (selectedDocument?.header.documentType === "powerhouse/network-profile") {
|
|
70
|
+
preferredEditor = "network-profile-editor";
|
|
71
|
+
}
|
|
72
|
+
else if (selectedDocument?.header.documentType === "powerhouse/scopeofwork") {
|
|
73
|
+
preferredEditor = "scope-of-work-editor";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const editorModule = useEditorModuleById(selectedDocument?.header.meta?.preferredEditor || preferredEditor);
|
|
59
77
|
// Document export functionality - customize export behavior here
|
|
60
78
|
const onExport = useCallback(async () => {
|
|
61
79
|
if (selectedDocument) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-editor.d.ts","sourceRoot":"","sources":["../../../editors/request-for-proposals/markdown-editor.tsx"],"names":[],"mappings":"AAeA,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAY,EACZ,KAAiB,EACjB,cAAqD,GACtD,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"markdown-editor.d.ts","sourceRoot":"","sources":["../../../editors/request-for-proposals/markdown-editor.tsx"],"names":[],"mappings":"AAeA,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAY,EACZ,KAAiB,EACjB,cAAqD,GACtD,EAAE,mBAAmB,2CAuLrB"}
|
|
@@ -16,15 +16,29 @@ export function MarkdownEditor({ value, onChange, onBlur, height = 350, label =
|
|
|
16
16
|
const [MDEditor, setMDEditor] = useState(null);
|
|
17
17
|
const [contentValue, setContentValue] = useState(" ");
|
|
18
18
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
19
|
+
const [loadError, setLoadError] = useState(null);
|
|
19
20
|
const [viewMarkdownMode, setViewMarkdownMode] = useLocalStorage("markdown-editor-view-mode", "live");
|
|
21
|
+
// Ensure we have a valid mode for the editor
|
|
22
|
+
const editorMode = viewMarkdownMode || "live";
|
|
20
23
|
// Load the MDEditor component dynamically
|
|
21
24
|
useEffect(() => {
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// Use a more robust dynamic import approach
|
|
26
|
+
const loadEditor = async () => {
|
|
27
|
+
try {
|
|
28
|
+
const module = await import("@uiw/react-md-editor");
|
|
29
|
+
setMDEditor(() => module.default);
|
|
30
|
+
setIsLoaded(true);
|
|
31
|
+
setLoadError(null);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error("Failed to load MDEditor:", error);
|
|
35
|
+
setLoadError(error instanceof Error ? error.message : "Failed to load editor");
|
|
36
|
+
setIsLoaded(true);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// Add a small delay to ensure DOM is ready
|
|
40
|
+
const timer = setTimeout(loadEditor, 0);
|
|
41
|
+
return () => clearTimeout(timer);
|
|
28
42
|
}, []);
|
|
29
43
|
// Update contentValue when value prop changes
|
|
30
44
|
useEffect(() => {
|
|
@@ -113,7 +127,7 @@ export function MarkdownEditor({ value, onChange, onBlur, height = 350, label =
|
|
|
113
127
|
line-height: 24px !important;
|
|
114
128
|
}
|
|
115
129
|
|
|
116
|
-
` }), label && _jsx("p", { className: labelClassName, children: label }), !isLoaded && (_jsx("div", { className: "w-full border border-gray-300 rounded-md p-3 bg-white", style: { height: `${height}px` }, children: _jsx("div", { className: "w-full h-full flex items-center justify-center text-gray-500", children: "Loading editor..." }) })), isLoaded && MDEditor && (_jsx("div", { "data-color-mode": "light", className: "w-full", children: _jsx(MDEditor, { height: height, value: contentValue, onChange: handleContentChange, onBlur: handleContentBlur, previewOptions: previewOptions, enableScroll: true, preview:
|
|
130
|
+
` }), label && _jsx("p", { className: labelClassName, children: label }), !isLoaded && (_jsx("div", { className: "w-full border border-gray-300 rounded-md p-3 bg-white", style: { height: `${height}px` }, children: _jsx("div", { className: "w-full h-full flex items-center justify-center text-gray-500", children: "Loading editor..." }) })), isLoaded && loadError && (_jsx("div", { className: "w-full border border-red-300 rounded-md p-3 bg-red-50", style: { height: `${height}px` }, children: _jsxs("div", { className: "w-full h-full flex flex-col items-center justify-center text-red-600", children: [_jsx("p", { className: "text-sm font-medium mb-2", children: "Failed to load markdown editor" }), _jsx("p", { className: "text-xs text-red-500", children: loadError }), _jsx("textarea", { className: "w-full h-full mt-2 p-2 border border-gray-300 rounded text-sm", placeholder: "Fallback text editor - write your content here...", value: value, onChange: (e) => onChange(e.target.value), onBlur: (e) => onBlur?.(e.target.value) })] }) })), isLoaded && MDEditor && (_jsx("div", { "data-color-mode": "light", className: "w-full", children: _jsx(MDEditor, { height: height, value: contentValue, onChange: handleContentChange, onBlur: handleContentBlur, previewOptions: previewOptions, enableScroll: true, preview: editorMode, textareaProps: {
|
|
117
131
|
placeholder: "Write your content here...",
|
|
118
132
|
} }) }))] }));
|
|
119
133
|
}
|