mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-12-22 23:59:08 +03:00
Added markdown editor
This commit is contained in:
parent
c06af31f26
commit
00c509d0ec
4 changed files with 28 additions and 21 deletions
|
@ -35,11 +35,14 @@ Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn
|
|||
| To do | Is done? | Priority |
|
||||
| ----- | -------- | -------- |
|
||||
| Profile Message | 🟡 | LOW |
|
||||
| IPs of users will add SecretModel | ⚪ | MEDIUM |
|
||||
| IPs of users will add UserModel with select- | ⚪ | MEDIUM |
|
||||
| Better Auth | ⚪ | MEDIUM |
|
||||
- mod role, permissions
|
||||
- Fix footer, theme, category pages
|
||||
- upload other photos, model for it
|
||||
|
||||
- category system bloat.
|
||||
- replace not found errors with no perm
|
||||
- prewiev for send messages in markdown format.
|
||||
## Major Version History
|
||||
- V4: Caching
|
||||
- V3: New Theme
|
||||
|
|
|
@ -33,13 +33,13 @@ window.send_edit = async function (id) {
|
|||
const res = await request(`/api/messages/${id}/`, "PATCH", { content });
|
||||
if (res.error) return;
|
||||
alert(`Message updated`);
|
||||
message.querySelector(".content").innerHTML = res.content;
|
||||
message.querySelector(".content").innerHTML = converter.makeHtml(res.content);
|
||||
}
|
||||
window.edit_message = async function (id) {
|
||||
const content = document.getElementById(`message-${id}`).querySelector(".content");
|
||||
|
||||
content.innerHTML = `
|
||||
<textarea rows="4" cols="40" id="content">${content.innerHTML}</textarea>
|
||||
<textarea rows="4" cols="40" id="content">${content.rawText}</textarea>
|
||||
<button onclick="send_edit(${id});" class="btn-primary">Edit!</button>`;
|
||||
|
||||
}
|
||||
|
|
|
@ -30,10 +30,8 @@ app.get("/:id/", async (req, res) => {
|
|||
if (!user || !user.admin) query.deleted = false;
|
||||
|
||||
const messages = await Promise.all(await MessageModel.find(query).sort({ time: 1 }).limit(10).skip(page * 10)
|
||||
.then(messages => messages.map(async message => {
|
||||
message.content = clearContent(message.content)
|
||||
return await message.get_author();
|
||||
})));
|
||||
.then(messages => messages.map(message => message.get_author())));
|
||||
|
||||
res.reply("thread", { page, thread, messages, scroll: req.query.scroll || messages[0]?.id });
|
||||
|
||||
thread.save();
|
||||
|
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
<body>
|
||||
<%- include("extra/navbar") %>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
|
||||
|
||||
<link href='https://unpkg.com/boxicons@2.1.2/css/boxicons.min.css' rel='stylesheet'>
|
||||
|
||||
<link rel="stylesheet" href="/css/thread.css" />
|
||||
<link rel="stylesheet" href="/css/pages.css" />
|
||||
|
||||
<% if (user){ %>
|
||||
<script type="module" src="/js/thread.js"></script>
|
||||
<% }; %>
|
||||
|
||||
<div style="text-align:center;padding:8px">
|
||||
<div class="title" id="title"><%= thread.title %></div>
|
||||
|
@ -52,7 +51,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content"><%- message.content %></div>
|
||||
<div class="content"><%= message.content %></div>
|
||||
<% if(user){ %>
|
||||
<% if(user.id === message.authorID || user.admin){ %>
|
||||
|
||||
|
@ -92,7 +91,22 @@
|
|||
|
||||
<% }); %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const converter = new showdown.Converter();
|
||||
for (const message of document.querySelectorAll(".message")) {
|
||||
const content = message.querySelector(".content");
|
||||
content.innerHTML = converter.makeHtml(content.rawText = content.innerHTML);
|
||||
}
|
||||
document.getElementById("message-<%= scroll %>").scrollIntoView();
|
||||
|
||||
function dots(id) {
|
||||
document.getElementById('message-' + id).querySelector(".dots-menu").classList.toggle('active')
|
||||
}
|
||||
</script>
|
||||
|
||||
<% if (user){ %>
|
||||
<script type="module" src="/js/thread.js"></script>
|
||||
|
||||
<div class="message" id="send-div">
|
||||
<form id="send" style="width:100%">
|
||||
|
@ -121,7 +135,7 @@
|
|||
let tp = Number("<%= thread.pages %>")
|
||||
let tm = Number("<%= thread.count %>")
|
||||
if (tp * 10 === tm) tp++;
|
||||
if (res) location.href = `/threads/${data.get("threadID")}?page=${tp-1}`;
|
||||
if (res) location.href = `/threads/<%= thread.id %>?page=${tp-1}`;
|
||||
|
||||
|
||||
});
|
||||
|
@ -148,14 +162,6 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById("message-<%= scroll %>").scrollIntoView();
|
||||
|
||||
function dots(id) {
|
||||
document.getElementById('message-' + id).querySelector(".dots-menu").classList.toggle('active')
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue