blob: 5b5fca0a0a2796fb4447f88d985d6cf0a3dc112e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import React, { useEffect, useRef, useState } from "react";
import CommandPalette from "./components/CommandPallete";
import { useAppVisible } from "./utils";
const options = [
{ label: 'Ask Ai' },
{ label: 'Define' },
{ label: 'Divide into subtasks' },
{ label: 'Summarize' },
];
async function ollamaUI() {
console.log("Hello")
logseq.showMainUI({ autoFocus: true })
setTimeout(() => {
document.getElementById("ai-input")?.focus()
console.log(document.getElementById("ai-input"))
}, 300)
}
function App() {
const innerRef = useRef<HTMLDivElement>(null);
const visible = useAppVisible();
useEffect(() => {
logseq.Editor.registerSlashCommand("ollama", ollamaUI)
}, [])
if (visible) {
return (
<main
className="fixed inset-0 flex items-center justify-center"
onClick={(e) => {
if (!innerRef.current?.contains(e.target as any)) {
window.logseq.hideMainUI();
}
}}
>
<div ref={innerRef} className="text-white text-2xl">
<CommandPalette options={options} />
</div>
</main>
);
}
return null;
}
export default App;
|