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
Show 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
...
@@ -13,6 +13,7 @@ module Gargantext.Components.Annotation.Field where
import Gargantext.Prelude
import Gargantext.Prelude
import DOM.Simple.Event as DE
import Data.Array as A
import Data.Array as A
import Data.List (List(..), (:))
import Data.List (List(..), (:))
import Data.Map (Map)
import Data.Map (Map)
...
@@ -20,7 +21,6 @@ import Data.Maybe (Maybe(..), maybe)
...
@@ -20,7 +21,6 @@ import Data.Maybe (Maybe(..), maybe)
import Data.String.Common (joinWith)
import Data.String.Common (joinWith)
import Data.Tuple (Tuple(..), snd)
import Data.Tuple (Tuple(..), snd)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Event as DE
import Effect (Effect)
import Effect (Effect)
import Gargantext.Components.Annotation.Menu (annotationMenu, AnnotationMenu)
import Gargantext.Components.Annotation.Menu (annotationMenu, AnnotationMenu)
import Gargantext.Components.Annotation.Types (MenuType(..), ModeType(..), termClass)
import Gargantext.Components.Annotation.Types (MenuType(..), ModeType(..), termClass)
...
@@ -29,6 +29,7 @@ import Gargantext.Core.NgramsTable.Types (HighlightElement, NgramsRepoElement(..
...
@@ -29,6 +29,7 @@ import Gargantext.Core.NgramsTable.Types (HighlightElement, NgramsRepoElement(..
import Gargantext.Types (CTabNgramType(..), TermList)
import Gargantext.Types (CTabNgramType(..), TermList)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Selection as Sel
import Gargantext.Utils.Selection as Sel
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Reactix.SyntheticEvent as E
import Reactix.SyntheticEvent as E
...
@@ -59,14 +60,16 @@ annotatedFieldCpt = here.component "annotatedField" cpt where
...
@@ -59,14 +60,16 @@ annotatedFieldCpt = here.component "annotatedField" cpt where
cpt props _ = do
cpt props _ = do
menuRef <- R.useRef (Nothing :: Maybe (Record AnnotationMenu))
menuRef <- R.useRef (Nothing :: Maybe (Record AnnotationMenu))
redrawMenu <- T.useBox false
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 =
type InnerProps =
( menuRef :: R.Ref (Maybe (Record AnnotationMenu))
( menuRef :: R.Ref (Maybe (Record AnnotationMenu))
, redrawMenu :: T.Box Boolean
, redrawMenu :: T.Box Boolean
, reload :: T2.ReloadS
| Props
| Props
)
)
...
@@ -81,6 +84,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
...
@@ -81,6 +84,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
, text: fieldText
, text: fieldText
, mode
, mode
, cache
, cache
, reload
} _ = do
} _ = do
-- | States
-- | States
-- |
-- |
...
@@ -94,7 +98,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
...
@@ -94,7 +98,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
wrap :: Tuple String (List (Tuple NgramsTerm TermList)) -> Record RunProps
wrap :: Tuple String (List (Tuple NgramsTerm TermList)) -> Record RunProps
wrap (text /\ list)
wrap (text /\ list)
= { list
= { list
, onSelect: onAnnotationSelect { menuRef, ngrams, redrawMenu, setTermList
}
, onSelect: onAnnotationSelect { menuRef, ngrams, redrawMenu, setTermList
, reload
}
, text
, text
}
}
...
@@ -126,7 +130,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
...
@@ -126,7 +130,7 @@ annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
annotateRun
annotateRun
{ list: mempty
{ list: mempty
, text: t
, text: t
, onSelect: onAnnotationSelect { menuRef, ngrams, redrawMenu, setTermList }
, onSelect: onAnnotationSelect { menuRef, ngrams, redrawMenu, setTermList
, reload
}
}
}
]
]
...
@@ -149,12 +153,13 @@ onAnnotationSelect :: forall e.
...
@@ -149,12 +153,13 @@ onAnnotationSelect :: forall e.
, ngrams :: NgramsTable
, ngrams :: NgramsTable
, redrawMenu :: T.Box Boolean
, redrawMenu :: T.Box Boolean
, setTermList :: NgramsTerm -> Maybe TermList -> TermList -> Effect Unit
, setTermList :: NgramsTerm -> Maybe TermList -> TermList -> Effect Unit
, reload :: T2.ReloadS
}
}
-> Maybe (Tuple NgramsTerm TermList)
-> Maybe (Tuple NgramsTerm TermList)
-> E.SyntheticEvent e
-> E.SyntheticEvent e
-> Effect Unit
-> Effect Unit
onAnnotationSelect
onAnnotationSelect
{ menuRef, ngrams, redrawMenu, setTermList
}
{ menuRef, ngrams, redrawMenu, setTermList
, reload
}
Nothing
Nothing
event
event
= do
= do
...
@@ -170,11 +175,12 @@ onAnnotationSelect
...
@@ -170,11 +175,12 @@ onAnnotationSelect
, menuType: NewNgram
, menuType: NewNgram
, ngram: sel' -- normNgram CTabTerms sel'
, ngram: sel' -- normNgram CTabTerms sel'
, redrawMenu
, redrawMenu
, setTermList }
, setTermList
, reload }
Nothing -> hideMenu { menuRef, redrawMenu }
Nothing -> hideMenu { menuRef, redrawMenu }
onAnnotationSelect
onAnnotationSelect
{ menuRef, redrawMenu, setTermList }
{ menuRef, redrawMenu, setTermList
, reload
}
(Just (Tuple ngram list))
(Just (Tuple ngram list))
event
event
= showMenu
= showMenu
...
@@ -185,6 +191,7 @@ onAnnotationSelect
...
@@ -185,6 +191,7 @@ onAnnotationSelect
, ngram
, ngram
, redrawMenu
, redrawMenu
, setTermList
, setTermList
, reload
}
}
-- showMenu :: forall p e. DE.IsMouseEvent e => { event :: E.SyntheticEvent e | p } -> Effect Unit
-- showMenu :: forall p e. DE.IsMouseEvent e => { event :: E.SyntheticEvent e | p } -> Effect Unit
...
@@ -197,10 +204,11 @@ showMenu :: forall e.
...
@@ -197,10 +204,11 @@ showMenu :: forall e.
, ngram :: NgramsTerm
, ngram :: NgramsTerm
, redrawMenu :: T.Box Boolean
, redrawMenu :: T.Box Boolean
, setTermList :: NgramsTerm -> Maybe TermList -> TermList -> Effect Unit
, setTermList :: NgramsTerm -> Maybe TermList -> TermList -> Effect Unit
, reload :: T2.ReloadS
}
}
-> Effect Unit
-> Effect Unit
showMenu
showMenu
{ event, getList, menuRef, menuType, ngram, redrawMenu, setTermList }
{ event, getList, menuRef, menuType, ngram, redrawMenu, setTermList
, reload
}
= do
= do
let x = E.clientX event
let x = E.clientX event
y = E.clientY event
y = E.clientY event
...
@@ -210,6 +218,7 @@ showMenu
...
@@ -210,6 +218,7 @@ showMenu
setList t = do
setList t = do
setTermList ngram list t
setTermList ngram list t
hideMenu { menuRef, redrawMenu }
hideMenu { menuRef, redrawMenu }
T2.reload reload
E.preventDefault event
E.preventDefault event
--range <- Sel.getRange sel 0
--range <- Sel.getRange sel 0
--here.log2 "selection range" $ Sel.rangeToTuple range
--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