git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit f815ce842a77e397cb805d2045e8e7033e54da31

compose: insert image/attachment at cursor

fixes #576
Matt McKegg committed on 7/1/2017, 10:25:47 AM
Parent: 0839379f2aeeb22bd18fed24094f50e96f13421a

Files changed

modules/message/html/compose.jschanged
modules/message/html/compose.jsView
@@ -57,10 +57,13 @@
5757 files.push(file)
5858 filesById[file.link] = file
5959
6060 var embed = file.type.indexOf('image/') === 0 ? '!' : ''
61+ var spacer = embed ? '\n' : ' '
62+ var insertLink = `${spacer}${embed}[${file.name}](${file.link})${spacer}`
6163
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)}`
6366 console.log('added:', file)
6467 })
6568
6669 fileInput.onclick = function () {

Built with git-ssb-web