git ssb

10+

Matt McKegg / patchwork



Commit 833e6272fdc03999e6a10c74b5adff86a11d8d39

compose: improve insert attachment rules

still could be better #576
Matt McKegg committed on 7/1/2017, 10:41:04 AM
Parent: f815ce842a77e397cb805d2045e8e7033e54da31

Files changed

modules/message/html/compose.jschanged
modules/message/html/compose.jsView
@@ -57,13 +57,17 @@
5757 files.push(file)
5858 filesById[file.link] = file
5959
6060 var embed = file.type.indexOf('image/') === 0 ? '!' : ''
61 + var pos = textArea.selectionStart
62 + var before = textArea.value.slice(0, pos)
63 + var after = textArea.value.slice(pos)
64 +
6165 var spacer = embed ? '\n' : ' '
62- var insertLink = `${spacer}${embed}[${file.name}](${file.link})${spacer}`
66 + if (before && !before.endsWith(spacer)) before += spacer
67 + if (!after.startsWith(spacer)) after = spacer + after
6368
64- var pos = textArea.selectionStart
65- textArea.value = `${textArea.value.slice(0, pos)}${insertLink}${textArea.value.slice(pos)}`
69 + textArea.value = `${before}![${file.name}](${file.link})${after}`
6670 console.log('added:', file)
6771 })
6872
6973 fileInput.onclick = function () {

Built with git-ssb-web