diff --git a/lib/commands/core.js b/lib/commands/core.js new file mode 100644 index 0000000..554e26b --- /dev/null +++ b/lib/commands/core.js @@ -0,0 +1,3 @@ +"use babel"; + +export default []; diff --git a/lib/components/command.js b/lib/components/command.js index 7cc7735..5ec7562 100644 --- a/lib/components/command.js +++ b/lib/components/command.js @@ -12,18 +12,6 @@ export default Option = (props) => { // hide modal after executing } - function checkfocus() { - if (document.activeElement.id === "cpInput") { - return true; - } else { - return false; - } - } - - const isHighlighted = { - backgroundColor: idx === 0 ? "var(--highlight-background)" : "", - }; - return (

diff --git a/lib/components/palette.js b/lib/components/palette.js index 0337aba..f56996b 100644 --- a/lib/components/palette.js +++ b/lib/components/palette.js @@ -5,12 +5,10 @@ import Option from "./command.js"; import Commands from "../commands/application.js"; import { logger, useModal } from "inkdrop"; import useArrowKeyNavigation from "../navigation/hook.js"; -import { ipcRenderer } from "electron"; const CommandPalette = (props) => { const modal = useModal(); const { Dialog } = inkdrop.components.classes; - const parentRef = useArrowKeyNavigation({ selectors: "a,input" }); const inputRef = useRef(null); const [searchQuery, setSearchQuery] = React.useState(""); @@ -23,6 +21,7 @@ const CommandPalette = (props) => { const sub = inkdrop.commands.add(document.body, { "commandpalette:toggle": toggle, }); + console.log("useeffect triggered"); return () => sub.dispose(); }, [toggle]); @@ -58,10 +57,15 @@ const CommandPalette = (props) => { {...modal.state} onBackdropClick={modal.close} className="commandpalette flex-col" - ref={parentRef} > -

+
{ const eventHandler = (event) => { - handleEvents({ event, parentNode: parentNode.current, selectors }); + handleEvents({ + event, + parentNode: parentNode.current, + selectors, + modal: modal, + }); }; document.addEventListener("keydown", eventHandler); return () => document.removeEventListener("keydown", eventHandler);