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 @@
"prelude",
"unsafe-coerce"
],
"repo": "https://github.com/poorscript/purescript-dom-simple",
"repo": "https://github.com/irresponsible/purescript-dom-simple",
"version": "v0.2.7"
},
"dotenv": {
......@@ -1218,7 +1218,7 @@
"nullable",
"unsafe-coerce"
],
"repo": "https://github.com/poorscript/purescript-ffi-simple",
"repo": "https://github.com/irresponsible/purescript-ffi-simple",
"version": "v0.2.10"
},
"filterable": {
......@@ -1411,9 +1411,13 @@
},
"formula": {
"dependencies": [
"effect",
"prelude",
"reactix",
"record",
"toestand",
"tuples",
"typelevel-prelude",
"typisch"
],
"repo": "https://github.com/poorscript/purescript-formula",
......@@ -3812,10 +3816,9 @@
"functions",
"nullable",
"prelude",
"tuples",
"unsafe-coerce"
],
"repo": "https://github.com/poorscript/purescript-reactix",
"repo": "https://github.com/irresponsible/purescript-reactix",
"version": "v0.4.11"
},
"read": {
......@@ -4719,12 +4722,14 @@
"dependencies": [
"aff",
"coroutines",
"web-dom",
"freet",
"profunctor-lenses",
"react"
"react",
"react-dom"
],
"repo": "https://github.com/paf31/purescript-thermite.git",
"version": "v6.3.1"
"repo": "https://github.com/poorscript/purescript-thermite.git",
"version": "hide-2020-03-04"
},
"thermite-dom": {
"dependencies": [
......@@ -4746,13 +4751,13 @@
},
"toestand": {
"dependencies": [
"prelude",
"effect",
"foldable-traversable",
"reactix",
"prelude",
"record",
"tuples",
"typelevel-prelude"
"typelevel-prelude",
"typisch"
],
"repo": "https://github.com/poorscript/purescript-toestand",
"version": "v0.6.1"
......
......@@ -212,7 +212,7 @@
name = "dom-simple";
version = "v0.2.7";
src = pkgs.fetchgit {
url = "https://github.com/poorscript/purescript-dom-simple";
url = "https://github.com/irresponsible/purescript-dom-simple";
rev = "v0.2.7";
sha256 = "02f1vsjk5frva3p3xpbrnj2zg4rg01l07dnvc3i6axvc5k30i282";
};
......@@ -266,7 +266,7 @@
name = "ffi-simple";
version = "v0.2.10";
src = pkgs.fetchgit {
url = "https://github.com/poorscript/purescript-ffi-simple";
url = "https://github.com/irresponsible/purescript-ffi-simple";
rev = "v0.2.10";
sha256 = "14slcccmy96ml7r8rzhhqnw486qj1b385i9095fdymms78g5gnj5";
};
......@@ -372,11 +372,11 @@
};
"generics-rep" = {
name = "generics-rep";
version = "v6.1.1";
version = "v6.1.3";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-generics-rep.git";
rev = "v6.1.1";
sha256 = "15vchzbcvf6byks90q14lvcwb8hnxqzm2mrlxi7v1f7has4s74kn";
rev = "v6.1.3";
sha256 = "18yz3wfhh0xk1aw6scgv94mlr0hyf0q1ydhi8y3wm4zlch0lpy5i";
};
};
"globals" = {
......@@ -705,11 +705,11 @@
};
"proxy" = {
name = "proxy";
version = "v3.0.0";
version = "v3.0.2";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-proxy.git";
rev = "v3.0.0";
sha256 = "0rqf25b1n9p5sgx7gdsxwrfv9rb3sqxgqmqpp5kdm30lfk7snz24";
rev = "v3.0.2";
sha256 = "0p941cp8qz7dqyvybm7l1dyx6hbid4azxf35clj9i0zxr4k3vb8l";
};
};
"psci-support" = {
......@@ -752,7 +752,7 @@
name = "reactix";
version = "v0.4.11";
src = pkgs.fetchgit {
url = "https://github.com/poorscript/purescript-reactix";
url = "https://github.com/irresponsible/purescript-reactix";
rev = "v0.4.11";
sha256 = "1prxqww81lk32cp4mr318yanvf51kf9hz7x4n6rxdbcprj27710d";
};
......
......@@ -70,10 +70,8 @@ annotatedFieldInner p = R.createElement annotatedFieldInnerCpt p []
annotatedFieldInnerCpt :: R.Component InnerProps
annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
cpt { menuRef, ngrams, redrawMenu, setTermList, text: fieldText } _ = do
-- redrawMenu <- T.useBox false
redrawMenu' <- T.useLive T.unequal redrawMenu
-- menuRef <- R.useRef (Nothing :: Maybe (Record AnnotationMenu))
-- menu <- T.useBox (Nothing :: Maybe (Record AnnotationMenu))
let wrap (text /\ list) = { list
......@@ -138,8 +136,6 @@ showMenu { event, getList, menuRef, menuType, ngram, redrawMenu, setTermList } =
setList t = do
setTermList ngram list t
hideMenu { menuRef, redrawMenu }
-- here.log2 "x" x
-- here.log2 "y" y
E.preventDefault event
--range <- Sel.getRange sel 0
--here.log2 "selection range" $ Sel.rangeToTuple range
......
......@@ -36,12 +36,11 @@ contextMenu = R.createElement contextMenuCpt
contextMenuCpt :: forall t. R.Component (Props t)
contextMenuCpt = here.component "contextMenu" cpt
where
cpt menu@{ x, y, onClose } children = do
cpt menu@{ onClose, x, y } children = do
host <- R2.getPortalHost
root <- R.useRef null
-- rect <- T.useBox $ Just $ R2.domRectFromRect { x, y, width: 224.6, height: 102.0 }
let childRect = R2.boundingRect children
rect <- T.useBox $ Just $ R2.domRectFromRect { x, y, width: childRect.width, height: childRect.height }
-- NOTE: Just some dummy width/height here, it should be set properly in the effect function later
rect <- T.useBox $ Just $ R2.domRectFromRect { x, y, width: 100.0, height: 100.0 }
rect' <- T.useLive T.unequal rect
R.useLayoutEffect1 (R.readRef root) $ do
......@@ -92,8 +91,10 @@ contextMenuEffect onClose rootRef =
documentClickHandler :: Effect Unit -> DOM.Element -> Callback DE.MouseEvent
documentClickHandler onClose menu =
R2.named "hideMenuOnClickOutside" $ callback $ \e ->
when (Element.contains menu (DE.target e)) onClose
R2.named "hideMenuOnClickOutside" $ callback $ \e -> do
when (R2.mouseClickInElement e menu) $ do
here.log "mouse in element"
onClose
documentScrollHandler :: Effect Unit -> Callback DE.MouseEvent
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
mousePosition :: RE.SyntheticEvent DE.MouseEvent -> Point
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 = mousePosition <<< unsafeCoerce
-- | 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