|
|
@@ -11,6 +11,7 @@ import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
|
import EditorContainer from '~/client/services/EditorContainer';
|
|
|
import { toastError } from '~/client/util/apiNotification';
|
|
|
+import { DownloadDictModal } from './DownloadDictModal';
|
|
|
|
|
|
|
|
|
export const defaultEditorOptions = {
|
|
|
@@ -34,6 +35,8 @@ class OptionsSelector extends React.Component {
|
|
|
this.state = {
|
|
|
isCddMenuOpened: false,
|
|
|
isMathJaxEnabled,
|
|
|
+ isDownloadDictModalShown: false,
|
|
|
+ isSkipAskingAgainChecked: false,
|
|
|
};
|
|
|
|
|
|
this.availableThemes = [
|
|
|
@@ -53,6 +56,8 @@ class OptionsSelector extends React.Component {
|
|
|
this.onClickRenderMathJaxInRealtime = this.onClickRenderMathJaxInRealtime.bind(this);
|
|
|
this.onClickMarkdownTableAutoFormatting = this.onClickMarkdownTableAutoFormatting.bind(this);
|
|
|
this.switchTextlintEnabledHandler = this.switchTextlintEnabledHandler.bind(this);
|
|
|
+ this.confirmEnableTextlintHandler = this.confirmEnableTextlintHandler.bind(this);
|
|
|
+ this.toggleTextlint = this.toggleTextlint.bind(this);
|
|
|
this.updateIsTextlintEnabledToDB = this.updateIsTextlintEnabledToDB.bind(this);
|
|
|
this.onToggleConfigurationDropdown = this.onToggleConfigurationDropdown.bind(this);
|
|
|
this.onChangeIndentSize = this.onChangeIndentSize.bind(this);
|
|
|
@@ -124,11 +129,29 @@ class OptionsSelector extends React.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async switchTextlintEnabledHandler() {
|
|
|
+ toggleTextlint() {
|
|
|
const { editorContainer } = this.props;
|
|
|
const newVal = !editorContainer.state.isTextlintEnabled;
|
|
|
editorContainer.setState({ isTextlintEnabled: newVal });
|
|
|
- this.updateIsTextlintEnabledToDB(newVal);
|
|
|
+ if (this.state.isSkipAskingAgainChecked) {
|
|
|
+ this.updateIsTextlintEnabledToDB(newVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ switchTextlintEnabledHandler() {
|
|
|
+ const { editorContainer } = this.props;
|
|
|
+ if (editorContainer.state.isTextlintEnabled === null) {
|
|
|
+ this.setState({ isDownloadDictModalShown: true });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.toggleTextlint();
|
|
|
+ }
|
|
|
+
|
|
|
+ confirmEnableTextlintHandler(isSkipAskingAgainChecked) {
|
|
|
+ this.setState(
|
|
|
+ { isSkipAskingAgainChecked, isDownloadDictModalShown: false },
|
|
|
+ () => this.toggleTextlint(),
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
onToggleConfigurationDropdown(newValue) {
|
|
|
@@ -359,12 +382,22 @@ class OptionsSelector extends React.Component {
|
|
|
|
|
|
render() {
|
|
|
return (
|
|
|
- <div className="d-flex flex-row">
|
|
|
- <span>{this.renderThemeSelector()}</span>
|
|
|
- <span className="d-none d-sm-block ml-2 ml-sm-4">{this.renderKeymapModeSelector()}</span>
|
|
|
- <span className="ml-2 ml-sm-4">{this.renderIndentSizeSelector()}</span>
|
|
|
- <span className="ml-2 ml-sm-4">{this.renderConfigurationDropdown()}</span>
|
|
|
- </div>
|
|
|
+ <>
|
|
|
+ <div className="d-flex flex-row">
|
|
|
+ <span>{this.renderThemeSelector()}</span>
|
|
|
+ <span className="d-none d-sm-block ml-2 ml-sm-4">{this.renderKeymapModeSelector()}</span>
|
|
|
+ <span className="ml-2 ml-sm-4">{this.renderIndentSizeSelector()}</span>
|
|
|
+ <span className="ml-2 ml-sm-4">{this.renderConfigurationDropdown()}</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {!this.state.isSkipAskingAgainChecked && (
|
|
|
+ <DownloadDictModal
|
|
|
+ isModalOpen={this.state.isDownloadDictModalShown}
|
|
|
+ onConfirmEnableTextlint={this.confirmEnableTextlintHandler}
|
|
|
+ onCancel={() => this.setState({ isDownloadDictModalShown: false })}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </>
|
|
|
);
|
|
|
}
|
|
|
|