@@ -3,11 +3,12 @@ import React from 'react';
33import type { ExcalidrawImperativeAPI } from '@atyrode/excalidraw/types' ;
44import type { MainMenu as MainMenuType } from '@atyrode/excalidraw' ;
55
6- import { LogOut , SquarePlus , LayoutDashboard , SquareCode , Eye , Coffee , Grid2x2 , User } from 'lucide-react' ;
6+ import { LogOut , SquarePlus , LayoutDashboard , SquareCode , Eye , Coffee , Grid2x2 , User , Text } from 'lucide-react' ;
77import { capture } from '../utils/posthog' ;
88import { ExcalidrawElementFactory , PlacementMode } from '../lib/ExcalidrawElementFactory' ;
99import { useUserProfile } from "../api/hooks" ;
1010import { queryClient } from "../api/queryClient" ;
11+ import Editor from '../pad/editors/Editor' ;
1112
1213interface MainMenuConfigProps {
1314 MainMenu : typeof MainMenuType ;
@@ -32,8 +33,8 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
3233 if ( ! excalidrawAPI ) return ;
3334
3435 const htmlEditorElement = ExcalidrawElementFactory . createEmbeddableElement ( {
35- link : "!editor " ,
36- width : 1200 ,
36+ link : "!html " ,
37+ width : 800 ,
3738 height : 500
3839 } ) ;
3940
@@ -75,6 +76,22 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
7576 scrollToView : true
7677 } ) ;
7778 } ;
79+
80+ const handleEditorClick = ( ) => {
81+ if ( ! excalidrawAPI ) return ;
82+
83+ const editorElement = ExcalidrawElementFactory . createEmbeddableElement ( {
84+ link : "!editor" ,
85+ width : 800 ,
86+ height : 500
87+ } ) ;
88+
89+ ExcalidrawElementFactory . placeInScene ( editorElement , excalidrawAPI , {
90+ mode : PlacementMode . NEAR_VIEWPORT_CENTER ,
91+ bufferPercentage : 10 ,
92+ scrollToView : true
93+ } ) ;
94+ } ;
7895
7996 const handleGridToggle = ( ) => {
8097 if ( ! excalidrawAPI ) return ;
@@ -154,6 +171,12 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
154171 >
155172 Insert HTML Editor
156173 </ MainMenu . Item >
174+ < MainMenu . Item
175+ icon = { < Text /> }
176+ onClick = { handleEditorClick }
177+ >
178+ Insert Code Editor
179+ </ MainMenu . Item >
157180 < MainMenu . Item
158181 icon = { < LayoutDashboard /> }
159182 onClick = { handleDashboardButtonClick }
0 commit comments