mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
renamed currentNote to activeNote to be consistent with frontend API
This commit is contained in:
parent
0d0464549f
commit
ef40c66344
@ -49,7 +49,7 @@ window.glob.noteChanged = noteDetailService.noteChanged;
|
||||
window.glob.refreshTree = treeService.reload;
|
||||
|
||||
// required for ESLint plugin
|
||||
window.glob.getCurrentNote = noteDetailService.getCurrentNote;
|
||||
window.glob.getActiveNote = noteDetailService.getActiveNote;
|
||||
window.glob.requireLibrary = libraryLoader.requireLibrary;
|
||||
window.glob.ESLINT = libraryLoader.ESLINT;
|
||||
|
||||
|
@ -27,7 +27,7 @@ function setLinkType(linkType) {
|
||||
async function showDialog() {
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
if (noteDetailService.getCurrentNoteType() === 'text') {
|
||||
if (noteDetailService.getActiveNoteType() === 'text') {
|
||||
$linkTypeHtml.prop('disabled', false);
|
||||
|
||||
setLinkType('html');
|
||||
@ -99,14 +99,14 @@ $form.submit(() => {
|
||||
else if (linkType === 'selected-to-current') {
|
||||
const prefix = $clonePrefix.val();
|
||||
|
||||
cloningService.cloneNoteTo(noteId, noteDetailService.getCurrentNoteId(), prefix);
|
||||
cloningService.cloneNoteTo(noteId, noteDetailService.getActiveNoteId(), prefix);
|
||||
|
||||
$dialog.modal('hide');
|
||||
}
|
||||
else if (linkType === 'current-to-selected') {
|
||||
const prefix = $clonePrefix.val();
|
||||
|
||||
cloningService.cloneNoteTo(noteDetailService.getCurrentNoteId(), noteId, prefix);
|
||||
cloningService.cloneNoteTo(noteDetailService.getActiveNoteId(), noteId, prefix);
|
||||
|
||||
$dialog.modal('hide');
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ function AttributesModel() {
|
||||
}
|
||||
|
||||
this.loadAttributes = async function() {
|
||||
const noteId = noteDetailService.getCurrentNoteId();
|
||||
const noteId = noteDetailService.getActiveNoteId();
|
||||
|
||||
const attributes = await server.get('notes/' + noteId + '/attributes');
|
||||
|
||||
@ -136,7 +136,7 @@ function AttributesModel() {
|
||||
|
||||
self.updateAttributePositions();
|
||||
|
||||
const noteId = noteDetailService.getCurrentNoteId();
|
||||
const noteId = noteDetailService.getActiveNoteId();
|
||||
|
||||
const attributesToSave = self.ownedAttributes()
|
||||
.map(attribute => attribute())
|
||||
|
@ -13,13 +13,13 @@ function showDialog() {
|
||||
|
||||
$dialog.modal();
|
||||
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
const activeNote = noteDetailService.getActiveNote();
|
||||
|
||||
$noteId.text(currentNote.noteId);
|
||||
$utcDateCreated.text(currentNote.utcDateCreated);
|
||||
$utcDateModified.text(currentNote.utcDateModified);
|
||||
$type.text(currentNote.type);
|
||||
$mime.text(currentNote.mime);
|
||||
$noteId.text(activeNote.noteId);
|
||||
$utcDateCreated.text(activeNote.utcDateCreated);
|
||||
$utcDateModified.text(activeNote.utcDateModified);
|
||||
$type.text(activeNote.type);
|
||||
$mime.text(activeNote.mime);
|
||||
}
|
||||
|
||||
$okButton.click(() => $dialog.modal('hide'));
|
||||
|
@ -11,7 +11,7 @@ let revisionItems = [];
|
||||
let note;
|
||||
|
||||
async function showCurrentNoteRevisions() {
|
||||
await showNoteRevisionsDialog(noteDetailService.getCurrentNoteId());
|
||||
await showNoteRevisionsDialog(noteDetailService.getActiveNoteId());
|
||||
}
|
||||
|
||||
async function showNoteRevisionsDialog(noteId, noteRevisionId) {
|
||||
@ -22,7 +22,7 @@ async function showNoteRevisionsDialog(noteId, noteRevisionId) {
|
||||
$list.empty();
|
||||
$content.empty();
|
||||
|
||||
note = noteDetailService.getCurrentNote();
|
||||
note = noteDetailService.getActiveNote();
|
||||
revisionItems = await server.get('notes/' + noteId + '/revisions');
|
||||
|
||||
for (const item of revisionItems) {
|
||||
|
@ -8,7 +8,7 @@ function showDialog() {
|
||||
|
||||
$dialog.modal();
|
||||
|
||||
const noteText = noteDetailService.getCurrentNote().noteContent.content;
|
||||
const noteText = noteDetailService.getActiveNote().noteContent.content;
|
||||
|
||||
$noteSource.text(formatHtml(noteText));
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ function invalidateAttributes() {
|
||||
}
|
||||
|
||||
function reloadAttributes() {
|
||||
attributePromise = server.get('notes/' + noteDetailService.getCurrentNoteId() + '/attributes');
|
||||
attributePromise = server.get('notes/' + noteDetailService.getActiveNoteId() + '/attributes');
|
||||
}
|
||||
|
||||
async function refreshAttributes() {
|
||||
@ -40,7 +40,7 @@ async function showAttributes() {
|
||||
$attributeList.hide();
|
||||
$attributeListInner.empty();
|
||||
|
||||
const note = noteDetailService.getCurrentNote();
|
||||
const note = noteDetailService.getActiveNote();
|
||||
|
||||
const attributes = await attributePromise;
|
||||
|
||||
@ -283,7 +283,7 @@ async function promotedAttributeChanged(event) {
|
||||
value = $attr.val();
|
||||
}
|
||||
|
||||
const result = await server.put("notes/" + noteDetailService.getCurrentNoteId() + "/attribute", {
|
||||
const result = await server.put("notes/" + noteDetailService.getActiveNoteId() + "/attribute", {
|
||||
attributeId: $attr.prop("attribute-id"),
|
||||
type: $attr.prop("attribute-type"),
|
||||
name: $attr.prop("attribute-name"),
|
||||
|
@ -202,13 +202,13 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
|
||||
* @method
|
||||
* @returns {string} content of active note (loaded into right pane)
|
||||
*/
|
||||
this.getActiveNoteContent = noteDetailService.getCurrentNoteContent;
|
||||
this.getActiveNoteContent = noteDetailService.getActiveNoteContent;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @returns {NoteFull} active note (loaded into right pane)
|
||||
*/
|
||||
this.getActiveNote = noteDetailService.getCurrentNote;
|
||||
this.getActiveNote = noteDetailService.getActiveNote;
|
||||
|
||||
/**
|
||||
* This method checks whether user navigated away from the note from which the scripts has been started.
|
||||
@ -220,7 +220,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
|
||||
* @return {boolean} returns true if the original note is still loaded, false if user switched to another
|
||||
*/
|
||||
this.isNoteStillActive = () => {
|
||||
return this.originEntity.noteId === noteDetailService.getCurrentNoteId();
|
||||
return this.originEntity.noteId === noteDetailService.getActiveNoteId();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,7 @@ const SELECTED_PATH_KEY = "data-note-path";
|
||||
async function autocompleteSource(term, cb) {
|
||||
const result = await server.get('autocomplete'
|
||||
+ '?query=' + encodeURIComponent(term)
|
||||
+ '¤tNoteId=' + noteDetailService.getCurrentNoteId());
|
||||
+ '&activeNoteId=' + noteDetailService.getActiveNoteId());
|
||||
|
||||
if (result.length === 0) {
|
||||
result.push({
|
||||
|
@ -32,7 +32,7 @@ const $scriptArea = $("#note-detail-script-area");
|
||||
const $savedIndicator = $("#saved-indicator");
|
||||
const $body = $("body");
|
||||
|
||||
let currentNote = null;
|
||||
let activeNote = null;
|
||||
|
||||
let noteChangeDisabled = false;
|
||||
|
||||
@ -52,7 +52,7 @@ const components = {
|
||||
|
||||
function getComponent(type) {
|
||||
if (!type) {
|
||||
type = getCurrentNote().type;
|
||||
type = getActiveNote().type;
|
||||
}
|
||||
|
||||
if (components[type]) {
|
||||
@ -63,18 +63,18 @@ function getComponent(type) {
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentNote() {
|
||||
return currentNote;
|
||||
function getActiveNote() {
|
||||
return activeNote;
|
||||
}
|
||||
|
||||
function getCurrentNoteId() {
|
||||
return currentNote ? currentNote.noteId : null;
|
||||
function getActiveNoteId() {
|
||||
return activeNote ? activeNote.noteId : null;
|
||||
}
|
||||
|
||||
function getCurrentNoteType() {
|
||||
const currentNote = getCurrentNote();
|
||||
function getActiveNoteType() {
|
||||
const activeNote = getActiveNote();
|
||||
|
||||
return currentNote ? currentNote.type : null;
|
||||
return activeNote ? activeNote.type : null;
|
||||
}
|
||||
|
||||
function noteChanged() {
|
||||
@ -90,18 +90,18 @@ function noteChanged() {
|
||||
async function reload() {
|
||||
// no saving here
|
||||
|
||||
await loadNoteDetail(getCurrentNoteId());
|
||||
await loadNoteDetail(getActiveNoteId());
|
||||
}
|
||||
|
||||
async function switchToNote(noteId) {
|
||||
if (getCurrentNoteId() !== noteId) {
|
||||
if (getActiveNoteId() !== noteId) {
|
||||
await saveNoteIfChanged();
|
||||
|
||||
await loadNoteDetail(noteId);
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentNoteContent() {
|
||||
function getActiveNoteContent() {
|
||||
return getComponent().getContent();
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ function onNoteChange(func) {
|
||||
}
|
||||
|
||||
async function saveNote() {
|
||||
const note = getCurrentNote();
|
||||
const note = getActiveNote();
|
||||
|
||||
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||
return;
|
||||
@ -119,7 +119,7 @@ async function saveNote() {
|
||||
note.title = $noteTitle.val();
|
||||
|
||||
if (note.noteContent != null) { // might be null for file/image
|
||||
note.noteContent.content = getCurrentNoteContent(note);
|
||||
note.noteContent.content = getActiveNoteContent(note);
|
||||
}
|
||||
|
||||
// it's important to set the flag back to false immediatelly after retrieving title and content
|
||||
@ -137,7 +137,7 @@ async function saveNote() {
|
||||
$savedIndicator.fadeIn();
|
||||
|
||||
// run async
|
||||
bundleService.executeRelationBundles(getCurrentNote(), 'runOnNoteChange');
|
||||
bundleService.executeRelationBundles(getActiveNote(), 'runOnNoteChange');
|
||||
}
|
||||
|
||||
async function saveNoteIfChanged() {
|
||||
@ -150,11 +150,11 @@ async function saveNoteIfChanged() {
|
||||
}
|
||||
|
||||
function updateNoteView() {
|
||||
$noteDetailWrapper.toggleClass("protected", currentNote.isProtected);
|
||||
$protectButton.toggleClass("active", currentNote.isProtected);
|
||||
$protectButton.prop("disabled", currentNote.isProtected);
|
||||
$unprotectButton.toggleClass("active", !currentNote.isProtected);
|
||||
$unprotectButton.prop("disabled", !currentNote.isProtected || !protectedSessionHolder.isProtectedSessionAvailable());
|
||||
$noteDetailWrapper.toggleClass("protected", activeNote.isProtected);
|
||||
$protectButton.toggleClass("active", activeNote.isProtected);
|
||||
$protectButton.prop("disabled", activeNote.isProtected);
|
||||
$unprotectButton.toggleClass("active", !activeNote.isProtected);
|
||||
$unprotectButton.prop("disabled", !activeNote.isProtected || !protectedSessionHolder.isProtectedSessionAvailable());
|
||||
|
||||
for (const clazz of Array.from($body[0].classList)) { // create copy to safely iterate over while removing classes
|
||||
if (clazz.startsWith("type-") || clazz.startsWith("mime-")) {
|
||||
@ -162,14 +162,14 @@ function updateNoteView() {
|
||||
}
|
||||
}
|
||||
|
||||
$body.addClass(utils.getNoteTypeClass(currentNote.type));
|
||||
$body.addClass(utils.getMimeTypeClass(currentNote.mime));
|
||||
$body.addClass(utils.getNoteTypeClass(activeNote.type));
|
||||
$body.addClass(utils.getMimeTypeClass(activeNote.mime));
|
||||
}
|
||||
|
||||
async function handleProtectedSession() {
|
||||
const newSessionCreated = await protectedSessionService.ensureProtectedSession(currentNote.isProtected, false);
|
||||
const newSessionCreated = await protectedSessionService.ensureProtectedSession(activeNote.isProtected, false);
|
||||
|
||||
if (currentNote.isProtected) {
|
||||
if (activeNote.isProtected) {
|
||||
protectedSessionHolder.touchProtectedSession();
|
||||
}
|
||||
|
||||
@ -192,8 +192,8 @@ async function loadNoteDetail(noteId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only now that we're in sync with tree active node we will switch currentNote
|
||||
currentNote = loadedNote;
|
||||
// only now that we're in sync with tree active node we will switch activeNote
|
||||
activeNote = loadedNote;
|
||||
|
||||
if (utils.isDesktop()) {
|
||||
// needs to happen after loading the note itself because it references current noteId
|
||||
@ -211,15 +211,15 @@ async function loadNoteDetail(noteId) {
|
||||
noteChangeDisabled = true;
|
||||
|
||||
try {
|
||||
$noteTitle.val(currentNote.title);
|
||||
$noteTitle.val(activeNote.title);
|
||||
|
||||
if (utils.isDesktop()) {
|
||||
noteTypeService.setNoteType(currentNote.type);
|
||||
noteTypeService.setNoteMime(currentNote.mime);
|
||||
noteTypeService.setNoteType(activeNote.type);
|
||||
noteTypeService.setNoteMime(activeNote.mime);
|
||||
}
|
||||
|
||||
for (const componentType in components) {
|
||||
if (componentType !== currentNote.type) {
|
||||
if (componentType !== activeNote.type) {
|
||||
components[componentType].cleanup();
|
||||
}
|
||||
}
|
||||
@ -234,7 +234,7 @@ async function loadNoteDetail(noteId) {
|
||||
|
||||
$noteTitle.removeAttr("readonly"); // this can be set by protected session service
|
||||
|
||||
await getComponent(currentNote.type).show();
|
||||
await getComponent(activeNote.type).show();
|
||||
}
|
||||
finally {
|
||||
noteChangeDisabled = false;
|
||||
@ -243,13 +243,13 @@ async function loadNoteDetail(noteId) {
|
||||
treeService.setBranchBackgroundBasedOnProtectedStatus(noteId);
|
||||
|
||||
// after loading new note make sure editor is scrolled to the top
|
||||
getComponent(currentNote.type).scrollToTop();
|
||||
getComponent(activeNote.type).scrollToTop();
|
||||
|
||||
fireDetailLoaded();
|
||||
|
||||
$scriptArea.empty();
|
||||
|
||||
await bundleService.executeRelationBundles(getCurrentNote(), 'runOnNoteView');
|
||||
await bundleService.executeRelationBundles(getActiveNote(), 'runOnNoteView');
|
||||
|
||||
if (utils.isDesktop()) {
|
||||
await attributeService.showAttributes();
|
||||
@ -259,7 +259,7 @@ async function loadNoteDetail(noteId) {
|
||||
}
|
||||
|
||||
async function showChildrenOverview() {
|
||||
const note = getCurrentNote();
|
||||
const note = getActiveNote();
|
||||
const attributes = await attributeService.getAttributes();
|
||||
const hideChildrenOverview = attributes.some(attr => attr.type === 'label' && attr.name === 'hideChildrenOverview')
|
||||
|| note.type === 'relation-map'
|
||||
@ -273,7 +273,7 @@ async function showChildrenOverview() {
|
||||
|
||||
$childrenOverview.empty();
|
||||
|
||||
const notePath = treeService.getCurrentNotePath();
|
||||
const notePath = treeService.getActiveNotePath();
|
||||
|
||||
for (const childBranch of await note.getChildBranches()) {
|
||||
const link = $('<a>', {
|
||||
@ -317,7 +317,7 @@ function addDetailLoadedListener(noteId, callback) {
|
||||
|
||||
function fireDetailLoaded() {
|
||||
for (const {noteId, callback} of detailLoadedListeners) {
|
||||
if (noteId === currentNote.noteId) {
|
||||
if (noteId === activeNote.noteId) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
@ -327,7 +327,7 @@ function fireDetailLoaded() {
|
||||
}
|
||||
|
||||
messagingService.subscribeToSyncMessages(syncData => {
|
||||
if (syncData.some(sync => sync.entityName === 'notes' && sync.entityId === getCurrentNoteId())) {
|
||||
if (syncData.some(sync => sync.entityName === 'notes' && sync.entityId === getActiveNoteId())) {
|
||||
infoService.showMessage('Reloading note because of background changes');
|
||||
|
||||
reload();
|
||||
@ -339,7 +339,7 @@ $noteDetailWrapper.on("dragover", e => e.preventDefault());
|
||||
$noteDetailWrapper.on("dragleave", e => e.preventDefault());
|
||||
|
||||
$noteDetailWrapper.on("drop", e => {
|
||||
importDialog.uploadFiles(getCurrentNoteId(), e.originalEvent.dataTransfer.files, {
|
||||
importDialog.uploadFiles(getActiveNoteId(), e.originalEvent.dataTransfer.files, {
|
||||
safeImport: true,
|
||||
shrinkImages: true,
|
||||
textImportedAsText: true,
|
||||
@ -354,7 +354,7 @@ $(document).ready(() => {
|
||||
|
||||
const title = $noteTitle.val();
|
||||
|
||||
treeService.setNoteTitle(getCurrentNoteId(), title);
|
||||
treeService.setNoteTitle(getActiveNoteId(), title);
|
||||
});
|
||||
|
||||
noteDetailText.focus();
|
||||
@ -371,10 +371,10 @@ export default {
|
||||
switchToNote,
|
||||
updateNoteView,
|
||||
loadNote,
|
||||
getCurrentNote,
|
||||
getCurrentNoteContent,
|
||||
getCurrentNoteType,
|
||||
getCurrentNoteId,
|
||||
getActiveNote,
|
||||
getActiveNoteContent,
|
||||
getActiveNoteType,
|
||||
getActiveNoteId,
|
||||
focusOnTitle,
|
||||
focusAndSelectTitle,
|
||||
saveNote,
|
||||
|
@ -44,14 +44,14 @@ async function show() {
|
||||
|
||||
$component.show();
|
||||
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
const activeNote = noteDetailService.getActiveNote();
|
||||
|
||||
// this needs to happen after the element is shown, otherwise the editor won't be refreshed
|
||||
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
|
||||
// we provide fallback
|
||||
codeEditor.setValue(currentNote.noteContent.content || "");
|
||||
codeEditor.setValue(activeNote.noteContent.content || "");
|
||||
|
||||
const info = CodeMirror.findModeByMIME(currentNote.mime);
|
||||
const info = CodeMirror.findModeByMIME(activeNote.mime);
|
||||
|
||||
if (info) {
|
||||
codeEditor.setOption("mode", info.mime);
|
||||
@ -71,21 +71,21 @@ function focus() {
|
||||
|
||||
async function executeCurrentNote() {
|
||||
// ctrl+enter is also used elsewhere so make sure we're running only when appropriate
|
||||
if (noteDetailService.getCurrentNoteType() !== 'code') {
|
||||
if (noteDetailService.getActiveNoteType() !== 'code') {
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure note is saved so we load latest changes
|
||||
await noteDetailService.saveNoteIfChanged();
|
||||
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
const activeNote = noteDetailService.getActiveNote();
|
||||
|
||||
if (currentNote.mime.endsWith("env=frontend")) {
|
||||
await bundleService.getAndExecuteBundle(noteDetailService.getCurrentNoteId());
|
||||
if (activeNote.mime.endsWith("env=frontend")) {
|
||||
await bundleService.getAndExecuteBundle(noteDetailService.getActiveNoteId());
|
||||
}
|
||||
|
||||
if (currentNote.mime.endsWith("env=backend")) {
|
||||
await server.post('script/run/' + noteDetailService.getCurrentNoteId());
|
||||
if (activeNote.mime.endsWith("env=backend")) {
|
||||
await server.post('script/run/' + noteDetailService.getActiveNoteId());
|
||||
}
|
||||
|
||||
infoService.showMessage("Note executed");
|
||||
|
@ -15,21 +15,21 @@ const $downloadButton = $("#file-download");
|
||||
const $openButton = $("#file-open");
|
||||
|
||||
async function show() {
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
const activeNote = noteDetailService.getActiveNote();
|
||||
|
||||
const attributes = await server.get('notes/' + currentNote.noteId + '/attributes');
|
||||
const attributes = await server.get('notes/' + activeNote.noteId + '/attributes');
|
||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||
|
||||
$component.show();
|
||||
|
||||
$fileNoteId.text(currentNote.noteId);
|
||||
$fileNoteId.text(activeNote.noteId);
|
||||
$fileName.text(attributeMap.originalFileName || "?");
|
||||
$fileSize.text((attributeMap.fileSize || "?") + " bytes");
|
||||
$fileType.text(currentNote.mime);
|
||||
$fileType.text(activeNote.mime);
|
||||
|
||||
if (currentNote.noteContent && currentNote.noteContent.content) {
|
||||
if (activeNote.noteContent && activeNote.noteContent.content) {
|
||||
$previewRow.show();
|
||||
$previewContent.text(currentNote.noteContent.content);
|
||||
$previewContent.text(activeNote.noteContent.content);
|
||||
}
|
||||
else {
|
||||
$previewRow.hide();
|
||||
@ -51,7 +51,7 @@ $openButton.click(() => {
|
||||
|
||||
function getFileUrl() {
|
||||
// electron needs absolute URL so we extract current host, port, protocol
|
||||
return utils.getHost() + "/api/notes/" + noteDetailService.getCurrentNoteId();
|
||||
return utils.getHost() + "/api/notes/" + noteDetailService.getActiveNoteId();
|
||||
}
|
||||
|
||||
export default {
|
||||
|
@ -15,18 +15,18 @@ const $fileType = $("#image-filetype");
|
||||
const $fileSize = $("#image-filesize");
|
||||
|
||||
async function show() {
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
const activeNote = noteDetailService.getActiveNote();
|
||||
|
||||
const attributes = await server.get('notes/' + currentNote.noteId + '/attributes');
|
||||
const attributes = await server.get('notes/' + activeNote.noteId + '/attributes');
|
||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||
|
||||
$component.show();
|
||||
|
||||
$fileName.text(attributeMap.originalFileName || "?");
|
||||
$fileSize.text((attributeMap.fileSize || "?") + " bytes");
|
||||
$fileType.text(currentNote.mime);
|
||||
$fileType.text(activeNote.mime);
|
||||
|
||||
$imageView.prop("src", `api/images/${currentNote.noteId}/${currentNote.title}`);
|
||||
$imageView.prop("src", `api/images/${activeNote.noteId}/${activeNote.title}`);
|
||||
}
|
||||
|
||||
$imageDownloadButton.click(() => utils.download(getFileUrl()));
|
||||
@ -62,7 +62,7 @@ $copyToClipboardButton.click(() => {
|
||||
|
||||
function getFileUrl() {
|
||||
// electron needs absolute URL so we extract current host, port, protocol
|
||||
return utils.getHost() + "/api/notes/" + noteDetailService.getCurrentNoteId() + "/download";
|
||||
return utils.getHost() + "/api/notes/" + noteDetailService.getActiveNoteId() + "/download";
|
||||
}
|
||||
|
||||
export default {
|
||||
|
@ -79,7 +79,7 @@ const linkOverlays = [
|
||||
];
|
||||
|
||||
function loadMapData() {
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
const activeNote = noteDetailService.getActiveNote();
|
||||
mapData = {
|
||||
notes: [],
|
||||
// it is important to have this exact value here so that initial transform is same as this
|
||||
@ -93,9 +93,9 @@ function loadMapData() {
|
||||
}
|
||||
};
|
||||
|
||||
if (currentNote.noteContent.content) {
|
||||
if (activeNote.noteContent.content) {
|
||||
try {
|
||||
mapData = JSON.parse(currentNote.noteContent.content);
|
||||
mapData = JSON.parse(activeNote.noteContent.content);
|
||||
} catch (e) {
|
||||
console.log("Could not parse content: ", e);
|
||||
}
|
||||
@ -507,7 +507,7 @@ $createChildNote.click(async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const {note} = await server.post(`notes/${noteDetailService.getCurrentNoteId()}/children`, {
|
||||
const {note} = await server.post(`notes/${noteDetailService.getActiveNoteId()}/children`, {
|
||||
title,
|
||||
target: 'into'
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ async function render() {
|
||||
|
||||
$noteDetailRenderContent.append(bundle.html);
|
||||
|
||||
await bundleService.executeBundle(bundle, noteDetailService.getCurrentNote());
|
||||
await bundleService.executeBundle(bundle, noteDetailService.getActiveNote());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,10 @@ const $refreshButton = $('#note-detail-search-refresh-results-button');
|
||||
function show() {
|
||||
$component.show();
|
||||
|
||||
console.log(noteDetailService.getCurrentNote());
|
||||
console.log(noteDetailService.getActiveNote());
|
||||
|
||||
try {
|
||||
const json = JSON.parse(noteDetailService.getCurrentNote().noteContent.content);
|
||||
const json = JSON.parse(noteDetailService.getActiveNote().noteContent.content);
|
||||
|
||||
$searchString.val(json.searchString);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ async function show() {
|
||||
|
||||
$component.show();
|
||||
|
||||
textEditor.setData(noteDetailService.getCurrentNote().noteContent.content);
|
||||
textEditor.setData(noteDetailService.getActiveNote().noteContent.content);
|
||||
}
|
||||
|
||||
function getContent() {
|
||||
|
@ -97,7 +97,7 @@ function NoteTypeModel() {
|
||||
};
|
||||
|
||||
async function save() {
|
||||
const note = noteDetailService.getCurrentNote();
|
||||
const note = noteDetailService.getActiveNote();
|
||||
|
||||
await server.put('notes/' + note.noteId
|
||||
+ '/type/' + encodeURIComponent(self.type())
|
||||
@ -112,7 +112,7 @@ function NoteTypeModel() {
|
||||
}
|
||||
|
||||
function confirmChangeIfContent() {
|
||||
if (!noteDetailService.getCurrentNoteContent()) {
|
||||
if (!noteDetailService.getActiveNoteContent()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -112,13 +112,13 @@ async function enterProtectedSessionOnServer(password) {
|
||||
}
|
||||
|
||||
async function protectNoteAndSendToServer() {
|
||||
if (noteDetailService.getCurrentNote().isProtected) {
|
||||
if (noteDetailService.getActiveNote().isProtected) {
|
||||
return;
|
||||
}
|
||||
|
||||
await ensureProtectedSession(true, true);
|
||||
|
||||
const note = noteDetailService.getCurrentNote();
|
||||
const note = noteDetailService.getActiveNote();
|
||||
note.isProtected = true;
|
||||
|
||||
await noteDetailService.saveNote(note);
|
||||
@ -129,10 +129,10 @@ async function protectNoteAndSendToServer() {
|
||||
}
|
||||
|
||||
async function unprotectNoteAndSendToServer() {
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
const activeNote = noteDetailService.getActiveNote();
|
||||
|
||||
if (!currentNote.isProtected) {
|
||||
infoService.showAndLogError(`Note ${currentNote.noteId} is not protected`);
|
||||
if (!activeNote.isProtected) {
|
||||
infoService.showAndLogError(`Note ${activeNote.noteId} is not protected`);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -146,11 +146,11 @@ async function unprotectNoteAndSendToServer() {
|
||||
return;
|
||||
}
|
||||
|
||||
currentNote.isProtected = false;
|
||||
activeNote.isProtected = false;
|
||||
|
||||
await noteDetailService.saveNote(currentNote);
|
||||
await noteDetailService.saveNote(activeNote);
|
||||
|
||||
treeService.setProtected(currentNote.noteId, currentNote.isProtected);
|
||||
treeService.setProtected(activeNote.noteId, activeNote.isProtected);
|
||||
|
||||
noteDetailService.updateNoteView();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ function getCurrentNode() {
|
||||
return $tree.fancytree("getActiveNode");
|
||||
}
|
||||
|
||||
function getCurrentNotePath() {
|
||||
function getActiveNotePath() {
|
||||
const node = getCurrentNode();
|
||||
|
||||
return treeUtils.getNotePath(node);
|
||||
@ -330,7 +330,7 @@ async function setExpandedToServer(branchId, isExpanded) {
|
||||
function addRecentNote(branchId, notePath) {
|
||||
setTimeout(async () => {
|
||||
// we include the note into recent list only if the user stayed on the note at least 5 seconds
|
||||
if (notePath && notePath === getCurrentNotePath()) {
|
||||
if (notePath && notePath === getActiveNotePath()) {
|
||||
await server.post('recent-notes', { branchId, notePath });
|
||||
}
|
||||
}, 1500);
|
||||
@ -339,12 +339,12 @@ function addRecentNote(branchId, notePath) {
|
||||
function setCurrentNotePathToHash(node) {
|
||||
utils.assertArguments(node);
|
||||
|
||||
const currentNotePath = treeUtils.getNotePath(node);
|
||||
const activeNotePath = treeUtils.getNotePath(node);
|
||||
const currentBranchId = node.data.branchId;
|
||||
|
||||
document.location.hash = currentNotePath;
|
||||
document.location.hash = activeNotePath;
|
||||
|
||||
addRecentNote(currentBranchId, currentNotePath);
|
||||
addRecentNote(currentBranchId, activeNotePath);
|
||||
}
|
||||
|
||||
function getSelectedNodes(stopOnParents = false) {
|
||||
@ -563,7 +563,7 @@ async function createNote(node, parentNoteId, target, isProtected, saveSelection
|
||||
isProtected = false;
|
||||
}
|
||||
|
||||
if (noteDetailService.getCurrentNoteType() !== 'text') {
|
||||
if (noteDetailService.getActiveNoteType() !== 'text') {
|
||||
saveSelection = false;
|
||||
}
|
||||
else {
|
||||
@ -714,7 +714,7 @@ $(window).bind('hashchange', function() {
|
||||
if (isNotePathInAddress()) {
|
||||
const notePath = getHashValueFromAddress();
|
||||
|
||||
if (notePath !== '-' && getCurrentNotePath() !== notePath) {
|
||||
if (notePath !== '-' && getActiveNotePath() !== notePath) {
|
||||
console.debug("Switching to " + notePath + " because of hash change");
|
||||
|
||||
activateNote(notePath);
|
||||
@ -738,7 +738,7 @@ export default {
|
||||
activateNote,
|
||||
getFocusedNode,
|
||||
getCurrentNode,
|
||||
getCurrentNotePath,
|
||||
getActiveNotePath,
|
||||
setCurrentNotePathToHash,
|
||||
setNoteTitle,
|
||||
setPrefix,
|
||||
|
@ -8,14 +8,14 @@ const optionService = require('../../services/options');
|
||||
|
||||
async function getAutocomplete(req) {
|
||||
const query = req.query.query;
|
||||
const currentNoteId = req.query.currentNoteId || 'none';
|
||||
const activeNoteId = req.query.activeNoteId || 'none';
|
||||
|
||||
let results;
|
||||
|
||||
const timestampStarted = Date.now();
|
||||
|
||||
if (query.trim().length === 0) {
|
||||
results = await getRecentNotes(currentNoteId);
|
||||
results = await getRecentNotes(activeNoteId);
|
||||
}
|
||||
else {
|
||||
results = await noteCacheService.findNotes(query);
|
||||
@ -30,7 +30,7 @@ async function getAutocomplete(req) {
|
||||
return results;
|
||||
}
|
||||
|
||||
async function getRecentNotes(currentNoteId) {
|
||||
async function getRecentNotes(activeNoteId) {
|
||||
let extraCondition = '';
|
||||
|
||||
const hoistedNoteId = await optionService.getOption('hoistedNoteId');
|
||||
@ -51,7 +51,7 @@ async function getRecentNotes(currentNoteId) {
|
||||
${extraCondition}
|
||||
ORDER BY
|
||||
utcDateCreated DESC
|
||||
LIMIT 200`, [currentNoteId]);
|
||||
LIMIT 200`, [activeNoteId]);
|
||||
|
||||
return recentNotes.map(rn => {
|
||||
const title = noteCacheService.getNoteTitleForPath(rn.notePath.split('/'));
|
||||
|
@ -22,7 +22,7 @@ const appInfo = require('./app_info');
|
||||
function BackendScriptApi(currentNote, apiParams) {
|
||||
/** @property {Note} note where script started executing */
|
||||
this.startNote = apiParams.startNote;
|
||||
/** @property {Note} note where script is currently executing */
|
||||
/** @property {Note} note where script is currently executing. Don't mix this up with concept of active note */
|
||||
this.currentNote = currentNote;
|
||||
/** @property {Entity} entity whose event triggered this executions */
|
||||
this.originEntity = apiParams.originEntity;
|
||||
|
Loading…
x
Reference in New Issue
Block a user