π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add clickable More link to truncated file descriptions in FileViewer
Anand Baburajan9a98767e8345
diff --git a/web/apps/embed/src/styles/photoswipe.css b/web/apps/embed/src/styles/photoswipe.cssindex c6ec10cb87..8a18e97b5a 100644--- a/web/apps/embed/src/styles/photoswipe.css+++ b/web/apps/embed/src/styles/photoswipe.css@@ -249,6 +249,19 @@}}+.pswp-ente .pswp__caption-more {+ color: white;+ text-decoration: underline;+ cursor: pointer;+}++/* When More link is present, don't use line-clamp since JS already truncated */+.pswp-ente .pswp__caption p:has(.pswp__caption-more) {+ display: block;+ -webkit-line-clamp: unset;+ line-clamp: unset;+}+/* Change the cursor on the thumbnail to the default arrow to indicate that itis not interactable (PhotoSwipe by default shows the zoom out icon). */.pswp-ente .pswp__img {diff --git a/web/apps/photos/src/styles/photoswipe.css b/web/apps/photos/src/styles/photoswipe.cssindex 441afadc5a..26460c2ff4 100644--- a/web/apps/photos/src/styles/photoswipe.css+++ b/web/apps/photos/src/styles/photoswipe.css@@ -251,6 +251,19 @@}}+.pswp-ente .pswp__caption-more {+ color: white;+ text-decoration: underline;+ cursor: pointer;+}++/* When More link is present, don't use line-clamp since JS already truncated */+.pswp-ente .pswp__caption p:has(.pswp__caption-more) {+ display: block;+ -webkit-line-clamp: unset;+ line-clamp: unset;+}+/* Change the cursor on the thumbnail to the default arrow to indicate that itis not interactable (PhotoSwipe by default shows the zoom out icon). */.pswp-ente .pswp__img {diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex 2d227a6320..e4cc6712f2 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -1543,9 +1543,17 @@ export class FileViewerPhotoSwipe {pswp.on("change", () => {const { fileType, alt } = currSlideData();- const captionText = truncateCaptionIfNeeded(alt);- captionEl.querySelector("p")!.innerText =- captionText ?? "";+ const { text: captionText, wasTruncated } =+ truncateCaptionIfNeeded(alt);+ const captionP = captionEl.querySelector("p")!;+ captionP.innerText = captionText ?? "";+ if (wasTruncated) {+ const moreLink = document.createElement("span");+ moreLink.className = "pswp__caption-more";+ moreLink.textContent = "More";+ moreLink.addEventListener("click", handleViewInfo);+ captionP.appendChild(moreLink);+ }captionEl.style.display = captionText? "block": "none";@@ -2086,12 +2094,17 @@ const bottomRightControlsHTML = () => `/*** Truncate caption text to 154 characters.+ *+ * @returns An object with the (possibly truncated) text and a flag indicating+ * whether or not the text was truncated.*/-const truncateCaptionIfNeeded = (text: string | undefined) => {- if (!text) return text;+const truncateCaptionIfNeeded = (+ text: string | undefined,+): { text: string | undefined; wasTruncated: boolean } => {+ if (!text) return { text, wasTruncated: false };const maxLength = 154;- if (text.length <= maxLength) return text;- return text.slice(0, maxLength) + "β¦";+ if (text.length <= maxLength) return { text, wasTruncated: false };+ return { text: text.slice(0, maxLength) + "β¦ ", wasTruncated: true };};const createElementFromHTMLString = (htmlString: string) => {