mirror of
https://github.com/zadam/trilium.git
synced 2025-11-15 09:45:52 +01:00
chore(prettier): fix all files
This commit is contained in:
@@ -16,7 +16,6 @@ export interface AbstractButtonWidgetSettings {
|
||||
}
|
||||
|
||||
export default class AbstractButtonWidget<SettingsT extends AbstractButtonWidgetSettings> extends NoteContextAwareWidget {
|
||||
|
||||
protected settings!: SettingsT;
|
||||
protected tooltip!: bootstrap.Tooltip;
|
||||
|
||||
@@ -31,13 +30,13 @@ export default class AbstractButtonWidget<SettingsT extends AbstractButtonWidget
|
||||
this.tooltip = new bootstrap.Tooltip(this.$widget, {
|
||||
html: true,
|
||||
title: () => this.getTitle(),
|
||||
trigger: 'hover',
|
||||
trigger: "hover",
|
||||
placement: this.settings.titlePlacement,
|
||||
fallbackPlacements: [ this.settings.titlePlacement ]
|
||||
})
|
||||
fallbackPlacements: [this.settings.titlePlacement]
|
||||
});
|
||||
|
||||
if (this.settings.onContextMenu) {
|
||||
this.$widget.on("contextmenu", e => {
|
||||
this.$widget.on("contextmenu", (e) => {
|
||||
this.tooltip.hide();
|
||||
|
||||
if (this.settings.onContextMenu) {
|
||||
@@ -52,9 +51,7 @@ export default class AbstractButtonWidget<SettingsT extends AbstractButtonWidget
|
||||
}
|
||||
|
||||
getTitle() {
|
||||
return typeof this.settings.title === "function"
|
||||
? this.settings.title()
|
||||
: this.settings.title;
|
||||
return typeof this.settings.title === "function" ? this.settings.title() : this.settings.title;
|
||||
}
|
||||
|
||||
refreshIcon() {
|
||||
@@ -64,9 +61,7 @@ export default class AbstractButtonWidget<SettingsT extends AbstractButtonWidget
|
||||
}
|
||||
}
|
||||
|
||||
const icon = typeof this.settings.icon === "function"
|
||||
? this.settings.icon()
|
||||
: this.settings.icon;
|
||||
const icon = typeof this.settings.icon === "function" ? this.settings.icon() : this.settings.icon;
|
||||
|
||||
if (icon) {
|
||||
this.$widget.addClass(icon);
|
||||
|
||||
@@ -41,36 +41,36 @@ const TPL = `
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
|
||||
<li data-trigger-command="openAttachment" class="dropdown-item"
|
||||
title="${t('attachments_actions.open_externally_title')}"><span class="bx bx-file-find"></span> ${t('attachments_actions.open_externally')}</li>
|
||||
title="${t("attachments_actions.open_externally_title")}"><span class="bx bx-file-find"></span> ${t("attachments_actions.open_externally")}</li>
|
||||
|
||||
<li data-trigger-command="openAttachmentCustom" class="dropdown-item"
|
||||
title="${t('attachments_actions.open_custom_title')}"><span class="bx bx-customize"></span> ${t('attachments_actions.open_custom')}</li>
|
||||
title="${t("attachments_actions.open_custom_title")}"><span class="bx bx-customize"></span> ${t("attachments_actions.open_custom")}</li>
|
||||
|
||||
<li data-trigger-command="downloadAttachment" class="dropdown-item">
|
||||
<span class="bx bx-download"></span> ${t('attachments_actions.download')}</li>
|
||||
<span class="bx bx-download"></span> ${t("attachments_actions.download")}</li>
|
||||
|
||||
<li data-trigger-command="copyAttachmentLinkToClipboard" class="dropdown-item"><span class="bx bx-link">
|
||||
</span> ${t('attachments_actions.copy_link_to_clipboard')}</li>
|
||||
</span> ${t("attachments_actions.copy_link_to_clipboard")}</li>
|
||||
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
|
||||
<li data-trigger-command="uploadNewAttachmentRevision" class="dropdown-item"><span class="bx bx-upload">
|
||||
</span> ${t('attachments_actions.upload_new_revision')}</li>
|
||||
</span> ${t("attachments_actions.upload_new_revision")}</li>
|
||||
|
||||
<li data-trigger-command="renameAttachment" class="dropdown-item">
|
||||
<span class="bx bx-rename"></span> ${t('attachments_actions.rename_attachment')}</li>
|
||||
<span class="bx bx-rename"></span> ${t("attachments_actions.rename_attachment")}</li>
|
||||
|
||||
<li data-trigger-command="deleteAttachment" class="dropdown-item">
|
||||
<span class="bx bx-trash destructive-action-icon"></span> ${t('attachments_actions.delete_attachment')}</li>
|
||||
<span class="bx bx-trash destructive-action-icon"></span> ${t("attachments_actions.delete_attachment")}</li>
|
||||
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
|
||||
<li data-trigger-command="convertAttachmentIntoNote" class="dropdown-item"><span class="bx bx-note">
|
||||
</span> ${t('attachments_actions.convert_attachment_into_note')}</li>
|
||||
</span> ${t("attachments_actions.convert_attachment_into_note")}</li>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -92,46 +92,34 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.dropdown = bootstrap.Dropdown.getOrCreateInstance(this.$widget.find("[data-bs-toggle='dropdown']"));
|
||||
this.$widget.on('click', '.dropdown-item', () => this.dropdown.toggle());
|
||||
this.$widget.on("click", ".dropdown-item", () => this.dropdown.toggle());
|
||||
|
||||
this.$uploadNewRevisionInput = this.$widget.find(".attachment-upload-new-revision-input");
|
||||
this.$uploadNewRevisionInput.on('change', async () => {
|
||||
this.$uploadNewRevisionInput.on("change", async () => {
|
||||
const fileToUpload = this.$uploadNewRevisionInput[0].files[0]; // copy to allow reset below
|
||||
this.$uploadNewRevisionInput.val('');
|
||||
this.$uploadNewRevisionInput.val("");
|
||||
|
||||
const result = await server.upload(`attachments/${this.attachmentId}/file`, fileToUpload);
|
||||
|
||||
if (result.uploaded) {
|
||||
toastService.showMessage(t('attachments_actions.upload_success'));
|
||||
toastService.showMessage(t("attachments_actions.upload_success"));
|
||||
} else {
|
||||
toastService.showError(t('attachments_actions.upload_failed'));
|
||||
toastService.showError(t("attachments_actions.upload_failed"));
|
||||
}
|
||||
});
|
||||
|
||||
const isElectron = utils.isElectron();
|
||||
if (!this.isFullDetail) {
|
||||
const $openAttachmentButton = this.$widget.find("[data-trigger-command='openAttachment']");
|
||||
$openAttachmentButton
|
||||
.addClass("disabled")
|
||||
.append($('<span class="bx bx-info-circle disabled-tooltip" />')
|
||||
.attr("title", t('attachments_actions.open_externally_detail_page'))
|
||||
);
|
||||
$openAttachmentButton.addClass("disabled").append($('<span class="bx bx-info-circle disabled-tooltip" />').attr("title", t("attachments_actions.open_externally_detail_page")));
|
||||
if (isElectron) {
|
||||
const $openAttachmentCustomButton = this.$widget.find("[data-trigger-command='openAttachmentCustom']");
|
||||
$openAttachmentCustomButton
|
||||
.addClass("disabled")
|
||||
.append($('<span class="bx bx-info-circle disabled-tooltip" />')
|
||||
.attr("title", t('attachments_actions.open_externally_detail_page'))
|
||||
);
|
||||
$openAttachmentCustomButton.addClass("disabled").append($('<span class="bx bx-info-circle disabled-tooltip" />').attr("title", t("attachments_actions.open_externally_detail_page")));
|
||||
}
|
||||
}
|
||||
if (!isElectron) {
|
||||
const $openAttachmentCustomButton = this.$widget.find("[data-trigger-command='openAttachmentCustom']");
|
||||
$openAttachmentCustomButton
|
||||
.addClass("disabled")
|
||||
.append($('<span class="bx bx-info-circle disabled-tooltip" />')
|
||||
.attr("title", t('attachments_actions.open_custom_client_only'))
|
||||
);
|
||||
$openAttachmentCustomButton.addClass("disabled").append($('<span class="bx bx-info-circle disabled-tooltip" />').attr("title", t("attachments_actions.open_custom_client_only")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +136,7 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
async uploadNewAttachmentRevisionCommand() {
|
||||
this.$uploadNewRevisionInput.trigger('click');
|
||||
this.$uploadNewRevisionInput.trigger("click");
|
||||
}
|
||||
|
||||
async copyAttachmentLinkToClipboardCommand() {
|
||||
@@ -156,29 +144,29 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
async deleteAttachmentCommand() {
|
||||
if (!await dialogService.confirm(t('attachments_actions.delete_confirm', { title: this.attachment.title }))) {
|
||||
if (!(await dialogService.confirm(t("attachments_actions.delete_confirm", { title: this.attachment.title })))) {
|
||||
return;
|
||||
}
|
||||
|
||||
await server.remove(`attachments/${this.attachmentId}`);
|
||||
toastService.showMessage(t('attachments_actions.delete_success', { title: this.attachment.title }));
|
||||
toastService.showMessage(t("attachments_actions.delete_success", { title: this.attachment.title }));
|
||||
}
|
||||
|
||||
async convertAttachmentIntoNoteCommand() {
|
||||
if (!await dialogService.confirm(t('attachments_actions.convert_confirm', { title: this.attachment.title }))) {
|
||||
if (!(await dialogService.confirm(t("attachments_actions.convert_confirm", { title: this.attachment.title })))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { note: newNote } = await server.post(`attachments/${this.attachmentId}/convert-to-note`)
|
||||
toastService.showMessage(t('attachments_actions.convert_success', { title: this.attachment.title }));
|
||||
const { note: newNote } = await server.post(`attachments/${this.attachmentId}/convert-to-note`);
|
||||
toastService.showMessage(t("attachments_actions.convert_success", { title: this.attachment.title }));
|
||||
await ws.waitForMaxKnownEntityChangeId();
|
||||
await appContext.tabManager.getActiveContext().setNote(newNote.noteId);
|
||||
}
|
||||
|
||||
async renameAttachmentCommand() {
|
||||
const attachmentTitle = await dialogService.prompt({
|
||||
title: t('attachments_actions.rename_attachment'),
|
||||
message: t('attachments_actions.enter_new_name'),
|
||||
title: t("attachments_actions.rename_attachment"),
|
||||
message: t("attachments_actions.enter_new_name"),
|
||||
defaultValue: this.attachment.title
|
||||
});
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ export default class BookmarkFolderWidget extends RightDropdownButtonWidget {
|
||||
doRender() {
|
||||
super.doRender();
|
||||
|
||||
this.$parentNote = this.$dropdownContent.find('.parent-note');
|
||||
this.$childrenNotes = this.$dropdownContent.find('.children-notes');
|
||||
this.$parentNote = this.$dropdownContent.find(".parent-note");
|
||||
this.$childrenNotes = this.$dropdownContent.find(".children-notes");
|
||||
}
|
||||
|
||||
async dropdownShown() {
|
||||
@@ -66,19 +66,10 @@ export default class BookmarkFolderWidget extends RightDropdownButtonWidget {
|
||||
showNoteIcon: true
|
||||
};
|
||||
|
||||
this.$parentNote.append(
|
||||
(await linkService.createLink(this.note.noteId, linkOptions))
|
||||
.addClass("note-link")
|
||||
);
|
||||
this.$parentNote.append((await linkService.createLink(this.note.noteId, linkOptions)).addClass("note-link"));
|
||||
|
||||
for (const childNote of await this.note.getChildNotes()) {
|
||||
this.$childrenNotes.append(
|
||||
$("<li>")
|
||||
.append(
|
||||
(await linkService.createLink(childNote.noteId, linkOptions))
|
||||
.addClass("note-link")
|
||||
)
|
||||
);
|
||||
this.$childrenNotes.append($("<li>").append((await linkService.createLink(childNote.noteId, linkOptions)).addClass("note-link")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,26 +28,22 @@ export default class ButtonFromNoteWidget extends CommandButtonWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
froca.getNote(buttonNoteId).then(note => {
|
||||
froca.getNote(buttonNoteId).then((note) => {
|
||||
this.settings.icon = note.getIcon();
|
||||
|
||||
this.refreshIcon();
|
||||
});
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({loadResults}) {
|
||||
entitiesReloadedEvent({ loadResults }) {
|
||||
const buttonNote = froca.getNoteFromCache(this.buttonNoteIdProvider());
|
||||
|
||||
if (!buttonNote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadResults.getAttributeRows(this.componentId).find(attr =>
|
||||
attr.type === 'label'
|
||||
&& attr.name === 'iconClass'
|
||||
&& attributeService.isAffecting(attr, buttonNote))) {
|
||||
|
||||
if (loadResults.getAttributeRows(this.componentId).find((attr) => attr.type === "label" && attr.name === "iconClass" && attributeService.isAffecting(attr, buttonNote))) {
|
||||
this.updateIcon();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ const DROPDOWN_TPL = `
|
||||
aria-expanded="false"
|
||||
data-calendar-input="month"></button>
|
||||
<ul class="dropdown-menu" data-calendar-input="month-list">
|
||||
${Object.entries(MONTHS).map(([i, month]) => `<li><button class="dropdown-item" data-value=${i}>${month}</button></li>`).join("")}
|
||||
${Object.entries(MONTHS)
|
||||
.map(([i, month]) => `<li><button class="dropdown-item" data-value=${i}>${month}</button></li>`)
|
||||
.join("")}
|
||||
</ul>
|
||||
|
||||
<button class="calendar-btn bx bx-chevron-right" data-calendar-toggle="next"></button>
|
||||
@@ -61,15 +63,7 @@ const DROPDOWN_TPL = `
|
||||
<div class="calendar-body" data-calendar-area="month"></div>
|
||||
</div>`;
|
||||
|
||||
const DAYS_OF_WEEK = [
|
||||
t("calendar.sun"),
|
||||
t("calendar.mon"),
|
||||
t("calendar.tue"),
|
||||
t("calendar.wed"),
|
||||
t("calendar.thu"),
|
||||
t("calendar.fri"),
|
||||
t("calendar.sat")
|
||||
];
|
||||
const DAYS_OF_WEEK = [t("calendar.sun"), t("calendar.mon"), t("calendar.tue"), t("calendar.wed"), t("calendar.thu"), t("calendar.fri"), t("calendar.sat")];
|
||||
|
||||
export default class CalendarWidget extends RightDropdownButtonWidget {
|
||||
constructor(title, icon) {
|
||||
@@ -91,18 +85,18 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
||||
e.stopPropagation();
|
||||
});
|
||||
this.monthDropdown = bootstrap.Dropdown.getOrCreateInstance(this.$monthSelect);
|
||||
this.$dropdownContent.find('[data-calendar-input="month-list"] button').on("click", (e) => {
|
||||
this.$dropdownContent.find('[data-calendar-input="month-list"] button').on("click", (e) => {
|
||||
this.date.setMonth(e.target.dataset.value);
|
||||
this.createMonth();
|
||||
this.monthDropdown.hide();
|
||||
});
|
||||
this.$next = this.$dropdownContent.find('[data-calendar-toggle="next"]');
|
||||
this.$next.on('click', () => {
|
||||
this.$next.on("click", () => {
|
||||
this.date.setMonth(this.date.getMonth() + 1);
|
||||
this.createMonth();
|
||||
});
|
||||
this.$previous = this.$dropdownContent.find('[data-calendar-toggle="previous"]');
|
||||
this.$previous.on('click', e => {
|
||||
this.$previous.on("click", (e) => {
|
||||
this.date.setMonth(this.date.getMonth() - 1);
|
||||
this.createMonth();
|
||||
});
|
||||
@@ -114,34 +108,33 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
||||
this.createMonth();
|
||||
});
|
||||
this.$nextYear = this.$dropdownContent.find('[data-calendar-toggle="nextYear"]');
|
||||
this.$nextYear.on('click', () => {
|
||||
this.$nextYear.on("click", () => {
|
||||
this.date.setFullYear(this.date.getFullYear() + 1);
|
||||
this.createMonth();
|
||||
});
|
||||
this.$previousYear = this.$dropdownContent.find('[data-calendar-toggle="previousYear"]');
|
||||
this.$previousYear.on('click', e => {
|
||||
this.$previousYear.on("click", (e) => {
|
||||
this.date.setFullYear(this.date.getFullYear() - 1);
|
||||
this.createMonth();
|
||||
});
|
||||
|
||||
this.$dropdownContent.find('.calendar-header').on("click", e => e.stopPropagation());
|
||||
this.$dropdownContent.find(".calendar-header").on("click", (e) => e.stopPropagation());
|
||||
|
||||
this.$dropdownContent.on('click', '.calendar-date', async ev => {
|
||||
const date = $(ev.target).closest('.calendar-date').attr('data-calendar-date');
|
||||
this.$dropdownContent.on("click", ".calendar-date", async (ev) => {
|
||||
const date = $(ev.target).closest(".calendar-date").attr("data-calendar-date");
|
||||
|
||||
const note = await dateNoteService.getDayNote(date);
|
||||
|
||||
if (note) {
|
||||
appContext.tabManager.getActiveContext().setNote(note.noteId);
|
||||
this.dropdown.hide();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
toastService.showError(t("calendar.cannot_find_day_note"));
|
||||
}
|
||||
|
||||
ev.stopPropagation();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Prevent dismissing the calendar popup by clicking on an empty space inside it.
|
||||
this.$dropdownContent.on("click", (e) => e.stopPropagation());
|
||||
}
|
||||
@@ -175,10 +168,8 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
||||
}
|
||||
|
||||
createDay(dateNotesForMonth, num, day) {
|
||||
const $newDay = $('<a>')
|
||||
.addClass("calendar-date")
|
||||
.attr('data-calendar-date', utils.formatDateISO(this.date));
|
||||
const $date = $('<span>').html(num);
|
||||
const $newDay = $("<a>").addClass("calendar-date").attr("data-calendar-date", utils.formatDateISO(this.date));
|
||||
const $date = $("<span>").html(num);
|
||||
|
||||
// if it's the first day of the month
|
||||
if (num === 1) {
|
||||
@@ -187,24 +178,23 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
||||
// 1 2 3 4 5 6 0
|
||||
// Mo Tu We Th Fr Sa Su
|
||||
let dayOffset = day - this.firstDayOfWeek;
|
||||
if (dayOffset < 0)
|
||||
dayOffset = 7 + dayOffset;
|
||||
$newDay.css("marginLeft", (dayOffset * 14.28) + '%');
|
||||
if (dayOffset < 0) dayOffset = 7 + dayOffset;
|
||||
$newDay.css("marginLeft", dayOffset * 14.28 + "%");
|
||||
}
|
||||
|
||||
const dateNoteId = dateNotesForMonth[utils.formatDateISO(this.date)];
|
||||
|
||||
if (dateNoteId) {
|
||||
$newDay.addClass('calendar-date-exists');
|
||||
$newDay.addClass("calendar-date-exists");
|
||||
$newDay.attr("data-href", `#root/${dateNoteId}`);
|
||||
}
|
||||
|
||||
if (this.isEqual(this.date, this.activeDate)) {
|
||||
$newDay.addClass('calendar-date-active');
|
||||
$newDay.addClass("calendar-date-active");
|
||||
}
|
||||
|
||||
if (this.isEqual(this.date, this.todaysDate)) {
|
||||
$newDay.addClass('calendar-date-today');
|
||||
$newDay.addClass("calendar-date-today");
|
||||
}
|
||||
|
||||
$newDay.append($date);
|
||||
@@ -212,13 +202,11 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
||||
}
|
||||
|
||||
isEqual(a, b) {
|
||||
if (!a && b || a && !b) {
|
||||
if ((!a && b) || (a && !b)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return a.getFullYear() === b.getFullYear()
|
||||
&& a.getMonth() === b.getMonth()
|
||||
&& a.getDate() === b.getDate();
|
||||
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
||||
}
|
||||
|
||||
async createMonth() {
|
||||
@@ -229,12 +217,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
||||
|
||||
const currentMonth = this.date.getMonth();
|
||||
while (this.date.getMonth() === currentMonth) {
|
||||
const $day = this.createDay(
|
||||
dateNotesForMonth,
|
||||
this.date.getDate(),
|
||||
this.date.getDay(),
|
||||
this.date.getFullYear()
|
||||
);
|
||||
const $day = this.createDay(dateNotesForMonth, this.date.getDate(), this.date.getDay(), this.date.getFullYear());
|
||||
|
||||
this.$month.append($day);
|
||||
|
||||
@@ -256,5 +239,4 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
||||
this.manageFirstDayOfWeek();
|
||||
this.createMonth();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@ import OnClickButtonWidget from "./onclick_button.js";
|
||||
|
||||
export default class ClosePaneButton extends OnClickButtonWidget {
|
||||
isEnabled() {
|
||||
return super.isEnabled()
|
||||
return (
|
||||
super.isEnabled() &&
|
||||
// main note context should not be closeable
|
||||
&& this.noteContext && !!this.noteContext.mainNtxId;
|
||||
this.noteContext &&
|
||||
!!this.noteContext.mainNtxId
|
||||
);
|
||||
}
|
||||
|
||||
async noteContextReorderEvent({ntxIdsInOrder}) {
|
||||
async noteContextReorderEvent({ ntxIdsInOrder }) {
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import AbstractButtonWidget, { AbstractButtonWidgetSettings } from "./abstract_b
|
||||
|
||||
let actions: Action[];
|
||||
|
||||
keyboardActionsService.getActions().then(as => actions = as);
|
||||
keyboardActionsService.getActions().then((as) => (actions = as));
|
||||
|
||||
// TODO: Is this actually used?
|
||||
export type ClickHandler = (widget: CommandButtonWidget, e: JQuery.ClickEvent<any, any, any, any>) => void;
|
||||
type CommandOrCallback = (CommandNames | (() => CommandNames));
|
||||
type CommandOrCallback = CommandNames | (() => CommandNames);
|
||||
|
||||
interface CommandButtonWidgetSettings extends AbstractButtonWidgetSettings {
|
||||
command?: CommandOrCallback;
|
||||
@@ -16,11 +16,10 @@ interface CommandButtonWidgetSettings extends AbstractButtonWidgetSettings {
|
||||
}
|
||||
|
||||
export default class CommandButtonWidget extends AbstractButtonWidget<CommandButtonWidgetSettings> {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.settings = {
|
||||
titlePlacement: 'right',
|
||||
titlePlacement: "right",
|
||||
title: null,
|
||||
icon: null,
|
||||
onContextMenu: null
|
||||
@@ -46,7 +45,7 @@ export default class CommandButtonWidget extends AbstractButtonWidget<CommandBut
|
||||
getTitle() {
|
||||
const title = super.getTitle();
|
||||
|
||||
const action = actions.find(act => act.actionName === this._command);
|
||||
const action = actions.find((act) => act.actionName === this._command);
|
||||
|
||||
if (action && action.effectiveShortcuts.length > 0) {
|
||||
return `${title} (${action.effectiveShortcuts.join(", ")})`;
|
||||
@@ -66,8 +65,6 @@ export default class CommandButtonWidget extends AbstractButtonWidget<CommandBut
|
||||
}
|
||||
|
||||
get _command() {
|
||||
return typeof this.settings.command === "function"
|
||||
? this.settings.command()
|
||||
: this.settings.command;
|
||||
return typeof this.settings.command === "function" ? this.settings.command() : this.settings.command;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export default class CreatePaneButton extends OnClickButtonWidget {
|
||||
this.icon("bx-dock-right")
|
||||
.title(t("create_pane_button.create_new_split"))
|
||||
.titlePlacement("bottom")
|
||||
.onClick(widget => widget.triggerCommand("openNewNoteSplit", { ntxId: widget.getClosestNtxId() }))
|
||||
.onClick((widget) => widget.triggerCommand("openNewNoteSplit", { ntxId: widget.getClosestNtxId() }))
|
||||
.class("icon-action");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import { t } from "../../services/i18n.js";
|
||||
|
||||
export default class EditButton extends OnClickButtonWidget {
|
||||
isEnabled() {
|
||||
return super.isEnabled()
|
||||
&& this.note
|
||||
&& this.noteContext.viewScope.viewMode === 'default';
|
||||
return super.isEnabled() && this.note && this.noteContext.viewScope.viewMode === "default";
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@@ -17,10 +15,10 @@ export default class EditButton extends OnClickButtonWidget {
|
||||
this.icon("bx-edit-alt")
|
||||
.title(t("edit_button.edit_this_note"))
|
||||
.titlePlacement("bottom")
|
||||
.onClick(widget => {
|
||||
.onClick((widget) => {
|
||||
this.noteContext.viewScope.readOnlyTemporarilyDisabled = true;
|
||||
|
||||
appContext.triggerEvent('readOnlyTemporarilyDisabled', {noteContext: this.noteContext});
|
||||
appContext.triggerEvent("readOnlyTemporarilyDisabled", { noteContext: this.noteContext });
|
||||
|
||||
this.refresh();
|
||||
});
|
||||
@@ -29,8 +27,7 @@ export default class EditButton extends OnClickButtonWidget {
|
||||
async refreshWithNote(note) {
|
||||
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||
this.toggleInt(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// prevent flickering by assuming hidden before async operation
|
||||
this.toggleInt(false);
|
||||
|
||||
@@ -53,19 +50,15 @@ export default class EditButton extends OnClickButtonWidget {
|
||||
await super.refreshWithNote(note);
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({loadResults}) {
|
||||
if (loadResults.getAttributeRows().find(
|
||||
attr => attr.type === 'label'
|
||||
&& attr.name.toLowerCase().includes("readonly")
|
||||
&& attributeService.isAffecting(attr, this.note)
|
||||
)) {
|
||||
entitiesReloadedEvent({ loadResults }) {
|
||||
if (loadResults.getAttributeRows().find((attr) => attr.type === "label" && attr.name.toLowerCase().includes("readonly") && attributeService.isAffecting(attr, this.note))) {
|
||||
this.noteContext.viewScope.readOnlyTemporarilyDisabled = false;
|
||||
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
async noteTypeMimeChangedEvent({noteId}) {
|
||||
async noteTypeMimeChangedEvent({ noteId }) {
|
||||
if (this.isNote(noteId)) {
|
||||
await this.refresh();
|
||||
}
|
||||
|
||||
@@ -108,13 +108,13 @@ const TPL = `
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li class="dropdown-item" data-trigger-command="openNewWindow">
|
||||
<span class="bx bx-window-open"></span>
|
||||
${t('global_menu.open_new_window')}
|
||||
${t("global_menu.open_new_window")}
|
||||
<kbd data-command="openNewWindow"></kbd>
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item" data-trigger-command="showShareSubtree">
|
||||
<span class="bx bx-share-alt"></span>
|
||||
${t('global_menu.show_shared_notes_subtree')}
|
||||
${t("global_menu.show_shared_notes_subtree")}
|
||||
</li>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
@@ -122,92 +122,92 @@ const TPL = `
|
||||
<span class="zoom-container dropdown-item dropdown-item-container">
|
||||
<div>
|
||||
<span class="bx bx-empty"></span>
|
||||
${t('global_menu.zoom')}
|
||||
${t("global_menu.zoom")}
|
||||
</div>
|
||||
|
||||
<div class="zoom-buttons">
|
||||
<a data-trigger-command="toggleFullscreen" title="${t('global_menu.toggle_fullscreen')}" class="bx bx-expand-alt"></a>
|
||||
<a data-trigger-command="toggleFullscreen" title="${t("global_menu.toggle_fullscreen")}" class="bx bx-expand-alt"></a>
|
||||
|
||||
|
||||
|
||||
<a data-trigger-command="zoomOut" title="${t('global_menu.zoom_out')}" class="bx bx-minus"></a>
|
||||
<a data-trigger-command="zoomOut" title="${t("global_menu.zoom_out")}" class="bx bx-minus"></a>
|
||||
|
||||
<span data-trigger-command="zoomReset" title="${t('global_menu.reset_zoom_level')}" class="zoom-state"></span>
|
||||
<span data-trigger-command="zoomReset" title="${t("global_menu.reset_zoom_level")}" class="zoom-state"></span>
|
||||
|
||||
<a data-trigger-command="zoomIn" title="${t('global_menu.zoom_in')}" class="bx bx-plus"></a>
|
||||
<a data-trigger-command="zoomIn" title="${t("global_menu.zoom_in")}" class="bx bx-plus"></a>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
<li class="dropdown-item toggle-pin">
|
||||
<span class="bx bx-pin"></span>
|
||||
${t('title_bar_buttons.window-on-top')}
|
||||
${t("title_bar_buttons.window-on-top")}
|
||||
</li>
|
||||
|
||||
<div class="dropdown-divider zoom-container-separator"></div>
|
||||
|
||||
<li class="dropdown-item switch-to-mobile-version-button" data-trigger-command="switchToMobileVersion">
|
||||
<span class="bx bx-mobile"></span>
|
||||
${t('global_menu.switch_to_mobile_version')}
|
||||
${t("global_menu.switch_to_mobile_version")}
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item switch-to-desktop-version-button" data-trigger-command="switchToDesktopVersion">
|
||||
<span class="bx bx-desktop"></span>
|
||||
${t('global_menu.switch_to_desktop_version')}
|
||||
${t("global_menu.switch_to_desktop_version")}
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item" data-trigger-command="showLaunchBarSubtree">
|
||||
<span class="bx ${utils.isMobile() ? "bx-mobile" : "bx-sidebar"}"></span>
|
||||
${t('global_menu.configure_launchbar')}
|
||||
${t("global_menu.configure_launchbar")}
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item dropdown-submenu">
|
||||
<span class="dropdown-toggle">
|
||||
<span class="bx bx-chip"></span>
|
||||
${t('global_menu.advanced')}
|
||||
${t("global_menu.advanced")}
|
||||
</span>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-item" data-trigger-command="showHiddenSubtree">
|
||||
<span class="bx bx-hide"></span>
|
||||
${t('global_menu.show_hidden_subtree')}
|
||||
${t("global_menu.show_hidden_subtree")}
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item" data-trigger-command="showSearchHistory">
|
||||
<span class="bx bx-search-alt"></span>
|
||||
${t('global_menu.open_search_history')}
|
||||
${t("global_menu.open_search_history")}
|
||||
</li>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<li class="dropdown-item" data-trigger-command="showBackendLog">
|
||||
<span class="bx bx-detail"></span>
|
||||
${t('global_menu.show_backend_log')}
|
||||
${t("global_menu.show_backend_log")}
|
||||
<kbd data-command="showBackendLog"></kbd>
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item" data-trigger-command="showSQLConsole">
|
||||
<span class="bx bx-data"></span>
|
||||
${t('global_menu.open_sql_console')}
|
||||
${t("global_menu.open_sql_console")}
|
||||
<kbd data-command="showSQLConsole"></kbd>
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item" data-trigger-command="showSQLConsoleHistory">
|
||||
<span class="bx bx-data"></span>
|
||||
${t('global_menu.open_sql_console_history')}
|
||||
${t("global_menu.open_sql_console_history")}
|
||||
</li>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<li class="dropdown-item open-dev-tools-button" data-trigger-command="openDevTools">
|
||||
<span class="bx bx-bug-alt"></span>
|
||||
${t('global_menu.open_dev_tools')}
|
||||
${t("global_menu.open_dev_tools")}
|
||||
<kbd data-command="openDevTools"></kbd>
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item" data-trigger-command="reloadFrontendApp"
|
||||
title="${t('global_menu.reload_hint')}">
|
||||
title="${t("global_menu.reload_hint")}">
|
||||
<span class="bx bx-refresh"></span>
|
||||
${t('global_menu.reload_frontend')}
|
||||
${t("global_menu.reload_frontend")}
|
||||
<kbd data-command="reloadFrontendApp"></kbd>
|
||||
</li>
|
||||
|
||||
@@ -216,20 +216,20 @@ const TPL = `
|
||||
|
||||
<li class="dropdown-item" data-trigger-command="showOptions">
|
||||
<span class="bx bx-cog"></span>
|
||||
${t('global_menu.options')}
|
||||
${t("global_menu.options")}
|
||||
</li>
|
||||
|
||||
<div class="dropdown-divider desktop-only"></div>
|
||||
|
||||
<li class="dropdown-item show-help-button" data-trigger-command="showHelp">
|
||||
<span class="bx bx-help-circle"></span>
|
||||
${t('global_menu.show_help')}
|
||||
${t("global_menu.show_help")}
|
||||
<kbd data-command="showHelp"></kbd>
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item show-about-dialog-button">
|
||||
<span class="bx bx-info-circle"></span>
|
||||
${t('global_menu.about')}
|
||||
${t("global_menu.about")}
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item update-to-latest-version-button" data-trigger-command="downloadLatestVersion">
|
||||
@@ -242,14 +242,13 @@ const TPL = `
|
||||
|
||||
<li class="dropdown-item logout-button" data-trigger-command="logout">
|
||||
<span class="bx bx-log-out"></span>
|
||||
${t('global_menu.logout')}
|
||||
${t("global_menu.logout")}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class GlobalMenuWidget extends BasicWidget {
|
||||
|
||||
private updateAvailableWidget: UpdateAvailableWidget;
|
||||
private isHorizontalLayout: boolean;
|
||||
private tooltip!: bootstrap.Tooltip;
|
||||
@@ -272,10 +271,11 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
this.$widget.addClass("dropend");
|
||||
}
|
||||
|
||||
const $globalMenuButton = this.$widget.find(".global-menu-button")
|
||||
const $globalMenuButton = this.$widget.find(".global-menu-button");
|
||||
if (!this.isHorizontalLayout) {
|
||||
$globalMenuButton.prepend($(`\
|
||||
<svg viewBox="0 0 256 256" data-bs-toggle="tooltip" title="${t('global_menu.menu')}">
|
||||
$globalMenuButton.prepend(
|
||||
$(`\
|
||||
<svg viewBox="0 0 256 256" data-bs-toggle="tooltip" title="${t("global_menu.menu")}">
|
||||
<g>
|
||||
<path class="st0" d="m202.9 112.7c-22.5 16.1-54.5 12.8-74.9 6.3l14.8-11.8 14.1-11.3 49.1-39.3-51.2 35.9-14.3 10-14.9 10.5c0.7-21.2 7-49.9 28.6-65.4 1.8-1.3 3.9-2.6 6.1-3.8 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.4 2.8-4.9 5.4-7.4 7.8-3.4 3.5-6.8 6.4-10.1 8.8z"/>
|
||||
<path class="st1" d="m213.1 104c-22.2 12.6-51.4 9.3-70.3 3.2l14.1-11.3 49.1-39.3-51.2 35.9-14.3 10c0.5-18.1 4.9-42.1 19.7-58.6 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.3 2.8-4.8 5.4-7.2 7.8z"/>
|
||||
@@ -289,7 +289,8 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
<path class="st7" d="m75.4 54.8c18.9 12 28.4 35.6 31.6 52.6l-14.5-6.3-50.6-22 48.7 24.9 13.6 6.9c-14.1 6.8-34.5 13-53.3 8.2-2.3-1.5-4.5-3.2-6.8-5.1-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.1 0.8 6.2 1.6 9.1 2.6z"/>
|
||||
<path class="st8" d="m66.3 52.2c15.3 12.8 23.3 33.6 26.1 48.9l-50.6-22 48.8 24.9c-12.2 6-29.6 11.8-46.5 10-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3z"/>
|
||||
</g>
|
||||
</svg>`));
|
||||
</svg>`)
|
||||
);
|
||||
//TODO: Fix once bootstrap is imported via modules.
|
||||
//@ts-ignore
|
||||
this.tooltip = new bootstrap.Tooltip(this.$widget.find("[data-bs-toggle='tooltip']"), { trigger: "hover" });
|
||||
@@ -303,7 +304,7 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
alignment: "bottom"
|
||||
});
|
||||
|
||||
this.$widget.find(".show-about-dialog-button").on('click', () => this.triggerCommand("openAboutDialog"));
|
||||
this.$widget.find(".show-about-dialog-button").on("click", () => this.triggerCommand("openAboutDialog"));
|
||||
|
||||
const isElectron = utils.isElectron();
|
||||
|
||||
@@ -311,15 +312,15 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
if (isElectron) {
|
||||
this.$widget.on("click", ".toggle-pin", (e) => {
|
||||
const $el = $(e.target);
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
const remote = utils.dynamicRequire("@electron/remote");
|
||||
const focusedWindow = remote.BrowserWindow.getFocusedWindow();
|
||||
const isAlwaysOnTop = focusedWindow.isAlwaysOnTop()
|
||||
const isAlwaysOnTop = focusedWindow.isAlwaysOnTop();
|
||||
if (isAlwaysOnTop) {
|
||||
focusedWindow.setAlwaysOnTop(false)
|
||||
$el.removeClass('active');
|
||||
focusedWindow.setAlwaysOnTop(false);
|
||||
$el.removeClass("active");
|
||||
} else {
|
||||
focusedWindow.setAlwaysOnTop(true);
|
||||
$el.addClass('active');
|
||||
$el.addClass("active");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -331,22 +332,20 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
this.$widget.find(".switch-to-mobile-version-button").toggle(!isElectron && utils.isDesktop());
|
||||
this.$widget.find(".switch-to-desktop-version-button").toggle(!isElectron && utils.isMobile());
|
||||
|
||||
this.$widget.on('click', '.dropdown-item', e => {
|
||||
this.$widget.on("click", ".dropdown-item", (e) => {
|
||||
if ($(e.target).parent(".zoom-buttons")) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.dropdown.toggle();
|
||||
});
|
||||
this.$widget.on('click', '.dropdown-submenu', e => {
|
||||
if ($(e.target).children(".dropdown-menu").length === 1 || $(e.target).hasClass('dropdown-toggle')) {
|
||||
this.$widget.on("click", ".dropdown-submenu", (e) => {
|
||||
if ($(e.target).children(".dropdown-menu").length === 1 || $(e.target).hasClass("dropdown-toggle")) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
this.$widget.find(".global-menu-button-update-available").append(
|
||||
this.updateAvailableWidget.render()
|
||||
);
|
||||
this.$widget.find(".global-menu-button-update-available").append(this.updateAvailableWidget.render());
|
||||
|
||||
this.$updateToLatestVersionButton = this.$widget.find(".update-to-latest-version-button");
|
||||
|
||||
@@ -356,7 +355,7 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
this.$zoomState = this.$widget.find(".zoom-state");
|
||||
this.$widget.on('show.bs.dropdown', () => {
|
||||
this.$widget.on("show.bs.dropdown", () => {
|
||||
this.updateZoomState();
|
||||
if (this.tooltip) {
|
||||
this.tooltip.hide();
|
||||
@@ -364,10 +363,11 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
}
|
||||
});
|
||||
if (this.tooltip) {
|
||||
this.$widget.on('hide.bs.dropdown', () => this.tooltip.enable());
|
||||
this.$widget.on("hide.bs.dropdown", () => this.tooltip.enable());
|
||||
}
|
||||
|
||||
this.$widget.find(".zoom-buttons").on("click",
|
||||
this.$widget.find(".zoom-buttons").on(
|
||||
"click",
|
||||
// delay to wait for the actual zoom change
|
||||
() => setTimeout(() => this.updateZoomState(), 300)
|
||||
);
|
||||
@@ -382,7 +382,7 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
const zoomFactor = utils.dynamicRequire('electron').webFrame.getZoomFactor();
|
||||
const zoomFactor = utils.dynamicRequire("electron").webFrame.getZoomFactor();
|
||||
const zoomPercent = Math.round(zoomFactor * 100);
|
||||
|
||||
this.$zoomState.text(`${zoomPercent}%`);
|
||||
@@ -391,7 +391,7 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
async updateVersionStatus() {
|
||||
await options.initializedPromise;
|
||||
|
||||
if (options.get("checkForUpdates") !== 'true') {
|
||||
if (options.get("checkForUpdates") !== "true") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
|
||||
.command(() => command)
|
||||
.titlePlacement("right")
|
||||
.buttonNoteIdProvider(() => launcherNote.noteId)
|
||||
.onContextMenu(e => this.showContextMenu(e))
|
||||
.onContextMenu((e) => this.showContextMenu(e))
|
||||
.class("launcher-button");
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
|
||||
super.doRender();
|
||||
|
||||
if (utils.isElectron()) {
|
||||
this.webContents = utils.dynamicRequire('@electron/remote').getCurrentWebContents();
|
||||
this.webContents = utils.dynamicRequire("@electron/remote").getCurrentWebContents();
|
||||
|
||||
// without this, the history is preserved across frontend reloads
|
||||
this.webContents.clearHistory();
|
||||
@@ -34,7 +34,8 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
|
||||
|
||||
// API is broken and will be replaced: https://github.com/electron/electron/issues/33899
|
||||
// until then no context menu
|
||||
if (true) { // avoid warning in dev console
|
||||
if (true) {
|
||||
// avoid warning in dev console
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,17 +49,21 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
|
||||
|
||||
for (const idx in this.webContents.history) {
|
||||
const url = this.webContents.history[idx];
|
||||
const [_, notePathWithTab] = url.split('#');
|
||||
const [_, notePathWithTab] = url.split("#");
|
||||
// broken: use linkService.parseNavigationStateFromUrl();
|
||||
const [notePath, ntxId] = notePathWithTab.split('-');
|
||||
const [notePath, ntxId] = notePathWithTab.split("-");
|
||||
|
||||
const title = await treeService.getNotePathTitle(notePath);
|
||||
|
||||
items.push({
|
||||
title,
|
||||
idx,
|
||||
uiIcon: idx == activeIndex ? "bx bx-radio-circle-marked" : // compare with type coercion!
|
||||
(idx < activeIndex ? "bx bx-left-arrow-alt" : "bx bx-right-arrow-alt")
|
||||
uiIcon:
|
||||
idx == activeIndex
|
||||
? "bx bx-radio-circle-marked" // compare with type coercion!
|
||||
: idx < activeIndex
|
||||
? "bx bx-left-arrow-alt"
|
||||
: "bx bx-right-arrow-alt"
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +77,7 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
|
||||
x: e.pageX,
|
||||
y: e.pageY,
|
||||
items,
|
||||
selectMenuItemHandler: ({idx}) => this.webContents.goToIndex(idx)
|
||||
selectMenuItemHandler: ({ idx }) => this.webContents.goToIndex(idx)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export default class AbstractLauncher extends OnClickButtonWidget {
|
||||
/** @type {FNote} */
|
||||
this.launcherNote = launcherNote;
|
||||
|
||||
for (const label of launcherNote.getOwnedLabels('keyboardShortcut')) {
|
||||
for (const label of launcherNote.getOwnedLabels("keyboardShortcut")) {
|
||||
this.bindNoteShortcutHandler(label);
|
||||
}
|
||||
}
|
||||
@@ -23,18 +23,19 @@ export default class AbstractLauncher extends OnClickButtonWidget {
|
||||
bindNoteShortcutHandler(labelOrRow) {
|
||||
const namespace = labelOrRow.attributeId;
|
||||
|
||||
if (labelOrRow.isDeleted) { // only applicable if row
|
||||
if (labelOrRow.isDeleted) {
|
||||
// only applicable if row
|
||||
shortcutService.removeGlobalShortcut(namespace);
|
||||
} else {
|
||||
shortcutService.bindGlobalShortcut(labelOrRow.value, () => this.launch(), namespace);
|
||||
}
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({loadResults}) {
|
||||
entitiesReloadedEvent({ loadResults }) {
|
||||
for (const attr of loadResults.getAttributeRows()) {
|
||||
if (attr.noteId === this.launcherNote.noteId && attr.type === 'label' && attr.name === 'keyboardShortcut') {
|
||||
if (attr.noteId === this.launcherNote.noteId && attr.type === "label" && attr.name === "keyboardShortcut") {
|
||||
this.bindNoteShortcutHandler(attr);
|
||||
} else if (attr.type === 'label' && attr.name === 'iconClass' && attributesService.isAffecting(attr, this.launcherNote)) {
|
||||
} else if (attr.type === "label" && attr.name === "iconClass" && attributesService.isAffecting(attr, this.launcherNote)) {
|
||||
this.refreshIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export default class NoteLauncher extends AbstractLauncher {
|
||||
.icon(() => this.launcherNote.getIcon())
|
||||
.onClick((widget, evt) => this.launch(evt))
|
||||
.onAuxClick((widget, evt) => this.launch(evt))
|
||||
.onContextMenu(evt => {
|
||||
.onContextMenu((evt) => {
|
||||
const targetNoteId = this.getTargetNoteId();
|
||||
if (!targetNoteId) {
|
||||
return;
|
||||
@@ -56,7 +56,7 @@ export default class NoteLauncher extends AbstractLauncher {
|
||||
}
|
||||
|
||||
getTargetNoteId() {
|
||||
const targetNoteId = this.launcherNote.getRelationValue('target');
|
||||
const targetNoteId = this.launcherNote.getRelationValue("target");
|
||||
|
||||
if (!targetNoteId) {
|
||||
dialogService.info(t("note_launcher.this_launcher_doesnt_define_target_note"));
|
||||
@@ -67,14 +67,14 @@ export default class NoteLauncher extends AbstractLauncher {
|
||||
}
|
||||
|
||||
getHoistedNoteId() {
|
||||
return this.launcherNote.getRelationValue('hoistedNote')
|
||||
|| appContext.tabManager.getActiveContext().hoistedNoteId;
|
||||
return this.launcherNote.getRelationValue("hoistedNote") || appContext.tabManager.getActiveContext().hoistedNoteId;
|
||||
}
|
||||
|
||||
getTitle() {
|
||||
const shortcuts = this.launcherNote.getLabels("keyboardShortcut")
|
||||
.map(l => l.value)
|
||||
.filter(v => !!v)
|
||||
const shortcuts = this.launcherNote
|
||||
.getLabels("keyboardShortcut")
|
||||
.map((l) => l.value)
|
||||
.filter((v) => !!v)
|
||||
.join(", ");
|
||||
|
||||
let title = super.getTitle();
|
||||
|
||||
@@ -10,10 +10,10 @@ export default class ScriptLauncher extends AbstractLauncher {
|
||||
}
|
||||
|
||||
async launch() {
|
||||
if (this.launcherNote.isLabelTruthy('scriptInLauncherContent')) {
|
||||
if (this.launcherNote.isLabelTruthy("scriptInLauncherContent")) {
|
||||
await this.launcherNote.executeScript();
|
||||
} else {
|
||||
const script = await this.launcherNote.getRelationTarget('script');
|
||||
const script = await this.launcherNote.getRelationTarget("script");
|
||||
|
||||
await script.executeScript();
|
||||
}
|
||||
|
||||
@@ -14,16 +14,12 @@ export default class LeftPaneToggleWidget extends CommandButtonWidget {
|
||||
return "bx-sidebar";
|
||||
}
|
||||
|
||||
return (options.is('leftPaneVisible') ? "bx-chevrons-left" : "bx-chevrons-right");
|
||||
return options.is("leftPaneVisible") ? "bx-chevrons-left" : "bx-chevrons-right";
|
||||
};
|
||||
|
||||
this.settings.title = () => options.is('leftPaneVisible')
|
||||
? t("left_pane_toggle.hide_panel")
|
||||
: t("left_pane_toggle.show_panel");
|
||||
this.settings.title = () => (options.is("leftPaneVisible") ? t("left_pane_toggle.hide_panel") : t("left_pane_toggle.show_panel"));
|
||||
|
||||
this.settings.command = () => options.is('leftPaneVisible')
|
||||
? "hideLeftPane"
|
||||
: "showLeftPane";
|
||||
this.settings.command = () => (options.is("leftPaneVisible") ? "hideLeftPane" : "showLeftPane");
|
||||
|
||||
if (isHorizontalLayout) {
|
||||
this.settings.titlePlacement = "bottom";
|
||||
@@ -33,10 +29,10 @@ export default class LeftPaneToggleWidget extends CommandButtonWidget {
|
||||
refreshIcon() {
|
||||
super.refreshIcon();
|
||||
|
||||
splitService.setupLeftPaneResizer(options.is('leftPaneVisible'));
|
||||
splitService.setupLeftPaneResizer(options.is("leftPaneVisible"));
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({loadResults}) {
|
||||
entitiesReloadedEvent({ loadResults }) {
|
||||
if (loadResults.isOptionReloaded("leftPaneVisible")) {
|
||||
this.refreshIcon();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class MovePaneButton extends OnClickButtonWidget {
|
||||
.titlePlacement("bottom")
|
||||
.onClick(async (widget, e) => {
|
||||
e.stopPropagation();
|
||||
widget.triggerCommand("moveThisNoteSplit", {ntxId: widget.getClosestNtxId(), isMovingLeft: this.isMovingLeft});
|
||||
widget.triggerCommand("moveThisNoteSplit", { ntxId: widget.getClosestNtxId(), isMovingLeft: this.isMovingLeft });
|
||||
})
|
||||
.class("icon-action");
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export default class MovePaneButton extends OnClickButtonWidget {
|
||||
// movable if the current context is not a main context, i.e. non-null mainNtxId
|
||||
return !!this.noteContext?.mainNtxId;
|
||||
} else {
|
||||
const currentIndex = appContext.tabManager.noteContexts.findIndex(c => c.ntxId === this.ntxId);
|
||||
const currentIndex = appContext.tabManager.noteContexts.findIndex((c) => c.ntxId === this.ntxId);
|
||||
const nextContext = appContext.tabManager.noteContexts[currentIndex + 1];
|
||||
// movable if the next context is not null and not a main context, i.e. non-null mainNtxId
|
||||
return !!nextContext?.mainNtxId;
|
||||
|
||||
@@ -40,43 +40,43 @@ const TPL = `
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<li data-trigger-command="convertNoteIntoAttachment" class="dropdown-item">
|
||||
<span class="bx bx-paperclip"></span> ${t('note_actions.convert_into_attachment')}
|
||||
<span class="bx bx-paperclip"></span> ${t("note_actions.convert_into_attachment")}
|
||||
</li>
|
||||
|
||||
<li data-trigger-command="renderActiveNote" class="dropdown-item render-note-button">
|
||||
<span class="bx bx-extension"></span> ${t('note_actions.re_render_note')}<kbd data-command="renderActiveNote"></kbd>
|
||||
<span class="bx bx-extension"></span> ${t("note_actions.re_render_note")}<kbd data-command="renderActiveNote"></kbd>
|
||||
</li>
|
||||
|
||||
<li data-trigger-command="findInText" class="dropdown-item find-in-text-button">
|
||||
<span class='bx bx-search'></span> ${t('note_actions.search_in_note')}<kbd data-command="findInText"></kbd>
|
||||
<span class='bx bx-search'></span> ${t("note_actions.search_in_note")}<kbd data-command="findInText"></kbd>
|
||||
</li>
|
||||
|
||||
<li data-trigger-command="printActiveNote" class="dropdown-item print-active-note-button">
|
||||
<span class="bx bx-printer"></span> ${t('note_actions.print_note')}<kbd data-command="printActiveNote"></kbd></li>
|
||||
<span class="bx bx-printer"></span> ${t("note_actions.print_note")}<kbd data-command="printActiveNote"></kbd></li>
|
||||
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
|
||||
<li class="dropdown-item import-files-button"><span class="bx bx-import"></span> ${t('note_actions.import_files')}</li>
|
||||
<li class="dropdown-item import-files-button"><span class="bx bx-import"></span> ${t("note_actions.import_files")}</li>
|
||||
|
||||
<li class="dropdown-item export-note-button"><span class="bx bx-export"></span> ${t('note_actions.export_note')}</li>
|
||||
<li class="dropdown-item export-note-button"><span class="bx bx-export"></span> ${t("note_actions.export_note")}</li>
|
||||
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
|
||||
|
||||
<li data-trigger-command="openNoteExternally" class="dropdown-item open-note-externally-button" title="${t('note_actions.open_note_externally_title')}">
|
||||
<span class="bx bx-file-find"></span> ${t('note_actions.open_note_externally')}<kbd data-command="openNoteExternally"></kbd>
|
||||
<li data-trigger-command="openNoteExternally" class="dropdown-item open-note-externally-button" title="${t("note_actions.open_note_externally_title")}">
|
||||
<span class="bx bx-file-find"></span> ${t("note_actions.open_note_externally")}<kbd data-command="openNoteExternally"></kbd>
|
||||
</li>
|
||||
|
||||
<li data-trigger-command="openNoteCustom" class="dropdown-item open-note-custom-button">
|
||||
<span class="bx bx-customize"></span> ${t('note_actions.open_note_custom')}<kbd data-command="openNoteCustom"></kbd>
|
||||
<span class="bx bx-customize"></span> ${t("note_actions.open_note_custom")}<kbd data-command="openNoteCustom"></kbd>
|
||||
</li>
|
||||
|
||||
<li data-trigger-command="showNoteSource" class="dropdown-item show-source-button">
|
||||
<span class="bx bx-code"></span> ${t('note_actions.note_source')}<kbd data-command="showNoteSource"></kbd>
|
||||
<span class="bx bx-code"></span> ${t("note_actions.note_source")}<kbd data-command="showNoteSource"></kbd>
|
||||
</li>
|
||||
|
||||
|
||||
@@ -84,39 +84,39 @@ const TPL = `
|
||||
|
||||
|
||||
<li data-trigger-command="forceSaveRevision" class="dropdown-item save-revision-button">
|
||||
<span class="bx bx-save"></span> ${t('note_actions.save_revision')}<kbd data-command="forceSaveRevision"></kbd>
|
||||
<span class="bx bx-save"></span> ${t("note_actions.save_revision")}<kbd data-command="forceSaveRevision"></kbd>
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item delete-note-button"><span class="bx bx-trash destructive-action-icon"></span> ${t('note_actions.delete_note')}</li>
|
||||
<li class="dropdown-item delete-note-button"><span class="bx bx-trash destructive-action-icon"></span> ${t("note_actions.delete_note")}</li>
|
||||
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
|
||||
<li data-trigger-command="showAttachments" class="dropdown-item show-attachments-button">
|
||||
<span class="bx bx-paperclip"></span> ${t('note_actions.note_attachments')}<kbd data-command="showAttachments"></kbd>
|
||||
<span class="bx bx-paperclip"></span> ${t("note_actions.note_attachments")}<kbd data-command="showAttachments"></kbd>
|
||||
</li>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
isEnabled() {
|
||||
return this.note?.type !== 'launcher';
|
||||
return this.note?.type !== "launcher";
|
||||
}
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$widget.on('show.bs.dropdown', () => this.refreshVisibility(this.note));
|
||||
this.$widget.on("show.bs.dropdown", () => this.refreshVisibility(this.note));
|
||||
|
||||
this.$convertNoteIntoAttachmentButton = this.$widget.find("[data-trigger-command='convertNoteIntoAttachment']");
|
||||
this.$findInTextButton = this.$widget.find('.find-in-text-button');
|
||||
this.$printActiveNoteButton = this.$widget.find('.print-active-note-button');
|
||||
this.$showSourceButton = this.$widget.find('.show-source-button');
|
||||
this.$showAttachmentsButton = this.$widget.find('.show-attachments-button');
|
||||
this.$renderNoteButton = this.$widget.find('.render-note-button');
|
||||
this.$findInTextButton = this.$widget.find(".find-in-text-button");
|
||||
this.$printActiveNoteButton = this.$widget.find(".print-active-note-button");
|
||||
this.$showSourceButton = this.$widget.find(".show-source-button");
|
||||
this.$showAttachmentsButton = this.$widget.find(".show-attachments-button");
|
||||
this.$renderNoteButton = this.$widget.find(".render-note-button");
|
||||
this.$saveRevisionButton = this.$widget.find(".save-revision-button");
|
||||
|
||||
this.$exportNoteButton = this.$widget.find('.export-note-button');
|
||||
this.$exportNoteButton = this.$widget.find(".export-note-button");
|
||||
this.$exportNoteButton.on("click", () => {
|
||||
if (this.$exportNoteButton.hasClass("disabled")) {
|
||||
return;
|
||||
@@ -128,17 +128,17 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
});
|
||||
});
|
||||
|
||||
this.$importNoteButton = this.$widget.find('.import-files-button');
|
||||
this.$importNoteButton.on("click", () => this.triggerCommand("showImportDialog", {noteId: this.noteId}));
|
||||
this.$importNoteButton = this.$widget.find(".import-files-button");
|
||||
this.$importNoteButton.on("click", () => this.triggerCommand("showImportDialog", { noteId: this.noteId }));
|
||||
|
||||
this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-bs-toggle='dropdown']").dropdown('toggle'));
|
||||
this.$widget.on("click", ".dropdown-item", () => this.$widget.find("[data-bs-toggle='dropdown']").dropdown("toggle"));
|
||||
|
||||
this.$openNoteExternallyButton = this.$widget.find(".open-note-externally-button");
|
||||
this.$openNoteCustomButton = this.$widget.find(".open-note-custom-button");
|
||||
|
||||
this.$deleteNoteButton = this.$widget.find(".delete-note-button");
|
||||
this.$deleteNoteButton.on("click", () => {
|
||||
if (this.note.noteId === 'root') {
|
||||
if (this.note.noteId === "root") {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,36 +151,37 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
|
||||
this.$convertNoteIntoAttachmentButton.toggle(note.isEligibleForConversionToAttachment());
|
||||
|
||||
this.toggleDisabled(this.$findInTextButton, ['text', 'code', 'book'].includes(note.type));
|
||||
this.toggleDisabled(this.$findInTextButton, ["text", "code", "book"].includes(note.type));
|
||||
|
||||
this.toggleDisabled(this.$showAttachmentsButton, !isInOptions);
|
||||
this.toggleDisabled(this.$showSourceButton, ['text', 'code', 'relationMap', 'mermaid', 'canvas', 'mindMap'].includes(note.type));
|
||||
this.toggleDisabled(this.$showSourceButton, ["text", "code", "relationMap", "mermaid", "canvas", "mindMap"].includes(note.type));
|
||||
|
||||
this.toggleDisabled(this.$printActiveNoteButton, ['text', 'code'].includes(note.type));
|
||||
this.toggleDisabled(this.$printActiveNoteButton, ["text", "code"].includes(note.type));
|
||||
|
||||
this.$renderNoteButton.toggle(note.type === 'render');
|
||||
this.$renderNoteButton.toggle(note.type === "render");
|
||||
|
||||
this.toggleDisabled(this.$openNoteExternallyButton, utils.isElectron() && !['search', 'book'].includes(note.type));
|
||||
this.toggleDisabled(this.$openNoteCustomButton,
|
||||
utils.isElectron()
|
||||
&& !utils.isMac() // no implementation for Mac yet
|
||||
&& !['search', 'book'].includes(note.type)
|
||||
this.toggleDisabled(this.$openNoteExternallyButton, utils.isElectron() && !["search", "book"].includes(note.type));
|
||||
this.toggleDisabled(
|
||||
this.$openNoteCustomButton,
|
||||
utils.isElectron() &&
|
||||
!utils.isMac() && // no implementation for Mac yet
|
||||
!["search", "book"].includes(note.type)
|
||||
);
|
||||
|
||||
// I don't want to handle all special notes like this, but intuitively user might want to export content of backend log
|
||||
this.toggleDisabled(this.$exportNoteButton, !['_backendLog'].includes(note.noteId) && !isInOptions);
|
||||
this.toggleDisabled(this.$exportNoteButton, !["_backendLog"].includes(note.noteId) && !isInOptions);
|
||||
|
||||
this.toggleDisabled(this.$importNoteButton, !['search'].includes(note.type) && !isInOptions);
|
||||
this.toggleDisabled(this.$importNoteButton, !["search"].includes(note.type) && !isInOptions);
|
||||
this.toggleDisabled(this.$deleteNoteButton, !isInOptions);
|
||||
this.toggleDisabled(this.$saveRevisionButton, !isInOptions);
|
||||
}
|
||||
|
||||
async convertNoteIntoAttachmentCommand() {
|
||||
if (!await dialogService.confirm(t("note_actions.convert_into_attachment_prompt", { title: this.note.title }))) {
|
||||
if (!(await dialogService.confirm(t("note_actions.convert_into_attachment_prompt", { title: this.note.title })))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {attachment: newAttachment} = await server.post(`notes/${this.noteId}/convert-to-attachment`);
|
||||
const { attachment: newAttachment } = await server.post(`notes/${this.noteId}/convert-to-attachment`);
|
||||
|
||||
if (!newAttachment) {
|
||||
toastService.showMessage(t("note_actions.convert_into_attachment_failed", { title: this.note.title }));
|
||||
@@ -191,7 +192,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
await ws.waitForMaxKnownEntityChangeId();
|
||||
await appContext.tabManager.getActiveContext().setNote(newAttachment.ownerId, {
|
||||
viewScope: {
|
||||
viewMode: 'attachments',
|
||||
viewMode: "attachments",
|
||||
attachmentId: newAttachment.attachmentId
|
||||
}
|
||||
});
|
||||
@@ -199,13 +200,13 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
|
||||
toggleDisabled($el, enable) {
|
||||
if (enable) {
|
||||
$el.removeAttr('disabled');
|
||||
$el.removeAttr("disabled");
|
||||
} else {
|
||||
$el.attr('disabled', 'disabled');
|
||||
$el.attr("disabled", "disabled");
|
||||
}
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({loadResults}) {
|
||||
entitiesReloadedEvent({ loadResults }) {
|
||||
if (loadResults.isNoteReloaded(this.noteId)) {
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
@@ -10,11 +10,10 @@ interface OnClickButtonWidgetSettings extends AbstractButtonWidgetSettings {
|
||||
}
|
||||
|
||||
export default class OnClickButtonWidget extends AbstractButtonWidget<OnClickButtonWidgetSettings> {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.settings = {
|
||||
titlePlacement: 'right',
|
||||
titlePlacement: "right",
|
||||
title: null,
|
||||
icon: null,
|
||||
onContextMenu: null
|
||||
@@ -25,7 +24,7 @@ export default class OnClickButtonWidget extends AbstractButtonWidget<OnClickBut
|
||||
super.doRender();
|
||||
|
||||
if (this.settings.onClick) {
|
||||
this.$widget.on("click", e => {
|
||||
this.$widget.on("click", (e) => {
|
||||
this.$widget.tooltip("hide");
|
||||
|
||||
if (this.settings.onClick) {
|
||||
@@ -37,7 +36,7 @@ export default class OnClickButtonWidget extends AbstractButtonWidget<OnClickBut
|
||||
}
|
||||
|
||||
if (this.settings.onAuxClick) {
|
||||
this.$widget.on("auxclick", e => {
|
||||
this.$widget.on("auxclick", (e) => {
|
||||
this.$widget.tooltip("hide");
|
||||
|
||||
if (this.settings.onAuxClick) {
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class OpenNoteButtonWidget extends OnClickButtonWidget {
|
||||
.icon(() => this.noteToOpen.getIcon())
|
||||
.onClick((widget, evt) => this.launch(evt))
|
||||
.onAuxClick((widget, evt) => this.launch(evt))
|
||||
.onContextMenu(evt => linkContextMenuService.openContextMenu(this.noteToOpen.noteId, evt));
|
||||
.onContextMenu((evt) => linkContextMenuService.openContextMenu(this.noteToOpen.noteId, evt));
|
||||
}
|
||||
|
||||
async launch(evt) {
|
||||
|
||||
@@ -8,17 +8,11 @@ export default class ProtectedSessionStatusWidget extends CommandButtonWidget {
|
||||
|
||||
this.class("launcher-button");
|
||||
|
||||
this.settings.icon = () => protectedSessionHolder.isProtectedSessionAvailable()
|
||||
? "bx-check-shield"
|
||||
: "bx-shield-quarter";
|
||||
this.settings.icon = () => (protectedSessionHolder.isProtectedSessionAvailable() ? "bx-check-shield" : "bx-shield-quarter");
|
||||
|
||||
this.settings.title = () => protectedSessionHolder.isProtectedSessionAvailable()
|
||||
? t("protected_session_status.active")
|
||||
: t("protected_session_status.inactive");
|
||||
this.settings.title = () => (protectedSessionHolder.isProtectedSessionAvailable() ? t("protected_session_status.active") : t("protected_session_status.inactive"));
|
||||
|
||||
this.settings.command = () => protectedSessionHolder.isProtectedSessionAvailable()
|
||||
? "leaveProtectedSession"
|
||||
: "enterProtectedSession";
|
||||
this.settings.command = () => (protectedSessionHolder.isProtectedSessionAvailable() ? "leaveProtectedSession" : "enterProtectedSession");
|
||||
}
|
||||
|
||||
protectedSessionStartedEvent() {
|
||||
|
||||
@@ -5,14 +5,10 @@ export default class RevisionsButton extends CommandButtonWidget {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.icon('bx-history')
|
||||
.title(t("revisions_button.note_revisions"))
|
||||
.command("showRevisions")
|
||||
.titlePlacement("bottom")
|
||||
.class("icon-action");
|
||||
this.icon("bx-history").title(t("revisions_button.note_revisions")).command("showRevisions").titlePlacement("bottom").class("icon-action");
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
return super.isEnabled() && !['launcher', 'doc'].includes(this.note?.type);
|
||||
return super.isEnabled() && !["launcher", "doc"].includes(this.note?.type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export default class RightDropdownButtonWidget extends BasicWidget {
|
||||
this.dropdownTpl = dropdownTpl;
|
||||
|
||||
this.settings = {
|
||||
titlePlacement: "right"
|
||||
titlePlacement: "right"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,16 +33,17 @@ export default class RightDropdownButtonWidget extends BasicWidget {
|
||||
this.$tooltip = this.$widget.find(".tooltip-trigger").attr("title", this.title);
|
||||
this.tooltip = new bootstrap.Tooltip(this.$tooltip, {
|
||||
placement: this.settings.titlePlacement,
|
||||
fallbackPlacements: [ this.settings.titlePlacement ]
|
||||
fallbackPlacements: [this.settings.titlePlacement]
|
||||
});
|
||||
|
||||
this.$widget.find(".right-dropdown-button")
|
||||
this.$widget
|
||||
.find(".right-dropdown-button")
|
||||
.addClass(this.iconClass)
|
||||
.on("click", () => this.tooltip.hide())
|
||||
.on('mouseenter', () => this.tooltip.show())
|
||||
.on('mouseleave', () => this.tooltip.hide());
|
||||
.on("mouseenter", () => this.tooltip.show())
|
||||
.on("mouseleave", () => this.tooltip.hide());
|
||||
|
||||
this.$widget.on('show.bs.dropdown', async () => {
|
||||
this.$widget.on("show.bs.dropdown", async () => {
|
||||
await this.dropdownShown();
|
||||
|
||||
const rect = this.$dropdownMenu[0].getBoundingClientRect();
|
||||
@@ -58,5 +59,5 @@ export default class RightDropdownButtonWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
// to be overridden
|
||||
async dropdownShow() { }
|
||||
async dropdownShow() {}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@ import { t } from "../../services/i18n.js";
|
||||
|
||||
export default class ShowHighlightsListWidgetButton extends OnClickButtonWidget {
|
||||
isEnabled() {
|
||||
return super.isEnabled()
|
||||
&& this.note
|
||||
&& this.note.type === 'text'
|
||||
&& this.noteContext.viewScope.viewMode === 'default';
|
||||
return super.isEnabled() && this.note && this.note.type === "text" && this.noteContext.viewScope.viewMode === "default";
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@@ -17,7 +14,7 @@ export default class ShowHighlightsListWidgetButton extends OnClickButtonWidget
|
||||
this.icon("bx-highlight")
|
||||
.title(t("show_highlights_list_widget_button.show_highlights_list"))
|
||||
.titlePlacement("bottom")
|
||||
.onClick(widget => {
|
||||
.onClick((widget) => {
|
||||
this.noteContext.viewScope.highlightsListTemporarilyHidden = false;
|
||||
appContext.triggerEvent("showHighlightsListWidget", { noteId: this.noteId });
|
||||
this.toggleInt(false);
|
||||
@@ -35,9 +32,11 @@ export default class ShowHighlightsListWidgetButton extends OnClickButtonWidget
|
||||
async entitiesReloadedEvent({ loadResults }) {
|
||||
if (loadResults.isNoteContentReloaded(this.noteId)) {
|
||||
await this.refresh();
|
||||
} else if (loadResults.getAttributeRows().find(attr => attr.type === 'label'
|
||||
&& (attr.name.toLowerCase().includes('readonly') || attr.name === 'hideHighlightWidget')
|
||||
&& attributeService.isAffecting(attr, this.note))) {
|
||||
} else if (
|
||||
loadResults
|
||||
.getAttributeRows()
|
||||
.find((attr) => attr.type === "label" && (attr.name.toLowerCase().includes("readonly") || attr.name === "hideHighlightWidget") && attributeService.isAffecting(attr, this.note))
|
||||
) {
|
||||
await this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@ import { t } from "../../services/i18n.js";
|
||||
|
||||
export default class ShowTocWidgetButton extends OnClickButtonWidget {
|
||||
isEnabled() {
|
||||
return super.isEnabled()
|
||||
&& this.note
|
||||
&& this.note.type === 'text'
|
||||
&& this.noteContext.viewScope.viewMode === 'default';
|
||||
return super.isEnabled() && this.note && this.note.type === "text" && this.noteContext.viewScope.viewMode === "default";
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@@ -17,7 +14,7 @@ export default class ShowTocWidgetButton extends OnClickButtonWidget {
|
||||
this.icon("bx-objects-horizontal-left")
|
||||
.title(t("show_toc_widget_button.show_toc"))
|
||||
.titlePlacement("bottom")
|
||||
.onClick(widget => {
|
||||
.onClick((widget) => {
|
||||
this.noteContext.viewScope.tocTemporarilyHidden = false;
|
||||
appContext.triggerEvent("showTocWidget", { noteId: this.noteId });
|
||||
this.toggleInt(false);
|
||||
@@ -35,9 +32,11 @@ export default class ShowTocWidgetButton extends OnClickButtonWidget {
|
||||
async entitiesReloadedEvent({ loadResults }) {
|
||||
if (loadResults.isNoteContentReloaded(this.noteId)) {
|
||||
await this.refresh();
|
||||
} else if (loadResults.getAttributeRows().find(attr => attr.type === 'label'
|
||||
&& (attr.name.toLowerCase().includes('readonly') || attr.name === 'toc')
|
||||
&& attributeService.isAffecting(attr, this.note))) {
|
||||
} else if (
|
||||
loadResults
|
||||
.getAttributeRows()
|
||||
.find((attr) => attr.type === "label" && (attr.name.toLowerCase().includes("readonly") || attr.name === "toc") && attributeService.isAffecting(attr, this.note))
|
||||
) {
|
||||
await this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ const TPL = `
|
||||
}
|
||||
</style>
|
||||
|
||||
<span class="bx bx-sync global-menu-button-update-available-button" title="${t('update_available.update_available')}"></span>
|
||||
<span class="bx bx-sync global-menu-button-update-available-button" title="${t("update_available.update_available")}"></span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user