]> code.citadel.org Git - citadel.git/commitdiff
content editable window with focus and cursor
authorArt Cancro <ajc@citadel.org>
Tue, 23 Nov 2021 21:13:48 +0000 (16:13 -0500)
committerArt Cancro <ajc@citadel.org>
Tue, 23 Nov 2021 21:13:48 +0000 (16:13 -0500)
webcit-ng/static/js/view_forum.js

index 464e59a4a69090730a1f2a1a347fce1c47b9e000..823c983f3f9f3e8aa0270847a900f11778ce1240 100644 (file)
@@ -216,7 +216,7 @@ function open_reply_box(prefix, msgnum, is_quoted) {
          "</div><br>"                                                  // end header
 
 
-       + "<div class=\"ctdl-msg-body\" style=\"height:30vh;\">"        // begin body
+       + "<div class=\"ctdl-msg-body\" id=\"ctdl-editor-body\" style=\"height:30vh; padding:5px;\" contenteditable=\"true\">"  // begin body
        + "This is where the reply text will go."
        + "</div>"                                                      // end body
 
@@ -252,4 +252,17 @@ function open_reply_box(prefix, msgnum, is_quoted) {
 
        document.getElementById(new_div_name).innerHTML = replybox;
        document.getElementById(new_div_name).scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"});
+
+       // This puts the focus and cursor in the edit box.
+       setTimeout(function() {
+               var tag = document.getElementById("ctdl-editor-body");
+              
+               // Set cursor on focus
+               tag.focus();
+
+               // cursor
+               var sel = window.getSelection();
+               sel.collapse(tag.firstChild, 0);
+
+       }, 0);
 }