mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	dragging notes from note tree will automatically insert them as images where appropriate (image, canvas, mermaid)
This commit is contained in:
		
							parent
							
								
									686af0c6a1
								
							
						
					
					
						commit
						93dcce2217
					
				@ -42,6 +42,7 @@ async function createLink(notePath, options = {}) {
 | 
			
		||||
    const showNotePath = options.showNotePath === undefined ? false : options.showNotePath;
 | 
			
		||||
    const showNoteIcon = options.showNoteIcon === undefined ? false : options.showNoteIcon;
 | 
			
		||||
    const referenceLink = options.referenceLink === undefined ? false : options.referenceLink;
 | 
			
		||||
    const autoConvertToImage = options.autoConvertToImage === undefined ? false : options.autoConvertToImage;
 | 
			
		||||
 | 
			
		||||
    const { noteId, parentNoteId } = treeService.getNoteIdAndParentIdFromUrl(notePath);
 | 
			
		||||
    const viewScope = options.viewScope || {};
 | 
			
		||||
@ -58,6 +59,16 @@ async function createLink(notePath, options = {}) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const note = await froca.getNote(noteId);
 | 
			
		||||
 | 
			
		||||
    if (autoConvertToImage && ['image', 'canvas', 'mermaid'].includes(note.type) && viewMode === 'default') {
 | 
			
		||||
        const encodedTitle = encodeURIComponent(linkTitle);
 | 
			
		||||
 | 
			
		||||
        return $("<img>")
 | 
			
		||||
            .attr("src", `api/images/${noteId}/${encodedTitle}?${Math.random()}`)
 | 
			
		||||
            .attr("alt", linkTitle);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const $container = $("<span>");
 | 
			
		||||
 | 
			
		||||
    if (showNoteIcon) {
 | 
			
		||||
 | 
			
		||||
@ -402,11 +402,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
 | 
			
		||||
                    }));
 | 
			
		||||
 | 
			
		||||
                    if (notes.length === 1) {
 | 
			
		||||
                        linkService.createLink(notes[0].noteId, {referenceLink: true})
 | 
			
		||||
                        linkService.createLink(notes[0].noteId, {referenceLink: true, autoConvertToImage: true})
 | 
			
		||||
                            .then($link => data.dataTransfer.setData("text/html", $link[0].outerHTML));
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        Promise.all(notes.map(note => linkService.createLink(note.noteId, {referenceLink: true}))).then(links => {
 | 
			
		||||
                        Promise.all(notes.map(note => linkService.createLink(note.noteId, {referenceLink: true, autoConvertToImage: true}))).then(links => {
 | 
			
		||||
                            const $list = $("<ul>").append(...links.map($link => $("<li>").append($link)));
 | 
			
		||||
 | 
			
		||||
                            data.dataTransfer.setData("text/html", $list[0].outerHTML);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user