diff options
| author | Alon Levy <alon@pobox.com> | 2015-03-08 14:55:15 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-03-08 14:55:16 +0200 |
| commit | 59c23de887c2938533b735f0dedbb788e22d0f6f (patch) | |
| tree | 0433b8b943ba13d599e7978bb861113706f4d9d9 /src/client/view/textanalyser_input.js | |
| parent | 84cf1a4f50ef5b5094b4e250b664fb0e7089ee10 (diff) | |
client/completion: support links as well
the suggestions from textanalysis now come as a dictionary with
{nodes: {name: id},
links: {name: id}}
(before it was a single dictionary, {name:id})
And the options bus for the textanalyser and search completion have been
updated accordingly. textanalyser also takes into account the cursor
position to determine which of the option dictionaries to use.
Diffstat (limited to 'src/client/view/textanalyser_input.js')
| -rw-r--r-- | src/client/view/textanalyser_input.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/client/view/textanalyser_input.js b/src/client/view/textanalyser_input.js index 184402b1..5ac72a72 100644 --- a/src/client/view/textanalyser_input.js +++ b/src/client/view/textanalyser_input.js @@ -89,9 +89,20 @@ function textanalyser_input(spec) { }, analysisCompleter = completer(element, $(spec.completer_name), completer_spec), document_keydown = new Bacon.Bus(), - input_bus = new Bacon.Bus(); + input_bus = new Bacon.Bus(), + selectionBus = element.asEventStream('selectstart input keyup').map(selectionStart).skipDuplicates(); - analysisCompleter.options.plug(textanalysis.suggestions_options); + analysisCompleter.options.plug( + textanalysis.suggestions_options + .combine(selectionBus, function (options, cursor) { return [options, cursor]; }) + .combine(ta.on_analysis__output, function (both, output) { return both; }) + .map( + function (both) { + var options = both[0], + cursor = both[1], + is_link = textanalysis.element_at_position__is_link(cursor); + return options[is_link ? 'links' : 'nodes']; + })); util.assert(1 === element.length); |
