Skip to content

Commit

Permalink
Electron menus plugin
Browse files Browse the repository at this point in the history
Listen to messages triggered by electron menus
  • Loading branch information
XuluWarrior committed Sep 22, 2024
1 parent e02c60e commit 02ca361
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/renderer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import 'swagger-editor-dist/swagger-editor.css'
import SwaggerEditorBundle from "swagger-editor-dist/swagger-editor-bundle.js";
import SwaggerEditorStandalonePreset from "swagger-editor-dist/swagger-editor-standalone-preset.js";

import electronMenus from './plugins/electron-menus'

window.onload = function() {
// Build a system\
const editor = window.SwaggerEditorBundle({
dom_id: '#swagger-editor',
layout: 'StandaloneLayout',
presets: [
window.SwaggerEditorStandalonePreset
],
plugins: [
electronMenus
]
});

Expand Down
20 changes: 20 additions & 0 deletions src/renderer/src/plugins/electron-menus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class ElectronMenus {
system = undefined;

constructor() {
window.electron.ipcRenderer.on("update-spec", this.updateSpec);
}

updateSpec = (_event, spec) => {
this.system.specActions.updateSpec(spec);
}

setupPlugin = (system) => {
this.system = system;
return {}
}
};

const electronMenus = new ElectronMenus()

export default electronMenus.setupPlugin

0 comments on commit 02ca361

Please sign in to comment.