generated from pengx17/logseq-plugin-template-react
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: New Logseq Plugin.
- Loading branch information
EINDEX
committed
Dec 1, 2022
1 parent
3b05ea6
commit 78a2506
Showing
8 changed files
with
328 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
# Logseq Plugin Template React | ||
# logseq-memos-sync | ||
|
||
> A memos sync plugin for logseq | ||
<a href="https://www.buymeacoffee.com/eindex"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=eindex&button_colour=40DCA5&font_colour=ffffff&font_family=Cookie&outline_colour=000000&coffee_colour=FFDD00" /></a> | ||
|
||
## Features | ||
|
||
- plug & play boilerplate with properly defined GitHub action defaults | ||
- develop with HMR, empowered by lightning fast Vite ⚡ with [vite-logseq-plugin](https://github.com/pengx17/vite-plugin-logseq) | ||
- TailwindCSS for styling | ||
- pnpm | ||
- Sync memos to logseq via memos openAPI | ||
|
||
## How to use | ||
|
||
1. Open plugin setting, setting up openAPI | ||
2. Open command panel | ||
3. Search for Sync Memos | ||
4. Run it | ||
|
||
## Limit | ||
|
||
- now just can first 1000 memos. | ||
- if memo exist, cannot update the content. | ||
- can not sync content from logseq to memos. | ||
|
||
## Thanks | ||
|
||
- [Memos](https://github.com/usememos/memos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,41 @@ | ||
import "@logseq/libs"; | ||
|
||
import React from "react"; | ||
import * as ReactDOM from "react-dom/client"; | ||
import App from "./App"; | ||
import "./index.css"; | ||
|
||
import { logseq as PL } from "../package.json"; | ||
|
||
// @ts-expect-error | ||
const css = (t, ...args) => String.raw(t, ...args); | ||
|
||
const pluginId = PL.id; | ||
import { IHookEvent } from "@logseq/libs/dist/LSPlugin"; | ||
import MemosSync from "./memos"; | ||
|
||
function main() { | ||
console.info(`#${pluginId}: MAIN`); | ||
const root = ReactDOM.createRoot(document.getElementById("app")!); | ||
|
||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
); | ||
|
||
function createModel() { | ||
return { | ||
show() { | ||
logseq.showMainUI(); | ||
}, | ||
}; | ||
} | ||
|
||
logseq.provideModel(createModel()); | ||
logseq.setMainUIInlineStyle({ | ||
zIndex: 11, | ||
}); | ||
|
||
const openIconName = "template-plugin-open"; | ||
|
||
logseq.provideStyle(css` | ||
.${openIconName} { | ||
opacity: 0.55; | ||
font-size: 20px; | ||
margin-top: 4px; | ||
} | ||
.${openIconName}:hover { | ||
opacity: 0.9; | ||
} | ||
`); | ||
|
||
logseq.App.registerUIItem("toolbar", { | ||
key: openIconName, | ||
template: ` | ||
<div data-on-click="show" class="${openIconName}">⚙️</div> | ||
`, | ||
}); | ||
console.log("Logseq Memos Plugin Loading!") | ||
logseq.useSettingsSchema([{ | ||
key: "openAPI", | ||
type: "string", | ||
title: "Open API", | ||
description: "Memos Open API, you can find this in memos setting", | ||
default: "", | ||
},{ | ||
key: "includeArchive", | ||
type: "boolean", | ||
title: "Include archive", | ||
description: "Also sync archive memos", | ||
default: false, | ||
},{ | ||
key: "mode", | ||
type: "enum", | ||
title: "Mode", | ||
description: "Mode to Sync Memos", | ||
default: "Custom Page", | ||
enumChoices: ["Journal", "Custom Page"], | ||
enumPicker: "select" | ||
},{ | ||
key: "customPage", | ||
type: "string", | ||
title: "Custom Page", | ||
description: "When you using `Custom Page` mode. You can choose a page to store Sync Memos", | ||
default: "Memos", | ||
}]) | ||
|
||
logseq.App.registerCommandPalette({key: "sync-memos", label: "Sync Memos"} , async (e: IHookEvent) => { | ||
(new MemosSync()).syncMemos() | ||
}) | ||
} | ||
|
||
logseq.ready(main).catch(console.error); |
Oops, something went wrong.