diff options
| author | Omar Magdy <99906646+omagdy7@users.noreply.github.com> | 2023-12-11 12:55:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-11 12:55:02 +0200 |
| commit | d215eea3cde99707380d1e8ee3e2daddb3b26ebf (patch) | |
| tree | 382f63adc9e56658dc77d4115db620d1dfc9cdcb /src/App.tsx | |
| parent | 5b671c04685acd36b49a20d0104829f6f91e728f (diff) | |
| parent | f4a66c83658c354a9c5e3d7f2476de4e429cae94 (diff) | |
| download | ollama-logseq-d215eea3cde99707380d1e8ee3e2daddb3b26ebf.tar.xz ollama-logseq-d215eea3cde99707380d1e8ee3e2daddb3b26ebf.zip | |
Merge pull request #10 from taweili/master
Use closure to make creating new menu event easier and added a way to add extra block menu commands through reading the props of ollama-logseq-page
Diffstat (limited to 'src/App.tsx')
| -rw-r--r-- | src/App.tsx | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/App.tsx b/src/App.tsx index 6ab84a8..b6b6918 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,9 +4,7 @@ import { convertToFlashCardFromEvent, DivideTaskIntoSubTasksFromEvent, ollamaUI, - summarizeBlockFromEvent, - promptFromBlockEvent, - expandBlockEvent + promptFromBlockEventClosure } from "./ollama"; import { useAppVisible } from "./utils"; @@ -46,16 +44,33 @@ function App() { if (!logseq.settings) { return } + +logseq.Editor.getPageBlocksTree("ollama-logseq-config").then((blocks) => { + blocks!.forEach((block) => { + logseq.Editor.getBlockProperty(block.uuid, "ollama-context-menu-title").then((title) => { + logseq.Editor.getBlockProperty(block.uuid, "ollama-prompt-prefix").then((prompt_prefix) => { + logseq.Editor.registerBlockContextMenuItem(title, promptFromBlockEventClosure(prompt_prefix)) + }) + }).catch((reason) => { + }) + }) +}).catch((reason) => { + console.log("Can not find the configuration page named 'ollama-logseq-config'") + console.log(reason) +}) + + logseq.Editor.registerSlashCommand("ollama", ollamaUI) logseq.Editor.registerBlockContextMenuItem("Ollama: Create a flash card", convertToFlashCardFromEvent) - logseq.Editor.registerBlockContextMenuItem("Ollama: Summarize block", summarizeBlockFromEvent) logseq.Editor.registerBlockContextMenuItem("Ollama: Divide into subtasks", DivideTaskIntoSubTasksFromEvent) - logseq.Editor.registerBlockContextMenuItem("Ollama: Prompt from Block", promptFromBlockEvent) - logseq.Editor.registerBlockContextMenuItem("Ollama: Expand Block", expandBlockEvent) + logseq.Editor.registerBlockContextMenuItem("Ollama: Prompt from Block", promptFromBlockEventClosure()) + logseq.Editor.registerBlockContextMenuItem("Ollama: Summarize block", promptFromBlockEventClosure("Summarize: ")) + logseq.Editor.registerBlockContextMenuItem("Ollama: Expand Block", promptFromBlockEventClosure("Expand: ")) + logseq.App.registerCommandShortcut( { "binding": logseq.settings.shortcut }, ollamaUI - ); + ); }, []) if (visible) { |
