From dd4299a4de8a31802a4551d631c67836484d9699 Mon Sep 17 00:00:00 2001
From: omagdy7 <omar.professional8777@gmail.com>
Date: Fri, 3 Nov 2023 17:57:35 +0200
Subject: Moved to react instead of vanilla js and added the basic skeleton of
 the plgin

---
 src/main.tsx | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 src/main.tsx

(limited to 'src/main.tsx')

diff --git a/src/main.tsx b/src/main.tsx
new file mode 100644
index 0000000..c994e33
--- /dev/null
+++ b/src/main.tsx
@@ -0,0 +1,93 @@
+import "@logseq/libs";
+
+import React, { useEffect } from "react";
+import * as ReactDOM from "react-dom/client";
+import App from "./App";
+import "./index.css";
+
+import { logseq as PL } from "../package.json";
+import { SettingSchemaDesc } from "@logseq/libs/dist/LSPlugin";
+
+// @ts-expect-error
+const css = (t, ...args) => String.raw(t, ...args);
+
+const delay = (t = 100) => new Promise(r => setTimeout(r, t))
+
+const pluginId = PL.id;
+
+
+
+let settings: SettingSchemaDesc[] = [
+  {
+    key: "host",
+    type: "string",
+    title: "Host",
+    description: "Set the host of your ollama model",
+    default: "localhost:11434"
+  },
+  {
+    key: "model",
+    type: "string",
+    title: "LLM Model",
+    description: "Set your desired model to use ollama",
+    default: "mistral:instruct"
+  },
+]
+
+function main() {
+  console.log("Hello")
+  console.info(`#${pluginId}: MAIN`);
+  // logseq.useSettingsSchema(settings)
+  let loading = false
+  const root = ReactDOM.createRoot(document.getElementById("app")!);
+
+  root.render(
+    <React.StrictMode>
+      <App />
+    </React.StrictMode>
+  );
+
+  function show() {
+    logseq.showMainUI();
+  }
+  function createModel() {
+    return {
+      show() {
+        logseq.showMainUI();
+      },
+    };
+  }
+
+  logseq.provideModel(createModel());
+  logseq.setMainUIInlineStyle({
+    zIndex: 11,
+  });
+
+  const openIconName = "template-plugin-open";
+
+
+  logseq.provideStyle(css`
+    .${openIconName} {
+      opacity: 1;
+      font-size: 20px;
+      margin-top: 4px;
+    }
+
+    .${openIconName}:hover {
+      color: red;
+    }
+  `);
+
+  logseq.App.registerUIItem("toolbar", {
+    key: openIconName,
+    template: `
+      <a data-on-click="show"
+         class="button">
+        <i class="ti ti-brand-reddit"></i>
+      </a>
+    `,
+  });
+}
+logseq.ready(main).catch(console.error);
+
+
-- 
cgit v1.2.3

