diff --git a/lib/commands/application.js b/lib/commands/application.js index 9719b9e..b9f8bd6 100644 --- a/lib/commands/application.js +++ b/lib/commands/application.js @@ -85,10 +85,4 @@ export default [ command: "application:quick-note", shortcut: [""], }, - { - name: "!Toggle Strong/Bold", - category: "Core", - command: "core:strong", - shortcut: [""], - }, ]; diff --git a/lib/commands/core.js b/lib/commands/core.js index 554e26b..b0acd18 100644 --- a/lib/commands/core.js +++ b/lib/commands/core.js @@ -1,3 +1,366 @@ "use babel"; -export default []; +export default [ + { + name: "!Copy", + category: "Core", + command: "core:copy", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Copy Image", + category: "Core", + command: "core:copy-image", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Copy Note Link", + category: "Core", + command: "core:copy-note-link", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Cut", + category: "Core", + command: "core:cut", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Delete Note", + category: "Core", + command: "core:delete-note", + selector: "body", + shortcut: [""], + }, + { + name: "!Delete Notebook", + category: "Core", + command: "core:delete-notebook", + state: "disabled", + shortcut: [""], + }, + { + name: "!Delete Tag", + category: "Core", + command: "core:delete-tag", + state: "disabled", + shortcut: [""], + }, + { + name: "!Duplicate Note", + category: "Core", + command: "core:duplicate-note", + selector: "body", + shortcut: [""], + }, + { + name: "!Empty Trash", + category: "Core", + command: "core:empty-trash", + selector: "body", + shortcut: [""], + }, + { + name: "!Filter notes", + category: "Core", + command: "core:filter-notes", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Filter by tag", + category: "Core", + command: "core:filter-by-tag", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Find", + category: "Core", + command: "core:find", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Clear search bar", + category: "Core", + command: "core:find-clear", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Find (Global)", + category: "Core", + command: "core:find-global", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Focus next", + category: "Core", + command: "core:focus-next", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Focus note list bar", + category: "Core", + command: "core:focus-note-list-bar", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Focus previous", + category: "Core", + command: "core:focus-previous", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Move notebook", + category: "Core", + command: "core:move-notebook", + state: "disabled", + selector: "body", + shortcut: [""], + }, + { + name: "!Move to notebook", + category: "Core", + command: "core:move-to-notebook", + selector: "body", + shortcut: [""], + }, + { + name: "!Navigate back", + category: "Core", + command: "core:navigate-back", + selector: "body", + shortcut: [""], + }, + { + name: "!Navigate forward", + category: "Core", + command: "core:navigate-forward", + selector: "body", + shortcut: [""], + }, + { + name: "!New Note", + category: "Core", + command: "core:new-note", + selector: "body", + shortcut: [""], + }, + { + name: "!New Notebook", + category: "Core", + command: "core:new-notebook", + selector: "body", + shortcut: [""], + }, + { + name: "!Show all notes", + category: "Core", + command: "core:note-list-show-all-notes", + selector: "body", + shortcut: [""], + }, + { + name: "!Show all notes in specified notebook", + category: "Core", + command: "core:note-list-show-notes-in-book", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Show all notes by tag", + category: "Core", + command: "core:notes-list-show-notes-with-tag", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Show all notes with status", + category: "Core", + command: "core:note-list-show-notes-with-status", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Show notes in book of editing note", + category: "Core", + command: "core:note-list-show-notes-in-book-of-editing-note", + selector: "body", + shortcut: [""], + }, + { + name: "!Open first note", + category: "Core", + command: "core:open-first-note", + selector: "body", + shortcut: [""], + }, + { + name: "!Open next note", + category: "Core", + command: "core:open-next-note", + selector: "body", + shortcut: [""], + }, + { + name: "!Close note", + category: "Core", + command: "core:close-note", + selector: "body", + shortcut: [""], + }, + { + name: "!Open note", + category: "Core", + command: "core:open-note", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Open note in separate window", + category: "Core", + command: "core:open-note-in-separate-window", + selector: "body", + shortcut: [""], + }, + { + name: "!Open previous note", + category: "Core", + command: "core:open-prev-note", + selector: "body", + shortcut: [""], + }, + { + name: "!Open tag settings", + category: "Core", + command: "core:open-tag-settings", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Paste", + category: "Core", + command: "core:paste", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Redo", + category: "Core", + command: "core:redo", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: "!Rename Notebook", + category: "Core", + command: "core:rename-notebook", + selector: "body", + state: "disabled", + shortcut: [""], + }, + { + name: "!Save Image", + category: "Core", + command: "core:save-image", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Save Note", + category: "Core", + command: "core:save-note", + selector: "body", + shortcut: [""], + }, + { + name: "!Select all", + category: "Core", + command: "core:select-all", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Search notes", + category: "Core", + command: "core:search-notes", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Share note", + category: "Core", + command: "core:share-note", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Show note revisions", + category: "Core", + command: "core:show-note-revisions", + selector: "body", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Focus sidebar", + category: "Core", + command: "core:sidebar-focus", + selector: "body", + state: "error", + shortcut: [""], + }, + { + name: "!Select next item on sidebar", + category: "Core", + command: "core:sidebar-select-next-item", + selector: "body", + shortcut: [""], + }, + { + name: "!Select previous item on sidebar", + category: "Core", + command: "core:sidebar-select-prev-item", + selector: "body", + shortcut: [""], + }, + { + name: "!Undo", + category: "Core", + command: "core:undo", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, +]; diff --git a/lib/commands/editor.js b/lib/commands/editor.js new file mode 100644 index 0000000..554e26b --- /dev/null +++ b/lib/commands/editor.js @@ -0,0 +1,3 @@ +"use babel"; + +export default []; diff --git a/lib/commands/formatting.js b/lib/commands/formatting.js new file mode 100644 index 0000000..0f74987 --- /dev/null +++ b/lib/commands/formatting.js @@ -0,0 +1,144 @@ +"use babel"; + +export default [ + { + name: ".Emphasize Text", + category: "Format", + command: "core:emphasize", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Indent", + category: "Format", + command: "core:indent", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Insert code block", + category: "Format", + command: "core:insert-code-block", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Insert horizontal rule", + category: "Format", + command: "core:insert-horizontal-rule", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Insert link", + category: "Format", + command: "core:insert-link", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Indent", + category: "Format", + command: "core:indent", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Insert code block", + category: "Format", + command: "core:insert-code-block", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Strikethrough", + category: "Format", + command: "core:strikethrough", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Embolden", + category: "Format", + command: "core:strong", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Toggle blockquote", + category: "Format", + command: "core:toggle-blockquote", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Toggle bulleted list", + category: "Format", + command: "core:toggle-bulleted-list", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Toggle heading 1", + category: "Format", + command: "core:toggle-heading-1", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Toggle heading 2", + category: "Format", + command: "core:toggle-heading-2", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Toggle heading 3", + category: "Format", + command: "core:toggle-heading-3", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Toggle-heading-4", + category: "Format", + command: "core:toggle-heading-4", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Make header bigger", + category: "Format", + command: "core:toggle-heading-bigger", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Make header smaller", + category: "Format", + command: "core:toggle-heading-smaller", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Toggle numbered list", + category: "Format", + command: "core:toggle-numbered-list", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Toggle task list", + category: "Format", + command: "core:toggle-task-list", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, + { + name: ".Unindent", + category: "Format", + command: "core:unindent", + selector: ".mde-cm-wrapper", + shortcut: [""], + }, +]; diff --git a/lib/commands/notetagsbar.js b/lib/commands/notetagsbar.js new file mode 100644 index 0000000..78a5dc2 --- /dev/null +++ b/lib/commands/notetagsbar.js @@ -0,0 +1,44 @@ +"use babel"; + +export default [ + { + name: "!Unselect items", + category: "Tags Bar", + command: "core:note-tags-bar-item-list-unselect", + selector: ".note-tags-bar-item-list", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Select previous item", + category: "Tags Bar", + command: "core:note-tags-bar-item-list-select-prev", + selector: ".note-tags-bar-item-list", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Select next item", + category: "Tags Bar", + command: "core:note-tags-bar-item-list-select-next", + selector: ".note-tags-bar-item-list", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Remove selected item and select previous item", + category: "Tags Bar", + command: "core:note-tags-bar-item-list-select-remove-item-before", + selector: ".note-tags-bar-item-list", + state: "inprogress", + shortcut: [""], + }, + { + name: "!Remove selected item", + category: "Tags Bar", + command: "core:note-tags-bar-item-list-select-remove-item", + selector: ".note-tags-bar-item-list", + state: "inprogress", + shortcut: [""], + }, +]; diff --git a/lib/components/command.js b/lib/components/command.js index 5ec7562..ed7805f 100644 --- a/lib/components/command.js +++ b/lib/components/command.js @@ -4,20 +4,42 @@ import React, { useEffect, useCallback, useLayoutEffect } from "react"; import { ipcRenderer } from "electron"; export default Option = (props) => { - let { name, category, command, shortcut, modal, idx } = props; + let { name, category, command, shortcut, modal, idx, selector, state, args } = + props; function execute() { - ipcRenderer.send("command", command, {}); modal.close(); + if (category === "Application") { + ipcRenderer.send("command", command, {}); + } + + if (category === "Core") { + if (selector === "body") { + inkdrop.commands.dispatch(document.body, command); + } else { + inkdrop.commands.dispatch(document.querySelector(selector), command); + } + } // hide modal after executing } + const status = { + color: + state === "error" + ? "#b86a85" + : state === "inprogress" + ? "#b7b86a" + : state === "disabled" + ? "var(--disabled-text-color)" + : null, + }; + return ( -

+

{category} {category != "" ? ": " : ""} - {name.replace(/!/g, "").replace(/>/g, "")} + {name.replace(/!/g, "").replace(/>/g, "").replace(/\./g, "")}

{idx === 0 ? ( @@ -25,6 +47,21 @@ export default Option = (props) => { top result ) : null}{" "} + {state === "error" ? ( + + not working / buggy + + ) : null}{" "} + {state === "inprogress" ? ( + + untested / unimplemented + + ) : null}{" "} + {state === "disabled" ? ( + + private command + + ) : null}{" "} {shortcut.map((key, index) => { if (key == "") return null; else diff --git a/lib/components/palette.js b/lib/components/palette.js index f56996b..5c92aab 100644 --- a/lib/components/palette.js +++ b/lib/components/palette.js @@ -2,11 +2,16 @@ import React, { useEffect, useCallback, useRef, useLayoutEffect } from "react"; import Option from "./command.js"; -import Commands from "../commands/application.js"; +import Application from "../commands/application.js"; +import Core from "../commands/core.js"; +import NoteTags from "../commands/notetagsbar.js"; +import Formatting from "../commands/formatting.js"; import { logger, useModal } from "inkdrop"; import useArrowKeyNavigation from "../navigation/hook.js"; const CommandPalette = (props) => { + const Commands = [...Formatting, ...Application, ...Core, ...NoteTags]; + const modal = useModal(); const { Dialog } = inkdrop.components.classes;