Commit 88b73a01 authored by James Laver's avatar James Laver Committed by Alexandre Delanoë

Wire in ngram highlighting

parent d85c07c6
...@@ -29,7 +29,7 @@ import Thermite ( PerformAction, Render, Spec ...@@ -29,7 +29,7 @@ import Thermite ( PerformAction, Render, Spec
, _render, modifyState, focus, focusState , _render, modifyState, focus, focusState
, simpleSpec, withState) , simpleSpec, withState)
import Gargantext.Types (TermList(..)) import Gargantext.Types (TermList(..))
import Gargantext.Components.NgramsTable (NgramsTable, termStyle) import Gargantext.Components.NgramsTable (NgramsTable(..), highlightNgrams, termStyle)
import Gargantext.Utils.React (WithChildren) import Gargantext.Utils.React (WithChildren)
import Gargantext.Utils.Selection (getSelection, toString) import Gargantext.Utils.Selection (getSelection, toString)
import React.SyntheticEvent (SyntheticMouseEvent, pageX, pageY) import React.SyntheticEvent (SyntheticMouseEvent, pageX, pageY)
...@@ -77,18 +77,14 @@ annotatedFieldClass = createClass "AnnotatedField" spec compile ...@@ -77,18 +77,14 @@ annotatedFieldClass = createClass "AnnotatedField" spec compile
compile :: Props -> State compile :: Props -> State
compile {text, ngrams} = { runs: runs text, contextMenu: { visible: false } } compile {text, ngrams} = { runs: runs text, contextMenu: { visible: false } }
where runs (Just txt) = hilite ngrams txt where runs (Just txt) = highlight ngrams txt
runs _ = Nil runs _ = Nil
-- highlightNgrams :: NgramsTable -> String -> Array (Tuple String (Maybe TermList)) -- highlightNgrams :: NgramsTable -> String -> Array (Tuple String (Maybe TermList))
-- TODO HOOK IN string search -- TODO HOOK IN string search
hilite :: NgramsTable -> String -> List Run highlight :: NgramsTable -> String -> List Run
hilite _ _ = List.fromFoldable highlight n t = List.fromFoldable $ highlightNgrams n t
[ Tuple "Hello" (Just CandidateTerm)
, Tuple " " Nothing
, Tuple "World" (Just CandidateTerm) ]
-- hilite = map tupleRun <<< highlightNgrams
contextMenuHandler :: (Action -> Effect Unit) -> SyntheticMouseEvent -> Effect Unit contextMenuHandler :: (Action -> Effect Unit) -> SyntheticMouseEvent -> Effect Unit
contextMenuHandler d e = contextMenuHandler d e =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment