~dricottone/noticable

21a3bc38e3d61b9385601ec3c317e7b8728ec2a5 — Dominic Ricottone 3 years ago c811dd1
Added 'New' to menu
2 files changed, 17 insertions(+), 2 deletions(-)

M main.js
M preload.js
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();