mirror of
https://github.com/sune-org/sune.git
synced 2026-10-17 15:47:53 +00:00
This build was committed by a bot.
This commit is contained in:
+44
-18
@@ -284,6 +284,7 @@ var el = window.el = Object.fromEntries([
|
||||
"footer",
|
||||
"attachBtn",
|
||||
"attachBadge",
|
||||
"attachPopover",
|
||||
"fileInput",
|
||||
"htmlEditor",
|
||||
"extensionHtmlEditor",
|
||||
@@ -1740,34 +1741,59 @@ function updateAttachBadge() {
|
||||
el.attachBadge.textContent = String(n);
|
||||
el.attachBadge.classList.toggle("hidden", n === 0);
|
||||
}
|
||||
$(el.attachBtn).on("click", () => {
|
||||
if (state.attachments.length) {
|
||||
state.attachments = [];
|
||||
updateAttachBadge();
|
||||
el.fileInput.value = "";
|
||||
}
|
||||
el.fileInput.click();
|
||||
});
|
||||
$(el.fileInput).on("change", async () => {
|
||||
const files = [...el.fileInput.files || []];
|
||||
if (!files.length) return;
|
||||
var addAttachments = async (files) => {
|
||||
for (const f of files) {
|
||||
const at = await toAttach(f).catch(() => null);
|
||||
if (at) state.attachments.push(at);
|
||||
}
|
||||
updateAttachBadge();
|
||||
};
|
||||
var hideAttachPopover = () => el.attachPopover.classList.add("hidden");
|
||||
function showAttachPopover() {
|
||||
if (!state.attachments.length || !el.attachPopover.classList.contains("hidden")) return;
|
||||
haptic();
|
||||
el.attachPopover.classList.remove("hidden");
|
||||
positionPopover(el.attachBtn, el.attachPopover);
|
||||
icons();
|
||||
}
|
||||
var attachHold = null, attachHeld = false;
|
||||
var holdAttach = () => {
|
||||
attachHeld = true;
|
||||
showAttachPopover();
|
||||
};
|
||||
$(el.attachBtn).on("pointerdown", (e) => {
|
||||
attachHeld = false;
|
||||
if (e.pointerType !== "mouse") attachHold = setTimeout(holdAttach, 500);
|
||||
}).on("pointerup pointercancel pointerleave", () => clearTimeout(attachHold)).on("contextmenu", (e) => {
|
||||
e.preventDefault();
|
||||
holdAttach();
|
||||
}).on("click", () => {
|
||||
if (attachHeld) return attachHeld = false;
|
||||
hideAttachPopover();
|
||||
el.fileInput.click();
|
||||
});
|
||||
$(el.attachPopover).on("click", (e) => {
|
||||
if (!e.target.closest("[data-action=\"clear\"]")) return;
|
||||
state.attachments = [];
|
||||
updateAttachBadge();
|
||||
hideAttachPopover();
|
||||
});
|
||||
$(document).on("click", (e) => {
|
||||
if (!el.attachPopover.contains(e.target) && !el.attachBtn.contains(e.target)) hideAttachPopover();
|
||||
});
|
||||
$(window).on("resize", () => {
|
||||
if (!el.attachPopover.classList.contains("hidden")) positionPopover(el.attachBtn, el.attachPopover);
|
||||
});
|
||||
$(el.fileInput).on("change", async () => {
|
||||
const files = [...el.fileInput.files || []];
|
||||
el.fileInput.value = "";
|
||||
await addAttachments(files);
|
||||
});
|
||||
$(el.composer).on("paste", async (e) => {
|
||||
const files = [...(e.clipboardData || e.originalEvent?.clipboardData)?.files || []];
|
||||
if (!files.length) return;
|
||||
e.preventDefault();
|
||||
state.attachments = [];
|
||||
el.fileInput.value = "";
|
||||
for (const f of files) {
|
||||
const at = await toAttach(f).catch(() => null);
|
||||
if (at) state.attachments.push(at);
|
||||
}
|
||||
updateAttachBadge();
|
||||
await addAttachments(files);
|
||||
});
|
||||
$(el.composer).on("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
@@ -7,6 +7,7 @@ html,body{overscroll-behavior-y:contain;font-family:'Assistant',sans-serif}
|
||||
.msg-avatar{font-size:16px}
|
||||
.menu-card{position:fixed;z-index:60;min-width:12rem;border-radius:0.75rem;border:1px solid #e5e7eb;background:#fff;box-shadow:0 10px 20px rgba(0,0,0,.08)}
|
||||
.menu-item{width:100%;text-align:left;padding:.5rem .75rem;font-size:0.875rem;display:flex;align-items:center;gap:.5rem}
|
||||
#attachBtn{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
|
||||
#htmlEditor,#extensionHtmlEditor,#jsonSchemaEditor{outline:none;white-space:pre!important;font-size:11px;line-height:1.5;}
|
||||
:not(pre)>code{font-size:85%;padding:.2em .4em;margin:0;border-radius:6px;background-color:rgba(175,184,193,0.2)}
|
||||
#threadRepoInput::placeholder{font-family:sans-serif;font-weight:500;color:#9ca3af}
|
||||
Reference in New Issue
Block a user