mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	drag & drop from tree will insert links to notes, closes #227
This commit is contained in:
		| @@ -13,6 +13,7 @@ import appContext from "../services/app_context.js"; | |||||||
| import keyboardActionsService from "../services/keyboard_actions.js"; | import keyboardActionsService from "../services/keyboard_actions.js"; | ||||||
| import clipboard from "../services/clipboard.js"; | import clipboard from "../services/clipboard.js"; | ||||||
| import protectedSessionService from "../services/protected_session.js"; | import protectedSessionService from "../services/protected_session.js"; | ||||||
|  | import linkService from "../services/link.js"; | ||||||
| import syncService from "../services/sync.js"; | import syncService from "../services/sync.js"; | ||||||
| import options from "../services/options.js"; | import options from "../services/options.js"; | ||||||
| import protectedSessionHolder from "../services/protected_session_holder.js"; | import protectedSessionHolder from "../services/protected_session_holder.js"; | ||||||
| @@ -393,6 +394,18 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|                         title: node.title |                         title: node.title | ||||||
|                     })); |                     })); | ||||||
|  |  | ||||||
|  |                     if (notes.length === 1) { | ||||||
|  |                         linkService.createNoteLink(notes[0].noteId, {referenceLink: true}) | ||||||
|  |                             .then($link => data.dataTransfer.setData("text/html", $link[0].outerHTML)); | ||||||
|  |                     } | ||||||
|  |                     else { | ||||||
|  |                         Promise.all(notes.map(note => linkService.createNoteLink(note.noteId, {referenceLink: true}))).then(links => { | ||||||
|  |                             const $list = $("<ul>").append(...links.map($link => $("<li>").append($link))); | ||||||
|  |  | ||||||
|  |                             data.dataTransfer.setData("text/html", $list[0].outerHTML); | ||||||
|  |                         }); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|                     data.dataTransfer.setData("text", JSON.stringify(notes)); |                     data.dataTransfer.setData("text", JSON.stringify(notes)); | ||||||
|                     return true; // allow dragging to start |                     return true; // allow dragging to start | ||||||
|                 }, |                 }, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user