git ssb

0+

dangerousbeans / patchbay-bootstrap



Commit 079f7646fd62a11c7e71deabb533b888890f1093

Combine mentions from markdown and files

Charles Lehner committed on 8/14/2016, 1:55:44 AM
Parent: 84d01396e7c8c55181da6c71061acdb78090dc4c

Files changed

modules/compose.jschanged
modules/compose.jsView
@@ -46,17 +46,26 @@
4646 if(ev.keyCode === 13 && ev.ctrlKey) publish()
4747 })
4848
4949 var files = []
50+ var filesById = {}
5051
5152 function publish() {
5253 publishBtn.disabled = true
5354 var content
5455 try {
5556 content = JSON.parse(ta.value)
5657 } catch (err) {
5758 meta.text = ta.value
58- meta.mentions = mentions(ta.value).concat(files)
59+ meta.mentions = mentions(ta.value).map(function (mention) {
60+ // merge markdown-detected mention with file info
61+ var file = filesById[mention.link]
62+ if (file) {
63+ if (file.type) mention.type = file.type
64+ if (file.size) mention.size = file.size
65+ }
66+ return mention
67+ })
5968 try {
6069 meta = prepublish(meta)
6170 } catch (err) {
6271 publishBtn.disabled = false
@@ -84,8 +93,9 @@
8493 //hidden until you focus the textarea
8594 {style: {display: 'none'}},
8695 file_input(function (file) {
8796 files.push(file)
97+ filesById[file.link] = file
8898
8999 var embed = file.type.indexOf('image/') === 0 ? '!' : ''
90100 ta.value += embed + '['+file.name+']('+file.link+')'
91101 console.log('added:', file)

Built with git-ssb-web