Browse Source

Hide toolbar when readOnly

Shun Miyazawa 2 years ago
parent
commit
b535c6e600

+ 9 - 5
packages/editor/src/components/CodeMirrorEditor/CodeMirrorEditor.tsx

@@ -41,11 +41,13 @@ export type CodeMirrorEditorProps = {
 
 
 type Props = CodeMirrorEditorProps & {
 type Props = CodeMirrorEditorProps & {
   editorKey: string | GlobalCodeMirrorEditorKey,
   editorKey: string | GlobalCodeMirrorEditorKey,
+  hideToolbar?: boolean,
 }
 }
 
 
 export const CodeMirrorEditor = (props: Props): JSX.Element => {
 export const CodeMirrorEditor = (props: Props): JSX.Element => {
   const {
   const {
     editorKey,
     editorKey,
+    hideToolbar,
     acceptedUploadFileType = AcceptedUploadFileType.NONE,
     acceptedUploadFileType = AcceptedUploadFileType.NONE,
     indentSize,
     indentSize,
     editorSettings,
     editorSettings,
@@ -209,11 +211,13 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
         <FileDropzoneOverlay isEnabled={isDragActive} />
         <FileDropzoneOverlay isEnabled={isDragActive} />
         <CodeMirrorEditorContainer ref={containerRef} />
         <CodeMirrorEditorContainer ref={containerRef} />
       </div>
       </div>
-      <Toolbar
-        editorKey={editorKey}
-        acceptedUploadFileType={acceptedUploadFileType}
-        onUpload={onUpload}
-      />
+      { !hideToolbar && (
+        <Toolbar
+          editorKey={editorKey}
+          acceptedUploadFileType={acceptedUploadFileType}
+          onUpload={onUpload}
+        />
+      ) }
     </div>
     </div>
   );
   );
 };
 };

+ 1 - 0
packages/editor/src/components/CodeMirrorEditorReadOnly.tsx

@@ -34,6 +34,7 @@ export const CodeMirrorEditorReadOnly = (props: Props): JSX.Element => {
 
 
   return (
   return (
     <CodeMirrorEditor
     <CodeMirrorEditor
+      hideToolbar
       editorKey={GlobalCodeMirrorEditorKey.READONLY}
       editorKey={GlobalCodeMirrorEditorKey.READONLY}
       {...otherProps}
       {...otherProps}
     />
     />