AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
feat(web): play common video attachments inline
tianma-ifb38750eda555
diff --git a/apps/api/src/resource-routes.test.mjs b/apps/api/src/resource-routes.test.mjsindex b635b597..1206a9f0 100644--- a/apps/api/src/resource-routes.test.mjs+++ b/apps/api/src/resource-routes.test.mjs@@ -298,6 +298,34 @@ describe("resource route contracts", () => {expect(response.headers.get("Accept-Ranges")).toBe("bytes");});+ test("serves filename-detected video inline with a playable MIME type", async () => {+ const environment = createEnvironment();+ environment.storage.resources = {+ get: async () => ({+ body: new Blob([new Uint8Array(256)]).stream(),+ size: 256,+ writeHttpMetadata: () => {},+ }),+ };+ const response = await createApp(agentAuth, async () => ({+ ...resourceRow,+ filename: "录屏.mp4",+ mime_type: "application/octet-stream",+ storage_config_id: null,+ })).request(+ "/api/v1/resources/res_1/blob",+ {},+ environment,+ );++ expect(response.status).toBe(200);+ expect(response.headers.get("Content-Type")).toBe("video/mp4");+ expect(response.headers.get("Content-Disposition")).toBe(+ "inline; filename=\"download.mp4\"; filename*=UTF-8''%E5%BD%95%E5%B1%8F.mp4",+ );+ expect(response.headers.get("Accept-Ranges")).toBe("bytes");+ });+test("rejects unsatisfiable ranges before object storage is read", async () => {const environment = createEnvironment();let reads = 0;diff --git a/apps/api/src/resource-routes.ts b/apps/api/src/resource-routes.tsindex d8f3aac4..3a62cd2b 100644--- a/apps/api/src/resource-routes.ts+++ b/apps/api/src/resource-routes.ts@@ -1,4 +1,4 @@-import { isPdfAttachment, resolveAudioMimeType, ResourceUpdateSchema, type MemoDetail, type Resource } from "@edgeever/shared";+import { isPdfAttachment, resolvePlayableMediaMimeType, ResourceUpdateSchema, type MemoDetail, type Resource } from "@edgeever/shared";import { zValidator } from "@hono/zod-validator";import type { Hono } from "hono";import { auditStatement } from "./audit";@@ -294,12 +294,12 @@ export const registerResourceRoutes = (const headers = new Headers();object.writeHttpMetadata(headers);- const audioMimeType = resolveAudioMimeType(resource.mime_type, resource.filename);+ const playableMimeType = resolvePlayableMediaMimeType(resource.mime_type, resource.filename);headers.set("Content-Type",isPdfAttachment(resource.mime_type, resource.filename)? "application/pdf"- : audioMimeType ?? resource.mime_type ?? headers.get("Content-Type") ?? "application/octet-stream",+ : playableMimeType ?? resource.mime_type ?? headers.get("Content-Type") ?? "application/octet-stream",);headers.set("Cache-Control", headers.get("Cache-Control") ?? "private, max-age=3600");headers.set("Accept-Ranges", "bytes");@@ -315,7 +315,7 @@ export const registerResourceRoutes = (}headers.set("Content-Disposition",- resource.kind === "image" || isPdfAttachment(resource.mime_type, resource.filename) || audioMimeType+ resource.kind === "image" || isPdfAttachment(resource.mime_type, resource.filename) || playableMimeType? contentDispositionInline(resource.filename): contentDispositionAttachment(resource.filename),);diff --git a/apps/api/src/share-routes.test.mjs b/apps/api/src/share-routes.test.mjsindex b48b2e8e..d1c91b51 100644--- a/apps/api/src/share-routes.test.mjs+++ b/apps/api/src/share-routes.test.mjs@@ -171,4 +171,35 @@ describe("public memo shares", () => {expect(response.headers.get("Accept-Ranges")).toBe("bytes");sqlite.close();});++ test("serves filename-detected shared video inline", async () => {+ const { sqlite, environment } = createDatabaseEnvironment();+ sqlite.query(+ `INSERT INTO resources (id, memo_id, object_key, kind, mime_type, filename, byte_size)+ VALUES (?, ?, ?, 'attachment', 'application/octet-stream', 'walkthrough.webm', 10)`,+ ).run("res_video", "memo_source", "video-key");+ environment.storage.resources = {+ get: async () => ({+ body: new Blob([new Uint8Array(10)]).stream(),+ size: 10,+ writeHttpMetadata: () => {},+ }),+ };+ const app = new Hono();+ registerPublicShareRoutes(app);++ const response = await app.request(+ `/api/public/shares/${sourceToken}/resources/res_video/blob`,+ {},+ environment,+ );++ expect(response.status).toBe(200);+ expect(response.headers.get("Content-Type")).toBe("video/webm");+ expect(response.headers.get("Content-Disposition")).toBe(+ "inline; filename=\"walkthrough.webm\"; filename*=UTF-8''walkthrough.webm",+ );+ expect(response.headers.get("Accept-Ranges")).toBe("bytes");+ sqlite.close();+ });});diff --git a/apps/api/src/share-routes.ts b/apps/api/src/share-routes.tsindex fa7652c2..80a3ccf1 100644--- a/apps/api/src/share-routes.ts+++ b/apps/api/src/share-routes.ts@@ -1,4 +1,4 @@-import { collectMemoLinkIds, isPdfAttachment, resolveAudioMimeType, resolveMemoContentDoc, type MemoShare, type PublicMemoShare, type TiptapDoc } from "@edgeever/shared";+import { collectMemoLinkIds, isPdfAttachment, resolveMemoContentDoc, resolvePlayableMediaMimeType, type MemoShare, type PublicMemoShare, type TiptapDoc } from "@edgeever/shared";import type { Hono } from "hono";import type { AppEnv } from "./api-context";import { audit } from "./audit";@@ -40,7 +40,7 @@ const mapMemoShare = (row: MemoShareRow): MemoShare => ({});const contentDisposition = (kind: SharedResourceRow["kind"], mimeType: string | null, filename: string | null) => {- const inline = kind === "image" || isPdfAttachment(mimeType, filename) || Boolean(resolveAudioMimeType(mimeType, filename));+ const inline = kind === "image" || isPdfAttachment(mimeType, filename) || Boolean(resolvePlayableMediaMimeType(mimeType, filename));return inline ? contentDispositionInline(filename) : contentDispositionAttachment(filename);};@@ -125,12 +125,12 @@ export const registerPublicShareRoutes = (app: Hono<AppEnv>) => {const headers = new Headers();object.writeHttpMetadata(headers);- const audioMimeType = resolveAudioMimeType(resource.mime_type, resource.filename);+ const playableMimeType = resolvePlayableMediaMimeType(resource.mime_type, resource.filename);headers.set("Content-Type",isPdfAttachment(resource.mime_type, resource.filename)? "application/pdf"- : audioMimeType ?? resource.mime_type ?? headers.get("Content-Type") ?? "application/octet-stream",+ : playableMimeType ?? resource.mime_type ?? headers.get("Content-Type") ?? "application/octet-stream",);headers.set("Accept-Ranges", "bytes");if (byteRange.kind === "range") {diff --git a/apps/web/src/components/attachments/AudioAttachmentPlayer.tsx b/apps/web/src/components/attachments/AudioAttachmentPlayer.tsxindex 056feabe..7ca09db1 100644--- a/apps/web/src/components/attachments/AudioAttachmentPlayer.tsx+++ b/apps/web/src/components/attachments/AudioAttachmentPlayer.tsx@@ -1,4 +1,5 @@import { useState, type SyntheticEvent } from "react";+import { pauseOtherMediaPlayers } from "./pause-other-media";export const AudioAttachmentPlayer = ({src,@@ -12,12 +13,7 @@ export const AudioAttachmentPlayer = ({const [failed, setFailed] = useState(false);const handlePlay = (event: SyntheticEvent<HTMLAudioElement>) => {- const activePlayer = event.currentTarget;- activePlayer.ownerDocument- .querySelectorAll<HTMLAudioElement>("audio[data-edgeever-audio-player]")- .forEach((player) => {- if (player !== activePlayer) player.pause();- });+ pauseOtherMediaPlayers(event.currentTarget);};if (failed) {diff --git a/apps/web/src/components/attachments/VideoAttachmentPlayer.test.mjs b/apps/web/src/components/attachments/VideoAttachmentPlayer.test.mjsnew file mode 100644index 00000000..0d130b07--- /dev/null+++ b/apps/web/src/components/attachments/VideoAttachmentPlayer.test.mjs@@ -0,0 +1,21 @@+import { describe, expect, test } from "bun:test";+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { VideoAttachmentPlayer } from "./VideoAttachmentPlayer.tsx";++describe("VideoAttachmentPlayer", () => {+ test("uses the native streaming player without eagerly downloading the file", () => {+ const markup = renderToStaticMarkup(createElement(VideoAttachmentPlayer, {+ src: "/api/v1/resources/video-1/blob",+ label: "walkthrough.mp4",+ unavailableMessage: "Unavailable",+ }));++ expect(markup).toContain("<video");+ expect(markup).toContain('preload="metadata"');+ expect(markup).toContain("playsInline");+ expect(markup).toContain('src="/api/v1/resources/video-1/blob"');+ expect(markup).toContain('aria-label="walkthrough.mp4"');+ expect(markup).toContain("data-edgeever-video-player");+ });+});diff --git a/apps/web/src/components/attachments/VideoAttachmentPlayer.tsx b/apps/web/src/components/attachments/VideoAttachmentPlayer.tsxnew file mode 100644index 00000000..c7dd8ada--- /dev/null+++ b/apps/web/src/components/attachments/VideoAttachmentPlayer.tsx@@ -0,0 +1,41 @@+import { useState, type SyntheticEvent } from "react";+import { pauseOtherMediaPlayers } from "./pause-other-media";++export const VideoAttachmentPlayer = ({+ src,+ label,+ unavailableMessage,+}: {+ src: string;+ label: string;+ unavailableMessage: string;+}) => {+ const [failed, setFailed] = useState(false);++ const handlePlay = (event: SyntheticEvent<HTMLVideoElement>) => {+ pauseOtherMediaPlayers(event.currentTarget);+ };++ if (failed) {+ return (+ <span className="flex min-h-10 items-center px-3 py-2 text-sm text-slate-500" role="status">+ {unavailableMessage}+ </span>+ );+ }++ return (+ <video+ className="aspect-video w-full bg-slate-950 object-contain"+ controls+ controlsList="nodownload"+ data-edgeever-video-player+ playsInline+ preload="metadata"+ src={src}+ aria-label={label}+ onError={() => setFailed(true)}+ onPlay={handlePlay}+ />+ );+};diff --git a/apps/web/src/components/attachments/pause-other-media.ts b/apps/web/src/components/attachments/pause-other-media.tsnew file mode 100644index 00000000..b17044b3--- /dev/null+++ b/apps/web/src/components/attachments/pause-other-media.ts@@ -0,0 +1,9 @@+const MEDIA_PLAYER_SELECTOR = "audio[data-edgeever-audio-player], video[data-edgeever-video-player]";++export const pauseOtherMediaPlayers = (activePlayer: HTMLMediaElement) => {+ activePlayer.ownerDocument+ .querySelectorAll<HTMLMediaElement>(MEDIA_PLAYER_SELECTOR)+ .forEach((player) => {+ if (player !== activePlayer) player.pause();+ });+};diff --git a/apps/web/src/components/editor/FileAttachment.tsx b/apps/web/src/components/editor/FileAttachment.tsxindex be453ef6..a2ffbe43 100644--- a/apps/web/src/components/editor/FileAttachment.tsx+++ b/apps/web/src/components/editor/FileAttachment.tsx@@ -3,19 +3,21 @@ import {formatAttachmentMetadata,getAttachmentFilenameFromLabel,resolveAttachmentKind,+ resolveFileDisplayMode,} from "@edgeever/shared";import { NodeViewWrapper, ReactNodeViewRenderer, type NodeViewProps } from "@tiptap/react";-import { Download, ExternalLink } from "lucide-react";+import { ChevronDown, ChevronUp, Download, ExternalLink } from "lucide-react";import { useTranslation } from "react-i18next";import { AttachmentFileIcon } from "@/components/attachments/AttachmentFileIcon";import { AudioAttachmentPlayer } from "@/components/attachments/AudioAttachmentPlayer";import { COMPACT_ATTACHMENT_WIDTH_CLASS } from "@/components/attachments/attachment-layout";+import { VideoAttachmentPlayer } from "@/components/attachments/VideoAttachmentPlayer";import { ButtonTooltip } from "@/components/ui/button-tooltip";import { useAttachmentByteSize } from "@/hooks/useAttachmentByteSize";import { isDesktopResourceRuntime, toApiResourceUrl } from "@/lib/desktop-resources";import { cn } from "@/lib/utils";-const FileAttachmentNodeView = ({ node }: NodeViewProps) => {+const FileAttachmentNodeView = ({ node, updateAttributes }: NodeViewProps) => {const { t } = useTranslation();const url = typeof node.attrs.url === "string" ? node.attrs.url : "";const label = typeof node.attrs.label === "string" ? node.attrs.label : "Attachment";@@ -26,24 +28,47 @@ const FileAttachmentNodeView = ({ node }: NodeViewProps) => {const resolvedUrl = isDesktopResourceRuntime() ? url : toApiResourceUrl(url);const byteSize = useAttachmentByteSize(resolvedUrl, node.attrs.byteSize);const metadata = formatAttachmentMetadata(mimeType, filename || label, byteSize);- const isAudio = resolveAttachmentKind(mimeType, filename || label) === "audio";+ const attachmentKind = resolveAttachmentKind(mimeType, filename || label);+ const isAudio = attachmentKind === "audio";+ const isVideo = attachmentKind === "video";+ const videoExpanded = isVideo && resolveFileDisplayMode(node.attrs.displayMode) === "inline";+ const setVideoExpanded = (expanded: boolean) => {+ updateAttributes({ displayMode: expanded ? "inline" : "compact" });+ };++ const identity = (+ <>+ <AttachmentFileIcon mimeType={mimeType} filename={filename || label} className="h-5 w-5 shrink-0" />+ <span className="flex min-w-0 flex-col">+ <span className="truncate text-sm font-semibold text-slate-800">{label}</span>+ <span className="truncate text-xs font-medium text-slate-500">{metadata}</span>+ </span>+ </>+ );return (<NodeViewWrapper as="span" className="edgeever-file-attachment-node" contentEditable={false}><span className={cn("edgeever-file-viewer flex min-h-12 flex-col overflow-hidden rounded-xl border border-slate-200 bg-card shadow-sm", COMPACT_ATTACHMENT_WIDTH_CLASS)}><span data-edgeever-resource-toolbar className="flex min-h-12 items-center gap-2 px-3">- <a- href={resolvedUrl}- target="_blank"- rel="noreferrer"- className="flex min-w-0 flex-1 items-center gap-2 text-left no-underline"- >- <AttachmentFileIcon mimeType={mimeType} filename={filename || label} className="h-5 w-5 shrink-0" />- <span className="flex min-w-0 flex-col">- <span className="truncate text-sm font-semibold text-slate-800">{label}</span>- <span className="truncate text-xs font-medium text-slate-500">{metadata}</span>- </span>- </a>+ {isVideo ? (+ <button+ type="button"+ className="flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left"+ aria-expanded={videoExpanded}+ onClick={() => setVideoExpanded(!videoExpanded)}+ >+ {identity}+ </button>+ ) : (+ <a+ href={resolvedUrl}+ target="_blank"+ rel="noreferrer"+ className="flex min-w-0 flex-1 items-center gap-2 text-left no-underline"+ >+ {identity}+ </a>+ )}<ButtonTooltip title={t("editor.resourceActions.download")}><a className="pdf-viewer-action" href={resolvedUrl} download={filename || label} aria-label={t("editor.resourceActions.download")}><Download aria-hidden="true" />@@ -54,6 +79,19 @@ const FileAttachmentNodeView = ({ node }: NodeViewProps) => {<ExternalLink aria-hidden="true" /></a></ButtonTooltip>+ {isVideo ? (+ <ButtonTooltip title={videoExpanded ? t("pdfViewer.collapse") : t("pdfViewer.expand")}>+ <button+ type="button"+ className="pdf-viewer-action"+ aria-label={videoExpanded ? t("pdfViewer.collapse") : t("pdfViewer.expand")}+ aria-expanded={videoExpanded}+ onClick={() => setVideoExpanded(!videoExpanded)}+ >+ {videoExpanded ? <ChevronUp aria-hidden="true" /> : <ChevronDown aria-hidden="true" />}+ </button>+ </ButtonTooltip>+ ) : null}</span>{isAudio && resolvedUrl ? (<span className="border-t border-slate-200 px-3 py-2">@@ -65,6 +103,16 @@ const FileAttachmentNodeView = ({ node }: NodeViewProps) => {/></span>) : null}+ {isVideo && videoExpanded && resolvedUrl ? (+ <span className="border-t border-slate-200">+ <VideoAttachmentPlayer+ key={resolvedUrl}+ src={resolvedUrl}+ label={t("videoPlayer.label", { filename: filename || label })}+ unavailableMessage={t("videoPlayer.unavailable")}+ />+ </span>+ ) : null}</span></NodeViewWrapper>);diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.cssindex 047ce668..ad0f07b6 100644--- a/apps/web/src/styles/globals.css+++ b/apps/web/src/styles/globals.css@@ -949,7 +949,8 @@ textarea {}.ProseMirror .edgeever-pdf-viewer a.pdf-viewer-action:hover,-.ProseMirror .edgeever-file-viewer a.pdf-viewer-action:hover {+.ProseMirror .edgeever-file-viewer a.pdf-viewer-action:hover,+.ProseMirror .edgeever-file-viewer button.pdf-viewer-action:hover {background: var(--brand-green-soft);color: var(--brand-green-text);}diff --git a/packages/shared/src/attachment-kind.test.mjs b/packages/shared/src/attachment-kind.test.mjsindex 8115f052..118d5931 100644--- a/packages/shared/src/attachment-kind.test.mjs+++ b/packages/shared/src/attachment-kind.test.mjs@@ -1,11 +1,19 @@import { describe, expect, test } from "bun:test";-import { resolveAttachmentKind, resolveAudioMimeType } from "./attachment-kind.ts";+import {+ resolveAttachmentKind,+ resolveAudioMimeType,+ resolvePlayableMediaMimeType,+ resolveVideoMimeType,+} from "./attachment-kind.ts";describe("attachment kind", () => {test("uses MIME types for media and filenames for common documents", () => {expect(resolveAttachmentKind("audio/mpeg", "recording.bin")).toBe("audio");expect(resolveAttachmentKind("application/octet-stream", "recording.FLAC")).toBe("audio");expect(resolveAttachmentKind(null, "archive.ape")).toBe("audio");+ expect(resolveAttachmentKind("video/mp4", "clip.bin")).toBe("video");+ expect(resolveAttachmentKind("application/octet-stream", "demo.MP4")).toBe("video");+ expect(resolveAttachmentKind(null, "screen.mov")).toBe("video");expect(resolveAttachmentKind(null, "report.PDF")).toBe("pdf");expect(resolveAttachmentKind(null, "budget.xlsx")).toBe("spreadsheet");expect(resolveAttachmentKind(null, "proposal.docx")).toBe("document");@@ -21,6 +29,19 @@ describe("attachment kind", () => {expect(resolveAudioMimeType("application/octet-stream", "payload.bin")).toBeNull();});+ test("normalizes browser-native video MIME types from filenames", () => {+ expect(resolveVideoMimeType("application/octet-stream", "clip.mp4")).toBe("video/mp4");+ expect(resolveVideoMimeType("", "walkthrough.webm")).toBe("video/webm");+ expect(resolveVideoMimeType("", "screen.MOV")).toBe("video/quicktime");+ expect(resolveVideoMimeType("video/quicktime", "clip.mp4")).toBe("video/quicktime");+ expect(resolveVideoMimeType("application/octet-stream", "payload.bin")).toBeNull();+ expect(resolveVideoMimeType("application/octet-stream", "movie.mkv")).toBeNull();+ expect(resolveAttachmentKind("application/octet-stream", "movie.mkv")).toBe("file");+ expect(resolveAttachmentKind("video/x-matroska", "movie.mkv")).toBe("video");+ expect(resolvePlayableMediaMimeType("application/octet-stream", "demo.mp4")).toBe("video/mp4");+ expect(resolvePlayableMediaMimeType("application/octet-stream", "voice.mp3")).toBe("audio/mpeg");+ });+test("falls back predictably for text and unknown files", () => {expect(resolveAttachmentKind("text/plain", "README")).toBe("text");expect(resolveAttachmentKind("application/octet-stream", "payload.bin")).toBe("file");diff --git a/packages/shared/src/attachment-kind.ts b/packages/shared/src/attachment-kind.tsindex 22ee7ad5..a1a3af51 100644--- a/packages/shared/src/attachment-kind.ts+++ b/packages/shared/src/attachment-kind.ts@@ -42,6 +42,30 @@ export const resolveAudioMimeType = (return AUDIO_MIME_TYPES_BY_EXTENSION[extensionOf(filename)] ?? null;};+const VIDEO_MIME_TYPES_BY_EXTENSION: Readonly<Record<string, string>> = {+ m4v: "video/mp4",+ mov: "video/quicktime",+ mp4: "video/mp4",+ ogv: "video/ogg",+ webm: "video/webm",+};++/** Resolve a video MIME type without overriding a specific type supplied by storage. */+export const resolveVideoMimeType = (+ mimeType: string | null | undefined,+ filename: string | null | undefined,+) => {+ const mime = mimeType?.trim().toLowerCase() ?? "";+ if (mime.startsWith("video/")) return mime;+ return VIDEO_MIME_TYPES_BY_EXTENSION[extensionOf(filename)] ?? null;+};++/** Audio or browser-native video MIME used for inline playback and Content-Type. */+export const resolvePlayableMediaMimeType = (+ mimeType: string | null | undefined,+ filename: string | null | undefined,+) => resolveAudioMimeType(mimeType, filename) ?? resolveVideoMimeType(mimeType, filename);+export const resolveAttachmentKind = (mimeType: string | null | undefined,filename: string | null | undefined,@@ -51,7 +75,7 @@ export const resolveAttachmentKind = (if (mime.startsWith("image/")) return "image";if (resolveAudioMimeType(mime, filename)) return "audio";- if (mime.startsWith("video/")) return "video";+ if (resolveVideoMimeType(mime, filename)) return "video";if (mime === "application/pdf" || extension === "pdf") return "pdf";if (diff --git a/packages/shared/src/content.test.mjs b/packages/shared/src/content.test.mjsindex ca543ecd..dba8ea96 100644--- a/packages/shared/src/content.test.mjs+++ b/packages/shared/src/content.test.mjs@@ -8,6 +8,7 @@ import {MERGE_DIVIDER_NODE_TYPE,FILE_ATTACHMENT_NODE_TYPE,PDF_ATTACHMENT_NODE_TYPE,+ resolveFileDisplayMode,PLUGIN_EMBED_NODE_TYPE,pluginEmbedToMarkdown,mergeMemoDocs,@@ -155,6 +156,13 @@ describe("file attachment Markdown compatibility", () => {expect(doc.content[0]?.content?.[0]?.type).toBe("text");});+ test("keeps video preview expanded unless compact display mode is stored", () => {+ expect(resolveFileDisplayMode(undefined)).toBe("inline");+ expect(resolveFileDisplayMode("inline")).toBe("inline");+ expect(resolveFileDisplayMode("compact")).toBe("compact");+ expect(resolveFileDisplayMode("hidden")).toBe("inline");+ });+test("upgrades a legacy standalone attachment link from rich content", () => {const legacyDoc = {type: "doc",diff --git a/packages/shared/src/content.ts b/packages/shared/src/content.tsindex 75c15206..ed8d0699 100644--- a/packages/shared/src/content.ts+++ b/packages/shared/src/content.ts@@ -44,9 +44,12 @@ export type { PdfDisplayMode } from "./pdf-attachment";export {FileAttachment,FILE_ATTACHMENT_NODE_TYPE,+ FILE_DISPLAY_MODES,isFileAttachmentLink,+ resolveFileDisplayMode,upgradeStandaloneFileLinks,} from "./file-attachment";+export type { FileDisplayMode } from "./file-attachment";export type TiptapTextNode = {type: "text";diff --git a/packages/shared/src/file-attachment.ts b/packages/shared/src/file-attachment.tsindex 30f119fa..06608456 100644--- a/packages/shared/src/file-attachment.ts+++ b/packages/shared/src/file-attachment.ts@@ -5,6 +5,12 @@ import { getAttachmentFilenameFromLabel } from "./resource-links";import { normalizeAttachmentByteSize } from "./attachment-metadata";export const FILE_ATTACHMENT_NODE_TYPE = "edgeeverFileAttachment" as const;+export const FILE_DISPLAY_MODES = ["compact", "inline"] as const;+export type FileDisplayMode = (typeof FILE_DISPLAY_MODES)[number];++/** Video preview defaults to expanded so notes open ready to play. */+export const resolveFileDisplayMode = (value: unknown): FileDisplayMode =>+ value === "compact" ? "compact" : "inline";const MARKDOWN_LINK_PATTERN = /^\[([^\]]+)\]\(([^\s)]+)(?:\s+"[^"]*")?\)/;const ATTACHMENT_LABEL_PATTERN = /^\s*(?:附件[::]|Attachment:)\s*/i;@@ -59,6 +65,14 @@ export const FileAttachment = Node.create({return byteSize === null ? {} : { "data-file-byte-size": String(byteSize) };},},+ displayMode: {+ default: "inline",+ parseHTML: (element) => resolveFileDisplayMode(element.getAttribute("data-file-display-mode")),+ renderHTML: (attributes) => {+ const displayMode = resolveFileDisplayMode(attributes.displayMode);+ return displayMode === "compact" ? { "data-file-display-mode": displayMode } : {};+ },+ },};},@@ -86,6 +100,7 @@ export const FileAttachment = Node.create({filename: getAttachmentFilenameFromLabel(label),mimeType: "",byteSize: null,+ displayMode: "inline",},};},diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex cff03838..8f6d5339 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -1529,6 +1529,10 @@ export const enUS = {label: "Audio player: {{filename}}",unavailable: "This audio format cannot be played on this device. You can still download it or open it externally.",},+ videoPlayer: {+ label: "Video player: {{filename}}",+ unavailable: "This video format cannot be played on this device. You can still download it or open it externally.",+ },editor: {imageScale: "Image scale",scaleTo: "Scale to {{percent}}%",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 0e22c6b3..bf4c7f69 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -1529,6 +1529,10 @@ export const zhCN = {label: "音频播放器:{{filename}}",unavailable: "当前设备无法播放此音频格式,你仍可下载或在外部打开。",},+ videoPlayer: {+ label: "视频播放器:{{filename}}",+ unavailable: "当前设备无法播放此视频格式,你仍可下载或在外部打开。",+ },editor: {imageScale: "图片缩放",scaleTo: "缩放到 {{percent}}%",