M main.js => main.js +7 -0
@@ 31,6 31,13 @@ const template = [
win.webContents.send("menu-save-text", "");
}
},
+ {
+ label: "New",
+ accelerator: "CmdOrCtrl+N",
+ click: () => {
+ win.webContents.send("menu-new-file", "");
+ }
+ },
{ type: "separator" },
{
label: "Show Notes Directory",
M preload.js => preload.js +10 -2
@@ 77,10 77,13 @@ function getActualFilename(filename) {
function getPrettyFilename(filename) {
return path.basename(filename, ".md").split("_").join(" ");
}
+function newFile() {
+ updateState("","");
+ requestLocalFilename();
+}
function readFile(filename) {
if (filename == newFileButton) {
- updateState("","");
- requestLocalFilename();
+ newFile()
} else {
let actualFilename = getActualFilename(filename);
fs.readFile(actualFilename, "utf8", (err, content) => {
@@ 145,6 148,11 @@ ipcRenderer.on("menu-render-markdown", () => {
requestEditorText();
requestUnfocusEditor();
});
+ipcRenderer.on("menu-new-file", () => {
+ debug("caught menu button for new file");
+ requestEditorText();
+ newFile();
+});
ipcRenderer.on("menu-focus-editor", () => {
debug("caught menu button for focus editor");
requestFocusEditor();