From 7bd73f77a4a5e15f5f84eca4e2d4361908c95899 Mon Sep 17 00:00:00 2001 From: Salihu <91833785+salihudickson@users.noreply.github.com> Date: Tue, 25 Aug 2026 02:43:19 +0100 Subject: [PATCH] feat: lightbox media display (#2420) * lightbox media display init * revert uninteded changes * load page media more accurately * restrict lock file changes to installed packages * revert changes in lock file * update lockfile * - support diagrams - support readonly mode - use softer backdrop - other enhancments --------- Co-authored-by: Philipinho <16838612+Philipinho@users.noreply.github.com> --- apps/client/package.json | 1 + .../public/locales/en-US/translation.json | 1 + .../src/features/editor/atoms/editor-atoms.ts | 8 + .../components/bubble-menu/bubble-menu.tsx | 31 ++- .../components/bubble-menu/color-selector.tsx | 161 ++++++++-------- .../components/bubble-menu/link-selector.tsx | 2 +- .../bubble-menu/text-alignment-selector.tsx | 7 +- .../components/common/lightbox-view.tsx | 176 ++++++++++++++++++ .../editor/components/drawio/drawio-menu.tsx | 21 +++ .../components/excalidraw/excalidraw-menu.tsx | 21 +++ .../editor/components/image/image-menu.tsx | 21 +++ .../components/subpages/subpages-view.tsx | 8 +- .../editor/components/video/video-menu.tsx | 21 +++ .../src/features/editor/page-editor.tsx | 31 +++ .../features/editor/readonly-page-editor.tsx | 48 ++++- apps/server/src/ee | 2 +- pnpm-lock.yaml | 25 +++ 17 files changed, 489 insertions(+), 96 deletions(-) create mode 100644 apps/client/src/features/editor/components/common/lightbox-view.tsx diff --git a/apps/client/package.json b/apps/client/package.json index cca0ef4be..d836d5db6 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -64,6 +64,7 @@ "react-router-dom": "7.18.2", "semver": "7.7.4", "socket.io-client": "4.8.3", + "yet-another-react-lightbox": "^3.32.2", "zod": "4.3.6" }, "devDependencies": { diff --git a/apps/client/public/locales/en-US/translation.json b/apps/client/public/locales/en-US/translation.json index 14bb06d85..098fb45dd 100644 --- a/apps/client/public/locales/en-US/translation.json +++ b/apps/client/public/locales/en-US/translation.json @@ -294,6 +294,7 @@ "Export space": "Export space", "Export {{type}}": "Export {{type}}", "File exceeds the {{limit}} attachment limit": "File exceeds the {{limit}} attachment limit", + "Media": "Media", "Align left": "Align left", "Align right": "Align right", "Align center": "Align center", diff --git a/apps/client/src/features/editor/atoms/editor-atoms.ts b/apps/client/src/features/editor/atoms/editor-atoms.ts index 74692d916..2de76fe70 100644 --- a/apps/client/src/features/editor/atoms/editor-atoms.ts +++ b/apps/client/src/features/editor/atoms/editor-atoms.ts @@ -16,6 +16,14 @@ export const showAiMenuAtom = atom(false); export const showLinkMenuAtom = atom(false); +export type LightboxRequest = { + src: string; + type: "image" | "video"; +} | null; + +const initialLightboxRequest: LightboxRequest = null; +export const lightboxRequestAtom = atom(initialLightboxRequest); + // Current page's edit mode — initialized from the user's saved preference on // first load, can be toggled locally without persisting to the server. export const currentPageEditModeAtom = atom(PageEditMode.Edit); diff --git a/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx b/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx index a1283e34a..02108292e 100644 --- a/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx +++ b/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx @@ -23,11 +23,21 @@ import { } from "@/features/comment/atoms/comment-atom"; import { useAtom, useAtomValue } from "jotai"; import { v7 as uuid7 } from "uuid"; -import { isCellSelection, isEditorReady, isTextSelected } from "@docmost/editor-ext"; +import { + isCellSelection, + isEditorReady, + isTextSelected, +} from "@docmost/editor-ext"; import { LinkSelector } from "@/features/editor/components/bubble-menu/link-selector.tsx"; import { useTranslation } from "react-i18next"; -import { showAiMenuAtom, showLinkMenuAtom } from "@/features/editor/atoms/editor-atoms"; -import { userAtom, workspaceAtom } from "@/features/user/atoms/current-user-atom"; +import { + showAiMenuAtom, + showLinkMenuAtom, +} from "@/features/editor/atoms/editor-atoms"; +import { + userAtom, + workspaceAtom, +} from "@/features/user/atoms/current-user-atom"; export interface BubbleMenuItem { name: string; @@ -217,7 +227,12 @@ export const EditorBubbleMenu: FC = (props) => { {items.map((item, index) => ( - + = (props) => { aria-label={t(item.name)} className={clsx({ [classes.active]: item.isActive() })} style={{ border: "none" }} - onClick={() => isEditorReady(props.editor) && item.command()} + onClick={() => + isEditorReady(props.editor) && item.command() + } > @@ -256,7 +273,9 @@ export const EditorBubbleMenu: FC = (props) => { radius="6px" aria-label={t(commentItem.name)} style={{ border: "none" }} - onClick={() => isEditorReady(props.editor) && commentItem.command()} + onClick={() => + isEditorReady(props.editor) && commentItem.command() + } > diff --git a/apps/client/src/features/editor/components/bubble-menu/color-selector.tsx b/apps/client/src/features/editor/components/bubble-menu/color-selector.tsx index a228dc645..533bcda8a 100644 --- a/apps/client/src/features/editor/components/bubble-menu/color-selector.tsx +++ b/apps/client/src/features/editor/components/bubble-menu/color-selector.tsx @@ -129,8 +129,7 @@ function handleColorKeyNav( grid: "text" | "highlight", ) { const cols = COLOR_GRID_COLS; - const total = - grid === "text" ? TEXT_COLORS.length : HIGHLIGHT_COLORS.length; + const total = grid === "text" ? TEXT_COLORS.length : HIGHLIGHT_COLORS.length; const col = index % cols; if (e.key === "ArrowRight") { @@ -163,8 +162,7 @@ function handleColorKeyNav( if (prev >= 0) { focusSwatch(grid, prev); } else if (grid === "highlight") { - const lastRowStart = - Math.floor((TEXT_COLORS.length - 1) / cols) * cols; + const lastRowStart = Math.floor((TEXT_COLORS.length - 1) / cols) * cols; focusSwatch("text", Math.min(lastRowStart + col, TEXT_COLORS.length - 1)); } return; @@ -222,7 +220,7 @@ export const ColorSelector: FC = ({ withArrow > - + - + + ); diff --git a/apps/client/src/features/editor/components/bubble-menu/link-selector.tsx b/apps/client/src/features/editor/components/bubble-menu/link-selector.tsx index fdacf6a18..0b7992f18 100644 --- a/apps/client/src/features/editor/components/bubble-menu/link-selector.tsx +++ b/apps/client/src/features/editor/components/bubble-menu/link-selector.tsx @@ -10,7 +10,7 @@ export const LinkSelector: FC = () => { const setShowLinkMenu = useSetAtom(showLinkMenuAtom); return ( - + = ({ onChange={setIsOpen} > - +