Commit 9ae1c46f226c40c608560b66d0b5ca42ecce151b
add ability to attach non-image files
mix irving committed on 4/10/2018, 10:06:11 PMParent: 26ec4bc385c250f6b9b1d0eb534ceaff0f876083
Files changed
app/page/blogNew.js | changed |
app/page/blogNew.js | ||
---|---|---|
@@ -93,26 +93,21 @@ | ||
93 | 93 … | const fileInput = api.blob.html.input(file => { |
94 | 94 … | filesById[file.link] = file |
95 | 95 … | |
96 | 96 … | 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 | |
100 | 97 … | |
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 | |
105 | 99 … | |
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', { | |
109 | 102 … | src: `http://localhost:8989/blobs/get/${encodeURIComponent(file.link)}`, |
110 | 103 … | alt: file.name |
111 | 104 … | }) |
112 | - ]) | |
105 … | + } else { | |
106 … | + content = h('a', { href: file.link }, file.name) | |
107 … | + } | |
113 | 108 … | // TODO - insert where the mouse is yo |
114 | - textArea.appendChild(img) | |
109 … | + textArea.appendChild(h('p', content)) | |
115 | 110 … | |
116 | 111 … | console.log('added:', file) |
117 | 112 … | }) |
118 | 113 … |
Built with git-ssb-web