fix bug with editing textarea

This commit is contained in:
Swrup 2022-05-18 22:59:35 +02:00
parent a820fe1823
commit ebe48d71b6

View file

@ -13,15 +13,15 @@ let insert_quote el _event =
match find_by_id_opt "comment" with match find_by_id_opt "comment" with
| None -> log "element `comment` not found, not logged in?@\n" | None -> log "element `comment` not found, not logged in?@\n"
| Some textarea -> | Some textarea ->
let inner_html = El.Prop.jstr (Jstr.of_string "innerHTML") in let value = El.Prop.value in
let content = Jstr.to_string @@ El.prop inner_html textarea in let content = Jstr.to_string @@ El.prop value textarea in
let new_content = let new_content =
if String.ends_with ~suffix:"\n" content || String.length content = 0 then if String.ends_with ~suffix:"\n" content || String.length content = 0 then
(* don't skip a line *) (* don't skip a line *)
Format.sprintf "%s[>%s] " content emojid Format.sprintf "%s[>%s] " content emojid
else Format.sprintf "%s@\n[>%s] " content emojid else Format.sprintf "%s@\n[>%s] " content emojid
in in
El.set_prop inner_html (Jstr.of_string new_content) textarea; El.set_prop value (Jstr.of_string new_content) textarea;
El.set_has_focus true textarea El.set_has_focus true textarea
(* make image description field visible when a file is selected*) (* make image description field visible when a file is selected*)