mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
more stable script button placement
This commit is contained in:
parent
ad123cfc1a
commit
c79fb2cc12
@ -58,8 +58,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
|
|||||||
this.addButtonToToolbar = opts => {
|
this.addButtonToToolbar = opts => {
|
||||||
const buttonId = "toolbar-button-" + opts.title.replace(/[^a-zA-Z0-9]/g, "-");
|
const buttonId = "toolbar-button-" + opts.title.replace(/[^a-zA-Z0-9]/g, "-");
|
||||||
|
|
||||||
$("#" + buttonId).remove();
|
|
||||||
|
|
||||||
const icon = $("<span>")
|
const icon = $("<span>")
|
||||||
.addClass("ui-icon ui-icon-" + opts.icon);
|
.addClass("ui-icon ui-icon-" + opts.icon);
|
||||||
|
|
||||||
@ -71,7 +69,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
|
|||||||
|
|
||||||
button.attr('id', buttonId);
|
button.attr('id', buttonId);
|
||||||
|
|
||||||
$pluginButtons.append(button);
|
if ($("#" + buttonId).replaceWith(button).length === 0) {
|
||||||
|
$pluginButtons.append(button);
|
||||||
|
}
|
||||||
|
|
||||||
if (opts.shortcut) {
|
if (opts.shortcut) {
|
||||||
$(document).bind('keydown', opts.shortcut, opts.action);
|
$(document).bind('keydown', opts.shortcut, opts.action);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user