@@ -179,6 +179,14 @@ export function renderInfoview(editorApi: EditorApi, uiElement: HTMLElement): In
179179 return infoviewApi
180180}
181181
182+ declare module '@leanprover/infoview-api' {
183+ interface InfoviewApi {
184+ goToDefinition ?: ( line : number , character : number ) => void ;
185+ }
186+ }
187+
188+
189+
182190export const InfoviewFc : React . FC <
183191 {
184192 mkEditorApi : ( infoviewApi : InfoviewApi ) => EditorApi ;
@@ -204,6 +212,7 @@ export const InfoviewFc: React.FC<
204212 changedInfoviewConfig : new EventEmitter ( ) ,
205213 runTestScript : new EventEmitter ( ) ,
206214 requestedAction : new EventEmitter ( ) ,
215+ clickedContextMenu : new EventEmitter ( ) ,
207216 goToDefinition : new EventEmitter ( ) ,
208217 }
209218
@@ -223,11 +232,19 @@ export const InfoviewFc: React.FC<
223232 changedCursorLocation : async loc => editorEvents . changedCursorLocation . fire ( loc ) ,
224233 changedInfoviewConfig : async conf => editorEvents . changedInfoviewConfig . fire ( conf ) ,
225234 requestedAction : async action => editorEvents . requestedAction . fire ( action , action . kind ) ,
226- goToDefinition : async id => editorEvents . goToDefinition . fire ( id , id ) ,
235+ goToDefinition : async id => editorEvents ? .goToDefinition . fire ( id , id ) ,
227236 // See https://rollupjs.org/guide/en/#avoiding-eval
228237 // eslint-disable-next-line @typescript-eslint/no-implied-eval
229238 runTestScript : async script => new Function ( script ) ( ) ,
230239 getInfoviewHtml : async ( ) => document . body . innerHTML ,
240+ clickedContextMenu : async action => {
241+ editorEvents . clickedContextMenu . fire ( action , `${ action . entry } :${ action . id } ` )
242+ // See comments on `InteractiveCodeTag`.
243+ const sel = window . getSelection ( )
244+ if ( sel && 0 < sel . rangeCount && '_InteractiveCodeTagAutoSelection' in sel . getRangeAt ( 0 ) )
245+ sel . removeAllRanges ( )
246+ } ,
247+
231248 }
232249
233250 const editorApi = mkEditorApi ( infoviewApi )
@@ -246,9 +263,9 @@ export const InfoviewFc: React.FC<
246263 return < > </ >
247264 }
248265
249- return (
266+ return (
250267 < EditorContext . Provider value = { ec } >
251268 < Main />
252269 </ EditorContext . Provider >
253- )
254- }
270+ )
271+ }
0 commit comments