this repo has no description

support external css stylesheet

ArthurW f2a12a2f 997a3bd6

+20 -3
+16 -1
src/cell.ml
··· 84 84 invalidate_from ~editor; 85 85 Client.fmt ~id:editor.id editor.worker doc 86 86 87 - let init ~id worker this = 87 + let init ~id ?extra_style worker this = 88 88 let shadow = Webcomponent.attach_shadow this in 89 89 90 90 El.append_children shadow 91 91 [ El.style [ El.txt @@ Jstr.of_string [%blob "style.css"] ] ]; 92 + (match extra_style with 93 + | None -> () 94 + | Some src_style -> 95 + El.append_children shadow 96 + [ 97 + El.link 98 + ~at: 99 + [ 100 + At.href src_style; 101 + At.rel (Jstr.of_string "stylesheet"); 102 + At.type' (Jstr.of_string "text/css"); 103 + ] 104 + (); 105 + ]); 106 + 92 107 let run_btn = El.button [ El.txt (Jstr.of_string "Run") ] in 93 108 El.append_children shadow 94 109 [ El.div ~at:[ At.class' (Jstr.of_string "run_btn") ] [ run_btn ] ];
+1 -1
src/cell.mli
··· 1 1 type t 2 2 3 - val init : id:int -> Client.t -> Webcomponent.t -> t 3 + val init : id:int -> ?extra_style:Jstr.t -> Client.t -> Webcomponent.t -> t 4 4 val id : t -> int 5 5 val set_source : t -> string -> unit 6 6 val add_message : t -> int -> X_protocol.output list -> unit
+3 -1
src/x_ocaml.ml
··· 32 32 | None -> Jstr.of_string "x-ocaml" 33 33 | Some name -> name 34 34 35 + let extra_style = current_attribute "src-style" 36 + 35 37 let _ = 36 38 Webcomponent.define elt_name @@ fun this -> 37 39 let prev = match !all with [] -> None | e :: _ -> Some e in 38 40 let id = List.length !all in 39 - let editor = Cell.init ~id worker this in 41 + let editor = Cell.init ~id ?extra_style worker this in 40 42 all := editor :: !all; 41 43 Cell.set_prev ~prev editor; 42 44 ()