diff --git a/lib/components/command.js b/lib/components/command.js index ed7805f..ac07a10 100644 --- a/lib/components/command.js +++ b/lib/components/command.js @@ -9,17 +9,17 @@ export default Option = (props) => { function execute() { modal.close(); - if (category === "Application") { - ipcRenderer.send("command", command, {}); - } + setTimeout(() => { + 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); } - } + }, 50); // hide modal after executing } @@ -66,7 +66,7 @@ export default Option = (props) => { if (key == "") return null; else return ( - + {key} {index !== shortcut.length - 1 ? " + " : ""} {console.log(key)} diff --git a/lib/components/palette.js b/lib/components/palette.js index 5c92aab..68bec88 100644 --- a/lib/components/palette.js +++ b/lib/components/palette.js @@ -2,15 +2,30 @@ import React, { useEffect, useCallback, useRef, useLayoutEffect } from "react"; import Option from "./command.js"; +import { logger, useModal } from "inkdrop"; +import useArrowKeyNavigation from "../navigation/hook.js"; + +// commands list 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"; +import Editor from "../commands/editor.js"; +import ExportImport from "../commands/exportimport.js"; +import View from "../commands/view.js"; +import Window from "../commands/window.js"; const CommandPalette = (props) => { - const Commands = [...Formatting, ...Application, ...Core, ...NoteTags]; + const Commands = [ + ...Formatting, + ...Editor, + ...Application, + ...Core, + ...NoteTags, + ...ExportImport, + ...View, + ...Window, + ]; const modal = useModal(); const { Dialog } = inkdrop.components.classes; @@ -85,12 +100,44 @@ const CommandPalette = (props) => {
{filteredResults.length === 0 ? ( -
-

{"(。>﹏<)"}

-

no matching commands

-

- try searching for a different term -

+
+
+

{"(。>﹏<)"}

+

no matching commands

+

+ try searching for a different term +

+
+ +
+

inkdrop command palette

+ +
) : null} {filteredResults.map((Command, index) => { diff --git a/styles/palettemodal.less b/styles/palettemodal.less index 770e58e..b9cd356 100644 --- a/styles/palettemodal.less +++ b/styles/palettemodal.less @@ -81,6 +81,22 @@ align-items: center; justify-content: center; } +.nomatchfooter { + text-align: center; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.nomatchwrapper { + height: 100%; + text-align: center; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; +} .nomatchemoji { font-size: 50px; @@ -92,3 +108,7 @@ color: var(--disabled-text-color); margin: 0; } + +.shortcut { + font-size: 12.5px; +} diff --git a/tools/main.py b/tools/main.py new file mode 100644 index 0000000..62edc96 --- /dev/null +++ b/tools/main.py @@ -0,0 +1,34 @@ +from asyncio import current_task +from urllib.error import ContentTooShortError + + +with open("window.js", "a") as f: + x = open ("source.txt", "r") + previouseditor= "" + currenteditor = "" + currentselector = "" + + f.write("\"use babel\";\n") + f.write("export default [\n") + + # if line starts with "editor:" add line to editor.js + for line in x: + print(line); + print(currenteditor) + print(currentselector) + if line.startswith("window:"): + currenteditor = line[7:] + if line.startswith("Selector: "): + currentselector = line[10:] + if line.startswith("Selector:"): + f.write("{\n") + f.write("name: \">%s\",\n" % (currenteditor.replace("-", " ").capitalize().strip())) + f.write("category: \"Window\",\n") + f.write("command: \"window:%s\",\n" % (currenteditor.strip())) + f.write("selector: \"%s\",\n" % (currentselector.strip())) + f.write("state: \"inprogress\",\n") + f.write("shortcut: [\"\"],\n") + f.write("},\n") + # insert values into the string + # if currenteditor variable changes, add line to editor.js + f.write("];") \ No newline at end of file