expose note hoisting to frontend API, closes #663

This commit is contained in:
zadam
2019-10-21 21:22:53 +02:00
parent f0496cb42c
commit 132360b46b
6 changed files with 226 additions and 47 deletions
@@ -10,6 +10,7 @@ import protectedSessionService from './protected_session.js';
import dateNotesService from './date_notes.js';
import StandardWidget from '../widgets/standard_widget.js';
import ws from "./ws.js";
import hoistedNoteService from "./hoisted_note.js";
/**
* This is the main frontend API interface for scripts. It's published in the local "api" object.
@@ -353,6 +354,15 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
* @return {Promise<NoteShort>}
*/
this.getYearNote = dateNotesService.getYearNote;
/**
* Hoist note. See https://github.com/zadam/trilium/wiki/Note-hoisting
*
* @method
* @param {string} noteId - set hoisted note. 'root' will effectively unhoist
* @return {Promise}
*/
this.setHoistedNoteId = hoistedNoteService.setHoistedNoteId;
}
export default FrontendScriptApi;
@@ -411,11 +411,13 @@ class TabContext {
}
async remove() {
// sometimes there are orphan autocompletes after closing the tab
this.cleanup();
if (this.$tabContent) {
// sometimes there are orphan autocompletes after closing the tab
this.cleanup();
await this.saveNoteIfChanged();
this.$tabContent.remove();
await this.saveNoteIfChanged();
this.$tabContent.remove();
}
}
cleanup() {