Просмотр исходного кода

Merge pull request #4291 from weseek/fix/7420-bug

GW-7420 Editor SettingsでOFFにした設定がLintに適用されてないのを修正する
stevenfukase 4 лет назад
Родитель
Сommit
2ef65e0a1c

+ 10 - 6
packages/app/src/components/PageEditor/CodeMirrorEditor.jsx

@@ -174,7 +174,7 @@ export default class CodeMirrorEditor extends AbstractEditor {
       this.setState({ isEnabledEmojiAutoComplete: true });
     }
 
-    this.initTextlintSettings();
+    this.initializeTextlint();
   }
 
   componentDidMount() {
@@ -200,11 +200,14 @@ export default class CodeMirrorEditor extends AbstractEditor {
     this.setKeymapMode(keymapMode);
   }
 
-  async initTextlintSettings() {
-    // If database has empty array, pass null instead to enable all default rules
-    const rulesForValidator = this.props.textlintRules?.length !== 0 ? this.props.textlintRules : null;
-    this.textlintValidator = createValidator(rulesForValidator);
-    this.codemirrorLintConfig = { getAnnotations: this.textlintValidator, async: true };
+  async initializeTextlint() {
+    if (this.props.onInitializeTextlint != null) {
+      await this.props.onInitializeTextlint();
+      // If database has empty array, pass null instead to enable all default rules
+      const rulesForValidator = this.props.textlintRules?.length !== 0 ? this.props.textlintRules : null;
+      this.textlintValidator = createValidator(rulesForValidator);
+      this.codemirrorLintConfig = { getAnnotations: this.textlintValidator, async: true };
+    }
   }
 
   getCodeMirror() {
@@ -988,6 +991,7 @@ CodeMirrorEditor.propTypes = Object.assign({
   lineNumbers: PropTypes.bool,
   onMarkdownHelpButtonClicked: PropTypes.func,
   onAddAttachmentButtonClicked: PropTypes.func,
+  onInitializeTextlint: PropTypes.func,
 }, AbstractEditor.propTypes);
 
 CodeMirrorEditor.defaultProps = {

+ 1 - 4
packages/app/src/components/PageEditor/Editor.jsx

@@ -47,10 +47,6 @@ class Editor extends AbstractEditor {
     this.renderDropzoneOverlay = this.renderDropzoneOverlay.bind(this);
   }
 
-  componentWillMount() {
-    this.props.editorContainer.retrieveEditorSettings();
-  }
-
   componentDidMount() {
     this.setState({ isComponentDidMount: true });
   }
@@ -323,6 +319,7 @@ class Editor extends AbstractEditor {
                         editorOptions={editorContainer.state.editorOptions}
                         isTextlintEnabled={editorContainer.state.isTextlintEnabled}
                         textlintRules={editorContainer.state.textlintRules}
+                        onInitializeTextlint={editorContainer.retrieveEditorSettings}
                         onPasteFiles={this.pasteFilesHandler}
                         onDragEnter={this.dragEnterHandler}
                         onMarkdownHelpButtonClicked={this.showMarkdownHelp}