From efc5cf4091e8afdf1bda78bf9f5a025e15884c4f Mon Sep 17 00:00:00 2001 From: azivner Date: Thu, 15 Nov 2018 14:51:09 +0100 Subject: [PATCH] Doubleclick on the image will take you to that image note, closes #236 --- .../javascripts/services/note_detail_text.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/public/javascripts/services/note_detail_text.js b/src/public/javascripts/services/note_detail_text.js index 8a8393427..64da5085a 100644 --- a/src/public/javascripts/services/note_detail_text.js +++ b/src/public/javascripts/services/note_detail_text.js @@ -1,5 +1,6 @@ import libraryLoader from "./library_loader.js"; import noteDetailService from './note_detail.js'; +import treeService from './tree.js'; const $component = $('#note-detail-text'); @@ -47,6 +48,22 @@ function onNoteChange(func) { textEditor.model.document.on('change:data', func); } +$component.on("dblclick", "img", e => { + const $img = $(e.target); + const src = $img.prop("src"); + + const match = src.match(/\/api\/images\/([A-Za-z0-9]+)\//); + + if (match) { + const noteId = match[1]; + + treeService.activateNote(noteId); + } + else { + window.open(src, '_blank'); + } +}); + export default { show, getEditor,