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

rename EditorOptionsContainer.js -> EditorContainer

Yuki Takei 6 лет назад
Родитель
Сommit
99ca4f19f8

+ 6 - 6
src/client/js/app.js

@@ -49,7 +49,7 @@ import GroupDeleteModal from './components/GroupDeleteModal/GroupDeleteModal';
 
 import PageContainer from './services/PageContainer';
 import CommentContainer from './components/PageComment/CommentContainer';
-import EditorOptionsContainer from './services/EditorOptionsContainer';
+import EditorContainer from './services/EditorContainer';
 
 
 const logger = loggerFactory('growi:app');
@@ -120,7 +120,7 @@ window.crowiRenderer = crowiRenderer;
 // create unstated container instance
 const pageContainer = new PageContainer();
 const commentContainer = new CommentContainer(crowi, pageContainer);
-const editorOptionsContainer = new EditorOptionsContainer(defaultEditorOptions, defaultPreviewOptions);
+const editorContainer = new EditorContainer(defaultEditorOptions, defaultPreviewOptions);
 
 // FIXME
 const isEnabledPlugins = $('body').data('plugin-enabled');
@@ -324,7 +324,7 @@ let pageComments = null;
 if (pageId) {
   componentMappings['page-comments-list'] = (
     <I18nextProvider i18n={i18n}>
-      <Provider inject={[commentContainer, editorOptionsContainer]}>
+      <Provider inject={[commentContainer, editorContainer]}>
         <PageComments
           ref={(elem) => {
             if (pageComments == null) {
@@ -481,7 +481,7 @@ const pageEditorElem = document.getElementById('page-editor');
 if (pageEditorElem) {
   ReactDOM.render(
     <I18nextProvider i18n={i18n}>
-      <Provider inject={[editorOptionsContainer]}>
+      <Provider inject={[editorContainer]}>
         <PageEditor
           ref={(elem) => {
             if (pageEditor == null) {
@@ -509,7 +509,7 @@ if (pageEditorElem) {
 const writeCommentElem = document.getElementById('page-comment-write');
 if (writeCommentElem) {
   ReactDOM.render(
-    <Provider inject={[commentContainer, editorOptionsContainer]}>
+    <Provider inject={[commentContainer, editorContainer]}>
       <I18nextProvider i18n={i18n}>
         <CommentEditorLazyRenderer
           crowi={crowi}
@@ -528,7 +528,7 @@ const pageEditorOptionsSelectorElem = document.getElementById('page-editor-optio
 if (pageEditorOptionsSelectorElem) {
   ReactDOM.render(
     <I18nextProvider i18n={i18n}>
-      <Provider inject={[editorOptionsContainer]}>
+      <Provider inject={[editorContainer]}>
         <OptionsSelector crowi={crowi} />
       </Provider>
     </I18nextProvider>,

+ 4 - 4
src/client/js/components/PageEditor/Editor.jsx

@@ -10,7 +10,7 @@ import TextAreaEditor from './TextAreaEditor';
 
 
 import pasteHelper from './PasteHelper';
-import EditorOptionsContainer from '../../services/EditorOptionsContainer';
+import EditorContainer from '../../services/EditorContainer';
 
 export default class Editor extends AbstractEditor {
 
@@ -274,12 +274,12 @@ export default class Editor extends AbstractEditor {
 
                 {/* for PC */}
                 { !isMobile && (
-                  <Subscribe to={[EditorOptionsContainer]}>
-                    { editorOptionsContainer => (
+                  <Subscribe to={[EditorContainer]}>
+                    { editorContainer => (
                       // eslint-disable-next-line arrow-body-style
                       <CodeMirrorEditor
                         ref={(c) => { this.cmEditor = c }}
-                        editorOptions={editorOptionsContainer.state.editorOptions}
+                        editorOptions={editorContainer.state.editorOptions}
                         onPasteFiles={this.pasteFilesHandler}
                         onDragEnter={this.dragEnterHandler}
                         {...this.props}

+ 30 - 30
src/client/js/components/PageEditor/OptionsSelector.jsx

@@ -11,7 +11,7 @@ import ControlLabel from 'react-bootstrap/es/ControlLabel';
 import Dropdown from 'react-bootstrap/es/Dropdown';
 import MenuItem from 'react-bootstrap/es/MenuItem';
 
-import EditorOptionsContainer from '../../services/EditorOptionsContainer';
+import EditorContainer from '../../services/EditorContainer';
 
 
 export const defaultEditorOptions = {
@@ -59,60 +59,60 @@ class OptionsSelector extends React.Component {
   }
 
   init() {
-    const { editorOptionsContainer } = this.props;
+    const { editorContainer } = this.props;
 
-    this.themeSelectorInputEl.value = editorOptionsContainer.state.editorOptions.theme;
-    this.keymapModeSelectorInputEl.value = editorOptionsContainer.state.editorOptions.keymapMode;
+    this.themeSelectorInputEl.value = editorContainer.state.editorOptions.theme;
+    this.keymapModeSelectorInputEl.value = editorContainer.state.editorOptions.keymapMode;
   }
 
   onChangeTheme() {
-    const { editorOptionsContainer } = this.props;
+    const { editorContainer } = this.props;
 
     const newValue = this.themeSelectorInputEl.value;
-    const newOpts = Object.assign(editorOptionsContainer.state.editorOptions, { theme: newValue });
-    editorOptionsContainer.setState({ editorOptions: newOpts });
+    const newOpts = Object.assign(editorContainer.state.editorOptions, { theme: newValue });
+    editorContainer.setState({ editorOptions: newOpts });
 
     // save to localStorage
-    editorOptionsContainer.saveToLocalStorage();
+    editorContainer.saveToLocalStorage();
   }
 
   onChangeKeymapMode() {
-    const { editorOptionsContainer } = this.props;
+    const { editorContainer } = this.props;
 
     const newValue = this.keymapModeSelectorInputEl.value;
-    const newOpts = Object.assign(editorOptionsContainer.state.editorOptions, { keymapMode: newValue });
-    editorOptionsContainer.setState({ editorOptions: newOpts });
+    const newOpts = Object.assign(editorContainer.state.editorOptions, { keymapMode: newValue });
+    editorContainer.setState({ editorOptions: newOpts });
 
     // save to localStorage
-    editorOptionsContainer.saveToLocalStorage();
+    editorContainer.saveToLocalStorage();
   }
 
   onClickStyleActiveLine(event) {
-    const { editorOptionsContainer } = this.props;
+    const { editorContainer } = this.props;
 
     // keep dropdown opened
     this._cddForceOpen = true;
 
-    const newValue = !editorOptionsContainer.state.editorOptions.styleActiveLine;
-    const newOpts = Object.assign(editorOptionsContainer.state.editorOptions, { styleActiveLine: newValue });
-    editorOptionsContainer.setState({ editorOptions: newOpts });
+    const newValue = !editorContainer.state.editorOptions.styleActiveLine;
+    const newOpts = Object.assign(editorContainer.state.editorOptions, { styleActiveLine: newValue });
+    editorContainer.setState({ editorOptions: newOpts });
 
     // save to localStorage
-    editorOptionsContainer.saveToLocalStorage();
+    editorContainer.saveToLocalStorage();
   }
 
   onClickRenderMathJaxInRealtime(event) {
-    const { editorOptionsContainer } = this.props;
+    const { editorContainer } = this.props;
 
     // keep dropdown opened
     this._cddForceOpen = true;
 
-    const newValue = !editorOptionsContainer.state.previewOptions.renderMathJaxInRealtime;
-    const newOpts = Object.assign(editorOptionsContainer.state.previewOptions, { renderMathJaxInRealtime: newValue });
-    editorOptionsContainer.setState({ previewOptions: newOpts });
+    const newValue = !editorContainer.state.previewOptions.renderMathJaxInRealtime;
+    const newOpts = Object.assign(editorContainer.state.previewOptions, { renderMathJaxInRealtime: newValue });
+    editorContainer.setState({ previewOptions: newOpts });
 
     // save to localStorage
-    editorOptionsContainer.saveToLocalStorage();
+    editorContainer.saveToLocalStorage();
   }
 
   /*
@@ -219,8 +219,8 @@ class OptionsSelector extends React.Component {
   }
 
   renderActiveLineMenuItem() {
-    const { t, editorOptionsContainer } = this.props;
-    const isActive = editorOptionsContainer.state.editorOptions.styleActiveLine;
+    const { t, editorContainer } = this.props;
+    const isActive = editorContainer.state.editorOptions.styleActiveLine;
 
     const iconClasses = ['text-info'];
     if (isActive) {
@@ -242,10 +242,10 @@ class OptionsSelector extends React.Component {
       return;
     }
 
-    const { editorOptionsContainer } = this.props;
+    const { editorContainer } = this.props;
 
     const isEnabled = this.state.isMathJaxEnabled;
-    const isActive = isEnabled && editorOptionsContainer.state.previewOptions.renderMathJaxInRealtime;
+    const isActive = isEnabled && editorContainer.state.previewOptions.renderMathJaxInRealtime;
 
     const iconClasses = ['text-info'];
     if (isActive) {
@@ -281,10 +281,10 @@ class OptionsSelectorWrapper extends React.Component {
 
   render() {
     return (
-      <Subscribe to={[EditorOptionsContainer]}>
-        { editorOptionsContainer => (
+      <Subscribe to={[EditorContainer]}>
+        { editorContainer => (
           // eslint-disable-next-line arrow-body-style
-          <OptionsSelector editorOptionsContainer={editorOptionsContainer} {...this.props} />
+          <OptionsSelector editorContainer={editorContainer} {...this.props} />
         )}
       </Subscribe>
     );
@@ -296,7 +296,7 @@ class OptionsSelectorWrapper extends React.Component {
 OptionsSelector.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   crowi: PropTypes.object.isRequired,
-  editorOptionsContainer: PropTypes.instanceOf(EditorOptionsContainer).isRequired,
+  editorContainer: PropTypes.instanceOf(EditorContainer).isRequired,
 };
 OptionsSelectorWrapper.propTypes = {
   t: PropTypes.func.isRequired, // i18next

+ 4 - 4
src/client/js/components/PageEditor/Preview.js

@@ -5,7 +5,7 @@ import { Subscribe } from 'unstated';
 
 import RevisionBody from '../Page/RevisionBody';
 
-import EditorOptionsContainer from '../../services/EditorOptionsContainer';
+import EditorContainer from '../../services/EditorContainer';
 
 /**
  * Wrapper component for Page/RevisionBody
@@ -14,8 +14,8 @@ export default class Preview extends React.Component {
 
   render() {
     return (
-      <Subscribe to={[EditorOptionsContainer]}>
-        { editorOptionsContainer => (
+      <Subscribe to={[EditorContainer]}>
+        { editorContainer => (
           // eslint-disable-next-line arrow-body-style
           <div
             className="page-editor-preview-body"
@@ -31,7 +31,7 @@ export default class Preview extends React.Component {
           >
             <RevisionBody
               {...this.props}
-              renderMathJaxInRealtime={editorOptionsContainer.state.previewOptions.renderMathJaxInRealtime}
+              renderMathJaxInRealtime={editorContainer.state.previewOptions.renderMathJaxInRealtime}
             />
           </div>
         )}

+ 1 - 1
src/client/js/services/EditorOptionsContainer.js → src/client/js/services/EditorContainer.js

@@ -4,7 +4,7 @@ import { Container } from 'unstated';
  * Service container related to options for Editor/Preview
  * @extends {Container} unstated Container
  */
-export default class EditorOptionsContainer extends Container {
+export default class EditorContainer extends Container {
 
   constructor(defaultEditorOptions, defaultPreviewOptions) {
     super();