Add mobile dropdown for plugin buttons (#1762)

* Add mobile toolbar buttons

* cleanup

* more cleanup

* Mobile plugin buttons: Add else block & change icon
This commit is contained in:
Patrick Moriarty
2021-03-18 15:09:08 -05:00
committed by GitHub
parent 6edc6e2825
commit eb437ff642
5 changed files with 36 additions and 9 deletions

View File

@@ -104,9 +104,18 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
this.addButtonToToolbar = opts => {
const buttonId = "toolbar-button-" + opts.title.replace(/\s/g, "-");
const button = $('<button class="noborder">')
.addClass("btn btn-sm")
.on('click', opts.action);
let button;
if (utils.isMobile()) {
$('#plugin-buttons-placeholder').remove();
button = $('<a class="dropdown-item" href="#">')
.on('click', () => {
setTimeout(() => $pluginButtons.dropdown('hide'), 0);
});
} else {
button = $('<button class="noborder">')
.addClass("btn btn-sm");
}
button = button.on('click', opts.action);
if (opts.icon) {
button.append($("<span>").addClass("bx bx-" + opts.icon))