Skip to content

Commit

Permalink
updates runtime code editor styling
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodeTherapy committed Oct 28, 2024
1 parent 3247c7f commit eea2e3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
width: calc(100vw - 200px);
height: calc(100vh - 200px);
top: 100px;
left:100px;
left: 100px;
border: 1px solid rgba(0, 0, 0, 0.5);
border-radius: 7px;
}
Expand All @@ -31,7 +31,7 @@
}

.documentList {
font-family: "monospace";
font-family: monospace;
font-size: 12px;
width: 250px !important;
min-width: 250px !important;
Expand All @@ -49,7 +49,7 @@
}

.fileListTitle {
font-family: monospace;
font-family: sans-serif, monospace;
color: #77aaff;
}

Expand Down Expand Up @@ -223,4 +223,4 @@
rgba(0, 0, 0, 1.0) +1px -1px +0px,
rgba(0, 0, 0, 1.0) -1px +1px +0px,
rgba(0, 0, 0, 1.0) -1px +1px +7px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const EditorPanelComponent = (props: EditorPanelProps, ref: ForwardedRef<EditorP
const [editorValue, setEditorValue] = useState<string>("");
const [documentList, setDocumentList] = useState<string[]>([]);
const [documentsWithCopies, setDocumentsWithCopies] = useState<string[]>([]);
const [selectedDocument, setSelectedDocument] = useState<string>(""); // Controls currently selected doc
const [selectedDocument, setSelectedDocument] = useState<string>("");
const [fetching, setFetching] = useState<boolean>(true);
const [fetchedValue, setFetchedValue] = useState<string>("");
const [canApply, setCanApply] = useState<boolean>(false);
Expand All @@ -44,7 +44,6 @@ const EditorPanelComponent = (props: EditorPanelProps, ref: ForwardedRef<EditorP
setIsVisible(false);
});

// Fetch the content of a selected document
const fetchDocumentContent = async (docName: string) => {
try {
setFetching(true);
Expand All @@ -60,22 +59,19 @@ const EditorPanelComponent = (props: EditorPanelProps, ref: ForwardedRef<EditorP
}
};

// Fetch list of documents
const fetchDocumentList = useCallback(async () => {
try {
setFetching(true);
const response = await fetch("/mml-documents-list");
const data = await response.json();
setDocumentList(data.documents);

// Fetch list of documents with copies
const copiesResponse = await fetch("/mml-documents-copies");
const copiesData = await copiesResponse.json();
setDocumentsWithCopies(copiesData.documents);

// If no document is selected, load the first document by default
if (!selectedDocument && data.documents.length > 0) {
fetchDocumentContent(data.documents[0]); // Automatically fetch the first document
fetchDocumentContent(data.documents[0]);
}

setFetching(false);
Expand All @@ -85,7 +81,6 @@ const EditorPanelComponent = (props: EditorPanelProps, ref: ForwardedRef<EditorP
}
}, [selectedDocument]);

// Save the document content
const saveDocument = useCallback(
async (content: string, docName: string) => {
if (content === fetchedValue) {
Expand All @@ -101,7 +96,6 @@ const EditorPanelComponent = (props: EditorPanelProps, ref: ForwardedRef<EditorP
});

const result = await response.json();
// Refresh document list and content after save
await fetchDocumentList();
await fetchDocumentContent(docName);
setFetchedValue(content);
Expand All @@ -114,7 +108,6 @@ const EditorPanelComponent = (props: EditorPanelProps, ref: ForwardedRef<EditorP
[fetchDocumentList, fetchedValue],
);

// Restore the original document from its copy
const restoreDocument = async (docName: string) => {
try {
setFetching(true);
Expand All @@ -124,7 +117,6 @@ const EditorPanelComponent = (props: EditorPanelProps, ref: ForwardedRef<EditorP
const result = await response.json();
console.log(result.message);

// Refresh the document content and list after restoration
await fetchDocumentContent(docName);
await fetchDocumentList();
} catch (error) {
Expand Down

0 comments on commit eea2e3a

Please sign in to comment.