In this section, we are going to provide support for the application menu. For the sake of simplicity, let's integrate the Open and Save features for now and extend the menu as we introduce new features to the application:
You can find out more about how to work with menus in Chapter 2, Building a Markdown Editor. Examples are also provided.
- In the project root folder, create a menu.js file with the following content:
const { Menu, BrowserWindow, dialog } = require('electron');
const fs = require('fs');
module.exports = Menu.buildFromTemplate([
{
label: 'File',
submenu: [
{
label: 'Open',
accelerator: 'CommandOrControl+O',
click() {
loadFile();
}
},
{
label: 'Save',
accelerator: 'CommandOrControl+S...