Skip to content

Commit

Permalink
fix: webview cefQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
dineug committed Jan 19, 2024
1 parent 0f0f296 commit cbb2172
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 10 additions & 4 deletions packages/erd-editor-jetbrains-webview/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
declare global {
interface Window {
cefQuery: (arg: any) => number;
}
interface Window {
cefQuery: (query: {
request: string;
onSuccess: (response: string) => void;
onFailure: (errorCode: number, errorMessage: string) => void;
context?: any;
persistent: boolean;
keepAlive?: boolean;
}) => number;
cefQueryCancel: (requestId: number) => void;
}
10 changes: 7 additions & 3 deletions packages/erd-editor-jetbrains-webview/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ import {
import { encode } from 'base64-arraybuffer';

const bridge = new Emitter();
// const vscode = globalThis.acquireVsCodeApi();
const editor = document.createElement('erd-editor');
const sharedStore = editor.getSharedStore({ mouseTracker: false });

const dispatch = (action: AnyAction) => {
// vscode.postMessage(action);
window.cefQuery({
request: JSON.stringify(action),
persistent: false,
onSuccess: () => {},
onFailure: () => {},
});
};

import('@dineug/erd-editor-shiki-worker').then(({ getShikiService }) => {
Expand Down Expand Up @@ -95,5 +99,5 @@ bridge.on({
},
});

globalThis.addEventListener('message', event => bridge.emit(event.data));
window.addEventListener('message', event => bridge.emit(event.data));
dispatch(vscodeInitialAction());

0 comments on commit cbb2172

Please sign in to comment.