obsidian-sample-plugin's People
Forkers
victorgrycuk arnoesterhuizen bennyxguo 1stprinciples graydon lukaborec akaalias skalnik yo-goto cristianvasquez gaaon ma7dev selfdeceited magicianred jared-chang aadilzbhatti tohsig spock74 wotwot563 chrisdmacrae trydalch sudhanshubhagwat tenundor clemens-e kostapc taurelas dbsheta yauhen-info manualbashing hlipnick rlam3 arminta7 mathisto lumoslovegood vortigan rami-ismael tokuhirom unboundhuman cirvoe jsonmartin shinymimiq sbrichardson jkjoker aidenlx ingshtrom lmonson musistudio funsun ikuyarihs dhanesh sometxdude jborichevskiy porterdarby kabumos kzhovn kellielutze-wm alleshka thuan1412 ricalamino bekmeh mfrank2016 creling kreonda arnarg garrett-wyatt suranyami lockcp slidenergy g-s-paris calpa gollyticker mikeerickson afriedel uday-samsani silvenlily settingdust hhenrichsen davidvdev famousherself fyears moses-noghbaudie ichiranakita madl1me 4lch4 softwarehistorysociety tfthacker rankiejiang gesubackups jimbrig murrayjack antvopilov cogscides frankhaotic elmarsto kcharecki platers abhijithnraj lostbirdx chenyukang kevsturmanobsidian-sample-plugin's Issues
Add `request` example to plugin
The request
module isn't imported/used in the sample plugin and is referenced here.
An example request
could look like:
import { request } from 'obsidian';
await request({
url: '/some-endpoint',
method: 'POST',
contentType: 'application/json',
body: JSON.stringify({
mySetting: this.settings.mySetting,
})
})
[BUG] Failed to compile on Linux Pop!_OS 22.04 LTS
Expected behaviour
The code compiles and runs
What Actually happened
The code didn't run and I got this error
> [email protected] build
> tsc -noEmit -skipLibCheck && node esbuild.config.mjs production
file:///home/fffluoride/Desktop/TEST/.obsidian/plugins/obsidian-sample-plugin/esbuild.config.mjs:14
const context = await esbuild.context({
^^^^^
SyntaxError: Unexpected reserved word
at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
at async link (internal/modules/esm/module_job.js:42:21)
Steps to reproduce
- Installed node, and npm from my package manager
- Clone the repository and run the commands in the obsidian docs - https://docs.obsidian.md/Plugins/Getting+started/Build+a+plugin#Step+1+Download+the+sample+plugin
- Build the plugin - https://docs.obsidian.md/Plugins/Getting+started/Build+a+plugin#Step+2+Build+the+plugin
- It didn't work :(
Can't build plugin with npm run dev
hi, i clone the repo and install all dependencies
and give me this error when i run npm run dev
:
> [email protected] dev
> node esbuild.config.mjs
file:///home/alex/Objectives/LifeVault/.obsidian/plugins/Life_app_Obsidina_pluging/esbuild.config.mjs:14
const context = await esbuild.context({
^^^^^
SyntaxError: Unexpected reserved word
at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
at async link (internal/modules/esm/module_job.js:42:21)
I don't understand, it seems like an error in the esbuild library, although I really have no idea, I'm quite an amateur
[BUG] TypeScript Compile fails in Sample Plugin with TypeScript `5.1.6`
Expected Behaviour:
npx tsc
works without error when using Typescript 5.1.6
Actual Behaviour:
The command fails with the following message
node_modules/@types/codemirror/index.d.ts:651:39 - error TS2304: Cannot find name 'DocumentAndElementEventHandlersEventMap'.
651 on<K extends DOMEvent & keyof DocumentAndElementEventHandlersEventMap>(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/codemirror/index.d.ts:653:59 - error TS2304: Cannot find name 'DocumentAndElementEventHandlersEventMap'.
653 handler: (instance: CodeMirror.Editor, event: DocumentAndElementEventHandlersEventMap[K]) => void,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/codemirror/index.d.ts:655:40 - error TS2304: Cannot find name 'DocumentAndElementEventHandlersEventMap'.
655 off<K extends DOMEvent & keyof DocumentAndElementEventHandlersEventMap>(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/codemirror/index.d.ts:657:59 - error TS2304: Cannot find name 'DocumentAndElementEventHandlersEventMap'.
657 handler: (instance: CodeMirror.Editor, event: DocumentAndElementEventHandlersEventMap[K]) => void,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 4 errors in the same file, starting at: node_modules/@types/codemirror/index.d.ts:651
The error seems to stem from Obsidian listing @types/codemirror
0.0.108
as a dependency, which is over two years old according to NPM.
https://www.npmjs.com/package/@types/codemirror/v/0.0.108?activeTab=readme
Steps to reproduce:
- clone the sample plugin
- change the version of typescript in the package.json to
^5.0.0
- run
npm i
- run
npx tsc
to invoke the TypeScript transpiler - the error occurs
remove default CSS rule in boilerplate?
hi there,
Would you accept a PR that eliminates the body
rule in styles.css
? I wasn't aware it was in there, and I hosed a lot of people's themes when they installed my plugin :-)
Let me know and I'd be happy to PR it.
ENOSPC: no space left on device, write
Would including a predefined `launch.json` file for VS Code in the sample be a good idea?
My problem is that occasionally I need to run a test script that's just a function, and I want to use the debugger for that. But I have trouble with configuring debugger with Node with TS. Do you think adding a predefined launch.json
file for VS Code be a good idea? You can add other config files for other editors as well.
es2020 as target/libs in tsconfig.json?
Hi. I wanted to use Promise.allSettled
in my plugin, but Typescript said:
Property 'allSettled' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later.ts(2550)
Are there any obstacles preventing Obsidian plugins to switch to es2020 from es2015? I think Electron apps like Obsidian use modern Chromium under the hood which should support es2020. Simple test in Obsidian dev console shows me that Obsidian knows about this method:
Add additional Functionality to the Plugin
Hello, your plugin is amazing! I love it. I wanted to create a few features that will extend the functionality of it such as: being able to drag and drop, a "zoom in" feature if you have tasks schedule for a time, and a increasing the size of the default displayed timeline/events. I'm thinking the best way for me to do it is to pull your plugin and add to it. I just wanted to ask your permission to use heavily use your plugin. I'll be sure to give credit to you and your plugin in anything I end up publishing.
(I'm quite a way away from understanding enough to develop a plugin that's worth publishing though.)
esbuild.config.mjs sourcecode
I was reading the code, when I saw the banner of that file, where can I find the source code of the config?
Where does console.log() log to?
This is probably a really dumb question, but I cannot find where it logs to.
Display download successful, but not in the local file library
Config Dir sync no longer working (Reported .DS_Store issue)
I've been syncing the config directory for a long time now, but have run into an issue today.
I get this message:
plugin:remotely-save:216 remotely-save-1701649036181: abort sync, triggerSource=manual, error while syncing
eval @ plugin:remotely-save:216
plugin:remotely-save:216 AggregateError:
Error: .obsidian/themes/.DS_Store: Response failed with a 409 code
at eval (plugin:remotely-save:211:314339)
Error: .obsidian/plugins/.DS_Store: Response failed with a 409 code
at eval (plugin:remotely-save:211:314339)
Error: .obsidian/.DS_Store: Response failed with a 409 code
at eval (plugin:remotely-save:211:314339)
Error: too many errors, stop the remaining tasks
at eval (plugin:remotely-save:211:314443)
at Generator.next (<anonymous>)
at a (plugin:remotely-save:177:280327)
at eval (plugin:remotely-save:211:314499)
at Generator.next (<anonymous>)
My setup
MacOS Sonoma 14.1.1 (Macbook Pro M1)
Obsidian 1.4.16 (Installer 1.4.14)
Remotely Save 0.3.25
Syncing to dropbox
What I've done to try and fix
- I've turned on hidden files and looked in .obsidian/ and .obsidian/themes and .obsidian/plugins. No .DS_Store files exist there.
- I've checked dropbox and found that none of those files exist there either.
- I did a bunch of tests were I delete files in remotely-save/vault-name on dropbox, uninstalled plugins, and resynced. Same issue.
Most revealing test
- I then created a completely new vault.
- I then installed Remotely Save through Obsidian.
- I was able to sync the empty vault successfully to dropbox multiple times.
- I then enabled Config Directory syncing.
- I was able to sync the vault successfully multiple times.
- I then added an empty folder inside the plugin directory to simulate another plugin existing.
- I then was not able to sync - experiencing the error shown above
(Note that the .DS_Store files reported were still in the same location - ie. not listed as inside the folder I created)
Custom View Explorer
License
this sample plugin doesn't have a license. When being strict, I'm not allowed to use this code in my plugin, as you have the copyright and don't allow me to use it.
Please add a license to this repository.
npm install not working?
hi there, i tried a million ways but nodeJS does not seem to complete the installation for some reason. any idea what it could be?
i follow clearly your steps.
thanks sebastian
Cannot find package 'esbuild' imported from C:\pictoys\DATA\obsidian\testvault.obsidian\plugins\obsidian-sample-plugin\esbuild.config.mjs
the version in `manifest.json` is 1.0.1 but there is no corresponding release
Although it should not affect any real-life usages, maybe it's better to create a 1.0.1 release here?
Feature request - Be able to pull Tasks from 2 or more folder
Hi,
first of all, great job and great Idea to create a plugin like this.
A way to select 2 folders instead just one or all would be nice.
Maybe it will possible in the future to select different folders. Who knows? :-D
Thank you.
can't use `child_process` or `fs` module?
I'm building a new plugin that needs to access the filesystem and spawn child processes. But npm run dev
throws an error when I import and use either of these modules.
How to replicate:
- clone this repo
- add
import { spawn } from 'child_process';
tomain.ts
(note, that this alone does not cause the issue) - add
spawn("something")
toonload()
npm run dev
The error I get is main.ts:2:29: error: Could not resolve "child_process" (use "platform: 'node'" when building for node)
Is this related to #11 and the switch to ESBuild instead of Rollup? <-- I don't understand any of this, but I do notice that all the other plugins that use child_process
and fs
refer to rollup
in package.json
instead of esbuild
.
My mistake
Sorry, this issue was done by mistake. You can delete it
Stuck build, many plugins affected. Any reason to gitignore package-lock.json?
The package-lock.json
is not included to git repo by intention.
What is the reason? If you want stable build, you usually want to check in such lock-files to VCS.
Today I faced the problem with my Imgur plugin based on this template. My build has stuck. That's exactly because package-lock.json
is not committed. The package.json
is not enough, because it does not pin exact version of dependencies. With the ^
-notation (example: "typescript": "^4.2.4"
) it allows actual minor and patch versions to be higher on npm install
if newer version of the dependency is available on npm registry (see npm docs).
The build of this plugin's template is currently broken too. It will stuck forever in the very end after:
...
main.ts → ....
created . in 1.4s
# stuck here
Other plugins generated from this template and not having lock-file in git are affected too, i.e.:
- sliding-panes-obsidian
- obsidian-mind-map
- obsidian-day-planner
- and any others without lock-file committed
I do not know the root cause of the problem. But from my experiments, the culprit of the stuck build with this Rollup setup is TypeScript 4.4.1+ which gets installed now on npm install
without package-lock.json
.
I think that the lock-file should not be ignored and must be committed to git.
Also another common mistake I see people make is: using npm install
instead of npm ci
on their automated builds. npm install
leaves a possibility for lock-file to be updated on clean install if the situation on npm registry has changed. I think the right choice for CI should be the npm ci
command with lock-file tracked by vcs to get stable reproducible builds.
Feature request - TSDoc integration
As someone who was the direct target audience for this plugin (i.e. some programming sans TypeScript/JavaScript experience and someone who just needed additional functionality not found in existing plugins) and who has had to look through the source code of other poorly (or un) documented plugins to figure out what I needed, I think it would be immensely helpful to encourage plugin developers to use TSDoc by implementing the boilerplate code right here in the official template plugin.
Obsidian App doesn't seem to load custom plugin
When I follow the directions, Obsidian does not show the plugin as loaded. I have confirmed the repository is in the correct place, the packages are correctly installed, and npm run dev
completes successfully.
I was reading the source code and noticed that one of the loading functions is sensitive to the "author" field in the manifest, so I went ahead and changed things around to match what I'm trying to do (support definition lists)
Here is my directory structure:
~/.obsidian/plugins/obsidian-definition-lists-plugin
I am on a MacBook Pro:
![Screenshot 2024-06-14 at 11 02 23 AM](https://private-user-images.githubusercontent.com/3092695/339831658-cc58002b-f04f-423e-bea5-37e753c23257.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNDc1MTQsIm5iZiI6MTcyNTE0NzIxNCwicGF0aCI6Ii8zMDkyNjk1LzMzOTgzMTY1OC1jYzU4MDAyYi1mMDRmLTQyM2UtYmVhNS0zN2U3NTNjMjMyNTcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgzMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MzFUMjMzMzM0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzA2ZDQ1YjMxZmMyZWFkMzY1MmYxNGMwZjdkMWU1NWFmMzM5MzM5OWFjMTZhNGJkZThlMzNkMGRkYWRjMGVkMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.e2973qdyv8_M36MW4H6jQ2UGN1BPCAM0dAMp8cEYzh0)
What I see:
![image](https://private-user-images.githubusercontent.com/3092695/339830204-0d9e6a54-ce52-4d10-8cb6-5ea30d710640.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNDc1MTQsIm5iZiI6MTcyNTE0NzIxNCwicGF0aCI6Ii8zMDkyNjk1LzMzOTgzMDIwNC0wZDllNmE1NC1jZTUyLTRkMTAtOGNiNi01ZWEzMGQ3MTA2NDAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgzMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MzFUMjMzMzM0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGNmODZhZjA2YThhNGJjMDBjZWFmMTUyYTAzMTQ0ODZjNmQ1ZjlmOGMzMGNjMjkyNTllNWRiMDFiMDBjNGI0NSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.K26wrHQKoplt2_s_8YvIez7HGstFmr9vzCCgLxpXj-w)
I expected to see the plugin listed here, as per the directions in the README.
What I've tried:
- Modifying the manifest
- A separate vault
- Moving main.js into the /plugins/ directory itself (didn't work, moved it back)
- Wiping it out and starting over
- With each attempt:
- Reloading Obsidian through command
- Fully closing Obsidian, making sure the process is halted, and re-starting.
Switch to esbuild 17
The provided file esbuild.config.mjs
is compatible / works well with esbuild<=16.*
but not with >=17.*
.
Would it be possible to update it using the new API? Sorry I have been unable to fix the file and create a PR myself, for I'm a total noob!
[feature request] multiple cursor positions (each linked to a different tab) for same file
Specs
OS: iPadOS 17.1.2
Obsidian version: 1.4.16 (114)
What happened
I'd previously opened the same file in 2 different tabs: after vault reload, 1 tab returned back to its cursor position, the other to the start
What I did
I checked the json file to see what info had been saved, this was it:
UW PICO 5.09 File: cursor-positions.json {"Moo.md":{"scroll":4.435,"cursor":{"from":{"ch":17,"line":0},"to":{"ch":17,"line":0}}}}
Looks like it had only been saving the last tab I edited in's cursor position, not both of them
Suggestion
it would be awesome if multiple cursor positions could be attributed to each file: that way, when opening multiple tabs of the same file, the plugin could 'distribute' the different cursor positions to multiple tabs of same file as these are opened.
PS
Don't know if this feature in particular works on other platforms, especially the desktop OSes, but just wanted to point out it certainly doesn't on iPadOS with my configuration (specified in 'Specs' heading).
Installed it manually. does not work.
wrong repo
obsidian fails to load sample plugin
quite honestly this issue might not be that justified since i have not tried everything at my disposal, but i have not encountered any similar issues with the sample pluging only with other third party plugins where fixes like version incompatibily didn't seem to help so i figured this is the quickes way to resolve this issue.
When i followed the tutorial, the sample plugin appearad, i tried to turn it on and i got a "failed to load plugin error" then when i tried to import the file manually i got the following error:
any and all advice is wellcome.
Thank you..
Spaces, not tabs
Very questionable choice to default to tabs in .editorconfig
. Take a look all over Github; you almost never see tabs (no arrows when looking at source code on github.com).
Now, lots of Obsidian plugins have tabs which just serves to annoy everyone who wants to contribute PRs.
Problems with basic process
Hello! I'm brand new and haven't typed a lick of NPM or TypeScript proper, when I followed these instructions, npm run dev
didn't appear to have the intended effects -- it took me to some sort of watch-type screen that hung for a few minutes without doing anything on Windows with:
npm 6.9.0
On intuition I punched in npm run build
and received the promised main.js
which worked when loaded into Obsidian.
This process differs from the process listed in README.md.
Obsidian
`version-bump.mjs` could use async file ops for speed up
version-bump.mjs
could be faster if async file operations and Promise.all()
are used.
Right now it waits for manifest.json
to be written before reading and writing versions.js
. But the latter only needs manifest.json
to be read.
However, I worry that this might make it harder for less experienced developers to use this template.
Organise typescript sources into separate src hierarchy
The plugin checklist recommends that plugin developers "Consider organizing your code base using folders":
If your plugin uses more than one .ts file, consider organizing them into folders to make it easier to review and maintain.
It would be helpful if the sample plugin did this so that there was an example to follow.
adding a toggle button
Thanks for putting this plugin together. It would be great to also have a "button" somewhere in the interface that would allow one do quickly toggle the vim mode on/off with a mouse (as opposed to just a keyboard shortcut).
thanks!
Obsidian Plug-in Sample
Options - Where is the button?
npm i -> `npm WARN tarball tarball data for obsidian seems to be corrupted`
Any idea what I can do to fix this? Mine is a clean clone from my repository - I have no package-lock.json in this directory.
My package.json
{
"name": "extract-highlights-plugin",
"version": "0.0.1",
"description": "his is a shortcut-based plugin extracts all ==highlights== in a note into your clipboard",
"main": "ExtractHighlightsPlugin.js",
"type": "module",
"scripts": {
"dev": "rollup --config rollup.config.js -w",
"build": "rollup --config rollup.config.js",
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register test/**/*.ts",
"test:watch": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register --watch --watch-files src, test/**/*.ts"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^6.0.0",
"@types/chai": "^4.2.14",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.14",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"ignore-styles": "^5.0.1",
"jsdom": "^16.4.0",
"jsdom-global": "^3.0.2",
"mocha": "^8.2.1",
"obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master",
"rollup": "^2.35.1",
"ts-node": "^9.1.1",
"tslib": "^1.14.1",
"typescript": "^4.1.3"
},
"dependencies": {
"electron": "^10.2.0"
}
}
What I get when running npm install
extract-highlights-plugin git:(master) npm install
npm WARN tarball tarball data for obsidian@https://github.com/obsidianmd/obsidian-api/tarball/master (sha512-AqIFKumTQk1zHCoBHVajfAIV0RYX/mw1I9KODkimBguCvPSmvYLsossh/WT7aOD0e0wqObkgZ7y1Yv3s3ZMNEw==) seems to be corrupted. Trying again.
Fails on iPhone
When installing the sample plugin on iPhone I receive the error
"Plugin failure: obsidian-sample-plugin"
Object {2}
@capacitor://localhost/app.js:1:120182
a@capacitor://localhost/app.js:119073
promiseReactionJob@[native code]
I receive a similar error for my plugin Obsidian Image Caption which is why I wanted to try with the basic sample plugin.
I'm running an iPhone 7 with software version 15.1, and Obsidian version 1.0.5.
Rename default branch `master` to `main`
Since GitHub renamed its default branch name to main
, the default branch of this repository could also be main
, since all newly created projects have the default name main
but any project created from this template is still master
- which can be confusing for people new to this.
Version number for tags and releases
Following the instructions in the README, if we run
yarn version [major | minor | patch
Yarn will do a number of things, including create a git tag with the next version, but that tag will be of the form V# (e.g., v1.0.0)
But README also states to not include prefix 'v' in the tag version.
Instead I propose that the commands instructions should be
# make sure to rebuild main.js
yarn build
# make sure to update minAppVersion (min Obsidian version) in manifest.json to whatever is required
# bumps package.json, versions.json, manifest.json (note that yarn has an internal version scrip that runs before the version script in package.json)
yarn version --new-version [major | minor | patch] --no-git-tag-version
git tag <version_num, no V!>
git push origin <version_num>
# use gh cli, or go to github to create a release
gh release create <version_num> manifest.json main.js <any other files> --title "Version <version_num>" --notes "<Version Note>"
Minify production build
It seems the default esbuild configuration doesn't minify the production build.
The difference for my plugin in main.js
was 4.02MB
to 1.35MB
.
The keyword 'interface' is reserved (Note that you need plugins to import files that are not JavaScript)
Getting this error. It seems to crop up on some other repos, but I'm not sure what's causing it yet. Reporting and will investigate myself a little later today.
Steps to reproduce:
- Fork repo using template
- Clone repo into .obsidian/plugins directory
- Run
npm i
- Run
npm run dev
Expected
5. It compiles into a dev environment
Actual
5. It errors (copied below)
Thanks for the amazing product, looking forward to developing some plugins for it!
rollup v2.51.1
bundles main.ts → ...
[!] Error: The keyword 'interface' is reserved (Note that you need plugins to import files that are not JavaScript)
\\jouly\home\Obsidian\home\.obsidian\plugins\node-red-obsidian\main.ts (3:0)
1: import { App, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
2:
3: interface NodeREDPluginSettings {
^
4: nodeRedUrl: string;
5: }
Error: The keyword 'interface' is reserved (Note that you need plugins to import files that are not JavaScript)
at error (U:\Obsidian\home\.obsidian\plugins\node-red-obsidian\node_modules\rollup\dist\shared\rollup.js:7917:30)
at Module.error (U:\Obsidian\home\.obsidian\plugins\node-red-obsidian\node_modules\rollup\dist\shared\rollup.js:9859:16)
at Module.tryParse (U:\Obsidian\home\.obsidian\plugins\node-red-obsidian\node_modules\rollup\dist\shared\rollup.js:10258:25)
at Module.setSource (U:\Obsidian\home\.obsidian\plugins\node-red-obsidian\node_modules\rollup\dist\shared\rollup.js:10161:24)
at ModuleLoader.addModuleSource (U:\Obsidian\home\.obsidian\plugins\node-red-obsidian\node_modules\rollup\dist\shared\rollup.js:19466:20)
at async ModuleLoader.fetchModule (U:\Obsidian\home\.obsidian\plugins\node-red-obsidian\node_modules\rollup\dist\shared\rollup.js:19522:9)
at async Promise.all (index 0)
[2021-06-10 09:37:59] waiting for changes...
Suggestions for enhancements to the plugin template
I think that the template could use a few improvements;
The suggestions suggested here are all something that I have WIP in a plugin I'm working on. The UI work is in a very early stage, and so maybe the solutions will change. At any rate my WIP is in this branch: https://github.com/stroiman/obsidian-frontmatter-smith/tree/config-ui
All of these are changes that I intend to include in my own fork of the template. So far the fork was focused on adding support for TDD; adding mocha, as well as tsx (typescript execute) to support using ESM in watch mode.
My previous plugins didn't have any significant UI complexity, but my current WIP requires more complexity; which exposed some problems that need to be solved in order to achieve an efficient development workflow.
The issues, and my solutions to the problems are describe below.
Question is; are these things you agree with could make their way into the plugin template?
If that is the case, I'd be glad to engage in a discussion about what form, and to which extend that should be included, and make a PR - separating my personal preferences from what we can agree on as a common ground.
CSS name conflict handling
It appears that plugin CSS style sheets are loaded into global scope. This can easily lead to naming conflicts where two plugin uses the same css class names; and therefore affect the layout of each other. Experienced we developers are aware of this; but many plugin developers have little web development experience.
CSS modules could be a solution to that, and I've set that up in my own project to use css modules in such a way that class names are automatically prefixed with the plugin id (read from manifest.json
so you don't need to update esbuild configuration).
If this was included as part of the template, and encouraged as a recommended strategy; the problem of class name conflicts should be solved.
My project has a bit of complication because esbuild generates a main.css
- but obsidian requires it to be called styles.css
, so now the css build output is registered as a new entry point, generating two css files instead of one.
If Obsidian could recognise "main.css" as an alternative to "styles.css", that would make the build process simpler (But that's a feature request for Obsidian itself; not the plugin template)
Using vite and a browser for fast visual feedback for UI code
A very important aspect of development efficiency is the feedback cycle. And having to reload the plugin Obsidian (even though that can be automated) to see the effects is less than ideal. In my case; the UI complexity is in the configuration of the plugin; which requires me to open the settings.
Being able to see the effect of my changes without leaving the editor is crucial for me working effectively with code.
For that purpose, I have setup vite to act as a dev server; allowing me to work on UI code and immediately see the visual effects of any changes; Any change to either a .js or .css file will immediately be reflected in the browser.
I was able to do that because the UI code is written in such a way that it is decoupled from the plugin API; it only depends on my internal model.
This required me to duplicate the CSS module configuration. Vite is build on top of esbuild - so perhaps it's possible to have some shared configuration; or possibly use vite to build, instead of esbuild.
This right now also include Obsidian's own stylesheet (which I think is what is in "app.css"?), to make CSS variables, and native styling available in the dev server.
TDD support
This becomes a little more opinionated; as different developers prefer different tools.
But to me, TDD is a very important for efficiency, as it's not about tests; but about fast feedback just for small pieces of code (my previous plugin actually worked the first time I actually loaded it in Obsidian)
That is why I have setup mocha; as it provides the fastest feedback cycle of all the tools I've so far tested. Jest; which has gained a lot of popularity is actually slow compared to mocha.
So far, I have only written tests for the logical parts; as I am just getting started on UI work. But I will probably also write tests for UI behaviour; in which case I need to add '@testing-library/dom' as well as a javascript DOM implementation like jsdom or happy-dom.
Seeking example: plugin that extends the markdown syntax
I'd like to extend the HyperMD / markdown parser, by matching patterns and adding css classnames if certain lines match a regex.
Is there an example that does this?
I can see how to style existing css classnames, but not how to add new classnames to the generated editor markup.
Thanks!
Configuration using `.obsidian` or JSON file
Hello team!
I am a huge nix user and manage my environments there. One thing that would be super neat is if this obsidian plugin could support reading the configuration details for the interpreter paths for languages from a json file. I dug around a little bit and haven't developed an extension for obsidian yet, but was wondering if this was something the maintainers would be open to discuss. More than happy to contribute this once I get a better understanding on extension development, but unsure if this is possible just yet :)
Enhance sample plugin with Jest Unit Test
In order to be able to guard custom obsidian plugins with unit tests, it'd be great if the sample plugin would already contain an initial Jest Unit Test and the package.json configured to execute it.
Feature request — expanding the sample plugin with more examples/features
Speaking from personal experience, and a very skimpy coding background, getting started with Obsidian plugins is very hard.
There are very few guides and examples to find, and the documentation is sparse. Looking through the code of existing plugins on GitHub is a good option, but it's hard to know which have the functionality you're looking to replicate, and many are so expansive that isolating one feature can be daunting for a newcomer.
I would like to suggest expanding this sample plugin with more examples/features/functionality.
Some suggestions could be:
- how to create a leaf for a plugin in the right sidebar
- how to perform a search of a given word/words in a document
- how to output HTML for leaf content layouts
- some examples of how scoping works
I realise that my low skill level means that I need more help than most, but I'm sure that others would find it useful to have this plugin fleshed out a bit as well. Hopefully, someone with more skill than I will be able to look into some of these suggestions 😃
Thanks for an awesome piece of software!
Cheers.
Error building sample plugin to confirm installation after upgrading to non-deprecated node.js modules
Ran 'git clone https://github.com/obsidianmd/obsidian-sample-plugin.git'
Ran 'npm install --save-dev' and received a deprecation error for server packages.
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
I ran 'npm run dev' and every worked fine. If I upgrade the deprecated modules I receive the following:
I'm building another obsidian.md plugin usnig typescript. Attached is my 'main.ts' file. When I type 'npm run build' I receive the following errors:
src/main.ts:14:2 - error TS2564: Property 'settings' has no initializer and is not definitely assigned in the constructor.
14 settings: MyPluginSettings;
~~~~~~~~
src/main.ts:43:4 - error TS2322: Type '(editor: Editor, view: MarkdownView) => void' is not assignable to type '(editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any'.
Types of parameters 'view' and 'ctx' are incompatible.
Type 'MarkdownView | MarkdownFileInfo' is not assignable to type 'MarkdownView'.
Type 'MarkdownFileInfo' is missing the following properties from type 'MarkdownView': previewMode, currentMode, getViewType, getMode, and 39 more.
43 editorCallback: (editor: Editor, view: MarkdownView) => {
~~~~~~~~~~~~~~
node_modules/obsidian/obsidian.d.ts:726:5
726 editorCallback?: (editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any;
~~~~~~~~~~~~~~
The expected type comes from property 'editorCallback' which is declared here on type 'Command'
Found 2 errors in the same file, starting at: src/main.ts:14
This fix resolves the issue.
Explanation:
- Property 'settings' has no initializer and is not definitely assigned in the constructor:
This error occurs because TypeScript expects the settings property to be initialized in the constructor or declared with a definite assignment assertion. To fix this, you can initialize settings with a default value or mark it with a definite assignment assertion (!).
- Type '(editor: Editor, view: MarkdownView) => void' is not assignable to type '(editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any':
This error occurs because the type signature for editorCallback in your Command expects the second parameter to be either a MarkdownView or MarkdownFileInfo. However, your callback currently only handles MarkdownView. You'll need to update the type signature to accommodate both types or ensure the correct type handling.
Failed to run `npm run dev`
I'm using npm 8.5.1 and node 12.22.9, directly run the command will get following error:
$ npm run dev
> [email protected] dev
> node esbuild.config.mjs
file:///mnt/f/obsidian/Phantom/.obsidian/plugins/obsidian-better-slides/esbuild.config.mjs:46
await context.rebuild();
^^^^^
SyntaxError: Unexpected reserved word
at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
at async link (internal/modules/esm/module_job.js:42:21)
This is my first time developing a plugin, I wonder if there is something wrong with my environment.
What updates are needed to reflect the change to codemirror CM 6?
The Obsidian forum has this guide for plugin developers on the CM 6 / codemirror v6.0 upgrade in the obsidian API. What changes need to be made to this sample plugin to follow the guide? For example, I think the list in the esbuild
config needs updating, but are other changes necessary? Thanks in advance for any and all answers or links to further reading!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.