diff --git a/app.js b/app.js new file mode 100644 index 0000000..e4fea55 --- /dev/null +++ b/app.js @@ -0,0 +1,1166 @@ +/* +=========================== +Discord Markdown Editor +by: github.com/pvrzz +=========================== +*/ + +const editor = document.getElementById("editor"); +const preview = document.getElementById("preview"); +const toolbar = document.getElementById("toolbar"); +const quickList = document.getElementById("quickList"); +const toast = document.getElementById("toast"); + +const TOOLS = [ + { id: "bold", fa: "fa-solid fa-bold", lbl: "Bold", wrap: ["**", "**"], ph: "bold text" }, + { id: "italic", fa: "fa-solid fa-italic", lbl: "Italic", wrap: ["*", "*"], ph: "italic text" }, + { id: "underline", fa: "fa-solid fa-underline", lbl: "Underline", wrap: ["__", "__"], ph: "underline" }, + { id: "strike", fa: "fa-solid fa-strikethrough", lbl: "Strike", wrap: ["~~", "~~"], ph: "strikethrough" }, + { id: "spoiler", fa: "fa-solid fa-eye-slash", lbl: "Spoiler", wrap: ["||", "||"], ph: "spoiler" }, + { sep: true }, + { id: "code", fa: "fa-solid fa-code", lbl: "Code", wrap: ["`", "`"], ph: "code" }, + { id: "codeblock", fa: "fa-solid fa-file-code", lbl: "Block", block: "codeblock", ph: "code block" }, + { sep: true }, + { id: "h1", ico: "H1", lbl: "", line: "# ", ph: "Big header" }, + { id: "h2", ico: "H2", lbl: "", line: "## ", ph: "Medium header" }, + { id: "h3", ico: "H3", lbl: "", line: "### ", ph: "Small header" }, + { id: "subtext", fa: "fa-solid fa-subscript", lbl: "Subtext", line: "-# ", ph: "subtext" }, + { sep: true }, + { id: "quote", fa: "fa-solid fa-quote-right", lbl: "Quote", line: "> ", ph: "quote" }, + { id: "blockquote", fa: "fa-solid fa-quote-left", lbl: "Block Quote", line: ">>> ", ph: "multi-line quote" }, + { id: "bullet", fa: "fa-solid fa-list-ul", lbl: "List", line: "- ", ph: "list item" }, + { id: "numbered", fa: "fa-solid fa-list-ol", lbl: "Numbered", line: "1. ", ph: "list item" }, + { sep: true }, + { id: "link", fa: "fa-solid fa-link", lbl: "Link", action: "link" }, +]; + +const QUICK = [ + { id: "bold", label: "Bold", key: "Ctrl+B" }, + { id: "italic", label: "Italic", key: "Ctrl+I" }, + { id: "underline", label: "Underline", key: "Ctrl+U" }, + { id: "strike", label: "Strikethrough" }, + { id: "spoiler", label: "Spoiler" }, + { id: "code", label: "Inline code" }, + { id: "codeblock", label: "Code block" }, + { id: "link", label: "Masked link" }, +]; + +function getTool(id) { return TOOLS.find(t => t.id === id); } + +function buildToolbar() { + TOOLS.forEach(t => { + if (t.sep) { + const s = document.createElement("div"); + s.className = "tool-sep"; + toolbar.appendChild(s); + return; + } + const b = document.createElement("button"); + b.className = "tool-btn"; + b.title = t.lbl || t.id; + let html = t.fa ? `` : `${t.ico}`; + if (t.lbl) html += `${t.lbl}`; + b.innerHTML = html; + b.addEventListener("click", () => applyTool(t)); + toolbar.appendChild(b); + }); +} + +function buildQuickList() { + QUICK.forEach(q => { + const b = document.createElement("button"); + b.className = "quick-item"; + b.innerHTML = `${q.label}${q.key ? `${q.key}` : ""}`; + b.addEventListener("click", () => applyTool(getTool(q.id))); + quickList.appendChild(b); + }); +} + +function applyTool(t) { + if (!t) return; + editor.focus(); + const start = editor.selectionStart; + const end = editor.selectionEnd; + const val = editor.value; + const selected = val.slice(start, end); + + if (t.action === "link") return insertLink(start, end, selected, val); + if (t.block === "codeblock") return insertCodeBlock(start, end, selected, val); + if (t.wrap) return wrapSelection(t, start, end, selected, val); + if (t.line) return prefixLines(t, start, end, selected, val); +} + +function wrapSelection(t, start, end, selected, val) { + const [open, close] = t.wrap; + const text = selected || t.ph; + const replacement = open + text + close; + editor.value = val.slice(0, start) + replacement + val.slice(end); + if (selected) { + setSel(start + open.length, start + open.length + text.length); + } else { + setSel(start + open.length, start + open.length + text.length); + } + render(); +} + +function insertCodeBlock(start, end, selected, val) { + const text = selected || "code here"; + const replacement = "```\n" + text + "\n```"; + editor.value = val.slice(0, start) + replacement + val.slice(end); + setSel(start + 4, start + 4 + text.length); + render(); +} + +function insertLink(start, end, selected, val) { + const label = selected || "link text"; + const url = "https://"; + const replacement = "[" + label + "](" + url + ")"; + editor.value = val.slice(0, start) + replacement + val.slice(end); + const urlStart = start + 1 + label.length + 2; + setSel(urlStart, urlStart + url.length); + render(); +} + +function prefixLines(t, start, end, selected, val) { + const lineStart = val.lastIndexOf("\n", start - 1) + 1; + let lineEnd = val.indexOf("\n", end); + if (lineEnd === -1) lineEnd = val.length; + const block = val.slice(lineStart, lineEnd); + const lines = block.length ? block.split("\n") : [""]; + + let counter = 1; + const out = lines.map(line => { + if (t.id === "numbered") return (counter++) + ". " + line; + return t.line + line; + }).join("\n"); + + let finalOut = out; + if (block.length === 0) { + finalOut = t.id === "numbered" ? "1. " + t.ph : t.line + t.ph; + } + + editor.value = val.slice(0, lineStart) + finalOut + val.slice(lineEnd); + if (block.length === 0) { + const prefixLen = (t.id === "numbered" ? 3 : t.line.length); + setSel(lineStart + prefixLen, lineStart + prefixLen + t.ph.length); + } else { + setSel(lineStart, lineStart + finalOut.length); + } + render(); +} + +function setSel(a, b) { + editor.selectionStart = a; + editor.selectionEnd = b; +} + +/* ============ MARKDOWN RENDERER ============ */ + +function escapeHtml(s) { + return s.replace(/&/g, "&").replace(//g, ">"); +} + +const MONTHS = ["January","February","March","April","May","June","July","August","September","October","November","December"]; +const DAYS = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; + +function fmtTime(d) { + let h = d.getHours(); + const m = String(d.getMinutes()).padStart(2, "0"); + const ap = h >= 12 ? "PM" : "AM"; + h = h % 12; if (h === 0) h = 12; + return `${h}:${m} ${ap}`; +} +function fmtTimeSec(d) { + let h = d.getHours(); + const m = String(d.getMinutes()).padStart(2, "0"); + const s = String(d.getSeconds()).padStart(2, "0"); + const ap = h >= 12 ? "PM" : "AM"; + h = h % 12; if (h === 0) h = 12; + return `${h}:${m}:${s} ${ap}`; +} +function fmtShortDate(d) { + return `${String(d.getMonth()+1).padStart(2,"0")}/${String(d.getDate()).padStart(2,"0")}/${d.getFullYear()}`; +} +function fmtLongDate(d) { + return `${MONTHS[d.getMonth()]} ${d.getDate()}, ${d.getFullYear()}`; +} +function relativeTime(d) { + const now = Date.now(); + let diff = d.getTime() - now; + const future = diff >= 0; + diff = Math.abs(diff); + const sec = Math.round(diff / 1000); + const units = [ + ["year", 31536000], ["month", 2592000], ["day", 86400], + ["hour", 3600], ["minute", 60], ["second", 1], + ]; + for (const [name, s] of units) { + if (sec >= s || name === "second") { + const n = Math.max(1, Math.floor(sec / s)); + const plural = n === 1 ? "" : "s"; + return future ? `in ${n} ${name}${plural}` : `${n} ${name}${plural} ago`; + } + } + return "now"; +} + +function renderTimestamp(unix, style) { + const d = new Date(unix * 1000); + switch (style) { + case "t": return fmtTime(d); + case "T": return fmtTimeSec(d); + case "d": return fmtShortDate(d); + case "D": return fmtLongDate(d); + case "f": return `${fmtLongDate(d)} ${fmtTime(d)}`; + case "F": return `${DAYS[d.getDay()]}, ${fmtLongDate(d)} ${fmtTime(d)}`; + case "R": return relativeTime(d); + default: return `${fmtLongDate(d)} ${fmtTime(d)}`; + } +} + +function renderInline(text) { + let out = ""; + let i = 0; + const n = text.length; + + while (i < n) { + const rest = text.slice(i); + + let m; + if ((m = rest.match(/^/))) { + const unix = parseInt(m[1], 10); + const style = m[2] || "f"; + out += `${escapeHtml(renderTimestamp(unix, style))}`; + i += m[0].length; continue; + } + if ((m = rest.match(/^<(@!?\d+|@&\d+|#\d+)>/))) { + const raw = m[1]; + let label = raw; + if (raw.startsWith("@&")) label = "@role"; + else if (raw.startsWith("@")) label = "@user"; + else if (raw.startsWith("#")) label = "#channel"; + out += `${label}`; + i += m[0].length; continue; + } + if (rest.startsWith("```")) { + const close = text.indexOf("```", i + 3); + if (close !== -1) { + let inner = text.slice(i + 3, close); + inner = inner.replace(/^[a-zA-Z0-9+\-]*\n/, ""); + inner = inner.replace(/^\n/, ""); + out += `
${escapeHtml(inner)}
`; + i = close + 3; continue; + } + } + if (rest[0] === "`") { + const close = text.indexOf("`", i + 1); + if (close !== -1) { + out += `${escapeHtml(text.slice(i + 1, close))}`; + i = close + 1; continue; + } + } + if (rest.startsWith("**")) { + const close = text.indexOf("**", i + 2); + if (close !== -1) { + out += `${renderInline(text.slice(i + 2, close))}`; + i = close + 2; continue; + } + } + if (rest.startsWith("__")) { + const close = text.indexOf("__", i + 2); + if (close !== -1) { + out += `${renderInline(text.slice(i + 2, close))}`; + i = close + 2; continue; + } + } + if (rest.startsWith("~~")) { + const close = text.indexOf("~~", i + 2); + if (close !== -1) { + out += `${renderInline(text.slice(i + 2, close))}`; + i = close + 2; continue; + } + } + if (rest.startsWith("||")) { + const close = text.indexOf("||", i + 2); + if (close !== -1) { + out += `${renderInline(text.slice(i + 2, close))}`; + i = close + 2; continue; + } + } + if (rest[0] === "*") { + const close = text.indexOf("*", i + 1); + if (close !== -1 && close > i + 1) { + out += `${renderInline(text.slice(i + 1, close))}`; + i = close + 1; continue; + } + } + if (rest[0] === "_") { + const close = text.indexOf("_", i + 1); + if (close !== -1 && close > i + 1) { + out += `${renderInline(text.slice(i + 1, close))}`; + i = close + 1; continue; + } + } + if ((m = rest.match(/^\[([^\]]+)\]\(\s*(https?:\/\/[^\s)]+)\s*\)/))) { + out += `${renderInline(m[1])}`; + i += m[0].length; continue; + } + + out += escapeHtml(text[i]); + i++; + } + return out; +} + +function autoGrow() { + editor.style.height = "auto"; + editor.style.height = Math.min(editor.scrollHeight, window.innerHeight * 0.5) + "px"; +} + +function render() { + const raw = editor.value; + preview.innerHTML = renderBlocks(raw); + attachSpoilers(); + autoGrow(); + saveState(); +} + +function renderBlocks(raw) { + const lines = raw.split("\n"); + let html = ""; + let i = 0; + let listType = null; + let listBuffer = []; + + function flushList() { + if (!listBuffer.length) return; + const tag = listType === "ol" ? "ol" : "ul"; + html += `<${tag} class="md-list">` + listBuffer.map(li => `
  • ${renderInline(li)}
  • `).join("") + ``; + listBuffer = []; + listType = null; + } + + while (i < lines.length) { + const line = lines[i]; + + if (line.trimStart().startsWith("```")) { + flushList(); + const block = []; + let opener = line; + i++; + while (i < lines.length && !lines[i].trimStart().startsWith("```")) { + block.push(lines[i]); i++; + } + i++; + let lang = opener.trim().replace(/^```/, ""); + let body = block.join("\n"); + html += `
    ${escapeHtml(body)}
    `; + continue; + } + + if (line.startsWith(">>> ")) { + flushList(); + const rest = [line.slice(4)]; + i++; + while (i < lines.length) { rest.push(lines[i]); i++; } + html += `
    ${renderInline(rest.join("\n"))}
    `; + continue; + } + + let m; + if ((m = line.match(/^(#{1,3})\s+(.*)$/))) { + flushList(); + const level = m[1].length; + html += `${renderInline(m[2])}`; + i++; continue; + } + if ((m = line.match(/^-#\s+(.*)$/))) { + flushList(); + html += `
    ${renderInline(m[1])}
    `; + i++; continue; + } + if ((m = line.match(/^>\s+(.*)$/))) { + flushList(); + const quoted = [m[1]]; + i++; + while (i < lines.length && (m = lines[i].match(/^>\s?(.*)$/))) { + quoted.push(m[1]); i++; + } + html += `
    ${renderInline(quoted.join("\n"))}
    `; + continue; + } + if ((m = line.match(/^\s*[-*]\s+(.*)$/))) { + if (listType && listType !== "ul") flushList(); + listType = "ul"; + listBuffer.push(m[1]); + i++; continue; + } + if ((m = line.match(/^\s*\d+\.\s+(.*)$/))) { + if (listType && listType !== "ol") flushList(); + listType = "ol"; + listBuffer.push(m[1]); + i++; continue; + } + + flushList(); + if (line === "") { + html += "\n"; + } else { + html += renderInline(line) + (i < lines.length - 1 ? "\n" : ""); + } + i++; + } + flushList(); + return html; +} + +function attachSpoilers() { + preview.querySelectorAll(".md-spoiler").forEach(s => { + s.addEventListener("click", () => s.classList.toggle("revealed")); + }); +} + +/* ============ TABS ============ */ + +function setupTabs() { + const channels = document.querySelectorAll(".channel[data-tab]"); + const panels = document.querySelectorAll(".tab-panel"); + const topbarName = document.getElementById("topbarName"); + const topbarDesc = document.getElementById("topbarDesc"); + const formattingGroup = document.getElementById("formattingGroup"); + const descs = { + editor: "Format your message visually — no symbols to memorize.", + embed: "Build rich embeds and copy webhook / bot ready JSON.", + timestamps: "Build dynamic timestamps that render in everyone's local time.", + snowflake: "Decode any Discord ID into its creation date.", + permissions: "Calculate permission bitfields and bot invite links.", + colors: "Convert hex, RGB and the decimal colors Discord uses.", + cheatsheet: "Every Discord markdown rule at a glance.", + }; + channels.forEach(ch => { + ch.addEventListener("click", () => { + const tab = ch.dataset.tab; + channels.forEach(c => c.classList.toggle("active", c === ch)); + panels.forEach(p => p.classList.toggle("active", p.dataset.panel === tab)); + topbarName.textContent = tab; + topbarDesc.textContent = descs[tab]; + formattingGroup.style.display = tab === "editor" ? "" : "none"; + const showEditorBtns = tab === "editor" ? "" : "none"; + document.getElementById("copyBtn").style.display = showEditorBtns; + document.getElementById("clearBtn").style.display = showEditorBtns; + }); + }); +} + +/* ============ TIMESTAMPS TAB ============ */ + +const TS_STYLES = [ + { code: "t", name: "Short Time" }, + { code: "T", name: "Long Time" }, + { code: "d", name: "Short Date" }, + { code: "D", name: "Long Date" }, + { code: "f", name: "Short Date/Time" }, + { code: "F", name: "Long Date/Time" }, + { code: "R", name: "Relative" }, +]; + +let tsState = { unix: Math.floor(Date.now() / 1000), style: "F" }; + +function setupTimestamps() { + const dateEl = document.getElementById("tsDate"); + const timeEl = document.getElementById("tsTime"); + const stylesEl = document.getElementById("tsStyles"); + const nowBtn = document.getElementById("tsNow"); + const codeEl = document.getElementById("tsCode"); + const previewEl = document.getElementById("tsPreview"); + const unixEl = document.getElementById("tsUnix"); + const copyBtn = document.getElementById("tsCopy"); + + function syncInputsFromState() { + const d = new Date(tsState.unix * 1000); + dateEl.value = `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`; + timeEl.value = `${String(d.getHours()).padStart(2,"0")}:${String(d.getMinutes()).padStart(2,"0")}:${String(d.getSeconds()).padStart(2,"0")}`; + } + + function readStateFromInputs() { + const [y, mo, da] = dateEl.value.split("-").map(Number); + const tparts = timeEl.value.split(":").map(Number); + const h = tparts[0] || 0, mi = tparts[1] || 0, se = tparts[2] || 0; + if (!y) return; + const d = new Date(y, mo - 1, da, h, mi, se); + tsState.unix = Math.floor(d.getTime() / 1000); + } + + function renderStyles() { + stylesEl.innerHTML = ""; + TS_STYLES.forEach(s => { + const b = document.createElement("button"); + b.className = "ts-style" + (s.code === tsState.style ? " active" : ""); + b.innerHTML = `${s.name} + :${s.code} + ${escapeHtml(renderTimestamp(tsState.unix, s.code))}`; + b.addEventListener("click", () => { tsState.style = s.code; update(); }); + stylesEl.appendChild(b); + }); + } + + function update() { + const code = ``; + codeEl.textContent = code; + previewEl.textContent = renderTimestamp(tsState.unix, tsState.style); + unixEl.textContent = tsState.unix; + renderStyles(); + } + + dateEl.addEventListener("input", () => { readStateFromInputs(); update(); }); + timeEl.addEventListener("input", () => { readStateFromInputs(); update(); }); + nowBtn.addEventListener("click", () => { tsState.unix = Math.floor(Date.now()/1000); syncInputsFromState(); update(); }); + copyBtn.addEventListener("click", () => copyText(``)); + + syncInputsFromState(); + update(); +} + +/* ============ CHEATSHEET TAB ============ */ + +const CHEAT = [ + { title: "Text Styles", rows: [ + ["**bold**", "bold"], + ["*italic*", "italic"], + ["__underline__", "underline"], + ["~~strikethrough~~", "strikethrough"], + ["***bold italic***", "bold italic"], + ["||spoiler||", 'spoiler'], + ]}, + { title: "Headers", rows: [ + ["# Big header", 'Big header'], + ["## Medium header", 'Medium header'], + ["### Small header", 'Small header'], + ["-# Subtext", 'Subtext'], + ]}, + { title: "Code", rows: [ + ["`inline code`", 'inline code'], + ["```\\ncode block\\n```", 'code block'], + ["```js\\ncode\\n```", 'syntax highlight'], + ]}, + { title: "Quotes & Lists", rows: [ + ["> quote", 'quote'], + [">>> block quote", 'multi-line'], + ["- bullet item", "• bullet item"], + ["1. numbered item", "1. numbered item"], + ]}, + { title: "Links & Mentions", rows: [ + ["[text](https://url)", 'text'], + ["<@123>", '@user'], + ["<@&123>", '@role'], + ["<#123>", '#channel'], + ]}, + { title: "Timestamps", rows: [ + ["", "5:13 PM"], + ["", "June 20, 2026"], + ["", "Saturday, June 20, 2026 5:13 PM"], + ["", "in 2 hours"], + ]}, +]; + +function buildCheatsheet() { + const wrap = document.getElementById("cheatWrap"); + CHEAT.forEach(card => { + const c = document.createElement("div"); + c.className = "cheat-card"; + c.innerHTML = `

    ${card.title}

    ` + card.rows.map(([syn, res]) => + `
    ${escapeHtml(syn.replace(/\\n/g, "↵"))}${res}
    ` + ).join(""); + wrap.appendChild(c); + }); +} + +/* ============ UTILS ============ */ + +function copyText(text) { + navigator.clipboard.writeText(text).then(() => showToast("Copied to clipboard")).catch(() => { + const ta = document.createElement("textarea"); + ta.value = text; document.body.appendChild(ta); ta.select(); + document.execCommand("copy"); document.body.removeChild(ta); + showToast("Copied to clipboard"); + }); +} + +let toastTimer; +function showToast(msg) { + toast.textContent = msg; + toast.classList.add("show"); + clearTimeout(toastTimer); + toastTimer = setTimeout(() => toast.classList.remove("show"), 1800); +} + +function saveState() { + try { localStorage.setItem("dme:editor", editor.value); } catch (e) {} +} +function loadState() { + try { + const v = localStorage.getItem("dme:editor"); + if (v !== null) editor.value = v; + } catch (e) {} +} + +/* ============ INIT ============ */ + +editor.addEventListener("input", render); +editor.addEventListener("keydown", e => { + if (e.ctrlKey || e.metaKey) { + const map = { b: "bold", i: "italic", u: "underline" }; + const id = map[e.key.toLowerCase()]; + if (id) { e.preventDefault(); applyTool(getTool(id)); } + } + if (e.key === "Tab") { + e.preventDefault(); + const s = editor.selectionStart; + editor.value = editor.value.slice(0, s) + " " + editor.value.slice(editor.selectionEnd); + setSel(s + 2, s + 2); + render(); + } +}); + +document.getElementById("copyBtn").addEventListener("click", () => copyText(editor.value)); +document.getElementById("copyComposer").addEventListener("click", () => copyText(editor.value)); +document.getElementById("clearBtn").addEventListener("click", () => { editor.value = ""; render(); editor.focus(); }); + +const DEFAULT_TEXT = `# Welcome to Toolscord +Format Discord messages **without memorizing symbols**. + +- Click the **toolbar buttons** to format selected text +- Try a ||hidden spoiler|| or some \`inline code\` +- Build embeds, timestamps & more in the other channels + +> "No more guessing which symbol does what." +-# Made with Toolscord`; + +/* ============ EMBED BUILDER ============ */ + +function embedGet(sel) { + const el = document.querySelector(`[data-embed="${sel}"]`); + return el ? el.value.trim() : ""; +} + +function setEmbedColor(hex) { + let h = (hex || "").trim().replace(/^#/, ""); + if (h.length === 3) h = h.split("").map(c => c + c).join(""); + if (!/^[0-9a-fA-F]{6}$/.test(h)) return; + const out = "#" + h.toUpperCase(); + document.getElementById("embedColor").value = out.toLowerCase(); + document.getElementById("embedColorHex").value = out; + document.getElementById("embedColorDec").value = parseInt(h, 16); +} + +function collectFields() { + return [...document.querySelectorAll("#fieldsList .field-item")].map(it => ({ + name: it.querySelector(".f-name").value, + value: it.querySelector(".f-value").value, + inline: it.querySelector(".f-inline").checked, + })).filter(f => f.name.trim() || f.value.trim()); +} + +function addField(name = "", value = "", inline = false) { + const list = document.getElementById("fieldsList"); + const item = document.createElement("div"); + item.className = "field-item"; + item.innerHTML = ` +
    +
    +
    +
    +
    +
    `; + item.querySelector(".f-name").value = name; + item.querySelector(".f-value").value = value; + item.querySelector(".f-inline").checked = !!inline; + item.querySelectorAll("input, textarea").forEach(el => el.addEventListener("input", renderEmbed)); + item.querySelector(".f-inline").addEventListener("change", renderEmbed); + item.querySelector(".field-remove").addEventListener("click", () => { item.remove(); renderEmbed(); }); + list.appendChild(item); +} + +function buildEmbedObject() { + const embed = {}; + const title = embedGet("title"); if (title) embed.title = title; + const url = embedGet("url"); if (url) embed.url = url; + const desc = embedGet("description"); if (desc) embed.description = desc; + const dec = parseInt(document.getElementById("embedColorDec").value, 10); + if (!isNaN(dec)) embed.color = dec; + const an = embedGet("author.name"); + if (an || embedGet("author.icon_url") || embedGet("author.url")) { + embed.author = { name: an }; + const au = embedGet("author.url"); if (au) embed.author.url = au; + const ai = embedGet("author.icon_url"); if (ai) embed.author.icon_url = ai; + } + const thumb = embedGet("thumbnail.url"); if (thumb) embed.thumbnail = { url: thumb }; + const img = embedGet("image.url"); if (img) embed.image = { url: img }; + const fields = collectFields(); + if (fields.length) embed.fields = fields.map(f => { const o = { name: f.name, value: f.value }; if (f.inline) o.inline = true; return o; }); + const ft = embedGet("footer.text"), fi = embedGet("footer.icon_url"); + if (ft || fi) { embed.footer = {}; if (ft) embed.footer.text = ft; if (fi) embed.footer.icon_url = fi; } + if (document.getElementById("embedTimestamp").checked) embed.timestamp = new Date().toISOString(); + return embed; +} + +function isEmptyEmbed(e) { + return Object.keys(e).filter(k => k !== "color").length === 0; +} + +function formatEmbedTimestamp(iso) { + const d = new Date(iso); + if (isNaN(d.getTime())) return ""; + return `${fmtShortDate(d)} ${fmtTime(d)}`; +} + +function renderEmbedPreview(e) { + if (isEmptyEmbed(e)) return `
    Your embed preview will appear here…
    `; + const colorHex = e.color != null ? "#" + (e.color & 0xffffff).toString(16).padStart(6, "0") : "var(--blurple)"; + let c = `
    `; + if (e.author) { + c += `
    `; + if (e.author.icon_url) c += ``; + c += `${escapeHtml(e.author.name || "")}
    `; + } + if (e.title) { + const t = renderInline(e.title); + c += `
    ${e.url ? `${t}` : t}
    `; + } + if (e.description) c += `
    ${renderInline(e.description)}
    `; + if (e.fields && e.fields.length) { + c += `
    `; + e.fields.forEach(f => { + c += `
    ${renderInline(f.name || "")}
    ${renderInline(f.value || "")}
    `; + }); + c += `
    `; + } + if (e.image && e.image.url) c += `
    `; + const footText = e.footer && e.footer.text; + const ts = e.timestamp ? formatEmbedTimestamp(e.timestamp) : ""; + if (footText || ts) { + c += ``; + } + c += `
    `; + const thumb = e.thumbnail && e.thumbnail.url + ? `
    ` : ""; + return `
    ${c}${thumb}
    `; +} + +function renderEmbed() { + const embed = buildEmbedObject(); + const out = document.getElementById("embedPreview"); + out.innerHTML = renderEmbedPreview(embed); + out.querySelectorAll(".md-spoiler").forEach(s => s.addEventListener("click", () => s.classList.toggle("revealed"))); + document.getElementById("embedJson").value = JSON.stringify({ embeds: [embed] }, null, 2); +} + +function setEmbedInput(path, val) { + const el = document.querySelector(`[data-embed="${path}"]`); + if (el) el.value = val == null ? "" : val; +} + +function populateEmbedForm(e) { + e = e || {}; + setEmbedInput("title", e.title); + setEmbedInput("url", e.url); + setEmbedInput("description", e.description); + setEmbedInput("author.name", e.author && e.author.name); + setEmbedInput("author.url", e.author && e.author.url); + setEmbedInput("author.icon_url", e.author && e.author.icon_url); + setEmbedInput("thumbnail.url", e.thumbnail && e.thumbnail.url); + setEmbedInput("image.url", e.image && e.image.url); + setEmbedInput("footer.text", e.footer && e.footer.text); + setEmbedInput("footer.icon_url", e.footer && e.footer.icon_url); + document.getElementById("embedTimestamp").checked = !!e.timestamp; + if (typeof e.color === "number") setEmbedColor("#" + (e.color & 0xffffff).toString(16).padStart(6, "0")); + document.getElementById("fieldsList").innerHTML = ""; + (e.fields || []).forEach(f => addField(f.name, f.value, f.inline)); + renderEmbed(); +} + +function importEmbedJson() { + try { + const data = JSON.parse(document.getElementById("embedJson").value); + let embed = data; + if (Array.isArray(data.embeds)) embed = data.embeds[0] || {}; + else if (data.embed) embed = data.embed; + populateEmbedForm(embed); + showToast("Imported JSON"); + } catch (err) { + showToast("Invalid JSON"); + } +} + +function setupEmbed() { + document.querySelectorAll("[data-embed]").forEach(el => el.addEventListener("input", renderEmbed)); + document.getElementById("embedColor").addEventListener("input", e => { setEmbedColor(e.target.value); renderEmbed(); }); + document.getElementById("embedColorHex").addEventListener("input", e => { setEmbedColor(e.target.value); renderEmbed(); }); + document.getElementById("embedTimestamp").addEventListener("change", renderEmbed); + document.getElementById("addField").addEventListener("click", () => { addField(); renderEmbed(); }); + document.getElementById("copyJson").addEventListener("click", () => copyText(document.getElementById("embedJson").value)); + document.getElementById("importJson").addEventListener("click", importEmbedJson); + populateEmbedForm({ + author: { name: "Toolscord" }, + title: "Welcome to the Embed Builder", + url: "https://github.com/pvrzz", + description: "Edit the fields on the left and watch this **embed** update live.\nThe JSON below is ready to drop into a webhook or bot.", + color: 5793266, + fields: [ + { name: "Markdown", value: "Works in **descriptions** & fields", inline: true }, + { name: "Output", value: "Copy-paste JSON", inline: true }, + ], + footer: { text: "Toolscord" }, + timestamp: new Date().toISOString(), + }); +} + +/* ============ SNOWFLAKE DECODER ============ */ + +const DISCORD_EPOCH = 1420070400000n; + +function decodeSnowflake() { + const raw = document.getElementById("sfInput").value.trim(); + const ids = ["sfDate", "sfRel", "sfUnixMs", "sfTag", "sfWorker", "sfProcess", "sfIncrement"]; + const set = (id, v) => document.getElementById(id).textContent = v; + if (raw === "") { ids.forEach(id => set(id, "—")); return; } + if (!/^\d{1,25}$/.test(raw)) { ids.forEach(id => set(id, "invalid id")); return; } + const sf = BigInt(raw); + const ms = (sf >> 22n) + DISCORD_EPOCH; + const d = new Date(Number(ms)); + set("sfDate", `${DAYS[d.getDay()]}, ${fmtLongDate(d)} ${fmtTimeSec(d)}`); + set("sfRel", relativeTime(d)); + set("sfUnixMs", ms.toString()); + set("sfTag", ``); + set("sfWorker", ((sf >> 17n) & 0x1fn).toString()); + set("sfProcess", ((sf >> 12n) & 0x1fn).toString()); + set("sfIncrement", (sf & 0xfffn).toString()); +} + +function setupSnowflake() { + const input = document.getElementById("sfInput"); + input.addEventListener("input", decodeSnowflake); + input.value = "175928847299117063"; + decodeSnowflake(); +} + +/* ============ PERMISSIONS CALCULATOR ============ */ + +const PERMISSIONS = [ + ["Create Invite", 0], ["Kick Members", 1], ["Ban Members", 2], ["Administrator", 3], + ["Manage Channels", 4], ["Manage Server", 5], ["Add Reactions", 6], ["View Audit Log", 7], + ["Priority Speaker", 8], ["Video / Go Live", 9], ["View Channels", 10], ["Send Messages", 11], + ["Send TTS Messages", 12], ["Manage Messages", 13], ["Embed Links", 14], ["Attach Files", 15], + ["Read Message History", 16], ["Mention @everyone", 17], ["Use External Emoji", 18], + ["View Server Insights", 19], ["Connect", 20], ["Speak", 21], ["Mute Members", 22], + ["Deafen Members", 23], ["Move Members", 24], ["Use Voice Activity", 25], ["Change Nickname", 26], + ["Manage Nicknames", 27], ["Manage Roles", 28], ["Manage Webhooks", 29], + ["Manage Emojis & Stickers", 30], ["Use Application Commands", 31], ["Request to Speak", 32], + ["Manage Events", 33], ["Manage Threads", 34], ["Create Public Threads", 35], + ["Create Private Threads", 36], ["Use External Stickers", 37], ["Send Messages in Threads", 38], + ["Use Embedded Activities", 39], ["Timeout Members", 40], ["Send Voice Messages", 46], +]; + +function updatePerms() { + let val = 0n; + document.querySelectorAll("#permGrid input:checked").forEach(i => { val |= (1n << BigInt(i.dataset.bit)); }); + document.getElementById("permValue").textContent = val.toString(); + const cid = document.getElementById("permClientId").value.trim() || "YOUR_CLIENT_ID"; + document.getElementById("permInvite").value = + `https://discord.com/oauth2/authorize?client_id=${encodeURIComponent(cid)}&scope=bot+applications.commands&permissions=${val.toString()}`; +} + +function setupPermissions() { + const grid = document.getElementById("permGrid"); + PERMISSIONS.forEach(([name, bit]) => { + const lab = document.createElement("label"); + lab.className = "perm-item"; + lab.innerHTML = `${name}`; + const cb = lab.querySelector("input"); + cb.addEventListener("change", () => { lab.classList.toggle("on", cb.checked); updatePerms(); }); + grid.appendChild(lab); + }); + document.getElementById("permClientId").addEventListener("input", updatePerms); + document.getElementById("permCopy").addEventListener("click", () => copyText(document.getElementById("permValue").textContent)); + document.getElementById("permInviteCopy").addEventListener("click", () => copyText(document.getElementById("permInvite").value)); + document.getElementById("permClear").addEventListener("click", () => { + grid.querySelectorAll("input").forEach(i => { i.checked = false; i.closest(".perm-item").classList.remove("on"); }); + updatePerms(); + }); + updatePerms(); +} + +/* ============ COLOR CONVERTER ============ */ + +const COLOR_PRESETS = [ + ["Blurple", "#5865F2"], ["Green", "#57F287"], ["Yellow", "#FEE75C"], ["Fuchsia", "#EB459E"], + ["Red", "#ED4245"], ["White", "#FFFFFF"], ["Black", "#000000"], ["Greyple", "#99AAB5"], + ["Dark", "#2C2F33"], ["Aqua", "#1ABC9C"], ["Blue", "#3498DB"], ["Purple", "#9B59B6"], + ["Orange", "#E67E22"], ["Gold", "#F1C40F"], +]; + +function clampByte(n) { return Math.max(0, Math.min(255, n | 0)); } + +function applyColor(value, from) { + let r, g, b; + if (from === "hex") { + let h = (value || "").trim().replace(/^#/, ""); + if (h.length === 3) h = h.split("").map(c => c + c).join(""); + if (!/^[0-9a-fA-F]{6}$/.test(h)) { document.getElementById("colHex").value = value; return; } + r = parseInt(h.slice(0, 2), 16); g = parseInt(h.slice(2, 4), 16); b = parseInt(h.slice(4, 6), 16); + } else if (from === "dec") { + let n = parseInt(value, 10); if (isNaN(n)) return; + n = Math.max(0, Math.min(16777215, n)); + r = (n >> 16) & 255; g = (n >> 8) & 255; b = n & 255; + } else { + r = clampByte(+document.getElementById("colR").value); + g = clampByte(+document.getElementById("colG").value); + b = clampByte(+document.getElementById("colB").value); + } + const hex = "#" + [r, g, b].map(x => x.toString(16).padStart(2, "0")).join("").toUpperCase(); + const dec = (r << 16) + (g << 8) + b; + document.getElementById("colInput").value = hex.toLowerCase(); + document.getElementById("colHex").value = hex; + document.getElementById("colDec").value = dec; + document.getElementById("colR").value = r; + document.getElementById("colG").value = g; + document.getElementById("colB").value = b; + document.getElementById("colSwatch").style.background = hex; +} + +function setupColors() { + const presets = document.getElementById("colPresets"); + COLOR_PRESETS.forEach(([name, hex]) => { + const b = document.createElement("button"); + b.className = "color-preset"; + b.innerHTML = `${name}`; + b.addEventListener("click", () => applyColor(hex, "hex")); + presets.appendChild(b); + }); + document.getElementById("colInput").addEventListener("input", e => applyColor(e.target.value, "hex")); + document.getElementById("colHex").addEventListener("input", e => applyColor(e.target.value, "hex")); + document.getElementById("colDec").addEventListener("input", e => applyColor(e.target.value, "dec")); + ["colR", "colG", "colB"].forEach(id => document.getElementById(id).addEventListener("input", () => applyColor(null, "rgb"))); + applyColor("#5865F2", "hex"); +} + +/* ============ EMOJI PICKER ============ */ + +const EMOJIS = [ + ["😀", "grinning smile happy"], ["😃", "smile happy"], ["😄", "laugh happy"], ["😁", "grin"], + ["😆", "laughing lol"], ["😅", "sweat nervous laugh"], ["🤣", "rofl rolling laughing"], ["😂", "joy tears laughing"], + ["🙂", "slight smile"], ["🙃", "upside down silly"], ["😉", "wink"], ["😊", "blush happy"], + ["😇", "innocent angel halo"], ["🥰", "love hearts"], ["😍", "heart eyes love"], ["🤩", "star struck wow"], + ["😘", "kiss blow"], ["😋", "yum tasty"], ["😛", "tongue"], ["😜", "wink tongue"], + ["🤪", "zany crazy"], ["🤨", "raised eyebrow suspicious"], ["🧐", "monocle thinking"], ["🤓", "nerd glasses"], + ["😎", "cool sunglasses"], ["🥳", "party celebrate"], ["😏", "smirk"], ["😒", "unamused meh"], + ["😞", "disappointed sad"], ["😔", "pensive sad"], ["😟", "worried"], ["😢", "cry sad tear"], + ["😭", "sob crying"], ["😤", "triumph steam angry"], ["😠", "angry mad"], ["😡", "rage furious"], + ["🤬", "cursing swearing"], ["🤯", "mind blown"], ["😳", "flushed shocked"], ["🥵", "hot heat"], + ["🥶", "cold freezing"], ["😱", "scream shocked"], ["😨", "fearful scared"], ["😰", "anxious sweat"], + ["😴", "sleeping zzz"], ["🤤", "drool"], ["😪", "sleepy"], ["😵", "dizzy"], + ["🤐", "zipper mouth quiet"], ["🥴", "woozy drunk"], ["🤢", "nauseated sick"], ["🤮", "vomit sick"], + ["🤧", "sneeze sick"], ["😷", "mask sick"], ["🤒", "thermometer sick"], ["🤕", "bandage hurt"], + ["🤑", "money mouth rich"], ["🤠", "cowboy"], ["😈", "devil smiling imp"], ["👿", "imp angry devil"], + ["💀", "skull dead"], ["☠️", "skull crossbones"], ["👻", "ghost boo"], ["👽", "alien"], + ["🤖", "robot bot"], ["💩", "poop"], ["🤡", "clown"], ["👹", "ogre monster"], + ["👍", "thumbs up like yes"], ["👎", "thumbs down dislike no"], ["👌", "ok perfect"], ["✌️", "peace victory"], + ["🤞", "fingers crossed luck"], ["🤟", "love you hand"], ["🤘", "rock horns"], ["🤙", "call me shaka"], + ["👈", "point left"], ["👉", "point right"], ["👆", "point up"], ["👇", "point down"], + ["☝️", "point up index"], ["✋", "raised hand stop"], ["🤚", "back hand"], ["🖐️", "hand fingers"], + ["🖖", "vulcan spock"], ["👋", "wave hello hi bye"], ["🤝", "handshake deal"], ["👏", "clap applause"], + ["🙌", "raised hands praise"], ["🙏", "pray thanks please"], ["✊", "fist"], ["👊", "punch fist bump"], + ["💪", "muscle strong flex"], ["🦾", "robot arm"], ["✍️", "writing"], ["🤳", "selfie"], + ["❤️", "red heart love"], ["🧡", "orange heart"], ["💛", "yellow heart"], ["💚", "green heart"], + ["💙", "blue heart"], ["💜", "purple heart"], ["🖤", "black heart"], ["🤍", "white heart"], + ["🤎", "brown heart"], ["💔", "broken heart"], ["❣️", "heart exclamation"], ["💕", "two hearts"], + ["💖", "sparkling heart"], ["💗", "growing heart"], ["💘", "heart arrow cupid"], ["💝", "heart gift"], + ["💯", "hundred 100 perfect"], ["🔥", "fire lit hot"], ["✨", "sparkles shine"], ["⭐", "star"], + ["🌟", "glowing star"], ["💫", "dizzy star"], ["⚡", "lightning bolt zap"], ["💥", "boom explosion"], + ["💢", "anger symbol"], ["💦", "sweat droplets water"], ["💨", "dash wind fast"], ["🎉", "tada party celebrate"], + ["🎊", "confetti party"], ["🎈", "balloon"], ["🎁", "gift present"], ["🏆", "trophy win"], + ["🥇", "first place gold medal"], ["🎯", "target bullseye dart"], ["🎮", "game controller"], ["🕹️", "joystick game"], + ["✅", "check mark yes done"], ["☑️", "checkbox checked"], ["✔️", "check"], ["❌", "cross no wrong"], + ["❎", "cross mark"], ["➕", "plus add"], ["➖", "minus"], ["❓", "question"], + ["❗", "exclamation"], ["⚠️", "warning caution"], ["🚫", "no prohibited"], ["💤", "zzz sleep"], + ["👀", "eyes looking"], ["🗣️", "speaking head"], ["💬", "speech bubble chat"], ["💭", "thought bubble"], + ["🤔", "thinking hmm"], ["🫡", "salute"], ["🫠", "melting"], ["🫶", "heart hands love"], +]; + +let emojiOpen = false; + +function renderEmojiGrid(filter) { + const grid = document.getElementById("emojiGrid"); + const q = (filter || "").trim().toLowerCase(); + const list = q ? EMOJIS.filter(([, n]) => n.includes(q)) : EMOJIS; + grid.innerHTML = list.map(([e, n]) => + `` + ).join("") || `
    No emoji found
    `; + grid.querySelectorAll(".emoji-cell").forEach(btn => + btn.addEventListener("click", () => insertEmoji(btn.dataset.emoji)) + ); +} + +function insertEmoji(emoji) { + const start = editor.selectionStart; + const end = editor.selectionEnd; + const val = editor.value; + editor.value = val.slice(0, start) + emoji + val.slice(end); + const pos = start + emoji.length; + editor.focus(); + setSel(pos, pos); + render(); +} + +function toggleEmoji(force) { + const popup = document.getElementById("emojiPopup"); + emojiOpen = force === undefined ? !emojiOpen : force; + popup.hidden = !emojiOpen; + if (emojiOpen) { + const search = document.getElementById("emojiSearch"); + search.value = ""; + renderEmojiGrid(""); + search.focus(); + } +} + +function setupEmoji() { + renderEmojiGrid(""); + document.getElementById("emojiBtn").addEventListener("click", e => { e.stopPropagation(); toggleEmoji(); }); + document.getElementById("emojiSearch").addEventListener("input", e => renderEmojiGrid(e.target.value)); + document.getElementById("emojiPopup").addEventListener("click", e => e.stopPropagation()); + document.addEventListener("click", () => { if (emojiOpen) toggleEmoji(false); }); + document.addEventListener("keydown", e => { if (e.key === "Escape" && emojiOpen) toggleEmoji(false); }); +} + +/* ============ WEBHOOK SENDER ============ */ + +function setWebhookStatus(msg, kind) { + const el = document.getElementById("whStatus"); + el.textContent = msg; + el.className = "webhook-status" + (kind ? " " + kind : ""); +} + +async function sendWebhook() { + const url = document.getElementById("whUrl").value.trim(); + const content = document.getElementById("whContent").value; + const name = document.getElementById("whName").value.trim(); + const avatar = document.getElementById("whAvatar").value.trim(); + const btn = document.getElementById("whSend"); + + if (!/^https:\/\/(discord|discordapp)\.com\/api\/webhooks\/\d+\/[\w-]+$/.test(url)) { + setWebhookStatus("Enter a valid Discord webhook URL.", "err"); + return; + } + + const embed = buildEmbedObject(); + const payload = {}; + if (content.trim()) payload.content = content; + if (name) payload.username = name; + if (avatar) payload.avatar_url = avatar; + if (!isEmptyEmbed(embed)) payload.embeds = [embed]; + + if (!payload.content && !payload.embeds) { + setWebhookStatus("Add some content or embed fields first.", "err"); + return; + } + + btn.disabled = true; + setWebhookStatus("Sending…", ""); + try { + const res = await fetch(url, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(payload), + }); + if (res.ok) { + setWebhookStatus("Sent to Discord ✓", "ok"); + showToast("Message sent"); + } else { + let detail = res.status; + try { const j = await res.json(); if (j.message) detail = j.message; } catch (e) {} + setWebhookStatus("Discord error: " + detail, "err"); + } + } catch (err) { + setWebhookStatus("Network error — check the URL.", "err"); + } finally { + btn.disabled = false; + } +} + +function setLoadStatus(msg, kind) { + const el = document.getElementById("whLoadStatus"); + el.textContent = msg; + el.className = "webhook-status" + (kind ? " " + kind : ""); +} + +async function loadWebhookMessage() { + const url = document.getElementById("whUrl").value.trim(); + const link = document.getElementById("whMsgLink").value.trim(); + const hint = document.getElementById("whHint"); + const btn = document.getElementById("whLoad"); + const urlValid = /^https:\/\/(discord|discordapp)\.com\/api\/webhooks\/\d+\/[\w-]+$/.test(url); + const m = link.match(/channels\/\d+\/\d+\/(\d+)/); + const msgId = m ? m[1] : (/^\d{5,}$/.test(link) ? link : null); + + document.getElementById("whUrl").classList.toggle("needs-fill", !urlValid); + document.getElementById("whMsgLink").classList.toggle("needs-fill", !msgId); + if (!urlValid || !msgId) { hint.hidden = false; setLoadStatus("", ""); return; } + hint.hidden = true; + + btn.disabled = true; + setLoadStatus("Loading…", ""); + try { + const res = await fetch(`${url}/messages/${msgId}`); + if (!res.ok) { + let detail = res.status; + try { const j = await res.json(); if (j.message) detail = j.message; } catch (e) {} + setLoadStatus("Couldn't load: " + detail, "err"); + return; + } + const msg = await res.json(); + const hasEmbed = msg.embeds && msg.embeds.length; + if (hasEmbed) populateEmbedForm(msg.embeds[0]); + if (typeof msg.content === "string") document.getElementById("whContent").value = msg.content; + setLoadStatus(hasEmbed ? "Embed loaded ✓" : "Loaded — message has no embed", "ok"); + if (hasEmbed) showToast("Embed loaded"); + } catch (err) { + setLoadStatus("Network error — check the URL.", "err"); + } finally { + btn.disabled = false; + } +} + +function setupWebhook() { + document.getElementById("whSend").addEventListener("click", sendWebhook); + document.getElementById("whLoad").addEventListener("click", loadWebhookMessage); + ["whUrl", "whMsgLink"].forEach(id => document.getElementById(id).addEventListener("input", () => { + document.getElementById(id).classList.remove("needs-fill"); + if (document.getElementById("whUrl").value.trim() && document.getElementById("whMsgLink").value.trim()) { + document.getElementById("whHint").hidden = true; + } + })); +} + +/* ============ INIT ============ */ + +buildToolbar(); +buildQuickList(); +setupTabs(); +setupTimestamps(); +buildCheatsheet(); +setupEmbed(); +setupEmoji(); +setupWebhook(); +setupSnowflake(); +setupPermissions(); +setupColors(); +loadState(); +if (!editor.value) editor.value = DEFAULT_TEXT; +render(); diff --git a/index.html b/index.html new file mode 100644 index 0000000..4dc4dd1 --- /dev/null +++ b/index.html @@ -0,0 +1,421 @@ + + + + + + + Toolscord — Discord Tools + + + + + + + +
    + + +
    +
    +
    + # + editor +
    +
    +
    Format your message visually — no symbols to memorize.
    +
    + + +
    + + +
    +
    +
    +
    #
    +

    Welcome to #editor

    +

    This is the start of the #editor channel. Type in the box below and watch your message render live — exactly how Discord will show it.

    +
    +
    +
    pz
    +
    +
    + you + APP + Today at 5:13 PM +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + +
    + + +
    +
    +
    +
    Renders live above  •  Ctrl+B/I/U to format  •  select text, then click a button
    +
    + + +
    + + +
    +
    +
    +

    Embed Builder

    +

    Design a rich embed visually, then copy the JSON for a webhook or bot. Markdown works in the description and field values.

    + +
    +
    Author
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    Body
    +
    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + +
    +
    Media
    +
    +
    +
    +
    +
    + +
    +
    + Fields + +
    +
    +
    + +
    +
    Footer
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    Previewlive Discord embed
    +
    +
    +
    pz
    +
    +
    + youAPP + Today at 5:13 PM +
    +
    +
    +
    +
    +
    +
    +
    + JSON + webhook / bot ready + + + +
    + +
    + +
    +
    + Webhook + load an existing message or send a new one +
    + +
    + + +
    +
    + +
    + + +
    + +
    +
    +
    +
    +
    +
    +
    + + +
    +
    + + +
    +

    Your webhook URL stays in this browser only — it is never saved, logged, or sent anywhere except Discord.

    +
    +
    +
    +
    + + +
    +
    +
    +

    Timestamp Builder

    +

    Discord renders timestamps in each viewer's own timezone. Pick a date & time, choose a style, and copy the code.

    +
    + + +
    +
    + + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    Code
    +
    + <t:0:F> + +
    +
    +
    +
    Preview
    +
    +
    +
    pz
    +
    +
    + you + Today at 5:13 PM +
    +
    —
    +
    +
    +
    +
    +
    +
    Unix
    +
    0
    +
    +
    +
    +
    + + +
    +
    +

    Snowflake Decoder

    +

    Every Discord ID (user, message, channel, server…) is a snowflake that encodes its creation time. Paste one to decode it.

    +
    + + +
    +
    +
    Created—
    +
    Relative—
    +
    Unix (ms)—
    +
    Timestamp tag—
    +
    Worker ID—
    +
    Process ID—
    +
    Increment—
    +
    +
    +
    + + +
    +
    +
    +

    Permissions Calculator

    +

    Pick permissions to get the bitfield integer and a ready-to-use bot invite link.

    +
    +
    +
    +
    + +
    0
    +
    +
    + + +
    +
    + + + +
    + +
    +
    +
    + + +
    +
    +

    Color Converter

    +

    Discord embeds and role colors use a decimal integer. Convert between hex, RGB and decimal, or grab a preset.

    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    Presets
    +
    +
    +
    + + +
    +
    +
    +
    +
    + +
    Copied to clipboard
    + + + diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..b50e1a6 --- /dev/null +++ b/styles.css @@ -0,0 +1,752 @@ +/* +=========================== +Discord Markdown Editor +by: github.com/pvrzz +=========================== +*/ + +:root { + --bg-deepest: #1e1f22; + --bg-rail: #1e1f22; + --bg-sidebar: #2b2d31; + --bg-main: #313338; + --bg-input: #383a40; + --bg-input-2: #1e1f22; + --bg-hover: #35373c; + --bg-active: #404249; + --blurple: #5865f2; + --blurple-hover: #4752c4; + --green: #23a559; + --text-normal: #dbdee1; + --text-muted: #949ba4; + --text-faint: #80848e; + --text-link: #00a8fc; + --header-primary: #f2f3f5; + --interactive-normal: #b5bac1; + --channel-default: #80848e; + --mention-bg: rgba(88, 101, 242, 0.3); + --mention-text: #c9cdfb; + --code-bg: #2b2d31; + --code-border: #1e1f22; + --spoiler-bg: #29292d; + --shadow: 0 8px 16px rgba(0, 0, 0, 0.24); + --radius: 8px; +} + +* { box-sizing: border-box; margin: 0; padding: 0; } + +html, body { height: 100%; } + +body { + font-family: 'Inter', 'gg sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; + background: var(--bg-deepest); + color: var(--text-normal); + font-size: 16px; + -webkit-font-smoothing: antialiased; + overflow: hidden; +} + +.app { display: flex; height: 100vh; } + +/* ============ SIDEBAR ============ */ +.sidebar { display: flex; flex-shrink: 0; } + +.server-rail { + width: 72px; + background: var(--bg-rail); + display: flex; + flex-direction: column; + align-items: center; + padding: 12px 0; + gap: 8px; +} + +.server-pill { + width: 48px; + height: 48px; + border-radius: 16px; + background: var(--bg-sidebar); + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + transition: border-radius .15s ease, background .15s ease; + text-decoration: none; + color: var(--text-normal); + position: relative; +} +.server-pill:hover { border-radius: 14px; background: var(--blurple); color: #fff; } +.server-pill.active { border-radius: 14px; background: var(--blurple); color: #fff; } +.server-pill.active::before { + content: ""; position: absolute; left: -16px; width: 4px; height: 40px; + background: #fff; border-radius: 0 4px 4px 0; +} +.server-glyph { font-weight: 700; font-size: 15px; } +.server-sep { width: 32px; height: 2px; background: #35363c; border-radius: 1px; } +.server-pill.ghost { background: var(--bg-sidebar); color: var(--green); } +.server-pill.ghost:hover { background: var(--green); color: #fff; } + +.channels { + width: 240px; + background: var(--bg-sidebar); + display: flex; + flex-direction: column; +} + +.channels-header { + height: 48px; + flex-shrink: 0; + padding: 0 16px; + display: flex; + align-items: center; + justify-content: space-between; + font-weight: 600; + font-size: 15px; + color: var(--header-primary); + box-shadow: 0 1px 0 rgba(0,0,0,0.2); + cursor: pointer; +} +.channels-header svg { color: var(--interactive-normal); } + +.channels-scroll { flex: 1; overflow-y: auto; min-height: 0; } +.channel-group { padding: 16px 8px 0; } +.channel-group-label { + font-size: 11px; + font-weight: 700; + letter-spacing: .02em; + text-transform: uppercase; + color: var(--channel-default); + padding: 0 8px 4px; +} + +.channel { + width: 100%; + display: flex; + align-items: center; + gap: 6px; + background: none; + border: none; + color: var(--channel-default); + font-family: inherit; + font-size: 15px; + font-weight: 500; + padding: 6px 8px; + border-radius: 4px; + cursor: pointer; + margin-bottom: 2px; + text-align: left; +} +.channel:hover { background: var(--bg-hover); color: var(--text-normal); } +.channel.active { background: var(--bg-active); color: var(--header-primary); } +.channel .hash { font-size: 20px; color: var(--text-faint); font-weight: 400; } + +.quick-list { display: flex; flex-direction: column; gap: 2px; } +.quick-item { + display: flex; align-items: center; gap: 8px; + padding: 6px 8px; border-radius: 4px; cursor: pointer; + color: var(--channel-default); font-size: 14px; font-weight: 500; + background: none; border: none; font-family: inherit; text-align: left; width: 100%; +} +.quick-item:hover { background: var(--bg-hover); color: var(--text-normal); } +.quick-item .qi-key { + margin-left: auto; font-size: 11px; color: var(--text-faint); + background: var(--bg-input-2); padding: 1px 6px; border-radius: 4px; +} + +.user-bar { + height: 52px; + flex-shrink: 0; + background: #232428; + display: flex; + align-items: center; + padding: 0 8px; + gap: 8px; +} +.user-avatar { + width: 32px; height: 32px; border-radius: 50%; + background: var(--blurple); color: #fff; + display: flex; align-items: center; justify-content: center; + font-size: 12px; font-weight: 700; flex-shrink: 0; +} +.user-meta { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; } +.user-name { font-size: 14px; font-weight: 600; color: var(--header-primary); } +.user-status { font-size: 12px; color: var(--text-muted); } +.user-gh { + color: var(--interactive-normal); padding: 6px; border-radius: 4px; + display: flex; align-items: center; +} +.user-gh:hover { background: var(--bg-hover); color: var(--text-normal); } + +/* ============ MAIN ============ */ +.main { + flex: 1; + background: var(--bg-main); + display: flex; + flex-direction: column; + min-width: 0; +} + +.topbar { + height: 48px; + flex-shrink: 0; + display: flex; + align-items: center; + padding: 0 16px; + gap: 8px; + box-shadow: 0 1px 0 rgba(0,0,0,0.2), 0 1.5px 0 rgba(0,0,0,0.05); + z-index: 2; +} +.topbar-title { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--header-primary); font-size: 16px; } +.hash.big { font-size: 24px; color: var(--text-faint); font-weight: 400; } +.topbar-divider { width: 1px; height: 24px; background: #3f4147; flex-shrink: 0; } +.topbar-title { flex-shrink: 0; } +.topbar-desc { + font-size: 14px; color: var(--text-muted); + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; +} +.topbar-spacer { flex: 1; min-width: 8px; } + +.ghost-btn { + display: flex; align-items: center; gap: 6px; + background: none; border: none; color: var(--interactive-normal); + font-family: inherit; font-size: 14px; font-weight: 500; + padding: 6px 10px; border-radius: 4px; cursor: pointer; +} +.ghost-btn:hover { background: var(--bg-hover); color: var(--text-normal); } + +.tab-panel { display: none; flex: 1; flex-direction: column; min-height: 0; } +.tab-panel.active { display: flex; } + +/* ============ CHAT AREA ============ */ +.chat-scroll { + flex: 1; + overflow-y: auto; + min-height: 0; + display: flex; + flex-direction: column; + justify-content: flex-end; + padding: 16px 16px 8px; +} +.channel-welcome { padding: 16px 0 20px; } +.cw-icon { + width: 68px; height: 68px; border-radius: 50%; + background: var(--bg-active); color: var(--header-primary); + display: flex; align-items: center; justify-content: center; + font-size: 40px; font-weight: 500; margin-bottom: 8px; +} +.channel-welcome h2 { font-size: 28px; color: var(--header-primary); margin-bottom: 6px; } +.channel-welcome p { font-size: 15px; color: var(--text-muted); max-width: 640px; line-height: 1.4; } +.channel-welcome strong { color: var(--text-normal); font-weight: 600; } + +.dp-message.live { + padding: 10px 8px; + border-radius: 8px; + margin: 0 -8px; + transition: background .12s ease; +} +.dp-message.live:hover { background: rgba(2,2,2,0.06); } + +/* ============ COMPOSER ============ */ +.composer-wrap { flex-shrink: 0; padding: 0 16px 8px; } +.composer { + background: var(--bg-input); + border-radius: 10px; + box-shadow: 0 1px 2px rgba(0,0,0,0.15); +} +.composer-toolbar { + display: flex; + flex-wrap: wrap; + gap: 2px; + align-items: center; + padding: 8px 12px; + border-bottom: 1px solid rgba(0,0,0,0.18); +} +.tool-btn { + min-width: 32px; height: 30px; + padding: 0 8px; + display: flex; align-items: center; justify-content: center; gap: 5px; + background: transparent; border: none; + color: var(--interactive-normal); + border-radius: 5px; cursor: pointer; + font-family: inherit; font-size: 14px; font-weight: 600; + transition: background .12s ease, color .12s ease, transform .05s ease; +} +.tool-btn:hover { background: rgba(255,255,255,0.06); color: var(--header-primary); } +.tool-btn:active { transform: translateY(1px); background: rgba(255,255,255,0.1); } +.tool-btn .ico { font-size: 15px; } +.tool-btn .lbl { font-size: 13px; font-weight: 500; } +.tool-sep { width: 1px; height: 20px; background: #4a4d54; margin: 0 5px; } + +.composer-main { display: flex; align-items: flex-end; gap: 12px; padding: 0 16px; } +.composer-add { + flex-shrink: 0; + width: 24px; height: 24px; + margin-bottom: 11px; + border-radius: 50%; + background: var(--interactive-normal); + color: var(--bg-input); + border: none; cursor: pointer; + display: flex; align-items: center; justify-content: center; + transition: background .12s ease; +} +.composer-add:hover { background: var(--header-primary); } + +#editor { + flex: 1; + resize: none; + background: transparent; + border: none; + color: var(--text-normal); + font-family: inherit; + font-size: 15px; + line-height: 1.4; + padding: 11px 0; + outline: none; + max-height: 50vh; +} +#editor::placeholder { color: var(--text-faint); } + +.composer-actions { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; } +.composer-action { + background: none; border: none; cursor: pointer; + color: var(--interactive-normal); padding: 4px; border-radius: 4px; + display: flex; align-items: center; +} +.composer-action:hover { color: var(--header-primary); } +.composer-emoji { font-size: 20px; cursor: default; filter: grayscale(.2); } + +.composer-hint { + font-size: 12px; color: var(--text-faint); + padding: 6px 4px 0; text-align: right; +} +.composer-hint strong { color: var(--text-muted); font-weight: 600; } + +/* ============ DISCORD PREVIEW (shared) ============ */ +.discord-preview { + background: var(--bg-input-2); + border: 1px solid rgba(0,0,0,0.3); + border-radius: var(--radius); + padding: 16px; + overflow-y: auto; +} +.discord-preview.compact { flex: none; padding: 12px 16px; } + +.dp-message { display: flex; gap: 16px; } +.dp-avatar { + width: 40px; height: 40px; border-radius: 50%; + background: linear-gradient(135deg, #5865f2, #8b5cf6); + color: #fff; display: flex; align-items: center; justify-content: center; + font-weight: 700; font-size: 14px; flex-shrink: 0; +} +.dp-body { min-width: 0; flex: 1; } +.dp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; } +.dp-name { color: #f2c14e; font-weight: 600; font-size: 16px; } +.dp-badge { + background: var(--blurple); color: #fff; font-size: 10px; font-weight: 600; + padding: 1px 4px; border-radius: 3px; text-transform: uppercase; letter-spacing: .02em; +} +.dp-time { color: var(--text-faint); font-size: 12px; } +.dp-content { + color: var(--text-normal); + font-size: 16px; + line-height: 1.375; + white-space: pre-wrap; + word-wrap: break-word; +} +.dp-content:empty::before { + content: "Your formatted message will appear here…"; + color: var(--text-faint); +} + +/* ============ RENDERED MARKDOWN ============ */ +.dp-content strong { font-weight: 700; } +.dp-content em { font-style: italic; } +.dp-content u { text-decoration: underline; } +.dp-content s { text-decoration: line-through; } + +.dp-content h1.md-h { font-size: 1.5em; font-weight: 700; line-height: 1.3; margin: 8px 0 4px; color: var(--header-primary); } +.dp-content h2.md-h { font-size: 1.25em; font-weight: 700; line-height: 1.3; margin: 8px 0 4px; color: var(--header-primary); } +.dp-content h3.md-h { font-size: 1.0em; font-weight: 700; line-height: 1.3; margin: 8px 0 4px; color: var(--header-primary); } +.dp-content .md-subtext { font-size: 0.8125em; color: var(--text-muted); line-height: 1.3; } + +.dp-content .md-inline-code { + font-family: 'Consolas', monospace; font-size: 0.85em; + background: var(--code-bg); border: 1px solid var(--code-border); + border-radius: 4px; padding: 0 3px; +} +.dp-content .md-codeblock { + font-family: 'Consolas', monospace; font-size: 0.85em; + background: var(--code-bg); border: 1px solid var(--code-border); + border-radius: 4px; padding: 8px 10px; margin: 4px 0; + white-space: pre-wrap; line-height: 1.3; +} + +.dp-content .md-quote { + border-left: 4px solid #4e5058; padding: 0 8px 0 12px; margin: 2px 0; + display: block; +} +.dp-content blockquote.md-blockquote { + border-left: 4px solid #4e5058; padding: 0 8px 0 12px; margin: 2px 0; +} + +.dp-content ul.md-list, .dp-content ol.md-list { margin: 2px 0; padding-left: 24px; } +.dp-content ul.md-list { list-style: disc; } +.dp-content ol.md-list { list-style: decimal; } +.dp-content li.md-li { margin: 2px 0; } + +.dp-content a.md-link { color: var(--text-link); text-decoration: none; cursor: pointer; } +.dp-content a.md-link:hover { text-decoration: underline; } + +.dp-content .md-spoiler { + background: var(--spoiler-bg); color: transparent; + border-radius: 4px; cursor: pointer; padding: 0 2px; + transition: color .1s ease, background .1s ease; +} +.dp-content .md-spoiler.revealed { background: rgba(70,72,79,0.6); color: var(--text-normal); } + +.dp-content .md-mention { + background: var(--mention-bg); color: var(--mention-text); + font-weight: 500; border-radius: 3px; padding: 0 2px; cursor: pointer; +} + +.md-timestamp { + background: var(--mention-bg); color: var(--text-normal); + border-radius: 3px; padding: 0 2px; +} + +/* ============ TIMESTAMP TAB ============ */ +.ts-wrap { + flex: 1; overflow-y: auto; padding: 24px; + display: grid; grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr); + gap: 24px; align-content: start; +} +.ts-controls h2 { color: var(--header-primary); font-size: 20px; margin-bottom: 6px; } +.ts-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; line-height: 1.4; } +.ts-field { margin-bottom: 16px; } +.ts-field > label { + display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; + letter-spacing: .02em; color: var(--text-muted); margin-bottom: 8px; +} +.ts-field input[type="date"], .ts-field input[type="time"] { + background: var(--bg-input-2); border: 1px solid rgba(0,0,0,0.3); + color: var(--text-normal); font-family: inherit; font-size: 15px; + padding: 10px 12px; border-radius: 6px; width: 100%; outline: none; + color-scheme: dark; +} +.ts-field input:focus { border-color: var(--blurple); } + +.mini-btn { + background: var(--blurple); color: #fff; border: none; + font-family: inherit; font-size: 14px; font-weight: 600; + padding: 9px 16px; border-radius: 6px; cursor: pointer; +} +.mini-btn:hover { background: var(--blurple-hover); } + +.ts-styles { display: flex; flex-direction: column; gap: 6px; } +.ts-style { + display: flex; align-items: center; gap: 10px; + background: var(--bg-input-2); border: 1px solid transparent; + border-radius: 6px; padding: 10px 12px; cursor: pointer; text-align: left; + font-family: inherit; color: var(--text-normal); +} +.ts-style:hover { background: var(--bg-input); } +.ts-style.active { border-color: var(--blurple); background: var(--bg-input); } +.ts-style .ts-style-name { font-size: 14px; font-weight: 600; } +.ts-style .ts-style-ex { margin-left: auto; font-size: 13px; color: var(--text-muted); } +.ts-style .ts-style-code { font-family: 'Consolas', monospace; font-size: 12px; color: var(--text-faint); } + +.ts-output { display: flex; flex-direction: column; gap: 20px; } +.ts-out-row {} +.ts-out-label { + font-size: 12px; font-weight: 700; text-transform: uppercase; + letter-spacing: .02em; color: var(--text-muted); margin-bottom: 8px; +} +.ts-out-code { + display: flex; align-items: center; gap: 10px; + background: var(--bg-input-2); border: 1px solid rgba(0,0,0,0.3); + border-radius: 6px; padding: 12px 14px; +} +.ts-out-code code { font-family: 'Consolas', monospace; font-size: 15px; color: #f2c14e; flex: 1; } +.ts-out-code .mini-btn { padding: 6px 12px; } + +/* ============ CHEATSHEET TAB ============ */ +.cheat-wrap { + flex: 1; overflow-y: auto; padding: 24px; + display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); + gap: 16px; align-content: start; +} +.cheat-card { + background: var(--bg-input-2); border: 1px solid rgba(0,0,0,0.2); + border-radius: var(--radius); padding: 16px; +} +.cheat-card h3 { color: var(--header-primary); font-size: 15px; margin-bottom: 12px; } +.cheat-row { + display: flex; align-items: center; justify-content: space-between; gap: 12px; + padding: 8px 0; border-top: 1px solid rgba(255,255,255,0.04); +} +.cheat-row:first-of-type { border-top: none; } +.cheat-syntax { + font-family: 'Consolas', monospace; font-size: 13px; color: var(--text-muted); + background: var(--code-bg); padding: 3px 7px; border-radius: 4px; + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; +} +.cheat-result { font-size: 14px; text-align: right; } + +/* ============ TOAST ============ */ +.toast { + position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); + background: var(--green); color: #fff; font-weight: 600; font-size: 14px; + padding: 12px 20px; border-radius: 8px; box-shadow: var(--shadow); + opacity: 0; transition: transform .25s ease, opacity .25s ease; pointer-events: none; z-index: 100; +} +.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; } + +/* scrollbars */ +::-webkit-scrollbar { width: 8px; height: 8px; } +::-webkit-scrollbar-thumb { background: var(--bg-input-2); border-radius: 4px; } +.channels::-webkit-scrollbar-thumb { background: #202225; } +::-webkit-scrollbar-track { background: transparent; } + +/* ============ SHARED TOOL UI ============ */ +.panel-sub { color: var(--text-muted); font-size: 14px; line-height: 1.45; margin-bottom: 20px; max-width: 720px; } +.tab-panel h2 { color: var(--header-primary); font-size: 20px; margin-bottom: 6px; } +.pane-label { + display: flex; align-items: center; gap: 10px; + font-size: 12px; font-weight: 700; text-transform: uppercase; + letter-spacing: .02em; color: var(--text-muted); margin-bottom: 8px; +} +.pane-hint { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); } +.pane-spacer { flex: 1; } +.mini-btn.small { padding: 5px 11px; font-size: 13px; } +.mini-btn.ghost-mini { background: transparent; color: var(--text-muted); border: 1px solid #4a4d54; } +.mini-btn.ghost-mini:hover { background: var(--bg-hover); color: var(--text-normal); } +.tool-wrap { flex: 1; overflow-y: auto; padding: 24px; } +.tool-wrap.narrow { max-width: 720px; } + +.ef-field { display: flex; flex-direction: column; flex: 1; min-width: 0; } +.ef-field.grow { flex: 2; } +.ef-field > label { + font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; + color: var(--text-muted); margin-bottom: 6px; +} +.ef-field input, .ef-field textarea, .json-box { + background: var(--bg-input-2); border: 1px solid rgba(0,0,0,0.3); + color: var(--text-normal); font-family: inherit; font-size: 14px; + padding: 9px 11px; border-radius: 6px; outline: none; width: 100%; +} +.ef-field textarea { resize: vertical; line-height: 1.4; } +.ef-field input:focus, .ef-field textarea:focus, .json-box:focus { border-color: var(--blurple); } +.ef-row { display: flex; gap: 12px; margin-bottom: 12px; } +.ef-check { display: flex; align-items: center; gap: 8px; color: var(--text-normal); font-size: 14px; margin-top: 12px; cursor: pointer; } +.ef-check input { width: 16px; height: 16px; accent-color: var(--blurple); } + +/* ============ EMBED TAB ============ */ +.embed-layout { + flex: 1; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr); + gap: 20px; padding: 20px; overflow: hidden; min-height: 0; +} +.embed-form { overflow-y: auto; padding-right: 6px; } +.ef-section { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,0.05); } +.ef-section:last-child { border-bottom: none; } +.ef-section-title { + display: flex; align-items: center; gap: 12px; + font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; + color: var(--header-primary); margin-bottom: 12px; +} +.ef-section-title .mini-btn { margin-left: auto; } +.ef-color { display: flex; gap: 8px; } +.ef-color input[type="color"] { + width: 44px; height: 38px; padding: 2px; border: 1px solid rgba(0,0,0,0.3); + background: var(--bg-input-2); border-radius: 6px; cursor: pointer; +} +.ef-color input[type="text"] { flex: 1; } + +.fields-list { display: flex; flex-direction: column; gap: 10px; } +.field-item { background: var(--bg-input-2); border: 1px solid rgba(0,0,0,0.25); border-radius: 8px; padding: 12px; } +.field-item .ef-row { margin-bottom: 8px; } +.field-item .ef-row:last-child { margin-bottom: 0; } +.field-foot { display: flex; align-items: center; justify-content: space-between; } +.field-remove { + background: none; border: none; color: #f23f43; cursor: pointer; font-size: 13px; font-weight: 600; + padding: 4px 6px; border-radius: 4px; +} +.field-remove:hover { background: rgba(242,63,67,0.1); } + +.embed-side { display: flex; flex-direction: column; gap: 16px; overflow: hidden; min-height: 0; } +.embed-preview-wrap { display: flex; flex-direction: column; min-height: 0; flex: 1; } +.embed-preview-wrap .discord-preview { flex: 1; } +.embed-json-wrap { display: flex; flex-direction: column; min-height: 0; flex: 1; } +.json-box { + flex: 1; resize: none; font-family: 'Consolas', monospace; font-size: 13px; + line-height: 1.5; color: var(--text-normal); min-height: 120px; +} +.json-box.short { min-height: 64px; height: 64px; } + +/* embed render */ +.embed { + max-width: 432px; background: var(--bg-sidebar); + border-radius: 4px; border-left: 4px solid var(--blurple); + padding: 8px 16px 16px 12px; margin-top: 4px; + display: grid; grid-template-columns: 1fr auto; gap: 0 12px; +} +.embed-content { min-width: 0; } +.embed-author { display: flex; align-items: center; gap: 8px; margin-top: 8px; } +.embed-author img { width: 24px; height: 24px; border-radius: 50%; } +.embed-author span { font-size: 14px; font-weight: 600; color: var(--header-primary); } +.embed-title { font-size: 16px; font-weight: 600; color: var(--header-primary); margin-top: 8px; } +.embed-title a { color: var(--text-link); text-decoration: none; } +.embed-title a:hover { text-decoration: underline; } +.embed-desc { font-size: 14px; line-height: 1.4; color: #dbdee1; margin-top: 8px; white-space: pre-wrap; word-wrap: break-word; } +.embed-fields { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; margin-top: 8px; } +.embed-field { grid-column: span 12; min-width: 0; } +.embed-field.inline { grid-column: span 6; } +.efield-name { font-size: 14px; font-weight: 600; color: var(--header-primary); margin-bottom: 2px; } +.efield-value { font-size: 14px; line-height: 1.4; color: #dbdee1; white-space: pre-wrap; word-wrap: break-word; } +.embed-image { margin-top: 16px; grid-column: 1 / -1; } +.embed-image img { max-width: 100%; border-radius: 4px; display: block; } +.embed-thumb { grid-column: 2; grid-row: 1; margin-top: 8px; } +.embed-thumb img { width: 80px; height: 80px; border-radius: 4px; object-fit: cover; } +.embed-footer { display: flex; align-items: center; gap: 8px; margin-top: 8px; grid-column: 1 / -1; } +.embed-footer img { width: 20px; height: 20px; border-radius: 50%; } +.embed-footer span { font-size: 12px; color: var(--text-muted); font-weight: 500; } +.embed-footer .dot { color: var(--text-faint); } +.embed-empty { color: var(--text-faint); font-size: 14px; font-style: italic; } + +/* shared markdown styling inside embeds */ +.embed-desc strong, .efield-value strong { font-weight: 700; } +.embed-desc em, .efield-value em { font-style: italic; } +.embed-desc a, .efield-value a { color: var(--text-link); text-decoration: none; } +.embed-desc .md-inline-code, .efield-value .md-inline-code { + font-family: 'Consolas', monospace; font-size: 0.85em; + background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 4px; padding: 0 3px; +} + +/* ============ SNOWFLAKE TAB ============ */ +.sf-result { + margin-top: 20px; background: var(--bg-input-2); + border: 1px solid rgba(0,0,0,0.25); border-radius: 8px; overflow: hidden; +} +.sf-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.04); gap: 12px; } +.sf-row:first-child { border-top: none; } +.sf-key { font-size: 13px; color: var(--text-muted); font-weight: 600; } +.sf-val { font-size: 15px; color: var(--header-primary); text-align: right; word-break: break-all; } +.sf-val.mono { font-family: 'Consolas', monospace; color: #f2c14e; font-size: 14px; } + +/* ============ PERMISSIONS TAB ============ */ +.perm-layout { + flex: 1; display: grid; grid-template-columns: 1fr minmax(300px, 360px); + gap: 20px; padding: 24px; overflow: hidden; min-height: 0; +} +.perm-list-wrap { overflow-y: auto; padding-right: 6px; } +.perm-grid { + display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 16px; +} +.perm-item { + display: flex; align-items: center; gap: 10px; padding: 10px 12px; + background: var(--bg-input-2); border: 1px solid transparent; border-radius: 6px; + cursor: pointer; font-size: 14px; color: var(--text-normal); +} +.perm-item:hover { background: var(--bg-input); } +.perm-item.on { border-color: var(--blurple); } +.perm-item input { width: 16px; height: 16px; accent-color: var(--blurple); flex-shrink: 0; } +.perm-side { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; } +.perm-side .ef-field { flex: none; } + +/* ============ COLORS TAB ============ */ +.color-main { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; } +.color-pick { display: flex; flex-direction: column; gap: 10px; } +.color-pick input[type="color"] { + width: 120px; height: 120px; padding: 4px; border: 1px solid rgba(0,0,0,0.3); + background: var(--bg-input-2); border-radius: 10px; cursor: pointer; +} +.color-swatch { height: 28px; border-radius: 6px; background: #5865f2; } +.color-fields { flex: 1; min-width: 280px; } +.color-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; } +.color-preset { + display: flex; align-items: center; gap: 8px; padding: 8px 10px; + background: var(--bg-input-2); border: 1px solid rgba(0,0,0,0.2); border-radius: 6px; + cursor: pointer; font-size: 13px; color: var(--text-normal); +} +.color-preset:hover { background: var(--bg-input); } +.color-preset .pswatch { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; } + +/* ============ FONT AWESOME ICONS ============ */ +.tool-btn i { font-size: 14px; } +.tool-btn .ico { font-size: 15px; } +.ghost-btn i { font-size: 14px; } +.channels-header i { color: var(--interactive-normal); font-size: 12px; } +.user-gh i { font-size: 18px; } +.composer-add i { font-size: 13px; } +.composer-action i { font-size: 19px; } +.mini-btn:disabled { opacity: .55; cursor: default; } + +/* ============ EMOJI PICKER ============ */ +.tab-panel[data-panel="editor"] { position: relative; } +.emoji-popup { + position: absolute; bottom: 86px; right: 24px; width: 332px; max-height: 326px; + background: var(--bg-deepest); border: 1px solid rgba(0,0,0,0.45); + border-radius: 10px; box-shadow: var(--shadow); z-index: 50; + display: flex; flex-direction: column; overflow: hidden; +} +.emoji-popup[hidden] { display: none; } +.emoji-search { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid rgba(0,0,0,0.35); } +.emoji-search i { color: var(--text-muted); font-size: 13px; padding-left: 4px; } +.emoji-search input { + flex: 1; background: var(--bg-input); border: none; outline: none; + color: var(--text-normal); font-family: inherit; font-size: 14px; padding: 8px 10px; border-radius: 6px; +} +.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; overflow-y: auto; } +.emoji-cell { + background: none; border: none; cursor: pointer; font-size: 21px; + padding: 4px 0; border-radius: 6px; line-height: 1; +} +.emoji-cell:hover { background: var(--bg-hover); } +.emoji-none { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding: 24px; font-size: 14px; } + +/* ============ WEBHOOK SENDER ============ */ +.embed-side { overflow-y: auto; padding-right: 4px; } +.embed-preview-wrap, .embed-json-wrap { flex: none; } +.embed-preview-wrap .discord-preview { flex: none; } +.json-box { flex: none; height: 190px; } +.webhook-box { border-top: 1px solid rgba(255,255,255,0.07); padding-top: 16px; } +.webhook-box .pane-label i { color: var(--green); margin-right: 4px; } +.opt { color: var(--text-faint); font-weight: 400; text-transform: none; letter-spacing: 0; } +.webhook-box .ef-field { margin-bottom: 12px; } +.webhook-foot { display: flex; align-items: center; gap: 14px; } +.webhook-status { font-size: 13px; font-weight: 600; } +.webhook-status.ok { color: var(--green); } +.webhook-status.err { color: #f23f43; } +.webhook-note { + display: flex; align-items: center; gap: 7px; line-height: 1.4; + font-size: 12px; color: var(--text-faint); margin-top: 14px; +} +.webhook-note i { color: var(--text-muted); } + +.wh-hint { + display: flex; align-items: center; gap: 8px; + background: rgba(250, 166, 26, 0.12); border: 1px solid #faa61a; color: #faa61a; + font-size: 13px; font-weight: 500; padding: 9px 12px; border-radius: 6px; margin-bottom: 14px; + animation: whPulse 1.4s ease infinite; +} +.wh-hint[hidden] { display: none; } +.wh-hint strong { font-weight: 700; } +@keyframes whPulse { + 0%, 100% { box-shadow: 0 0 0 0 rgba(250, 166, 26, 0.0); } + 50% { box-shadow: 0 0 0 4px rgba(250, 166, 26, 0.14); } +} +.ef-field input.needs-fill, .ef-field input.needs-fill:focus { + border-color: #faa61a; box-shadow: 0 0 0 1px #faa61a; +} +.wh-load-row { display: flex; gap: 8px; } +.wh-load-row input { flex: 1; } +.wh-load-row .mini-btn { flex-shrink: 0; } +.wh-divider { height: 1px; background: rgba(255,255,255,0.07); margin: 16px 0; } +#whLoadStatus { display: inline-block; margin-top: 8px; } + +@media (max-width: 1000px) { + .embed-layout, .perm-layout { grid-template-columns: 1fr; overflow-y: auto; } + .ts-wrap { grid-template-columns: 1fr; } +} +@media (max-width: 720px) { + .channels { display: none; } +}