Home    |    GitHub Page    |    API    |    FAQ

Plugins scope, and questions

Hi,
I'm asking myself if the plugins API allow us to add a new section to the settings view, for example under the keyboard shortcut section, I'd like to add a form to enter data.
And about that data, I suppose we store them in a json file and not in the database to avoid to break it ?

Currently it's not possible to add settings to the keyboard shortcut section, so you would need to create a separate section. For saving data, I'm planning to add some API later, for example to give access to a simple key/value store, but accessing the db directly probably won't be allowed as it could cause too much troubles.

In the meantime, indeed you can simply save the data to a JSON file.

I did not plan to modify anything to the keyboard shortcuts.
I would like to know if I could add a new section, by section , one like general section, keyboard shortcuts section, plugins (beta) section etc

Yes you can add new sections using joplin.settings.registerSection

i continue my journey inside the plugins land :slight_smile:
this does not display the message in the console at all but just a lot of warning

import joplin from 'api';

joplin.plugins.register({
	onStart: async function() {
		console.info('Test plugin started!');

		await joplin.settings.registerSection('newsReader', {
				label: 'News Reader',
				iconName: 'fas fa-rss-square'
		});

		await joplin.settings.registerSetting('newsReaderNameSetting', {
			value: '',
			type: 2,
			section: 'newsReader',
			public: true,
			label: 'Name',
		});

		await joplin.settings.registerSetting('newsReaderUrlSetting', {
			value: '',
			type: 2,
			section: 'newsReader',
			public: true,
			label: 'URL',
		});
	},
});

what did I miss ?

Now I can create a form and section, I think I understand.
I had to add a registerSetting to a registerSection to be able to display a form to fill

I need to figure out how to display the entered data in a table below the form like for the talbe of the encryption section.

I take any idea about it;)

Thanks

/me go back diving into plugins

(I use Joplin pre 1.3.11)
In that piece of code, several problems:

  • console.info() or .debug does not display anything in the devtools console
  • the type: 5 is not recognize by the app, the error is ype not implemented: plugin-nyuseu-plugin-joplin.newsReaderFolderSetting
    i've check the allowed provided types
// =================================================================
// Settings types
// =================================================================

export enum SettingItemType {
	Int = 1,
	String = 2,
	Bool = 3,
	Array = 4,
	Object = 5,
	Button = 6,
}

so it's sould be ok, sould'nt it ?

here is the piece of code

import joplin from 'api';
import { ToolbarButtonLocation } from 'api/types';

const newsData = require('./data.json');

joplin.plugins.register({
	onStart: async function() {

		console.debug(newsData);
		console.info('Test plugin started!');
		console.debug(await joplin.data.get(['folders']))

		await joplin.settings.registerSection('newsReader', {
				label: 'News Reader',
				iconName: 'fas fa-rss-square'
		});

		await joplin.settings.registerSetting('newsReaderNameSetting', {
			value: '',
			type: 2,
			section: 'newsReader',
			public: true,
			label: 'Name',
		});

		await joplin.settings.registerSetting('newsReaderFolderSetting', {
			value: await joplin.data.get(['folders']),
			type: 5,
			section: 'newsReader',
			public: true,
			label: 'Folder',
		});

		await joplin.settings.registerSetting('newsReaderUrlSetting', {
			value: '',
			type: 2,
			section: 'newsReader',
			public: true,
			label: 'URL',
		});

When it starts, it should open two dev tool windows. Is there no console statement in any of them? Scroll up and down to search for them as unfortunately Electron prints a ton of useless garbage when the app starts.

Full error message with stack trace would be more useful.

when joplin starts that gives

when i move to the option menu that gives

i don't have more log :frowning:

I think the issue is that the plugin devtool dialog is there, but it's hidden by the app devtool dialog. I didn't have this problem because I always use detached dialogs. So in the next version, I will force the plugin dialog to open detached and so you should see the log then.

You can also do that now by clicking on the three dots in the top right hand corner.

By the way, plugin support is broken in latest pre-release but fixed on dev branch.

1 Like

ok I'll try