diff --git a/client/src/App.css b/client/src/App.css index 60deed4..afc38e4 100644 --- a/client/src/App.css +++ b/client/src/App.css @@ -43,7 +43,7 @@ .sidebar-btn { position: absolute; - z-index: 2; + z-index: 5; top: 50%; transform: translateY(-50%); } @@ -179,7 +179,7 @@ #main, #main.w-full { - padding-top: 70px; + padding-top: 60px; width: 100%; } @@ -189,7 +189,6 @@ .debates { padding: 10px; - padding-top: 0; gap: 10px; } } \ No newline at end of file diff --git a/client/src/pages/create-debate/editor.css b/client/src/pages/create-debate/editor.css index be9d556..6d75eda 100644 --- a/client/src/pages/create-debate/editor.css +++ b/client/src/pages/create-debate/editor.css @@ -50,10 +50,6 @@ color: var(--color_primary); } -.e-richtexteditor .e-rte-content .e-content { - min-height: 40vh; -} - .e-richtexteditor .e-rte-content { z-index: 0 !important; background-color: transparent; diff --git a/client/src/pages/create-debate/editor.tsx b/client/src/pages/create-debate/editor.tsx index c12027e..462cff2 100644 --- a/client/src/pages/create-debate/editor.tsx +++ b/client/src/pages/create-debate/editor.tsx @@ -19,10 +19,15 @@ import { interface EditorProps { editorRef: React.RefObject - rteValue: string + rteValue?: string + isEditable: boolean + setDebateData?: React.Dispatch> } -const Editor: React.FC = ({ editorRef, rteValue }) => { +const Editor: React.FC = ({ editorRef, rteValue, isEditable, setDebateData }) => { const items = [ 'Undo', 'Redo', @@ -86,13 +91,22 @@ const Editor: React.FC = ({ editorRef, rteValue }) => { id="toolsRTE" ref={editorRef} value={rteValue} - showCharCount={true} - toolbarSettings={toolbarSettings} - quickToolbarSettings={quickToolbarSettings} - enableTabKey={true} - enableXhtml={true} + showCharCount={isEditable} + toolbarSettings={isEditable ? toolbarSettings : undefined} + quickToolbarSettings={isEditable ? quickToolbarSettings : undefined} + enableTabKey={isEditable} + enableXhtml={isEditable} placeholder="Your debate body" - enableResize={true} + enableResize={isEditable} + readonly={!isEditable} + change={(e: { value: string }) => { + if (isEditable && setDebateData) { + setDebateData(prevState => ({ + ...prevState, + body: e.value + })); + } + }} > = ({ isVisible, isFullscreen }) => { const editorRef = useRef(null); - const [editorContent, setEditorContent] = useState(''); + const [debateData, setDebateData] = useState({ title: 'Sony is the best camera of all time', body: '' }); + const [isPreview, setIsPreview] = useState(false); - const saveEditorContent = () => { - if (editorRef.current) { - const content = editorRef.current.value; - setEditorContent(content); + const handlePreviewToggle = () => { + if (!isPreview) { + if (editorRef.current) { + const content = editorRef.current.getHtml(); + setDebateData({ ...debateData, body: content }); + } } - }; console.log(editorContent); + setIsPreview(!isPreview); + }; return ( -
-
-

Title

-