Giter Site home page Giter Site logo

logseq-plugin-samples's Introduction

Logseq Plugin Samples

This repository contains sample code illustrating the Logseq Plugin API. You can read, play with or adapt from these samples to create your own plugins.

Plugin APIs: https://plugins-doc.logseq.com

Prerequisites

You need to have node and npm(or yarn) installed on your system to run the examples. Then install the latest Logseq Desktop App from here.

Using nvm to install node and npm

For those who are not familiar with the installation of Node.js and NPM, a simple solution would be to install Node Version Manager (NVM)(link). The installation is straightforward: just download and run the installation bash script. You may need to give access permissions to the script.

After installing nvm, using the command nvm install 16(for current) or nvm install 14(for LTS), you'll be able to install the current version of node and npm on your machine. Because nvm installs locally, there is no need for the sudo command.

For those familiar, nvm acts similarly to anaconda: the same way you can select your version of python with anaconda, you can choose your version of node.js.

Usage

  • git clone https://github.com/logseq/logseq-plugin-samples
  • open Logseq Desktop client and turn on Developer mode in user settings panel
  • open the toolbar dot menus and navigate to plugins page
  • read the README file of the sample you want to load, then determine if it should be rebuilt (npm install && npm run build)
  • navigate to the plugins dashboard: tp
  • click Load unpacked plugin button, then select the sample directory to load it

⚠️ To avoid loading plugin failures occasionally and for performance reasons, it is recommended to keep the plugin SDK @logseq/libs as up-to-date as possible.

Getting Started

License

MIT

logseq-plugin-samples's People

Contributors

benjypng avatar birdinforest avatar c6p avatar cannibalox avatar devonzuegel avatar jhixson avatar lachlanmcmillan avatar mathisto avatar pengx17 avatar rebornix avatar ssakhavi avatar stdword avatar tiensonqin avatar toftpokk avatar xyhp915 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

logseq-plugin-samples's Issues

Journals Calendar change first day to Monday

hey, I love this plugin, would be interested to learn how to change the first day to monday. I opened the file logseq-journals-calendar.json but since it's an empty file I couldn't figure out if there's an existing way to change the first day of the week

image

Let me know if it there's an existing way, if not this would be a great feature for those of use that prefer monday as the first day of the week

Thanks a lot!

Emojipicker's emojis dont display

Most emojis dont display at all in the picker, and display as a diagonaly striped rectangle when inserted in the text (which requires clicking a blank square in the picker).
It looks like if it requires some specific font but that font hasnt been installed.

On Ubuntu 22.04 LTS.

Example :

  • all "smile" emojis appear well except the last one "πŸ™‚"
  • πŸ€“ appears blank (and most of the proposed emojis)

@parcel/core: Unexpected output file type .html in target "main"

When trying to run npm run build for the sample "logseq-reddit-hot-news", the following error is encountered.
@parcel/core: Unexpected output file type .html in target "main"

The above error refers to the package.json file, where parcel expects a .js or .ts file. However, for the plugin, a .html file is needed in target 'main'.

I've created a pull request for the fix.

Translator plugin: handshake Timeout

I’m trying to run examples from the this repository.
I fetched the repo, switched to the logseq-a-translator dir, ran npm instal, then npm run build.
It has successfully built the dist and I installed it in Logseq.

However, upon enabling it I receive a message:

ERROR: [Loader:#_ifb2iwsl4 - logseq-a-translator][8:21:38 PM] loadhandshake Timeout Error: handshake Timeout
    at file:///tmp/.mount_LogseqMcGrxd/resources/app/js/lsplugin.core.js:2:88419
    at g (file:///tmp/.mount_LogseqMcGrxd/resources/app/js/main.js:3608:419)

Ideas?

I also created a thread in the Discuss forum:

https://discuss.logseq.com/t/logseq-plugin-samples-repository-translator-plugin-handshake-timeout/26500

Plugin sample in ClojureScript?

I'm unable to find a sample or published plugin wrote in ClojureScript. The majority are written in TypeScript. I'm wondering if I miss anything or is there a good reason?

Example for adding a shortcut

Hi! I've been experimenting with a few knowledge bases and tried Logseq for a while. I'm currently on Trilium Notes.

Trilium Notes is very scriptable and allows users to bind keyboard shortcuts to their own JavaScript. I currently have one for "create issue", which creates a note with a particular template (basically to make it an issue for my simple in-Trillium issue tracker).

It would be probably also useful for writers of Logseq plugins to have an example of how to do this properly (especially given that logseq has changeable shortcuts).

[Feature request] One day back and forth

It would be awesome if calendar drop-down would have next and previous days buttons.
Scenario: I am on 3rd of June 2022 page, pressing previous day would direct me to 2nd of June 2022 page
Also it would be awesome to have go to today button. It is actually similar to how Outlook is handling this:
Screenshot 2022-07-04 at 09 56 31

logseq-emoji-picker doesn't build: @parcel/core: Failed to resolve '@joeattardi/emoji-button' from './index.ts'

npm install && npm run build
npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility

added 181 packages, and audited 182 packages in 3s

72 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> [email protected] build
> parcel build --public-url . --no-source-maps index.html

🚨 Build failed.

@parcel/core: Failed to resolve '@joeattardi/emoji-button' from './index.ts'

  /home/dieter/code/logseq-plugin-samples/logseq-emoji-picker/index.ts:2:29
    1 | import '@logseq/libs'
  > 2 | import { EmojiButton } from '@joeattardi/emoji-button'
  >   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    3 | 
    4 | /**

logseq-query-builder fails to load

The logseq-query-builder plugin fails to load.

#pengx17_logseq-query-playground - logseq-query-playground can not resolve selector target #search

Screen Shot 2023-12-26 at 8 12 44 pm

Logseq: Version 0.10.3 (77)

yarn.lock contains private proxy server?

Tried to run yarn install in logseq-query-playground and got network timeout errors running yarn install

Looking at log I was finding error connecting to https://arti.freewheel.tv/api/npm/...
At first, I thought it was some proxy on my end and was confused where this came from then I realized these URLs come from the yarn.lock file and was able to resolve the issue by deleting the yarn.lock file before running yarn install

➜  logseq-query-playground git:(master) βœ— yarn install
yarn install v1.22.17
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://arti.freewheel.tv/api/npm/fw-npm/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.0.0.tgz: ETIMEDOUT".
info If you think this is a bug, please open a bug report with the information provided in "/Users/kurt.harriger/projects/logseq-plugins/logseq-plugin-samples/logseq-query-playground/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

No slash command for pomodoro timer

I installed the plugin sample for pomodoro, and can't see the slash command for creating a new pomodoro for some reason. This happened to me on earlier versions of logseq as well. Not sure what could be the problem. I restarted logseq after installing it as wel

pomodoro-error.mp4

l

Hello World build fails

npm i && npm run build fails with an error for the Hello World plugin (it worked e.g. for emoji picker):


> [email protected] build
> parcel build --public-url . --no-source-maps index.html

🚨  /Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/@logseq/libs/dist/lsplugin.user.js: Unexpected token: punc (.)
    at Z.get (/Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/terser/dist/bundle.min.js:1:525)
    at Object.errorToJson (/Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/@parcel/utils/src/errorUtils.js:9:20)
    at Pipeline.process (/Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/parcel-bundler/src/Pipeline.js:29:26)
    at async Object.run (/Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/parcel-bundler/src/worker.js:15:12)
    at async Bundler.loadAsset (/Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/parcel-bundler/src/Bundler.js:577:19)
    at async /Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/parcel-bundler/src/Bundler.js:610:13
    at async Promise.all (index 2)
    at async Bundler.loadAsset (/Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/parcel-bundler/src/Bundler.js:599:21)
    at async /Users/mschmidtkorth/Github/MSK/logseq-plugin-samples/logseq-hello-world/node_modules/parcel-bundler/src/Bundler.js:610:13
    at async Promise.all (index 0)```

fail to install on Macbook Air M1 - logseq-journals-calendar

logseq-journals-calendar
Here is the error message when run npm install && npm run build

> [email protected] postinstall /Users/royyang/Repos/logseq-plugin-samples/logseq-journals-calendar/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> [email protected] postinstall /Users/royyang/Repos/logseq-plugin-samples/logseq-journals-calendar/node_modules/esbuild
> node install.js

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

added 344 packages from 321 contributors and audited 344 packages in 14.485s

31 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


> [email protected] build /Users/royyang/Repos/logseq-plugin-samples/logseq-journals-calendar
> vite build


<--- Last few GCs --->

[94570:0x120008000]       70 ms: Scavenge 6.3 (9.2) -> 5.3 (10.0) MB, 0.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 
[94570:0x120008000]       77 ms: Scavenge 6.8 (10.0) -> 5.9 (10.5) MB, 0.4 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 
[94570:0x120008000]       85 ms: Scavenge 7.6 (14.5) -> 6.5 (15.2) MB, 0.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 


<--- JS stacktrace --->

FATAL ERROR: wasm code commit Allocation failed - process out of memory
 1: 0x1047d99d8 node::Abort() [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
 2: 0x1047d9b58 node::errors::TryCatchScope::~TryCatchScope() [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
 3: 0x1048f3330 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
 4: 0x1048f32c4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
 5: 0x104e88cbc v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
 6: 0x104e89950 v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(int, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
 7: 0x104e88618 v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
 8: 0x104e89760 v8::internal::wasm::NativeModule::NativeModule(v8::internal::wasm::WasmEngine*, v8::internal::wasm::WasmFeatures const&, v8::internal::VirtualMemory, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, std::__1::shared_ptr<v8::internal::Counters>, std::__1::shared_ptr<v8::internal::wasm::NativeModule>*) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
 9: 0x104e8bcd4 v8::internal::wasm::WasmCodeManager::NewNativeModule(v8::internal::wasm::WasmEngine*, v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
10: 0x104e977e8 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, unsigned long) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
11: 0x104e66b34 v8::internal::wasm::AsyncCompileJob::CreateNativeModule(std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, unsigned long) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
12: 0x104e66cfc v8::internal::wasm::AsyncCompileJob::GetOrCreateNativeModule(std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, unsigned long) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
13: 0x104e6f360 v8::internal::wasm::AsyncCompileJob::PrepareAndStartCompile::RunInForeground(v8::internal::wasm::AsyncCompileJob*) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
14: 0x104e6f12c v8::internal::wasm::AsyncCompileJob::CompileTask::RunInternal() [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
15: 0x104836c08 node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task> >) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
16: 0x1048358a0 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
17: 0x104fecc00 uv__async_io [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
18: 0x104ffe7c0 uv__io_poll [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
19: 0x104fed090 uv_run [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
20: 0x104811f40 node::NodeMainInstance::Run() [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
21: 0x1047b27d0 node::Start(int, char**) [/Users/royyang/.nvm/versions/node/v14.16.0/bin/node]
22: 0x19f2edf34 start [/usr/lib/system/libdyld.dylib]
[1]    94568 abort      npm run build

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.