-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublicNodeEditor.tsx
60 lines (48 loc) · 1.5 KB
/
PublicNodeEditor.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { usePlateEditorRef, selectEditor } from '@udecode/plate'
import { Link } from 'react-router-dom'
import styled from 'styled-components'
import { defaultContent } from '@mexit/core'
import { StyledEditor, EditorWrapper, Title } from '@mexit/shared'
import Metadata from '../EditorInfobar/Metadata'
import PublicNoteFooter from '../PublicNoteFooter'
import Editor from './Editor'
const PublicStyledEditor = styled(StyledEditor)`
display: flex;
flex-direction: column;
justify-content: center;
flex: 1;
max-width: 950px;
min-width: 400px;
padding: 0 2rem;
margin: 1rem;
&& > div {
width: 100%;
}
`
const PublicNodeEditor = ({ nodeId, node, namespaceId }) => {
const editorRef = usePlateEditorRef()
const onFocusClick = () => {
if (editorRef) {
selectEditor(editorRef, { focus: true })
}
}
return (
<PublicStyledEditor className="mex_editor">
<Title>
<Link to={'/'}>{node?.title}</Link>
</Title>
{node && <Metadata namespaceId={namespaceId} nodeId={nodeId} publicMetadata={node?.metadata} />}
<EditorWrapper onClick={onFocusClick}>
<Editor
readOnly={true}
nodeUID={nodeId}
nodePath={node?.title ?? ''}
content={node?.content ?? defaultContent.content}
onChange={() => {}} // eslint-disable-line @typescript-eslint/no-empty-function
/>
{node && <PublicNoteFooter nodeId={nodeId} />}
</EditorWrapper>
</PublicStyledEditor>
)
}
export default PublicNodeEditor