Răsfoiți Sursa

applied changes from 7093

Steven Fukase 4 ani în urmă
părinte
comite
c3b82f0070
1 a modificat fișierele cu 27 adăugiri și 34 ștergeri
  1. 27 34
      packages/app/src/components/PageEditor/CodeMirrorEditor.jsx

+ 27 - 34
packages/app/src/components/PageEditor/CodeMirrorEditor.jsx

@@ -857,49 +857,42 @@ export default class CodeMirrorEditor extends AbstractEditor {
     ];
     ];
   }
   }
 
 
+  // TODO: Get configs from db
+  isLintEnabled = true;
+
+  textlintConfig = [
+    {
+      name: 'max-comma',
+    },
+    {
+      name: 'dummy-rule',
+    },
+    {
+      name: 'common-misspellings',
+      options: {
+        ignore: [
+          'isnt',
+          'yuo',
+        ],
+      },
+    },
+  ];
+
+  textlintValidator = createValidator(this.textlintConfig);
+
+  codemirrorLintConfig = this.isLintEnabled ? { getAnnotations: this.textlintValidator, async: true } : undefined;
+
   render() {
   render() {
     const mode = this.state.isGfmMode ? 'gfm-growi' : undefined;
     const mode = this.state.isGfmMode ? 'gfm-growi' : undefined;
+    const lint = this.codemirrorLintConfig;
     const additionalClasses = Array.from(this.state.additionalClassSet).join(' ');
     const additionalClasses = Array.from(this.state.additionalClassSet).join(' ');
     const placeholder = this.state.isGfmMode ? 'Input with Markdown..' : 'Input with Plain Text..';
     const placeholder = this.state.isGfmMode ? 'Input with Markdown..' : 'Input with Plain Text..';
 
 
-    // TODO: Get configs from db
-    const isLintEnabled = true;
-    const textlintConfig = [
-      {
-        name: 'max-comma',
-      },
-      {
-        name: 'dummy-rule',
-      },
-      {
-        name: 'no-dropping-the-ra',
-      },
-      {
-        name: 'common-misspellings',
-        options: {
-          ignore: [
-            'isnt',
-            'yuo',
-          ],
-        },
-      },
-    ];
-
-    const textlintValidator = createValidator(textlintConfig);
-
-    const lint = {};
-    if (isLintEnabled === true) {
-      Object.assign(lint, {
-        getAnnotations: textlintValidator,
-        async: true,
-      });
-    }
-
     const gutters = [];
     const gutters = [];
     if (this.props.lineNumbers != null) {
     if (this.props.lineNumbers != null) {
       gutters.push('CodeMirror-linenumbers', 'CodeMirror-foldgutter');
       gutters.push('CodeMirror-linenumbers', 'CodeMirror-foldgutter');
     }
     }
-    if (isLintEnabled === true) {
+    if (this.isLintEnabled === true) {
       gutters.push('CodeMirror-lint-markers');
       gutters.push('CodeMirror-lint-markers');
     }
     }