diff --git a/src/public/javascripts/widgets/type_widgets/abstract_text_type_widget.js b/src/public/javascripts/widgets/type_widgets/abstract_text_type_widget.js new file mode 100644 index 000000000..9ab1cab56 --- /dev/null +++ b/src/public/javascripts/widgets/type_widgets/abstract_text_type_widget.js @@ -0,0 +1,57 @@ +import TypeWidget from "./type_widget.js"; +import appContext from "../../services/app_context.js"; +import treeCache from "../../services/tree_cache.js"; +import linkService from "../../services/link.js"; +import noteContentRenderer from "../../services/note_content_renderer.js"; + +export default class AbstractTextTypeWidget extends TypeWidget { + doRender() { + this.$widget.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]; + + appContext.tabManager.getActiveTabContext().setNote(noteId); + } + else { + window.open(src, '_blank'); + } + }); + } + + async loadIncludedNote(noteId, $el) { + const note = await treeCache.getNote(noteId); + + if (note) { + $el.empty().append($("