File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ async function createLink(notePath, options = {}) {
42
42
const showNotePath = options . showNotePath === undefined ? false : options . showNotePath ;
43
43
const showNoteIcon = options . showNoteIcon === undefined ? false : options . showNoteIcon ;
44
44
const referenceLink = options . referenceLink === undefined ? false : options . referenceLink ;
45
+ const autoConvertToImage = options . autoConvertToImage === undefined ? false : options . autoConvertToImage ;
45
46
46
47
const { noteId, parentNoteId } = treeService . getNoteIdAndParentIdFromUrl ( notePath ) ;
47
48
const viewScope = options . viewScope || { } ;
@@ -58,6 +59,16 @@ async function createLink(notePath, options = {}) {
58
59
}
59
60
}
60
61
62
+ const note = await froca . getNote ( noteId ) ;
63
+
64
+ if ( autoConvertToImage && [ 'image' , 'canvas' , 'mermaid' ] . includes ( note . type ) && viewMode === 'default' ) {
65
+ const encodedTitle = encodeURIComponent ( linkTitle ) ;
66
+
67
+ return $ ( "<img>" )
68
+ . attr ( "src" , `api/images/${ noteId } /${ encodedTitle } ?${ Math . random ( ) } ` )
69
+ . attr ( "alt" , linkTitle ) ;
70
+ }
71
+
61
72
const $container = $ ( "<span>" ) ;
62
73
63
74
if ( showNoteIcon ) {
Original file line number Diff line number Diff line change @@ -402,11 +402,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
402
402
} ) ) ;
403
403
404
404
if ( notes . length === 1 ) {
405
- linkService . createLink ( notes [ 0 ] . noteId , { referenceLink : true } )
405
+ linkService . createLink ( notes [ 0 ] . noteId , { referenceLink : true , autoConvertToImage : true } )
406
406
. then ( $link => data . dataTransfer . setData ( "text/html" , $link [ 0 ] . outerHTML ) ) ;
407
407
}
408
408
else {
409
- Promise . all ( notes . map ( note => linkService . createLink ( note . noteId , { referenceLink : true } ) ) ) . then ( links => {
409
+ Promise . all ( notes . map ( note => linkService . createLink ( note . noteId , { referenceLink : true , autoConvertToImage : true } ) ) ) . then ( links => {
410
410
const $list = $ ( "<ul>" ) . append ( ...links . map ( $link => $ ( "<li>" ) . append ( $link ) ) ) ;
411
411
412
412
data . dataTransfer . setData ( "text/html" , $list [ 0 ] . outerHTML ) ;
You can’t perform that action at this time.
0 commit comments