···8484 invalidate_from ~editor;
8585 Client.fmt ~id:editor.id editor.worker doc
86868787-let init ~id ?extra_style worker this =
8888- let shadow = Webcomponent.attach_shadow this in
8989-8787+let init_css shadow ~extra_style ~inline_style =
9088 El.append_children shadow
9191- [ El.style [ El.txt @@ Jstr.of_string [%blob "style.css"] ] ];
9292- (match extra_style with
8989+ [
9090+ El.style
9191+ (El.txt (Jstr.of_string [%blob "style.css"])
9292+ ::
9393+ (match inline_style with
9494+ | None -> []
9595+ | Some inline_style ->
9696+ [
9797+ El.txt
9898+ @@ Jstr.of_string (":host{" ^ Jstr.to_string inline_style ^ "}");
9999+ ]));
100100+ ];
101101+ match extra_style with
93102 | None -> ()
94103 | Some src_style ->
95104 El.append_children shadow
···102111 At.type' (Jstr.of_string "text/css");
103112 ]
104113 ();
105105- ]);
114114+ ]
115115+116116+let init ~id ?extra_style ?inline_style worker this =
117117+ let shadow = Webcomponent.attach_shadow this in
118118+ init_css shadow ~extra_style ~inline_style;
106119107120 let run_btn = El.button [ El.txt (Jstr.of_string "Run") ] in
108121 El.append_children shadow
+8-1
src/cell.mli
···11type t
2233-val init : id:int -> ?extra_style:Jstr.t -> Client.t -> Webcomponent.t -> t
33+val init :
44+ id:int ->
55+ ?extra_style:Jstr.t ->
66+ ?inline_style:Jstr.t ->
77+ Client.t ->
88+ Webcomponent.t ->
99+ t
1010+411val id : t -> int
512val set_source : t -> string -> unit
613val add_message : t -> int -> X_protocol.output list -> unit
+2-1
src/x_ocaml.ml
···3333 | Some name -> name
34343535let extra_style = current_attribute "src-style"
3636+let inline_style = current_attribute "inline-style"
36373738let _ =
3839 Webcomponent.define elt_name @@ fun this ->
3940 let prev = match !all with [] -> None | e :: _ -> Some e in
4041 let id = List.length !all in
4141- let editor = Cell.init ~id ?extra_style worker this in
4242+ let editor = Cell.init ~id ?extra_style ?inline_style worker this in
4243 all := editor :: !all;
4344 Cell.set_prev ~prev editor;
4445 ()