File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,11 +14,13 @@ import { getZIndexForNodeType } from "./zIndexHelper";
1414interface EditorToolbarProps {
1515 defaultLanguage ?: string ;
1616 disableSharing ?: boolean ;
17+ disableFileOperations ?: boolean ;
1718}
1819
1920export const EditorToolbar : React . FC < EditorToolbarProps > = ( {
2021 defaultLanguage = "en" ,
2122 disableSharing = false ,
23+ disableFileOperations = false ,
2224} ) => {
2325 const { screenToFlowPosition } = useReactFlow ( ) ;
2426
@@ -114,12 +116,16 @@ export const EditorToolbar: React.FC<EditorToolbarProps> = ({
114116 </ div >
115117 < div className = "toolbar-group" >
116118 < Menu menuButton = { < MenuButton className = "toolbar-button" > < MenuI /> </ MenuButton > } >
117- < MenuItem onClick = { openRoadmap } >
118- < FolderOpen size = { 16 } /> < span > { t . open } </ span >
119- </ MenuItem >
120- < MenuItem onClick = { downloadRoadmap } >
121- < Download size = { 16 } /> < span > { t . download } </ span >
122- </ MenuItem >
119+ { ! disableFileOperations && (
120+ < MenuItem onClick = { openRoadmap } >
121+ < FolderOpen size = { 16 } /> < span > { t . open } </ span >
122+ </ MenuItem >
123+ ) }
124+ { ! disableFileOperations && (
125+ < MenuItem onClick = { downloadRoadmap } >
126+ < Download size = { 16 } /> < span > { t . download } </ span >
127+ </ MenuItem >
128+ ) }
123129 { ! disableSharing && (
124130 < MenuItem onClick = { postToJsonStore } >
125131 < Share2 size = { 16 } /> < span > { t . share } </ span >
Original file line number Diff line number Diff line change @@ -16,13 +16,15 @@ export interface LearningMapEditorProps {
1616 language ?: string ;
1717 jsonStore ?: string ;
1818 disableSharing ?: boolean ;
19+ disableFileOperations ?: boolean ;
1920}
2021
2122export function LearningMapEditor ( {
2223 roadmapData,
2324 language = "en" ,
2425 jsonStore = "https://json.openpatch.org" ,
2526 disableSharing = false ,
27+ disableFileOperations = false ,
2628} : LearningMapEditorProps ) {
2729 // Only get minimal state needed in this component
2830 const nodes = useEditorStore ( state => state . nodes ) ;
@@ -66,7 +68,7 @@ export function LearningMapEditor({
6668 < KeyboardShortcuts jsonStore = { jsonStore } />
6769
6870 { /* Toolbar */ }
69- < EditorToolbar defaultLanguage = { language } disableSharing = { disableSharing } />
71+ < EditorToolbar defaultLanguage = { language } disableSharing = { disableSharing } disableFileOperations = { disableFileOperations } />
7072
7173 { /* Preview or Edit mode */ }
7274 { previewMode && < LearningMap roadmapData = { getRoadmapData ( ) } language = { effectiveLanguage } /> }
Original file line number Diff line number Diff line change 4747 "command" : " learningmap.new" ,
4848 "title" : " New Learningmap" ,
4949 "category" : " Learningmap"
50+ },
51+ {
52+ "command" : " learningmap.showSource" ,
53+ "title" : " Show Source" ,
54+ "category" : " Learningmap"
5055 }
5156 ]
5257 },
Original file line number Diff line number Diff line change @@ -73,6 +73,26 @@ export function activate(context: vscode.ExtensionContext) {
7373 } )
7474 ) ;
7575
76+ // Register command to show source
77+ context . subscriptions . push (
78+ vscode . commands . registerCommand ( 'learningmap.showSource' , async ( ) => {
79+ const activeEditor = vscode . window . activeTextEditor ;
80+ if ( ! activeEditor ) {
81+ vscode . window . showErrorMessage ( 'No active learningmap file' ) ;
82+ return ;
83+ }
84+
85+ const uri = activeEditor . document . uri ;
86+ if ( ! uri . path . endsWith ( '.learningmap' ) ) {
87+ vscode . window . showErrorMessage ( 'Active file is not a learningmap file' ) ;
88+ return ;
89+ }
90+
91+ // Open the file with the default text editor
92+ await vscode . commands . executeCommand ( 'vscode.openWith' , uri , 'default' ) ;
93+ } )
94+ ) ;
95+
7696 console . log ( 'Learningmap extension is now active' ) ;
7797}
7898
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ function WebviewEditor() {
127127 return < div style = { { padding : '20px' } } > Loading editor...</ div > ;
128128 }
129129
130- return < LearningMapEditor disableSharing = { true } /> ;
130+ return < LearningMapEditor disableSharing = { true } disableFileOperations = { true } /> ;
131131}
132132
133133// Mount the React component
You can’t perform that action at this time.
0 commit comments