@powerhousedao/network-admin 0.0.3 → 0.0.4
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 +12 -9
- 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 +2 -0
- 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 +9 -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":"AAuCA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,2CA8hCvC"}
|
|
@@ -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";
|
|
@@ -30,13 +31,6 @@ export function DriveExplorer(props) {
|
|
|
30
31
|
const selectedNodePath = useSelectedNodePath();
|
|
31
32
|
const sharingType = useDriveSharingType(selectedDrive?.header.id);
|
|
32
33
|
const allDocuments = useAllDocuments();
|
|
33
|
-
// === NAVIGATION SETUP ===
|
|
34
|
-
// Breadcrumbs for folder navigation
|
|
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
|
-
// });
|
|
40
34
|
const folderChildren = useFolderChildNodes();
|
|
41
35
|
const fileChildren = useFileChildNodes();
|
|
42
36
|
const filesWithDocuments = fileChildren.map((file) => {
|
|
@@ -47,6 +41,15 @@ export function DriveExplorer(props) {
|
|
|
47
41
|
state,
|
|
48
42
|
};
|
|
49
43
|
});
|
|
44
|
+
// === DROP HOOKS ===
|
|
45
|
+
const { isDropTarget, dropProps } = useDrop({
|
|
46
|
+
node: folderChildren?.length > 0
|
|
47
|
+
? folderChildren[folderChildren.length - 1]
|
|
48
|
+
: undefined,
|
|
49
|
+
onAddFile,
|
|
50
|
+
onCopyNode,
|
|
51
|
+
onMoveNode,
|
|
52
|
+
});
|
|
50
53
|
// check if workstream doc is created, set isWorkstreamCreated to true
|
|
51
54
|
const isWorkstreamCreated = fileChildren.some((file) => file.documentType === "powerhouse/workstream");
|
|
52
55
|
//check if network profile doc is created, set isNetworkProfileCreated to true
|
|
@@ -456,5 +459,5 @@ export function DriveExplorer(props) {
|
|
|
456
459
|
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
460
|
setActiveDocumentId(undefined);
|
|
458
461
|
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 })] }) }));
|
|
462
|
+
} }), _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
463
|
}
|
|
@@ -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":"
|
|
1
|
+
{"version":3,"file":"markdown-editor.d.ts","sourceRoot":"","sources":["../../../editors/request-for-proposals/markdown-editor.tsx"],"names":[],"mappings":"AAIA,OAAO,0CAA0C,CAAC;AAClD,OAAO,0CAA0C,CAAC;AAYlD,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,2CAoLrB"}
|
|
@@ -3,6 +3,8 @@ 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";
|
|
6
8
|
// Custom preview renderer to make links open in new tabs and ensure proper list rendering
|
|
7
9
|
const previewOptions = {
|
|
8
10
|
components: {
|
|
@@ -16,15 +18,27 @@ export function MarkdownEditor({ value, onChange, onBlur, height = 350, label =
|
|
|
16
18
|
const [MDEditor, setMDEditor] = useState(null);
|
|
17
19
|
const [contentValue, setContentValue] = useState(" ");
|
|
18
20
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
21
|
+
const [loadError, setLoadError] = useState(null);
|
|
19
22
|
const [viewMarkdownMode, setViewMarkdownMode] = useLocalStorage("markdown-editor-view-mode", "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: viewMarkdownMode, textareaProps: {
|
|
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: viewMarkdownMode, textareaProps: {
|
|
117
131
|
placeholder: "Write your content here...",
|
|
118
132
|
} }) }))] }));
|
|
119
133
|
}
|
package/dist/style.css
CHANGED
|
@@ -696,6 +696,9 @@
|
|
|
696
696
|
--tw-border-style: dashed;
|
|
697
697
|
border-style: dashed;
|
|
698
698
|
}
|
|
699
|
+
.border-blue-100 {
|
|
700
|
+
border-color: var(--color-blue-100);
|
|
701
|
+
}
|
|
699
702
|
.border-blue-700 {
|
|
700
703
|
border-color: var(--color-blue-700);
|
|
701
704
|
}
|
|
@@ -708,9 +711,15 @@
|
|
|
708
711
|
.border-gray-700 {
|
|
709
712
|
border-color: var(--color-gray-700);
|
|
710
713
|
}
|
|
714
|
+
.border-red-300 {
|
|
715
|
+
border-color: var(--color-red-300);
|
|
716
|
+
}
|
|
711
717
|
.border-red-700 {
|
|
712
718
|
border-color: var(--color-red-700);
|
|
713
719
|
}
|
|
720
|
+
.border-transparent {
|
|
721
|
+
border-color: transparent;
|
|
722
|
+
}
|
|
714
723
|
.bg-blue-50 {
|
|
715
724
|
background-color: var(--color-blue-50);
|
|
716
725
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/network-admin",
|
|
3
3
|
"description": "Network Admin package for Powerhouse",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"graphql": "^16.10.0",
|
|
67
67
|
"graphql-tag": "^2.12.6",
|
|
68
68
|
"rehype-slug": "^6.0.0",
|
|
69
|
+
"remark-gfm": "^4.0.1",
|
|
69
70
|
"zod": "^3.24.2"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|