Skip to content

Commit

Permalink
GUI: show codemirror in a non erased reactive signal
Browse files Browse the repository at this point in the history
  • Loading branch information
pirbo committed Feb 27, 2024
1 parent ff5d137 commit 3a4a12f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
12 changes: 4 additions & 8 deletions gui/subpanel_editor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ let content () =
(React.S.map
(fun model ->
match model.State_file.current with
| None -> [ "no-panel-body"; "flex-content" ]
| Some _ -> [ "panel-body"; "flex-content" ])
| None -> let () = Common.hide_codemirror () in
[ "no-panel-body"; "flex-content" ]
| Some _ -> let () = Common.show_codemirror () in
[ "panel-body"; "flex-content" ])
State_file.model);
Html.a_id editor_panel_id;
]
Expand Down Expand Up @@ -232,12 +234,6 @@ let onload () : unit =
dont_gc_me_signals :=
[
React.S.map (fun _ -> codemirror##performLint) State_error.errors;
React.S.map
(fun model ->
match model.State_file.current with
| None -> Common.hide_codemirror ()
| Some _ -> Common.show_codemirror ())
State_file.model;
]
in
let () =
Expand Down
6 changes: 2 additions & 4 deletions viz/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,9 @@ function childrenValue(element,selector,map){
}

function hideCodeMirror(){
var cm = $('.CodeMirror')[0].CodeMirror;
$(cm.getWrapperElement()).hide();
$.each($('.CodeMirror'),(_,cm) => $(cm.CodeMirror.getWrapperElement()).hide());
}

function showCodeMirror(){
var cm = $('.CodeMirror')[0].CodeMirror;
$(cm.getWrapperElement()).show();
$.each($('.CodeMirror'),(_,cm) => $(cm.CodeMirror.getWrapperElement()).show());
}

0 comments on commit 3a4a12f

Please sign in to comment.