Commit f815ce842a77e397cb805d2045e8e7033e54da31
compose: insert image/attachment at cursor
fixes #576Matt McKegg committed on 7/1/2017, 10:25:47 AM
Parent: 0839379f2aeeb22bd18fed24094f50e96f13421a
Files changed
modules/message/html/compose.js | changed |
modules/message/html/compose.js | ||
---|---|---|
@@ -57,10 +57,13 @@ | ||
57 | 57 | files.push(file) |
58 | 58 | filesById[file.link] = file |
59 | 59 | |
60 | 60 | var embed = file.type.indexOf('image/') === 0 ? '!' : '' |
61 | + var spacer = embed ? '\n' : ' ' | |
62 | + var insertLink = `${spacer}${embed}[${file.name}](${file.link})${spacer}` | |
61 | 63 | |
62 | - textArea.value += embed + `[${file.name}](${file.link})` | |
64 | + var pos = textArea.selectionStart | |
65 | + textArea.value = `${textArea.value.slice(0, pos)}${insertLink}${textArea.value.slice(pos)}` | |
63 | 66 | console.log('added:', file) |
64 | 67 | }) |
65 | 68 | |
66 | 69 | fileInput.onclick = function () { |
Built with git-ssb-web