Commit 15e4fe66 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch '287-dev-doc-annotation-menu' of...

Merge branch '287-dev-doc-annotation-menu' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents ef844ffc ce563ccf
...@@ -989,7 +989,7 @@ ...@@ -989,7 +989,7 @@
"prelude", "prelude",
"unsafe-coerce" "unsafe-coerce"
], ],
"repo": "https://github.com/poorscript/purescript-dom-simple", "repo": "https://github.com/irresponsible/purescript-dom-simple",
"version": "v0.2.7" "version": "v0.2.7"
}, },
"dotenv": { "dotenv": {
...@@ -1218,7 +1218,7 @@ ...@@ -1218,7 +1218,7 @@
"nullable", "nullable",
"unsafe-coerce" "unsafe-coerce"
], ],
"repo": "https://github.com/poorscript/purescript-ffi-simple", "repo": "https://github.com/irresponsible/purescript-ffi-simple",
"version": "v0.2.10" "version": "v0.2.10"
}, },
"filterable": { "filterable": {
...@@ -1411,9 +1411,13 @@ ...@@ -1411,9 +1411,13 @@
}, },
"formula": { "formula": {
"dependencies": [ "dependencies": [
"effect",
"prelude", "prelude",
"reactix", "reactix",
"record",
"toestand", "toestand",
"tuples",
"typelevel-prelude",
"typisch" "typisch"
], ],
"repo": "https://github.com/poorscript/purescript-formula", "repo": "https://github.com/poorscript/purescript-formula",
...@@ -3812,10 +3816,9 @@ ...@@ -3812,10 +3816,9 @@
"functions", "functions",
"nullable", "nullable",
"prelude", "prelude",
"tuples",
"unsafe-coerce" "unsafe-coerce"
], ],
"repo": "https://github.com/poorscript/purescript-reactix", "repo": "https://github.com/irresponsible/purescript-reactix",
"version": "v0.4.11" "version": "v0.4.11"
}, },
"read": { "read": {
...@@ -4719,12 +4722,14 @@ ...@@ -4719,12 +4722,14 @@
"dependencies": [ "dependencies": [
"aff", "aff",
"coroutines", "coroutines",
"web-dom",
"freet", "freet",
"profunctor-lenses", "profunctor-lenses",
"react" "react",
"react-dom"
], ],
"repo": "https://github.com/paf31/purescript-thermite.git", "repo": "https://github.com/poorscript/purescript-thermite.git",
"version": "v6.3.1" "version": "hide-2020-03-04"
}, },
"thermite-dom": { "thermite-dom": {
"dependencies": [ "dependencies": [
...@@ -4746,13 +4751,13 @@ ...@@ -4746,13 +4751,13 @@
}, },
"toestand": { "toestand": {
"dependencies": [ "dependencies": [
"prelude",
"effect", "effect",
"foldable-traversable",
"reactix", "reactix",
"prelude",
"record", "record",
"tuples", "tuples",
"typelevel-prelude" "typelevel-prelude",
"typisch"
], ],
"repo": "https://github.com/poorscript/purescript-toestand", "repo": "https://github.com/poorscript/purescript-toestand",
"version": "v0.6.1" "version": "v0.6.1"
......
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
name = "dom-simple"; name = "dom-simple";
version = "v0.2.7"; version = "v0.2.7";
src = pkgs.fetchgit { src = pkgs.fetchgit {
url = "https://github.com/poorscript/purescript-dom-simple"; url = "https://github.com/irresponsible/purescript-dom-simple";
rev = "v0.2.7"; rev = "v0.2.7";
sha256 = "02f1vsjk5frva3p3xpbrnj2zg4rg01l07dnvc3i6axvc5k30i282"; sha256 = "02f1vsjk5frva3p3xpbrnj2zg4rg01l07dnvc3i6axvc5k30i282";
}; };
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
name = "ffi-simple"; name = "ffi-simple";
version = "v0.2.10"; version = "v0.2.10";
src = pkgs.fetchgit { src = pkgs.fetchgit {
url = "https://github.com/poorscript/purescript-ffi-simple"; url = "https://github.com/irresponsible/purescript-ffi-simple";
rev = "v0.2.10"; rev = "v0.2.10";
sha256 = "14slcccmy96ml7r8rzhhqnw486qj1b385i9095fdymms78g5gnj5"; sha256 = "14slcccmy96ml7r8rzhhqnw486qj1b385i9095fdymms78g5gnj5";
}; };
...@@ -372,11 +372,11 @@ ...@@ -372,11 +372,11 @@
}; };
"generics-rep" = { "generics-rep" = {
name = "generics-rep"; name = "generics-rep";
version = "v6.1.1"; version = "v6.1.3";
src = pkgs.fetchgit { src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-generics-rep.git"; url = "https://github.com/purescript/purescript-generics-rep.git";
rev = "v6.1.1"; rev = "v6.1.3";
sha256 = "15vchzbcvf6byks90q14lvcwb8hnxqzm2mrlxi7v1f7has4s74kn"; sha256 = "18yz3wfhh0xk1aw6scgv94mlr0hyf0q1ydhi8y3wm4zlch0lpy5i";
}; };
}; };
"globals" = { "globals" = {
...@@ -705,11 +705,11 @@ ...@@ -705,11 +705,11 @@
}; };
"proxy" = { "proxy" = {
name = "proxy"; name = "proxy";
version = "v3.0.0"; version = "v3.0.2";
src = pkgs.fetchgit { src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-proxy.git"; url = "https://github.com/purescript/purescript-proxy.git";
rev = "v3.0.0"; rev = "v3.0.2";
sha256 = "0rqf25b1n9p5sgx7gdsxwrfv9rb3sqxgqmqpp5kdm30lfk7snz24"; sha256 = "0p941cp8qz7dqyvybm7l1dyx6hbid4azxf35clj9i0zxr4k3vb8l";
}; };
}; };
"psci-support" = { "psci-support" = {
...@@ -752,7 +752,7 @@ ...@@ -752,7 +752,7 @@
name = "reactix"; name = "reactix";
version = "v0.4.11"; version = "v0.4.11";
src = pkgs.fetchgit { src = pkgs.fetchgit {
url = "https://github.com/poorscript/purescript-reactix"; url = "https://github.com/irresponsible/purescript-reactix";
rev = "v0.4.11"; rev = "v0.4.11";
sha256 = "1prxqww81lk32cp4mr318yanvf51kf9hz7x4n6rxdbcprj27710d"; sha256 = "1prxqww81lk32cp4mr318yanvf51kf9hz7x4n6rxdbcprj27710d";
}; };
......
...@@ -70,10 +70,8 @@ annotatedFieldInner p = R.createElement annotatedFieldInnerCpt p [] ...@@ -70,10 +70,8 @@ annotatedFieldInner p = R.createElement annotatedFieldInnerCpt p []
annotatedFieldInnerCpt :: R.Component InnerProps annotatedFieldInnerCpt :: R.Component InnerProps
annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
cpt { menuRef, ngrams, redrawMenu, setTermList, text: fieldText } _ = do cpt { menuRef, ngrams, redrawMenu, setTermList, text: fieldText } _ = do
-- redrawMenu <- T.useBox false
redrawMenu' <- T.useLive T.unequal redrawMenu redrawMenu' <- T.useLive T.unequal redrawMenu
-- menuRef <- R.useRef (Nothing :: Maybe (Record AnnotationMenu))
-- menu <- T.useBox (Nothing :: Maybe (Record AnnotationMenu)) -- menu <- T.useBox (Nothing :: Maybe (Record AnnotationMenu))
let wrap (text /\ list) = { list let wrap (text /\ list) = { list
...@@ -138,8 +136,6 @@ showMenu { event, getList, menuRef, menuType, ngram, redrawMenu, setTermList } = ...@@ -138,8 +136,6 @@ showMenu { event, getList, menuRef, menuType, ngram, redrawMenu, setTermList } =
setList t = do setList t = do
setTermList ngram list t setTermList ngram list t
hideMenu { menuRef, redrawMenu } hideMenu { menuRef, redrawMenu }
-- here.log2 "x" x
-- here.log2 "y" y
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
......
...@@ -36,12 +36,11 @@ contextMenu = R.createElement contextMenuCpt ...@@ -36,12 +36,11 @@ contextMenu = R.createElement contextMenuCpt
contextMenuCpt :: forall t. R.Component (Props t) contextMenuCpt :: forall t. R.Component (Props t)
contextMenuCpt = here.component "contextMenu" cpt contextMenuCpt = here.component "contextMenu" cpt
where where
cpt menu@{ x, y, onClose } children = do cpt menu@{ onClose, x, y } children = do
host <- R2.getPortalHost host <- R2.getPortalHost
root <- R.useRef null root <- R.useRef null
-- rect <- T.useBox $ Just $ R2.domRectFromRect { x, y, width: 224.6, height: 102.0 } -- NOTE: Just some dummy width/height here, it should be set properly in the effect function later
let childRect = R2.boundingRect children rect <- T.useBox $ Just $ R2.domRectFromRect { x, y, width: 100.0, height: 100.0 }
rect <- T.useBox $ Just $ R2.domRectFromRect { x, y, width: childRect.width, height: childRect.height }
rect' <- T.useLive T.unequal rect rect' <- T.useLive T.unequal rect
R.useLayoutEffect1 (R.readRef root) $ do R.useLayoutEffect1 (R.readRef root) $ do
...@@ -92,8 +91,10 @@ contextMenuEffect onClose rootRef = ...@@ -92,8 +91,10 @@ contextMenuEffect onClose rootRef =
documentClickHandler :: Effect Unit -> DOM.Element -> Callback DE.MouseEvent documentClickHandler :: Effect Unit -> DOM.Element -> Callback DE.MouseEvent
documentClickHandler onClose menu = documentClickHandler onClose menu =
R2.named "hideMenuOnClickOutside" $ callback $ \e -> R2.named "hideMenuOnClickOutside" $ callback $ \e -> do
when (Element.contains menu (DE.target e)) onClose when (R2.mouseClickInElement e menu) $ do
here.log "mouse in element"
onClose
documentScrollHandler :: Effect Unit -> Callback DE.MouseEvent documentScrollHandler :: Effect Unit -> Callback DE.MouseEvent
documentScrollHandler onClose = documentScrollHandler onClose =
......
'use strict';
const ReactBootstrap = require('react-bootstrap');
if (typeof window !== 'undefined') {
window.ReactBootstrap = ReactBootstrap;
}
const OverlayTrigger = require('react-bootstrap/OverlayTrigger');
const Popover = require('react-bootstrap/Popover');
exports.overlayTriggerCpt = OverlayTrigger;
exports.popoverCpt = Popover;
exports.popoverContentCpt = Popover.Content;
exports.popoverTitleCpt = Popover.Title;
module Gargantext.Utils.ReactBootstrap where
import Reactix as R
import Gargantext.Prelude
type OverlayTriggerProps =
(
overlay :: R.Element
, placement :: String
, trigger :: String
)
type Props =
(
)
type ContentProps =
(
)
type TitleProps =
(
"as" :: String
)
foreign import overlayTriggerCpt :: R.Component OverlayTriggerProps
foreign import popoverCpt :: R.Component Props
foreign import popoverContentCpt :: R.Component ContentProps
foreign import popoverTitleCpt :: R.Component TitleProps
overlayTrigger :: Record OverlayTriggerProps -> Array R.Element -> R.Element
overlayTrigger = R.rawCreateElement overlayTriggerCpt
popover :: Record Props -> Array R.Element -> R.Element
popover = R.rawCreateElement popoverCpt
popoverContent :: Record ContentProps -> Array R.Element -> R.Element
popoverContent = R.rawCreateElement popoverContentCpt
popoverTitle :: Record TitleProps -> Array R.Element -> R.Element
popoverTitle = R.rawCreateElement popoverTitleCpt
-- example
-- example =
-- let popover = GUB.popover {} [
-- GUB.popoverTitle { "as": "h3" } [ H.text "hello title" ]
-- , GUB.popoverContent {} [ H.div {} [ H.text "content" ] ]
-- ]
-- in GUB.overlayTrigger { overlay: popover
-- , placement: "right"
-- , trigger: "click" } [
-- H.button { className: "btn btn-default" } [ H.text "Click me" ]
-- ]
...@@ -146,6 +146,13 @@ affEffect errmsg aff = do ...@@ -146,6 +146,13 @@ affEffect errmsg aff = do
mousePosition :: RE.SyntheticEvent DE.MouseEvent -> Point mousePosition :: RE.SyntheticEvent DE.MouseEvent -> Point
mousePosition e = Point { x: RE.clientX e, y: RE.clientY e } mousePosition e = Point { x: RE.clientX e, y: RE.clientY e }
mouseClickInElement :: DE.MouseEvent -> DOM.Element -> Boolean
mouseClickInElement e el = x <= cx && cx <= x + width && y <= cy && cy <= y + height
where
{ x, y, width, height } = Element.boundingRect el
cx = DE.clientX e
cy = DE.clientY e
domMousePosition :: DE.MouseEvent -> Point domMousePosition :: DE.MouseEvent -> Point
domMousePosition = mousePosition <<< unsafeCoerce domMousePosition = mousePosition <<< unsafeCoerce
-- | This is naughty, it quietly mutates the input and returns it -- | This is naughty, it quietly mutates the input and returns it
......
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