diff options
| -rwxr-xr-x | editor/plugins.ml | 1 | ||||
| -rwxr-xr-x | editor/tooltip.ml | 43 | 
2 files changed, 20 insertions, 24 deletions
| diff --git a/editor/plugins.ml b/editor/plugins.ml index 6173c4f..8dd960a 100755 --- a/editor/plugins.ml +++ b/editor/plugins.ml @@ -127,7 +127,6 @@ let default pm schema =    (* Add the custom keymaps in the list *)    let _ = setup##unshift keymaps in    let _ = setup##push (input_rule pm) in -  let _ = setup##push (Tooltip.tooltip_plugin pm) in    let _ = setup##push (Tooltip.bold_plugin pm) in diff --git a/editor/tooltip.ml b/editor/tooltip.ml index 06426d1..693d68d 100755 --- a/editor/tooltip.ml +++ b/editor/tooltip.ml @@ -20,9 +20,7 @@ let set_position      let box_left = Jv.(Id.of_jv @@ get (Jv.Id.to_jv box) "left") in      let box_bottom = Jv.(Id.of_jv @@ get (Jv.Id.to_jv box) "bottom") in -    let left = Float.max -        ((start##.left +. end'##.left) /. 2.) -        (start##.left +. 3.) in +    let left = (start##.left +. end'##.left) /. 2. in      El.set_inline_style (Jstr.v "left")        Jstr.( (of_float ( left -. box_left )) + (v "px") ) @@ -47,8 +45,7 @@ let tooltip        : PM.View.editor_view Js.t -> PM.State.editor_state Js. t Js.opt -> unit        = fun view state_opt -> -        Js.Opt.case state_opt -          (fun () -> ()) +        Js.Opt.iter state_opt            (fun previous_state ->               if ((view##.state##.doc##eq previous_state##.doc) = Js._true)               && ((previous_state##.selection##eq view##.state##.selection) = Js._true) @@ -101,24 +98,24 @@ let boldtip        : PM.View.editor_view Js.t -> PM.State.editor_state Js. t Js.opt -> unit        = fun view _state_opt ->          let state = view##.state in -        let is_bold = match PM.O.get state##.schema##.marks "strong" with -          | None -> None -          | Some mark_type -> -            let is_strong = Js.Opt.bind state##.storedMarks (fun t -> mark_type##isInSet t) in -            Js.Opt.case is_strong -              (fun () -> None) -              (fun _ -> Some (Jstr.v "gras")) in -        let is_em = match PM.O.get state##.schema##.marks "em" with -          | None -> None -          | Some mark_type -> -            let is_strong = Js.Opt.bind state##.storedMarks (fun t -> mark_type##isInSet t) in -            Js.Opt.case is_strong -              (fun () -> None) -              (fun _ -> Some (Jstr.(v "emphase"))) in - -        let marks = List.filter_map [is_bold ; is_em] -            ~f:(fun x -> x) in - +        let is_bold = Option.bind (PM.O.get state##.schema##.marks "strong") +            (fun mark_type -> +               let is_strong = +                 Js.Opt.bind state##.storedMarks +                   (fun t -> mark_type##isInSet t) in +               Js.Opt.case is_strong +                 (fun () -> None) +                 (fun _ -> Some (Jstr.v "gras"))) in +        let is_em = Option.bind (PM.O.get state##.schema##.marks "em") +            (fun mark_type -> +               let is_strong = +                 Js.Opt.bind state##.storedMarks +                   (fun t -> mark_type##isInSet t) in +               Js.Opt.case is_strong +                 (fun () -> None) +                 (fun _ -> Some (Jstr.(v "emphase")))) in + +        let marks = List.filter_map [is_bold; is_em] ~f:(fun x -> x) in          match marks with          | [] -> El.set_inline_style El.Style.display (Jstr.v "none") tooltip          | _ -> | 
