aboutsummaryrefslogtreecommitdiff
path: root/src/App.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/App.tsx')
-rw-r--r--src/App.tsx51
1 files changed, 36 insertions, 15 deletions
diff --git a/src/App.tsx b/src/App.tsx
index 5b5fca0..c88108d 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,30 +1,51 @@
+import { AppUserInfo } from "@logseq/libs/dist/LSPlugin";
import React, { useEffect, useRef, useState } from "react";
-import CommandPalette from "./components/CommandPallete";
+import { OllamaCommandPallete } from "./components/OllamaCommandPallete";
+import { convertToFlashCardFromEvent, DivideTaskIntoSubTasksFromEvent, ollamaUI } from "./ollama";
import { useAppVisible } from "./utils";
const options = [
- { label: 'Ask Ai' },
- { label: 'Define' },
- { label: 'Divide into subtasks' },
- { label: 'Summarize' },
+ 'Ask ai',
+ 'Ask with context',
+ 'Define',
+ 'Divide into subtasks',
+ 'Summarize',
+ 'Convert to flash card',
];
-
-async function ollamaUI() {
- console.log("Hello")
- logseq.showMainUI({ autoFocus: true })
- setTimeout(() => {
- document.getElementById("ai-input")?.focus()
- console.log(document.getElementById("ai-input"))
- }, 300)
+async function getTheme() {
+ const theme = await logseq.App.getUserInfo()
+ if (!theme) {
+ return "dark"
+ }
+ return theme.preferredThemeMode
}
function App() {
const innerRef = useRef<HTMLDivElement>(null);
const visible = useAppVisible();
+ const [theme, setTheme] = useState<string>('')
useEffect(() => {
+ const getTheme = async () => {
+ const theme = await logseq.App.getUserConfigs()
+ if (!theme) {
+ setTheme('dark')
+ } else {
+ setTheme(theme.preferredThemeMode)
+ }
+ }
+ getTheme();
+ if (!logseq.settings) {
+ return
+ }
logseq.Editor.registerSlashCommand("ollama", ollamaUI)
+ logseq.Editor.registerBlockContextMenuItem("Create a flash card", convertToFlashCardFromEvent)
+ logseq.Editor.registerBlockContextMenuItem("Make task into subtasks", DivideTaskIntoSubTasksFromEvent)
+ logseq.App.registerCommandShortcut(
+ { "binding": logseq.settings.shortcut },
+ ollamaUI
+ );
}, [])
if (visible) {
@@ -37,8 +58,8 @@ function App() {
}
}}
>
- <div ref={innerRef} className="text-white text-2xl">
- <CommandPalette options={options} />
+ <div ref={innerRef} className="flex items-center justify-center w-screen">
+ <OllamaCommandPallete options={options} theme={theme} />
</div>
</main>
);