Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
a9ee261e
Commit
a9ee261e
authored
Jun 18, 2023
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Doc annotation] Highlight changed terms immediately
parent
71928b67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
Field.purs
src/Gargantext/Components/Annotation/Field.purs
+17
-8
No files found.
src/Gargantext/Components/Annotation/Field.purs
View file @
a9ee261e
...
...
@@ -13,6 +13,7 @@ module Gargantext.Components.Annotation.Field where
import Gargantext.Prelude
import DOM.Simple.Event as DE
import Data.Array as A
import Data.List (List(..), (:))
import Data.Map (Map)
...
...
@@ -20,7 +21,6 @@ import Data.Maybe (Maybe(..), maybe)
import Data.String.Common (joinWith)
import Data.Tuple (Tuple(..), snd)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Event as DE
import Effect (Effect)
import Gargantext.Components.Annotation.Menu (annotationMenu, AnnotationMenu)
import Gargantext.Components.Annotation.Types (MenuType(..), ModeType(..), termClass)
...
...
@@ -29,6 +29,7 @@ import Gargantext.Core.NgramsTable.Types (HighlightElement, NgramsRepoElement(..
import Gargantext.Types (CTabNgramType(..), TermList)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Selection as Sel
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.SyntheticEvent as E
...
...
@@ -59,14 +60,16 @@ annotatedFieldCpt = here.component "annotatedField" cpt where
cpt props _ = do
menuRef <- R.useRef (Nothing :: Maybe (Record AnnotationMenu))
redrawMenu <- T.useBox false
reload <- T.useBox T2.newReload
pure $ annotatedFieldInner (Record.merge { menuRef, redrawMenu } props)
pure $ annotatedFieldInner (Record.merge { menuRef, redrawMenu
, reload
} props)
-----------------------------------------------------------------
type InnerProps =
( menuRef :: R.Ref (Maybe (Record AnnotationMenu))
, redrawMenu :: T.Box Boolean
, reload :: T2.ReloadS
| Props
)
...
...
@@ -81,6 +84,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
, text: fieldText
, mode
, cache
, reload
} _ = do
-- | States
-- |
...
...
@@ -94,7 +98,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
wrap :: Tuple String (List (Tuple NgramsTerm TermList)) -> Record RunProps
wrap (text /\ list)
= { list
, onSelect: onAnnotationSelect { menuRef, ngrams, redrawMenu, setTermList
}
, onSelect: onAnnotationSelect { menuRef, ngrams, redrawMenu, setTermList
, reload
}
, text
}
...
...
@@ -126,7 +130,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
annotateRun
{ list: mempty
, text: t
, onSelect: onAnnotationSelect { menuRef, ngrams, redrawMenu, setTermList }
, onSelect: onAnnotationSelect { menuRef, ngrams, redrawMenu, setTermList
, reload
}
}
]
...
...
@@ -149,12 +153,13 @@ onAnnotationSelect :: forall e.
, ngrams :: NgramsTable
, redrawMenu :: T.Box Boolean
, setTermList :: NgramsTerm -> Maybe TermList -> TermList -> Effect Unit
, reload :: T2.ReloadS
}
-> Maybe (Tuple NgramsTerm TermList)
-> E.SyntheticEvent e
-> Effect Unit
onAnnotationSelect
{ menuRef, ngrams, redrawMenu, setTermList
}
{ menuRef, ngrams, redrawMenu, setTermList
, reload
}
Nothing
event
= do
...
...
@@ -170,11 +175,12 @@ onAnnotationSelect
, menuType: NewNgram
, ngram: sel' -- normNgram CTabTerms sel'
, redrawMenu
, setTermList }
, setTermList
, reload }
Nothing -> hideMenu { menuRef, redrawMenu }
onAnnotationSelect
{ menuRef, redrawMenu, setTermList }
{ menuRef, redrawMenu, setTermList
, reload
}
(Just (Tuple ngram list))
event
= showMenu
...
...
@@ -185,6 +191,7 @@ onAnnotationSelect
, ngram
, redrawMenu
, setTermList
, reload
}
-- showMenu :: forall p e. DE.IsMouseEvent e => { event :: E.SyntheticEvent e | p } -> Effect Unit
...
...
@@ -197,10 +204,11 @@ showMenu :: forall e.
, ngram :: NgramsTerm
, redrawMenu :: T.Box Boolean
, setTermList :: NgramsTerm -> Maybe TermList -> TermList -> Effect Unit
, reload :: T2.ReloadS
}
-> Effect Unit
showMenu
{ event, getList, menuRef, menuType, ngram, redrawMenu, setTermList }
{ event, getList, menuRef, menuType, ngram, redrawMenu, setTermList
, reload
}
= do
let x = E.clientX event
y = E.clientY event
...
...
@@ -210,6 +218,7 @@ showMenu
setList t = do
setTermList ngram list t
hideMenu { menuRef, redrawMenu }
T2.reload reload
E.preventDefault event
--range <- Sel.getRange sel 0
--here.log2 "selection range" $ Sel.rangeToTuple range
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment