git ssb

2+

mixmix / ticktack



Commit 9ae1c46f226c40c608560b66d0b5ca42ecce151b

add ability to attach non-image files

mix irving committed on 4/10/2018, 10:06:11 PM
Parent: 26ec4bc385c250f6b9b1d0eb534ceaff0f876083

Files changed

app/page/blogNew.jschanged
app/page/blogNew.jsView
@@ -93,26 +93,21 @@
9393 const fileInput = api.blob.html.input(file => {
9494 filesById[file.link] = file
9595
9696 const isImage = file.type.match(/^image/)
97- const imgPrefix = isImage ? '!' : ''
98- const spacer = isImage ? '\n' : ' '
99- const insertLink = spacer + imgPrefix + '[' + file.name + ']' + '(' + file.link + ')' + spacer
10097
101- const pos = textArea.selectionStart
102- // var newText = textRaw().slice(0, pos) + insertLink + textRaw().slice(pos)
103- // textArea.value = newText
104- // textRaw.set(newText)
98 + var content
10599
106- // TODO pivot on image to insert link, or image
107- const img = h('p', [
108- h('img', {
100 + if (isImage) {
101 + content = h('img', {
109102 src: `http://localhost:8989/blobs/get/${encodeURIComponent(file.link)}`,
110103 alt: file.name
111104 })
112- ])
105 + } else {
106 + content = h('a', { href: file.link }, file.name)
107 + }
113108 // TODO - insert where the mouse is yo
114- textArea.appendChild(img)
109 + textArea.appendChild(h('p', content))
115110
116111 console.log('added:', file)
117112 })
118113

Built with git-ssb-web