From 0fcf8bb096220eb9ff43ffbe8d87ba225e36701d Mon Sep 17 00:00:00 2001 From: Almoizs-1310 Date: Fri, 5 Dec 2025 19:27:24 +0530 Subject: [PATCH 1/7] MC-3915 Update the UI and added Edit and delete functionality for the google docs plugin --- src/client/components/button.module.css | 7 +- src/client/sidebar/components/Sidebar.tsx | 307 +++++++++++++++------- src/client/sidebar/index.html | 2 + src/client/sidebar/index.jsx | 2 +- src/server/index.ts | 3 + src/server/ui.js | 24 ++ 6 files changed, 250 insertions(+), 95 deletions(-) diff --git a/src/client/components/button.module.css b/src/client/components/button.module.css index 3557db1..4143a3b 100644 --- a/src/client/components/button.module.css +++ b/src/client/components/button.module.css @@ -5,13 +5,14 @@ padding: 0.5rem; outline: none; border-radius: 0.375rem; - border: 1px solid rgb(207, 207, 211); - background-color: white; + border: none; + background-color: #E80962; cursor: pointer; + color: white; } .button:hover { - background-color: rgb(0, 66, 235); + background-color: #B20E45; color: white; transition: all 0.2s; } diff --git a/src/client/sidebar/components/Sidebar.tsx b/src/client/sidebar/components/Sidebar.tsx index 6a54a52..2bd6cc9 100644 --- a/src/client/sidebar/components/Sidebar.tsx +++ b/src/client/sidebar/components/Sidebar.tsx @@ -196,6 +196,32 @@ const Sidebar = () => { } }; + const handleEditDiagram = async (altDescription: string) => { + try { + await serverFunctions.selectChartImage(altDescription); + + await serverFunctions.openEditDiagramDialog(); + } catch (error) { + console.error('Error editing diagram', error); + showAlertDialog('Error editing diagram, please try again'); + } + }; + + const handleRemoveDiagram = async (altDescription: string) => { + try { + const result = await serverFunctions.removeDiagramByAltDescription(altDescription); + if (result.success) { + // Refresh the diagrams list after successful removal + getImages(); + } else { + showAlertDialog(result.message || 'Failed to remove diagram'); + } + } catch (error) { + console.error('Error removing diagram', error); + showAlertDialog('Error removing diagram, please try again'); + } + }; + if (authStatus === 'idle' || authStatus === 'loading') { return ( { padding: '15px 20px', }} > - mc - <> - {authState?.authorized ? ( - - ) : ( - - )} - + + +
- {authState?.authorized ? ( + +{!authState?.authorized ? ( + + + logo + + + Welcome to
+ the Mermaid +
+ + + Create and edit diagrams in Mermaid Chart and easily synchronize + documents with Google Docs. + + + + Login + + + + Don’t have an account? + + + window.open('https://mermaidchart.com/app/sign-up', '_blank')} + sx={{ + textTransform: 'none', + color: '#0071e3', + padding: 0, + minWidth: 'auto', + fontSize: '14px', + marginTop: '4px', + fontFamily: 'Recursive, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', + '&:hover': { + textDecoration: 'underline', + background: 'none', + }, + }} + > + Sign up + +
+) : ( <> - + + Create a new diagram - + Insert a diagram from Mermaid Chart - + Update all diagrams in document to most recent version