Merge remote-tracking branch 'origin/master'

This commit is contained in:
zadam 2021-03-18 22:11:45 +01:00
commit 76aa7d1451
5 changed files with 36 additions and 9 deletions

View file

@ -34,9 +34,7 @@ class AppContext extends Component {
this.tabManager.loadTabs();
if (utils.isDesktop()) {
setTimeout(() => bundleService.executeStartupBundles(), 2000);
}
setTimeout(() => bundleService.executeStartupBundles(), 2000);
}
showWidgets() {

View file

@ -2,6 +2,7 @@ import ScriptContext from "./script_context.js";
import server from "./server.js";
import toastService from "./toast.js";
import treeCache from "./tree_cache.js";
import utils from "./utils.js";
async function getAndExecuteBundle(noteId, originEntity = null) {
const bundle = await server.get('script/bundle/' + noteId);
@ -25,7 +26,8 @@ async function executeBundle(bundle, originEntity, $container) {
}
async function executeStartupBundles() {
const scriptBundles = await server.get("script/startup");
const isMobile = utils.isMobile();
const scriptBundles = await server.get("script/startup" + (isMobile ? "?mobile=true" : ""));
for (const bundle of scriptBundles) {
await executeBundle(bundle);

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))

View file

@ -13,6 +13,11 @@ const WIDGET_TPL = `
top: 8px;
width: 100%;
}
#plugin-buttons-placeholder {
font-size: smaller;
padding: 5px;
}
</style>
<a data-trigger-command="createNoteIntoInbox" title="New note" class="icon-action bx bx-folder-plus"></a>
@ -21,6 +26,14 @@ const WIDGET_TPL = `
<a data-trigger-command="scrollToActiveNote" title="Scroll to active note" class="icon-action bx bx-crosshair"></a>
<div class="dropdown">
<a title="Plugin buttons" class="icon-action bx bx-extension dropdown-toggle" data-toggle="dropdown"></a>
<div id="plugin-buttons" class="dropdown-menu dropdown-menu-right">
<p id="plugin-buttons-placeholder">No plugin buttons loaded yet.</p>
</div>
</div>
<div class="dropdown">
<a title="Global actions" class="icon-action bx bx-cog dropdown-toggle" data-toggle="dropdown"></a>

View file

@ -53,9 +53,14 @@ function getBundlesWithLabel(label, value) {
return bundles;
}
function getStartupBundles() {
function getStartupBundles(req) {
if (!process.env.TRILIUM_SAFE_MODE) {
return getBundlesWithLabel("run", "frontendStartup");
if (req.query.mobile === "true") {
return getBundlesWithLabel("run", "mobileStartup");
}
else {
return getBundlesWithLabel("run", "frontendStartup");
}
}
else {
return [];