message/html/compose.jsView |
---|
64 | 64 … | placeholder |
65 | 65 … | }) |
66 | 66 … | textArea.publish = publish |
67 | 67 … | |
| 68 … | + var warningMessage = Value(null) |
| 69 … | + var warning = h('section.warning', |
| 70 … | + { className: when(warningMessage, '-open', '-closed') }, |
| 71 … | + [ |
| 72 … | + h('div.warning', warningMessage), |
| 73 … | + h('div.close', { 'ev-click': () => warningMessage.set(null) }, 'x') |
| 74 … | + ] |
| 75 … | + ) |
68 | 76 … | var fileInput = api.blob.html.input(file => { |
| 77 … | + |
| 78 … | + const megabytes = file.size / 1024 / 1024 |
| 79 … | + if (megabytes >= 5) { |
| 80 … | + const rounded = Math.floor(megabytes*100)/100 |
| 81 … | + warningMessage.set([ |
| 82 … | + h('i.fa.fa-exclamation-triangle'), |
| 83 … | + h('strong', file.name), |
| 84 … | + ` is ${rounded}MB - the current limit is 5MB` |
| 85 … | + ]) |
| 86 … | + return |
| 87 … | + } |
| 88 … | + |
69 | 89 … | files.push(file) |
70 | 90 … | filesById[file.link] = file |
71 | 91 … | |
72 | | - var embed = file.type.match(/^image/) ? '!' : '' |
73 | | - var spacer = embed ? '\n' : ' ' |
74 | | - var insertLink = spacer + embed + '[' + file.name + ']' + '(' + file.link + ')' + spacer |
| 92 … | + const pos = textArea.selectionStart |
| 93 … | + const embed = file.type.match(/^image/) ? '!' : '' |
| 94 … | + const spacer = embed ? '\n' : ' ' |
| 95 … | + const insertLink = spacer + embed + '[' + file.name + ']' + '(' + file.link + ')' + spacer |
75 | 96 … | |
76 | | - var pos = textArea.selectionStart |
77 | 97 … | textArea.value = textArea.value.slice(0, pos) + insertLink + textArea.value.slice(pos) |
78 | 98 … | |
79 | 99 … | console.log('added:', file) |
80 | 100 … | }) |
92 | 112 … | classList: when(expanded, '-expanded', '-contracted') |
93 | 113 … | }, [ |
94 | 114 … | channelInput, |
95 | 115 … | textArea, |
| 116 … | + warning, |
96 | 117 … | actions |
97 | 118 … | ]) |
98 | 119 … | |
99 | 120 … | addSuggest(channelInput, (inputText, cb) => { |