Commit 42a6e511880c97c5b0b5d8ba131f7173b493ede4
Merge pull request #191 from ssbc/quote-example
Add quote buttonAnders Rune Jensen authored on 4/25/2018, 12:37:44 PM
GitHub committed on 4/25/2018, 12:37:44 PM
Parent: 822a744863931f6f173393bae8f44e31debafb99
Parent: c0a883625eb62b7bdc71dd9ef7b1fdac62f4278b
Files changed
main.js | changed |
message/html/compose.js | changed |
post-patchcore/message/html/action/quote.js | added |
main.js | ||
---|---|---|
@@ -26,8 +26,14 @@ | ||
26 | 26 … | history: require('patch-history') |
27 | 27 … | } |
28 | 28 … | } |
29 | 29 … | |
30 … | +const post = { | |
31 … | + patchbay: { | |
32 … | + message: bulk(__dirname, [ 'post-patchcore/message/**/*.js' ]) | |
33 … | + } | |
34 … | +} | |
35 … | + | |
30 | 36 … | // from more specialized to more general |
31 | 37 … | const sockets = combine( |
32 | 38 … | // require('ssb-horcrux'), |
33 | 39 … | // require('patch-hub'), |
@@ -36,9 +42,10 @@ | ||
36 | 42 … | require('patchbay-gatherings'), |
37 | 43 … | require('patchbay-book'), |
38 | 44 … | // require('patch-network), |
39 | 45 … | patchbay, |
40 | - require('patchcore') | |
46 … | + require('patchcore'), | |
47 … | + post | |
41 | 48 … | ) |
42 | 49 … | |
43 | 50 … | const api = entry(sockets, nest('app.html.app', 'first')) |
44 | 51 … | const app = api.app.html.app |
message/html/compose.js | |||
---|---|---|---|
@@ -148,8 +148,23 @@ | |||
148 | 148 … | warning, | |
149 | 149 … | actions | |
150 | 150 … | ]) | |
151 | 151 … | ||
152 … | + composer.addQuote = function (data) { | ||
153 … | + try { | ||
154 … | + if (typeof data.content.text === 'string') { | ||
155 … | + var text = data.content.text | ||
156 … | + textArea.value += '> ' + text.replace(/\r\n|\r|\n/g,'\n> ') + '\r\n\n' | ||
157 … | + hasContent.set(!!textArea.value) | ||
158 … | + } | ||
159 … | + } catch(err) { | ||
160 … | + // object not have text or content | ||
161 … | + } | ||
162 … | + } | ||
163 … | + | ||
164 … | + if (location.action == 'quote') | ||
165 … | + composer.addQuote(location.value) | ||
166 … | + | ||
152 | 167 … | addSuggest(channelInput, (inputText, cb) => { | |
153 | 168 … | if (inputText[0] === '#') { | |
154 | 169 … | cb(null, getChannelSuggestions(inputText.slice(1))) | |
155 | 170 … | } |
post-patchcore/message/html/action/quote.js | ||
---|---|---|
@@ -1,0 +1,17 @@ | ||
1 … | +var h = require('mutant/h') | |
2 … | +var nest = require('depnest') | |
3 … | + | |
4 … | +exports.needs = nest({ | |
5 … | + 'app.sync.goTo': 'first' | |
6 … | +}) | |
7 … | + | |
8 … | +exports.gives = nest('message.html.action') | |
9 … | + | |
10 … | +exports.create = (api) => { | |
11 … | + return nest('message.html.action', function quote (msg) { | |
12 … | + return h('a', { | |
13 … | + href: '#', | |
14 … | + 'ev-click': () => api.app.sync.goTo({ action: 'quote', key: msg.key, value: msg.value }) | |
15 … | + }, 'Quote') | |
16 … | + }) | |
17 … | +} |
Built with git-ssb-web