mirror of
https://github.com/docmost/docmost.git
synced 2025-11-14 03:31:11 +10:00
* add callout, youtube embed, image, video, table, detail, math * fix attachments module * other fixes
34 lines
870 B
TypeScript
34 lines
870 B
TypeScript
import { NodeViewProps, NodeViewWrapper } from "@tiptap/react";
|
|
import { useMemo } from "react";
|
|
import { Image } from "@mantine/core";
|
|
import { getBackendUrl } from "@/lib/config.ts";
|
|
|
|
export default function ImageView(props: NodeViewProps) {
|
|
const { node, selected } = props;
|
|
const { src, width, align } = node.attrs;
|
|
|
|
const flexJustifyContent = useMemo(() => {
|
|
if (align === "center") return "center";
|
|
if (align === "right") return "flex-end";
|
|
return "flex-start";
|
|
}, [align]);
|
|
|
|
return (
|
|
<NodeViewWrapper
|
|
style={{
|
|
position: "relative",
|
|
display: "flex",
|
|
justifyContent: flexJustifyContent,
|
|
}}
|
|
>
|
|
<Image
|
|
radius="md"
|
|
src={getBackendUrl() + src}
|
|
fit="contain"
|
|
w={width}
|
|
className={selected && "ProseMirror-selectednode"}
|
|
/>
|
|
</NodeViewWrapper>
|
|
);
|
|
}
|