Implements a markdown box

This commit is contained in:
MathMan05 2024-07-21 15:55:44 -05:00
parent 95a651396d
commit 02f53fb1e5
12 changed files with 221 additions and 30 deletions

View file

@ -122,7 +122,7 @@ async function enter(event){
if(event.key === "Enter"&&!event.shiftKey){
event.preventDefault();
if(channel.editing){
channel.editing.edit((typebox).value);
channel.editing.edit(markdown.rawString);
channel.editing=null;
}else{
replyingto= thisuser.channelfocus.replyingto;
@ -131,7 +131,7 @@ async function enter(event){
replyingto.div.classList.remove("replying");
}
thisuser.channelfocus.replyingto=null;
channel.sendMessage(typebox.value,{
channel.sendMessage(markdown.rawString,{
attachments:images,
replyingto:replying,
})
@ -141,12 +141,15 @@ async function enter(event){
images.pop();
pasteimage.removeChild(imageshtml.pop());
}
typebox.value="";
typebox.innerHTML="";
return;
}
}
const typebox=document.getElementById("typebox") as HTMLInputElement;
const typebox=document.getElementById("typebox") as HTMLDivElement;
const markdown=new MarkDown("",thisuser);
markdown.giveBox(typebox);
typebox["markdown"]=markdown;
typebox.addEventListener("keyup",enter);
typebox.addEventListener("keydown",event=>{
if(event.key === "Enter"&&!event.shiftKey) event.preventDefault();
@ -166,6 +169,7 @@ const images:Blob[]=[];
const imageshtml=[];
import { File } from "./file.js";
import { MarkDown } from "./markdown.js";
document.addEventListener('paste', async (e) => {
Array.from(e.clipboardData.files).forEach(async (f) => {
const file=File.initFromBlob(f);