diff --git a/dist/assets/index-C4jYdBxX.js b/dist/assets/index-DCxWcq5K.js similarity index 98% rename from dist/assets/index-C4jYdBxX.js rename to dist/assets/index-DCxWcq5K.js index ed3d4fa..bb574f0 100644 --- a/dist/assets/index-C4jYdBxX.js +++ b/dist/assets/index-DCxWcq5K.js @@ -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(); diff --git a/dist/assets/index-DUC1RW1F.css b/dist/assets/index-DDqI2rlK.css similarity index 95% rename from dist/assets/index-DUC1RW1F.css rename to dist/assets/index-DDqI2rlK.css index 77abf0a..ac35889 100644 --- a/dist/assets/index-DUC1RW1F.css +++ b/dist/assets/index-DDqI2rlK.css @@ -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} diff --git a/dist/index.html b/dist/index.html index 17130ac..4ba7b90 100644 --- a/dist/index.html +++ b/dist/index.html @@ -13,8 +13,8 @@ - - + +