mirror of
https://github.com/ryanamay/inkdrop-command-palette.git
synced 2024-09-20 01:40:34 +00:00
bugfixes and tooling
This commit is contained in:
parent
d54742a189
commit
a74d55639d
4 changed files with 116 additions and 15 deletions
|
@ -9,17 +9,17 @@ export default Option = (props) => {
|
|||
|
||||
function execute() {
|
||||
modal.close();
|
||||
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 (
|
||||
<span>
|
||||
<span className="shortcut">
|
||||
<kbd key={index}>{key}</kbd>
|
||||
{index !== shortcut.length - 1 ? " + " : ""}
|
||||
{console.log(key)}
|
||||
|
|
|
@ -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,6 +100,7 @@ const CommandPalette = (props) => {
|
|||
</div>
|
||||
<div className="cpContents">
|
||||
{filteredResults.length === 0 ? (
|
||||
<div className="nomatchwrapper">
|
||||
<div className="nomatch">
|
||||
<p className="nomatchemoji">{"(。>﹏<)"}</p>
|
||||
<p className="nomatchtext">no matching commands</p>
|
||||
|
@ -92,6 +108,37 @@ const CommandPalette = (props) => {
|
|||
try searching for a different term
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="nomatchfooter">
|
||||
<p className="nomatchtext"> inkdrop command palette</p>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
className="nomatchtext"
|
||||
>
|
||||
<a
|
||||
rel="noreferrer noopener"
|
||||
href="https://github.com/fuwaa/inkdrop-command-palette"
|
||||
target="_blank"
|
||||
style={{ margin: "0px 5px" }}
|
||||
>
|
||||
star on github
|
||||
</a>
|
||||
<a
|
||||
rel="noreferrer noopener"
|
||||
href="https://github.com/fuwaa/inkdrop-command-palette/issues/new"
|
||||
target="_blank"
|
||||
style={{ margin: "0px 5px" }}
|
||||
>
|
||||
report an issue
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{filteredResults.map((Command, index) => {
|
||||
return (
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
34
tools/main.py
Normal file
34
tools/main.py
Normal file
|
@ -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("];")
|
Loading…
Reference in a new issue