@powerhousedao/network-admin 0.0.4 → 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 +43 -7
- package/dist/editors/request-for-proposals/markdown-editor.d.ts +0 -2
- package/dist/editors/request-for-proposals/markdown-editor.d.ts.map +1 -1
- package/dist/editors/request-for-proposals/markdown-editor.js +3 -3
- package/dist/style.css +1290 -0
- package/package.json +1 -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"}
|
|
@@ -20,6 +20,8 @@ export function DriveExplorer(props) {
|
|
|
20
20
|
const [modalDocumentType, setModalDocumentType] = useState("powerhouse/workstream");
|
|
21
21
|
const selectedDocumentModel = useRef(null);
|
|
22
22
|
const editorModules = useEditorModules();
|
|
23
|
+
// Track the last created folder for drag and drop targeting
|
|
24
|
+
const [lastCreatedFolder, setLastCreatedFolder] = useState(undefined);
|
|
23
25
|
// === DRIVE CONTEXT HOOKS ===
|
|
24
26
|
// Core drive operations and document models
|
|
25
27
|
const { onAddFile, onAddFolder, onCopyNode, onDuplicateNode, onMoveNode, onRenameNode, showDeleteNodeModal, } = useDriveContext();
|
|
@@ -31,6 +33,8 @@ export function DriveExplorer(props) {
|
|
|
31
33
|
const selectedNodePath = useSelectedNodePath();
|
|
32
34
|
const sharingType = useDriveSharingType(selectedDrive?.header.id);
|
|
33
35
|
const allDocuments = useAllDocuments();
|
|
36
|
+
// All folders for the sidebar tree view
|
|
37
|
+
const allFolders = useAllFolderNodes();
|
|
34
38
|
const folderChildren = useFolderChildNodes();
|
|
35
39
|
const fileChildren = useFileChildNodes();
|
|
36
40
|
const filesWithDocuments = fileChildren.map((file) => {
|
|
@@ -41,12 +45,38 @@ export function DriveExplorer(props) {
|
|
|
41
45
|
state,
|
|
42
46
|
};
|
|
43
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]);
|
|
44
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]);
|
|
45
77
|
const { isDropTarget, dropProps } = useDrop({
|
|
46
|
-
node:
|
|
47
|
-
|
|
48
|
-
: undefined,
|
|
49
|
-
onAddFile,
|
|
78
|
+
node: dropTargetNode,
|
|
79
|
+
onAddFile: onAddFileWithTarget,
|
|
50
80
|
onCopyNode,
|
|
51
81
|
onMoveNode,
|
|
52
82
|
});
|
|
@@ -54,8 +84,6 @@ export function DriveExplorer(props) {
|
|
|
54
84
|
const isWorkstreamCreated = fileChildren.some((file) => file.documentType === "powerhouse/workstream");
|
|
55
85
|
//check if network profile doc is created, set isNetworkProfileCreated to true
|
|
56
86
|
const isNetworkProfileCreated = fileChildren.some((file) => file.documentType === "powerhouse/network-profile");
|
|
57
|
-
// All folders for the sidebar tree view
|
|
58
|
-
const allFolders = useAllFolderNodes();
|
|
59
87
|
// Convert folders and files to SidebarNode format
|
|
60
88
|
const sidebarNodes = useMemo(() => {
|
|
61
89
|
const workstreamsNode = {
|
|
@@ -180,6 +208,8 @@ export function DriveExplorer(props) {
|
|
|
180
208
|
// Handle sidebar node selection
|
|
181
209
|
const handleActiveNodeChange = useCallback((nodeId) => {
|
|
182
210
|
console.log("nodeId", nodeId);
|
|
211
|
+
// Clear the last created folder when navigating to a different node
|
|
212
|
+
setLastCreatedFolder(undefined);
|
|
183
213
|
// Find the node by ID
|
|
184
214
|
const findNodeById = (nodes, id) => {
|
|
185
215
|
for (const node of nodes) {
|
|
@@ -395,7 +425,10 @@ export function DriveExplorer(props) {
|
|
|
395
425
|
}
|
|
396
426
|
if (name?.trim()) {
|
|
397
427
|
try {
|
|
398
|
-
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);
|
|
399
432
|
}
|
|
400
433
|
catch (error) {
|
|
401
434
|
console.error("Failed to create folder:", error);
|
|
@@ -416,6 +449,9 @@ export function DriveExplorer(props) {
|
|
|
416
449
|
let folder = undefined;
|
|
417
450
|
if (documentType === "powerhouse/workstream") {
|
|
418
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);
|
|
419
455
|
}
|
|
420
456
|
const node = await addDocument(selectedDrive?.header.id || "", fileName, documentType, folder?.id, getNewDocumentObject(fileName, documentType), undefined, editorType);
|
|
421
457
|
selectedDocumentModel.current = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-editor.d.ts","sourceRoot":"","sources":["../../../editors/request-for-proposals/markdown-editor.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -3,8 +3,6 @@ import { useEffect, useState } from "react";
|
|
|
3
3
|
import remarkGfm from "remark-gfm";
|
|
4
4
|
import rehypeSlug from "rehype-slug";
|
|
5
5
|
import { useLocalStorage } from "usehooks-ts";
|
|
6
|
-
import "@uiw/react-md-editor/markdown-editor.css";
|
|
7
|
-
import "@uiw/react-markdown-preview/markdown.css";
|
|
8
6
|
// Custom preview renderer to make links open in new tabs and ensure proper list rendering
|
|
9
7
|
const previewOptions = {
|
|
10
8
|
components: {
|
|
@@ -20,6 +18,8 @@ export function MarkdownEditor({ value, onChange, onBlur, height = 350, label =
|
|
|
20
18
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
21
19
|
const [loadError, setLoadError] = useState(null);
|
|
22
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";
|
|
23
23
|
// Load the MDEditor component dynamically
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
// Use a more robust dynamic import approach
|
|
@@ -127,7 +127,7 @@ export function MarkdownEditor({ value, onChange, onBlur, height = 350, label =
|
|
|
127
127
|
line-height: 24px !important;
|
|
128
128
|
}
|
|
129
129
|
|
|
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:
|
|
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: {
|
|
131
131
|
placeholder: "Write your content here...",
|
|
132
132
|
} }) }))] }));
|
|
133
133
|
}
|