mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 08:52:39 +10:00
* Share - WIP * - public attachment links - WIP * WIP * WIP * Share - WIP * WIP * WIP * include userRole in space object * WIP * Server render shared page meta tags * disable user select * Close Navbar on outside click on mobile * update shared page spaceId * WIP * fix * close sidebar on click * close sidebar * defaults * update copy * Store share key in lowercase * refactor page breadcrumbs * Change copy * add link ref * open link button * add meta og:title * add twitter tags * WIP * make shares/info endpoint public * fix * * add /p/ segment to share urls * minore fixes * change mobile breadcrumb icon
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import "@/features/editor/styles/index.css";
|
|
import React, { useMemo } from "react";
|
|
import { EditorProvider } from "@tiptap/react";
|
|
import { mainExtensions } from "@/features/editor/extensions/extensions";
|
|
import { Document } from "@tiptap/extension-document";
|
|
import { Heading } from "@tiptap/extension-heading";
|
|
import { Text } from "@tiptap/extension-text";
|
|
import { Placeholder } from "@tiptap/extension-placeholder";
|
|
import { useAtom } from "jotai/index";
|
|
import {
|
|
pageEditorAtom,
|
|
readOnlyEditorAtom,
|
|
} from "@/features/editor/atoms/editor-atoms.ts";
|
|
import { Editor } from "@tiptap/core";
|
|
|
|
interface PageEditorProps {
|
|
title: string;
|
|
content: any;
|
|
}
|
|
|
|
export default function ReadonlyPageEditor({
|
|
title,
|
|
content,
|
|
}: PageEditorProps) {
|
|
const [, setReadOnlyEditor] = useAtom(readOnlyEditorAtom);
|
|
|
|
const extensions = useMemo(() => {
|
|
return [...mainExtensions];
|
|
}, []);
|
|
|
|
const titleExtensions = [
|
|
Document.extend({
|
|
content: "heading",
|
|
}),
|
|
Heading,
|
|
Text,
|
|
Placeholder.configure({
|
|
placeholder: "Untitled",
|
|
showOnlyWhenEditable: false,
|
|
}),
|
|
];
|
|
|
|
return (
|
|
<>
|
|
<EditorProvider
|
|
editable={false}
|
|
immediatelyRender={true}
|
|
extensions={titleExtensions}
|
|
content={title}
|
|
></EditorProvider>
|
|
|
|
<EditorProvider
|
|
editable={false}
|
|
immediatelyRender={true}
|
|
extensions={extensions}
|
|
content={content}
|
|
onCreate={({ editor }) => {
|
|
if (editor) {
|
|
// @ts-ignore
|
|
setReadOnlyEditor(editor);
|
|
}
|
|
}}
|
|
></EditorProvider>
|
|
<div style={{ paddingBottom: "20vh" }}></div>
|
|
</>
|
|
);
|
|
}
|