is it possible to create a tab in the preferences window via a plugin?
I would like to create a plugin where you can create snippets.
Thouse snippets could be managed in the preferences in multiple textareas (lets say snippet 1 to 10).
Then those snippets could be pasted via context menu like snippets / 1 - 10.
I haven’t found a plugin example of how to add a tab to the preferences. Perhaps you could give me a hint to the right direction.
I don’t know how to add a tab to the preferences window, but here are some ideas which may be useful.
You can detect whether your plugin is running in the preferences window by using inkdrop.windowType in your activate function like so:
export function activate() {
if (inkdrop.windowType === 'preferences') {
// Modify the page content to add a new tab?
}
}
You could also let the user configure their snippets via the plugin’s config like so (note that textareas this way are currently impossible, but for single-line snippets this works fine):
export const config = {};
for (let i = 1; i <= 5; i++) {
config[`snippet${i}`] = {
title: `Snippet ${i}`,
type: 'string',
default: '',
};
}
Or you could use my snippets plugin, which doesn’t work via the context menu but does let you type something, press Tab and have it expanded into the content of the snippet.
In addition to “\n”, because my plugin evaluates the snippet’s content as JavaScript, you can also use a configuration like this with my plugin to create a snippet containing multiple lines:
[
{
trigger: 'multiline',
content: `
Line 1
Line 2
Line 3
`.trim()
}
];
Thanks for the question.
Adding a tab to preferences is not supported at the moment.
Instead, I’d recommend you to use MessageDialog to provide UI for managing snippets if Inkdrop’s config is not sufficient.