diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js index 1c4de84ce..4196cbb78 100644 --- a/src/public/javascripts/services/note_detail.js +++ b/src/public/javascripts/services/note_detail.js @@ -76,6 +76,22 @@ function getActiveEditor() { } } +async function activateOrOpenNote(noteId) { + for (const tabContext of tabContexts) { + if (tabContext.note && tabContext.note.noteId === noteId) { + await tabContext.activate(); + return; + } + } + + // if no tab with this note has been found we'll create new tab + + await loadNoteDetail(noteId, { + newTab: true, + activate: true + }); +} + function getTabContexts() { return tabContexts; } @@ -544,6 +560,7 @@ export default { getTabContexts, getActiveTabContext, getActiveEditor, + activateOrOpenNote, clearOpenTabsTask, filterTabs, openEmptyTab, diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 7bcd09a61..d17773279 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -713,10 +713,7 @@ messagingService.subscribeToMessages(message => { reload(); } else if (message.type === 'open-note') { - noteDetailService.loadNoteDetail(message.noteId, { - newTab: true, - activate: true - }); + noteDetailService.activateOrOpenNote(message.noteId); if (utils.isElectron()) { const currentWindow = require("electron").remote.getCurrentWindow(); diff --git a/src/routes/api/clipper.js b/src/routes/api/clipper.js index 273591d7f..38cf6e1d2 100644 --- a/src/routes/api/clipper.js +++ b/src/routes/api/clipper.js @@ -38,7 +38,7 @@ async function addClipping(req) { const rewrittenContent = await addImagesToNote(images, clippingNote, content); - await clippingNote.setContent(await clippingNote.getContent() + rewrittenContent); + await clippingNote.setContent(await clippingNote.getContent() + '

' + rewrittenContent + '

'); return { noteId: clippingNote.noteId