mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Electron: Resolves #820: Allow dragging and dropping a note in another note to create a link
This commit is contained in:
parent
0cd7ebf9d3
commit
6ea77b36ce
@ -142,7 +142,20 @@ class NoteTextComponent extends React.Component {
|
||||
}
|
||||
|
||||
this.onDrop_ = async (event) => {
|
||||
const files = event.dataTransfer.files;
|
||||
const dt = event.dataTransfer;
|
||||
|
||||
if (dt.types.indexOf("text/x-jop-note-ids") >= 0) {
|
||||
const noteIds = JSON.parse(dt.getData("text/x-jop-note-ids"));
|
||||
const linkText = [];
|
||||
for (let i = 0; i < noteIds.length; i++) {
|
||||
const note = await Note.load(noteIds[i]);
|
||||
linkText.push(Note.markdownTag(note));
|
||||
}
|
||||
|
||||
this.wrapSelectionWithStrings("", "", '', linkText.join('\n'));
|
||||
}
|
||||
|
||||
const files = dt.files;
|
||||
if (!files || !files.length) return;
|
||||
|
||||
const filesToAttach = [];
|
||||
@ -1025,6 +1038,9 @@ class NoteTextComponent extends React.Component {
|
||||
end: { row: p.row, column: p.column + middleText.length },
|
||||
};
|
||||
|
||||
// BUG!! If replacementText contains newline characters, the logic
|
||||
// to select the new text will not work.
|
||||
|
||||
this.updateEditorWithDelay((editor) => {
|
||||
if (middleText && newRange) {
|
||||
const range = this.selectionRange_;
|
||||
|
@ -663,7 +663,12 @@ class BaseItem extends BaseModel {
|
||||
return super.save(o, options);
|
||||
}
|
||||
|
||||
static markdownTag(item) {
|
||||
static markdownTag(itemOrId) {
|
||||
const item = typeof itemOrId === 'object' ? itemOrId : {
|
||||
id: itemOrId,
|
||||
title: '',
|
||||
};
|
||||
|
||||
const output = [];
|
||||
output.push('[');
|
||||
output.push(markdownUtils.escapeLinkText(item.title));
|
||||
|
Loading…
Reference in New Issue
Block a user