From 59c23de887c2938533b735f0dedbb788e22d0f6f Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 8 Mar 2015 14:55:15 +0200 Subject: 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. --- src/client/view/textanalyser_input.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/client/view/textanalyser_input.js') 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(); - - analysisCompleter.options.plug(textanalysis.suggestions_options); + input_bus = new Bacon.Bus(), + selectionBus = element.asEventStream('selectstart input keyup').map(selectionStart).skipDuplicates(); + + 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); -- cgit v1.3.1