fixes and functions

This commit is contained in:
Mateusz Gruszczyński
2026-08-05 22:56:02 +02:00
parent 19d481fe72
commit b41ec22aab
5 changed files with 71 additions and 3 deletions
+24
View File
@@ -2368,6 +2368,18 @@ dialog::backdrop {
font-size: .8rem;
}
.files-head-actions {
display: flex;
align-items: center;
gap: 8px;
flex: 0 0 auto;
}
.files-head-actions .primary-button,
.files-head-actions .action-button {
width: auto;
}
.files-list {
display: grid;
gap: 9px;
@@ -2416,6 +2428,18 @@ dialog::backdrop {
}
@media (max-width: 620px) {
.files-head {
gap: 10px;
}
.files-head-actions {
gap: 6px;
}
.files-head-actions .action-button {
padding-inline: 9px;
}
.file-row {
grid-template-columns: 1fr;
}
+6 -1
View File
@@ -287,7 +287,12 @@
<div>
<h2>Note files</h2>
<p>Copy a direct link or ready Markdown/Alias code.</p>
</div><button id="close-files" class="icon-button" type="button">×</button>
</div>
<div class="files-head-actions">
<button id="files-upload-button" class="action-button action-button--primary compact-button"
type="button">Upload file</button>
<button id="close-files" class="icon-button" type="button" aria-label="Close files">×</button>
</div>
</div>
<div id="files-list" class="files-list"></div>
</div>
+20 -1
View File
@@ -329,7 +329,26 @@ export function startNoteEditor(adapter) {
setStatus(null, "Connecting…");
}
function updateAddressLabel() { document.querySelector(adapter.addressSelector).textContent = `${location.pathname}${location.search}`; }
async function renderMermaid() { const nodes = preview.querySelectorAll(".mermaid"); if (!nodes.length) return; try { const mermaid = await loadMermaid(); mermaid.initialize({ startOnLoad: false, theme: getTheme() === "dark" ? "dark" : "default", securityLevel: "strict" }); await mermaid.run({ nodes: [...nodes] }); } catch { nodes.forEach(n => n.insertAdjacentHTML("beforebegin", '<p class="error">Failed to load Mermaid.</p>')); } }
let mermaidRenderVersion = 0;
async function renderMermaid() {
const renderVersion = ++mermaidRenderVersion;
const nodes = [...preview.querySelectorAll(".mermaid")];
if (!nodes.length) return;
try {
const mermaid = await loadMermaid();
mermaid.initialize({ startOnLoad: false, theme: getTheme() === "dark" ? "dark" : "default", securityLevel: "strict" });
await mermaid.run({ nodes });
} catch {
if (renderVersion !== mermaidRenderVersion) return;
nodes.forEach(node => {
if (!node.isConnected || !preview.contains(node) || !node.parentNode) return;
const message = document.createElement("p");
message.className = "error mermaid-error";
message.textContent = "Failed to load Mermaid.";
node.parentNode.insertBefore(message, node);
});
}
}
async function renderCodeHighlight() { const nodes = preview.querySelectorAll('pre code[class^="language-"]:not(.language-mermaid)'); if (!nodes.length) return; try { const hljs = await loadHighlight(); nodes.forEach(node => { const lines = node.querySelectorAll(".code-line"); if (!lines.length) { hljs.highlightElement(node); return; } const language = [...node.classList].find(name => name.startsWith("language-"))?.slice(9); lines.forEach(line => { try { line.innerHTML = hljs.highlight(line.textContent, { language, ignoreIllegals: true }).value; } catch { line.innerHTML = hljs.highlightAuto(line.textContent).value; } }); node.classList.add("hljs"); }); } catch { } }
async function renderMediaPlayers() { const nodes = preview.querySelectorAll("[data-rustpad-player]"); if (!nodes.length) return; try { const { hydrateMediaPlayers } = await loadMediaPlayer(); hydrateMediaPlayers(preview); } catch { } }
function renderParticipantBadges(owners) {
+1
View File
@@ -237,6 +237,7 @@ export function bindNoteFiles({ editor, endpoints, getAccessToken, getUploadMaxS
document.querySelector("#upload-button")?.addEventListener("click", requestUpload);
document.querySelector("#mobile-upload-button")?.addEventListener("click", requestUpload);
document.querySelector("#files-upload-button")?.addEventListener("click", requestUpload);
input.addEventListener("change", async event => {
let file = event.target.files[0];
+20 -1
View File
@@ -22,8 +22,27 @@ const content = document.querySelector("#public-content");
const lineNumbersToggle = document.querySelector("#public-line-numbers-toggle");
const passwordDialog = document.querySelector("#public-password-dialog"), passwordForm = document.querySelector("#public-password-form"), passwordInput = document.querySelector("#public-password"), passwordError = document.querySelector("#public-password-error");
let pagePassword = "";
let mermaidRenderVersion = 0;
function pageHeaders() { return pagePassword ? { "X-RustPad-Page-Password": pagePassword } : {}; }
async function renderMermaid() { const nodes = content.querySelectorAll(".mermaid"); if (!nodes.length) return; try { const mermaid = await loadMermaid(); mermaid.initialize({ startOnLoad: false, theme: getTheme() === "dark" ? "dark" : "default", securityLevel: "strict" }); await mermaid.run({ nodes: [...nodes] }); } catch { nodes.forEach(n => n.insertAdjacentHTML("beforebegin", '<p class="error">Failed to load Mermaid.</p>')); } }
async function renderMermaid() {
const renderVersion = ++mermaidRenderVersion;
const nodes = [...content.querySelectorAll(".mermaid")];
if (!nodes.length) return;
try {
const mermaid = await loadMermaid();
mermaid.initialize({ startOnLoad: false, theme: getTheme() === "dark" ? "dark" : "default", securityLevel: "strict" });
await mermaid.run({ nodes });
} catch {
if (renderVersion !== mermaidRenderVersion) return;
nodes.forEach(node => {
if (!node.isConnected || !content.contains(node) || !node.parentNode) return;
const message = document.createElement("p");
message.className = "error mermaid-error";
message.textContent = "Failed to load Mermaid.";
node.parentNode.insertBefore(message, node);
});
}
}
async function renderCodeHighlight() { const blocks = content.querySelectorAll('pre code[class^="language-"]'); if (!blocks.length) return; try { const hljs = await loadHighlight(); blocks.forEach(block => { const lines = block.querySelectorAll(".code-line"); if (!lines.length) { hljs.highlightElement(block); return; } const language = [...block.classList].find(name => name.startsWith("language-"))?.slice(9); lines.forEach(line => { try { line.innerHTML = hljs.highlight(line.textContent, { language, ignoreIllegals: true }).value; } catch { line.innerHTML = hljs.highlightAuto(line.textContent).value; } }); block.classList.add("hljs"); }); } catch { } }
async function renderMediaPlayers() { const nodes = content.querySelectorAll("[data-rustpad-player]"); if (!nodes.length) return; try { const { hydrateMediaPlayers } = await loadMediaPlayer(); hydrateMediaPlayers(content); } catch { } }
function lockPublicContent(allowTaskUpdates) {