changeset 25:66fd3784e60e

back to textarea for bbcode
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 19 Jul 2022 22:24:24 -0600
parents fccbe5554fcc
children 0837820b97fb
files src/edit.js.luan src/save_edit.js.luan src/site.css src/thread.html.luan
diffstat 4 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/edit.js.luan	Tue Jul 19 22:07:02 2022 -0600
+++ b/src/edit.js.luan	Tue Jul 19 22:24:24 2022 -0600
@@ -17,8 +17,8 @@
 let postDiv = document.querySelector('[post="<%=post.id%>"]');
 postDiv.querySelector('[output]').style.display = 'none';
 postDiv.querySelector('[edit]').innerHTML = document.querySelector('[hidden][edit]').innerHTML;
-let contentEditable = postDiv.querySelector('[contentEditable]');
-contentEditable.innerHTML = <%= json_string(html_encode(post.content)) %>;
-contentEditable.focus();
+let textarea = postDiv.querySelector('textarea');
+textarea.innerHTML = <%= json_string(html_encode(post.content)) %>;
+textarea.focus();
 <%
 end
--- a/src/save_edit.js.luan	Tue Jul 19 22:07:02 2022 -0600
+++ b/src/save_edit.js.luan	Tue Jul 19 22:24:24 2022 -0600
@@ -7,7 +7,6 @@
 local Http = require "luan:http/Http.luan"
 local Post = require "site:/lib/Post.luan"
 local Bbcode = require "site:/lib/Bbcode.luan"
-local remove_html = Bbcode.remove_html or error()
 local bbcode_to_html = Bbcode.to_html or error()
 local Db = require "site:/lib/Db.luan"
 
@@ -15,7 +14,6 @@
 return function()
 	local post = Http.request.parameters.post or error()
 	local text = Http.request.parameters.text or error()
-	text = remove_html(text)
 	Db.run_in_transaction( function()
 		post = Post.get_by_id(post) or error()
 		post.author_is_current() or error()
--- a/src/site.css	Tue Jul 19 22:07:02 2022 -0600
+++ b/src/site.css	Tue Jul 19 22:24:24 2022 -0600
@@ -15,10 +15,10 @@
 	text-decoration: underline;
 }
 
-div[contenteditable] {
+textarea {
+	font: inherit;
 	padding: 7px;
-	border: 1px solid #777;
-	white-space: pre-wrap;
+	border-color: #DDDDDD;
 }
 
 div[header], div[footer] {
--- a/src/thread.html.luan	Tue Jul 19 22:07:02 2022 -0600
+++ b/src/thread.html.luan	Tue Jul 19 22:24:24 2022 -0600
@@ -56,7 +56,12 @@
 			[message] {
 				white-space: pre-wrap;
 			}
-		</style>
+			textarea {
+				width: 100%;
+				xmax-width: 450px;
+				height: 100px;
+			}
+ 		</style>
 		<script>
 			function getPostDiv(node) {
 				do {
@@ -73,7 +78,7 @@
 			function saveEdit(a) {
 				let postDiv = getPostDiv(a);
 				let post = postDiv.getAttribute('post');
-				let text = postDiv.querySelector('[contentEditable]').innerHTML;
+				let text = postDiv.querySelector('textarea').value;
 				let postData = 'post=' + post + '&text=' + encodeURIComponent(text);
 				ajax("save_edit.js",postData);
 			}
@@ -134,7 +139,7 @@
 		<span hidden delete>Delete? <a href="javascript:" onclick="deleteYes(parentNode)">yes</a> / <a href="javascript:" onclick="deleteNo(parentNode)">no</a></span>
 		<span hidden undelete><%deletePost()%></span>
 		<div hidden edit>
-			<div contentEditable></div>
+			<textarea></textarea>
 			<p>
 				<button onclick="saveEdit(this)">save</button>
 				<button onclick="cancelEdit(this)">cancel</button>