Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add summernote editor #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions static/css3/summernote-lite.min.css

Large diffs are not rendered by default.

Binary file added static/font/summernote.eot
Binary file not shown.
Binary file added static/font/summernote.ttf
Binary file not shown.
Binary file added static/font/summernote.woff
Binary file not shown.
Binary file added static/font/summernote.woff2
Binary file not shown.
3 changes: 3 additions & 0 deletions static/jscn/purify.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions static/jscn/summernote-lite.min.js

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions templates/chatroom.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<title>Sanctuary</title>
<link rel="stylesheet" href="{{ url_for("static", filename="css3/fontsome.css") }}" />
<link rel="stylesheet" href="{{ url_for("static", filename="css3/adminlte.css") }}" />
<link rel="stylesheet" href="{{ url_for("static", filename="css3/summernote-lite.min.css") }}" />
<style>
@font-face {
font-family: "Inter";
Expand All @@ -26,6 +27,9 @@
font-family: "Inter", sans-serif;
font-weight: 700;
}
#input-msg-container .note-editor{
flex-grow: 1;
}
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
Expand Down Expand Up @@ -193,6 +197,15 @@ <h4 class="modal-title headelem">Warning</h4>
</div>

<script src="{{ url_for("static", filename="jscn/jquery.min.js") }}"></script>
<script src="{{ url_for("static", filename="jscn/purify.min.js") }}"></script>
<script src="{{ url_for("static", filename="jscn/summernote-lite.min.js") }}"></script>

<script>
function sanitizeInput(inputValue){
return DOMPurify.sanitize(inputValue, {SAFE_FOR_TEMPLATES: true});
}
</script>

<script>
let webesock = new WebSocket("ws://" + document.domain + ":" + {{ chatport }} + "/");
sessionStorage.removeItem("username"); sessionStorage.removeItem("password"); sessionStorage.removeItem("roomiden");
Expand Down Expand Up @@ -234,6 +247,7 @@ <h4 class="modal-title headelem">Warning</h4>
{
if (!(/\s/.test(username) || /\s/.test(roomiden) || /\s/.test(password)))
{
username = sanitizeInput(username);
if (roomiden.match(/^[A-F0-9]{8}$/i) && password.match(/^[A-F0-9]{8}$/i))
{
sessionStorage.setItem("username", username); sessionStorage.setItem("roomiden", roomiden); sessionStorage.setItem("password", password);
Expand All @@ -254,11 +268,14 @@ <h4 class="modal-title headelem">Warning</h4>
"<button type='button' class='btn btn-tool' data-toggle='tooltip'><i class='fas fa-trash-alt'></i></button>" +
"</div>" + "</div>" + "<div class='card-body' id='mesgarea'>" + "<div class='direct-chat-messages' style='height: 100%;'>" +
"</div>" + "</div>" + "<div class='card-footer' style='padding-left: 10px; padding-right: 10px;'>" +
"<form onsubmit='FetchMessageFromTextbox()' action='javascript:;'>" + "<div class='input-group'>" +
"<input type='text' name='message' placeholder='Enter your message here' id='textmesg' class='form-control normelem'>" +
"<form onsubmit='FetchMessageFromTextbox()' action='javascript:;'>" + "<div id='input-msg-container' class='input-group'>" +
"<textarea name='message' placeholder='Enter your message here' id='textmesg' class='form-control normelem'></textarea>" +
"<span class='input-group-append'>" + "<button type='submit' class='btn bg-olive headelem'><i class='fas fa-share'></i></button>" +
"</span>" + "</div>" + "</form>" + "</div>" + "</div>"
$("#statwarn").append(modifdom); $("#statwarn").append(chatboxe);
$('#textmesg').summernote({
focus: true
});
}
}
}
Expand All @@ -272,6 +289,7 @@ <h4 class="modal-title headelem">Warning</h4>
else
{
let textmesg = document.getElementById("textmesg").value;
textmesg = sanitizeInput(textmesg);
if (textmesg != "")
{
if (textmesg == "/stop")
Expand Down