Skip to content

Commit 1e8760e

Browse files
committed
feat: add Terminal option to Main Menu
- Integrated a new Terminal item in the Main Menu for user access. - Implemented handleTerminalClick function to create and place a terminal element in the canvas. - Enhanced user experience by providing direct access to terminal functionality within the application.
1 parent c8ea467 commit 1e8760e

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/frontend/src/ui/MainMenu.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useState } from 'react';
33
import type { ExcalidrawImperativeAPI } from '@atyrode/excalidraw/types';
44
import type { MainMenu as MainMenuType } from '@atyrode/excalidraw';
55

6-
import { LogOut, SquarePlus, LayoutDashboard, SquareCode, Eye, Coffee, Grid2x2, User, Text, ArchiveRestore, Settings } from 'lucide-react';
6+
import { LogOut, SquarePlus, LayoutDashboard, SquareCode, Eye, Coffee, Grid2x2, User, Text, ArchiveRestore, Settings, Terminal } from 'lucide-react';
77
import { capture } from '../utils/posthog';
88
import { ExcalidrawElementFactory, PlacementMode } from '../lib/ExcalidrawElementFactory';
99
import { useUserProfile } from "../api/hooks";
@@ -100,6 +100,22 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
100100
scrollToView: true
101101
});
102102
};
103+
104+
const handleTerminalClick = () => {
105+
if (!excalidrawAPI) return;
106+
107+
const terminalElement = ExcalidrawElementFactory.createEmbeddableElement({
108+
link: "!terminal",
109+
width: 800,
110+
height: 500
111+
});
112+
113+
ExcalidrawElementFactory.placeInScene(terminalElement, excalidrawAPI, {
114+
mode: PlacementMode.NEAR_VIEWPORT_CENTER,
115+
bufferPercentage: 10,
116+
scrollToView: true
117+
});
118+
};
103119

104120
const handleCanvasBackupsClick = () => {
105121
setShowBackupsModal(true);
@@ -176,6 +192,12 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
176192
>
177193
Code Editor
178194
</MainMenu.Item>
195+
<MainMenu.Item
196+
icon={<Terminal />}
197+
onClick={handleTerminalClick}
198+
>
199+
Terminal
200+
</MainMenu.Item>
179201
<MainMenu.Item
180202
icon={<LayoutDashboard />}
181203
onClick={handleDashboardButtonClick}

0 commit comments

Comments
 (0)