@@ -30,8 +30,9 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
3030
3131 window . onDidChangeActiveTextEditor ( ( editor ) => {
3232 if ( editor ) {
33+ console . log ( "sending message to web view" , editor . document . uri . fsPath , "panel is present" , this . panel ?. webview ) ;
3334 this . panel ?. webview . postMessage ( {
34- key : "vscode_callback " ,
35+ key : "vscode_send " ,
3536 payload : {
3637 key : "changeFocusOnFile" ,
3738 payload : { path : editor . document . uri . fsPath } ,
@@ -82,9 +83,6 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
8283 const document = await workspace . openTextDocument ( fullPath ) ;
8384 await window . showTextDocument ( document ) ;
8485 break ;
85- case "formatProject" :
86- console . log ( "formatProject" , message . payload ) ;
87- break ;
8886 default :
8987 console . log ( `Unhandled message type in key: ${ message . key } ` ) ;
9088 }
@@ -129,10 +127,19 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
129127
130128 // Define a function to handle events from the extension and send them to the iframe
131129 const vscode = acquireVsCodeApi();
130+ vscode.postMessage = function(message) {
131+ // Forward the message to the iframe
132+ const iframe = document.querySelector('iframe');
133+ if (iframe && iframe.contentWindow) {
134+ iframe.contentWindow.postMessage(message, '*');
135+ }
136+ };
137+
138+ // Listen for messages from the extension
132139 window.addEventListener('message', (event) => {
133- // Check if the message is from the extension
134- if (event.source === window && event.data) {
135- // Forward the message to the iframe
140+ console.log(" message received in web view", event);
141+ // Only handle messages that are from the extension
142+ if (event.data && event.data.key === 'vscode_send') {
136143 const iframe = document.querySelector('iframe');
137144 if (iframe && iframe.contentWindow) {
138145 iframe.contentWindow.postMessage(event.data, '*');
0 commit comments