From my plugin:
await joplin.commands.register({
name: 'CreateButton',
label: 'Creates a button.',
enabledCondition: 'markdownEditorPaneVisible && !richTextEditorVisible',
iconName: 'fas fa-code',
execute: async () => {
let selectedText = (await joplin.commands.execute('selectedText') as string) || "Button Text";
const insert = isStringEmptyOrNull(selectedText);
const result = await dialogs.open(handle);
if (result.id === "cancel") {
await joplin.commands.execute('editor.focus');
return;
}
const res = result.formData.fm_button_form;
const hasLink = !isStringEmptyOrNull(res.button_link);
const openingMarkup = `<span class="fm-enhanced-link ${res.button_color} ${res.button_size} ${res.button_font} ${res.button_arrow}">`;
const finalElement = hasLink
? `${openingMarkup}[${selectedText}](${res.button_link})</span>`
: `${openingMarkup}${selectedText}</span>`;
await joplin.commands.execute(insert ? "insertText" : "replaceSelection", finalElement);
await joplin.commands.execute('editor.focus');
},
});
await joplin.views.toolbarButtons.create(
'CreateHTMLButton',
'CreateButton',
ToolbarButtonLocation.EditorToolbar,
);
The await joplin.views.toolbarButtons.create
function adds the button to both the RTE and MD Editor. I only want it visible in the MD editor. How can I do this? Is it possible?
Thanks for any help!