mirror of
https://github.com/zadam/trilium.git
synced 2025-11-15 17:55:52 +01:00
Merge branch 'stable'
This commit is contained in:
@@ -230,6 +230,15 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
}
|
||||
|
||||
async runActiveNoteCommand(params) {
|
||||
if (this.isNoteContext(params.ntxId)) {
|
||||
// make sure that script is saved before running it #4028
|
||||
await this.spacedUpdate.updateNowIfNecessary();
|
||||
}
|
||||
|
||||
return await this.parent.triggerCommand('runActiveNote', params);
|
||||
}
|
||||
|
||||
async printActiveNoteEvent() {
|
||||
if (!this.noteContext.isActive()) {
|
||||
return;
|
||||
|
||||
@@ -93,11 +93,11 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
||||
});
|
||||
|
||||
this.$iconCategory = this.$widget.find("select[name='icon-category']");
|
||||
this.$iconCategory.on('change', () => this.renderFilteredDropdown());
|
||||
this.$iconCategory.on('change', () => this.renderDropdown());
|
||||
this.$iconCategory.on('click', e => e.stopPropagation());
|
||||
|
||||
this.$iconSearch = this.$widget.find("input[name='icon-search']");
|
||||
this.$iconSearch.on('input', () => this.renderFilteredDropdown());
|
||||
this.$iconSearch.on('input', () => this.renderDropdown());
|
||||
|
||||
this.$notePathList = this.$widget.find(".note-path-list");
|
||||
this.$widget.on('show.bs.dropdown', async () => {
|
||||
@@ -140,15 +140,9 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
}
|
||||
|
||||
renderFilteredDropdown() {
|
||||
const categoryId = parseInt(this.$iconCategory.find('option:selected').val());
|
||||
const search = this.$iconSearch.val();
|
||||
|
||||
this.renderDropdown(categoryId, search);
|
||||
}
|
||||
|
||||
async renderDropdown(categoryId, search) {
|
||||
const iconToCountPromise = this.getIconToCountMap();
|
||||
async renderDropdown() {
|
||||
const iconToCount = await this.getIconToCountMap();
|
||||
const {icons} = (await import('./icon_list.js')).default;
|
||||
|
||||
this.$iconList.empty();
|
||||
|
||||
@@ -164,9 +158,8 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
||||
);
|
||||
}
|
||||
|
||||
const {icons} = (await import('./icon_list.js')).default;
|
||||
|
||||
search = search?.trim()?.toLowerCase();
|
||||
const categoryId = parseInt(this.$iconCategory.find('option:selected').val());
|
||||
const search = this.$iconSearch.val().trim().toLowerCase();
|
||||
|
||||
const filteredIcons = icons.filter(icon => {
|
||||
if (categoryId && icon.category_id !== categoryId) {
|
||||
@@ -182,8 +175,6 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
||||
return true;
|
||||
});
|
||||
|
||||
const iconToCount = await iconToCountPromise;
|
||||
|
||||
filteredIcons.sort((a, b) => {
|
||||
const countA = iconToCount[a.className] || 0;
|
||||
const countB = iconToCount[b.className] || 0;
|
||||
@@ -199,9 +190,12 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
async getIconToCountMap() {
|
||||
const {iconClassToCountMap} = await server.get('other/icon-usage');
|
||||
if (!this.iconToCountCache) {
|
||||
this.iconToCountCache = server.get('other/icon-usage');
|
||||
setTimeout(() => this.iconToCountCache = null, 20000); // invalidate cache after 20 seconds
|
||||
}
|
||||
|
||||
return iconClassToCountMap;
|
||||
return (await this.iconToCountCache).iconClassToCountMap;
|
||||
}
|
||||
|
||||
renderIcon(icon) {
|
||||
|
||||
@@ -285,6 +285,8 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
||||
})
|
||||
|
||||
const content = {
|
||||
type: "excalidraw",
|
||||
version: 2,
|
||||
_meta: "This note has type `canvas`. It uses excalidraw and stores an exported svg alongside.",
|
||||
elements, // excalidraw
|
||||
appState, // excalidraw
|
||||
|
||||
@@ -185,14 +185,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
async doRefresh(note) {
|
||||
const noteComplement = await froca.getNoteComplement(note.noteId);
|
||||
|
||||
await this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||
// https://github.com/zadam/trilium/issues/3914
|
||||
// todo: quite hacky, but it works. remove it if ckeditor has fixed it.
|
||||
this.$editor.trigger('focus');
|
||||
this.$editor.trigger('blur')
|
||||
|
||||
this.watchdog.editor.setData(noteComplement.content || "");
|
||||
});
|
||||
await this.spacedUpdate.allowUpdateWithoutChange(() =>
|
||||
this.watchdog.editor.setData(noteComplement.content || ""));
|
||||
}
|
||||
|
||||
getData() {
|
||||
|
||||
Reference in New Issue
Block a user