ソースを参照

Revert "remove markdown checkbox from CommentEditor"

This reverts commit 61b17c6b96fd0db46e007d2089b66c9c6630ccdc.
yuken 3 年 前
コミット
65bed8d8af
1 ファイル変更30 行追加0 行削除
  1. 30 0
      packages/app/src/components/PageComment/CommentEditor.tsx

+ 30 - 0
packages/app/src/components/PageComment/CommentEditor.tsx

@@ -59,6 +59,7 @@ type PropsType = {
 }
 }
 
 
 type EditorRef = {
 type EditorRef = {
+  setGfmMode: (value: boolean) => void,
   setValue: (value: string) => void,
   setValue: (value: string) => void,
   insertText: (text: string) => void,
   insertText: (text: string) => void,
   terminateUploadingState: () => void,
   terminateUploadingState: () => void,
@@ -96,6 +97,14 @@ const CommentEditor = (props: PropsType): JSX.Element => {
     setComment(value);
     setComment(value);
   };
   };
 
 
+  const updateStateCheckbox = (event) => {
+    if (editorRef.current == null) { return }
+    const value = event.target.checked;
+    setIsMarkdown(value);
+    // changeMode
+    editorRef.current.setGfmMode(value);
+  };
+
   const renderHtml = (markdown: string) => {
   const renderHtml = (markdown: string) => {
     const context = {
     const context = {
       markdown,
       markdown,
@@ -342,6 +351,27 @@ const CommentEditor = (props: PropsType): JSX.Element => {
 
 
         <div className="comment-submit">
         <div className="comment-submit">
           <div className="d-flex">
           <div className="d-flex">
+            <label className="mr-2">
+              {activeTab === 'comment_editor' && (
+                <span className="custom-control custom-checkbox">
+                  <input
+                    type="checkbox"
+                    className="custom-control-input"
+                    id="comment-form-is-markdown"
+                    name="isMarkdown"
+                    checked={isMarkdown}
+                    value="1"
+                    onChange={updateStateCheckbox}
+                  />
+                  <label
+                    className="ml-2 custom-control-label"
+                    htmlFor="comment-form-is-markdown"
+                  >
+                    Markdown
+                  </label>
+                </span>
+              ) }
+            </label>
             <span className="flex-grow-1" />
             <span className="flex-grow-1" />
             <span className="d-none d-sm-inline">{ errorMessage && errorMessage }</span>
             <span className="d-none d-sm-inline">{ errorMessage && errorMessage }</span>