import { NodeViewProps, NodeViewWrapper } from "@tiptap/react"; import { Group, Loader, Text } from "@mantine/core"; import { useMemo } from "react"; import { getFileUrl } from "@/lib/config.ts"; import { isInternalFileUrl } from "@docmost/editor-ext"; import classes from "./audio-view.module.css"; import { useTranslation } from "react-i18next"; export default function AudioView(props: NodeViewProps) { const { t } = useTranslation(); const { editor, node } = props; const { src, placeholder } = node.attrs; const safeSrc = useMemo(() => { if (!src || !isInternalFileUrl(src)) return null; return getFileUrl(src); }, [src]); const previewSrc = useMemo(() => { editor.storage.shared.audioPreviews = editor.storage.shared.audioPreviews || {}; if (placeholder?.id) { return editor.storage.shared.audioPreviews[placeholder.id]; } return null; }, [placeholder, editor]); return (
{safeSrc && (
); }