Explorar el Código

Merge branch 'reactify-admin/create-apiV3-linebreak' into reactify-admin/adjust-layout

# Conflicts:
#	src/client/js/components/Admin/MarkdownSetting/LineBreakForm.jsx
itizawa hace 6 años
padre
commit
56cb7e26d1

+ 2 - 2
resource/locales/en-US/translation.json

@@ -602,9 +602,9 @@
     "line_break_setting": "Line Break Setting",
     "line_break_setting": "Line Break Setting",
     "line_break_setting_desc": "You can change line break settings.",
     "line_break_setting_desc": "You can change line break settings.",
     "Enable Line Break": "Enable Line Break",
     "Enable Line Break": "Enable Line Break",
-    "Enable Line Break desc": "Treat line break in the text page as <br> in HTML",
+    "Enable Line Break desc": "Treat line break in the text page as<code>&lt;br&gt;</code>in HTML",
     "Enable Line Break for comment": "Enable Line Break in comment",
     "Enable Line Break for comment": "Enable Line Break in comment",
-    "Enable Line Break for comment desc": "Treat line break in comment as <br> in HTML",
+    "Enable Line Break for comment desc": "Treat line break in comment as<code>&lt;br&gt;</code>in HTML",
     "presentation_setting": "Presentation Setting",
     "presentation_setting": "Presentation Setting",
     "presentation_setting_desc": "You can change presentation settings.",
     "presentation_setting_desc": "You can change presentation settings.",
     "Page break setting": "Page break Setting",
     "Page break setting": "Page break Setting",

+ 2 - 2
resource/locales/ja/translation.json

@@ -586,9 +586,9 @@
     "line_break_setting": "Line Break設定",
     "line_break_setting": "Line Break設定",
     "line_break_setting_desc": "Line Breakの設定を変更できます。",
     "line_break_setting_desc": "Line Breakの設定を変更できます。",
     "Enable Line Break": "Line Break を有効にする",
     "Enable Line Break": "Line Break を有効にする",
-    "Enable Line Break desc": "ページテキスト中の改行を、HTML内で <br> として扱います",
+    "Enable Line Break desc": "ページテキスト中の改行を、HTML内で<code>&lt;br&gt;</code>として扱います",
     "Enable Line Break for comment": "コメント欄で Line Break を有効にする",
     "Enable Line Break for comment": "コメント欄で Line Break を有効にする",
-    "Enable Line Break for comment desc": "コメント中の改行を、HTML内で <br> として扱います",
+    "Enable Line Break for comment desc": "コメント中の改行を、HTML内で<code>&lt;br&gt;</code>として扱います",
     "presentation_setting": "プレゼンテーション設定",
     "presentation_setting": "プレゼンテーション設定",
     "presentation_setting_desc": "プレゼンテーションの設定を変更できます。",
     "presentation_setting_desc": "プレゼンテーションの設定を変更できます。",
     "Page break setting": "改頁を設定する",
     "Page break setting": "改頁を設定する",

+ 9 - 3
src/client/js/components/Admin/MarkdownSetting/LineBreakForm.jsx

@@ -1,3 +1,4 @@
+/* eslint-disable react/no-danger */
 /* eslint-disable max-len */
 /* eslint-disable max-len */
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
@@ -20,6 +21,7 @@ class LineBreakForm extends React.Component {
     this.onClickSubmit = this.onClickSubmit.bind(this);
     this.onClickSubmit = this.onClickSubmit.bind(this);
   }
   }
 
 
+
   async onClickSubmit() {
   async onClickSubmit() {
     const { t } = this.props;
     const { t } = this.props;
 
 
@@ -37,6 +39,8 @@ class LineBreakForm extends React.Component {
     const { t, markDownSettingContainer } = this.props;
     const { t, markDownSettingContainer } = this.props;
     const { isEnabledLinebreaks } = markDownSettingContainer.state;
     const { isEnabledLinebreaks } = markDownSettingContainer.state;
 
 
+    const helpLineBreak = { __html: t('markdown_setting.Enable Line Break desc') };
+
     return (
     return (
       <div className="form-group row">
       <div className="form-group row">
         <div className="col-xs-offset-4 col-xs-4 text-left">
         <div className="col-xs-offset-4 col-xs-4 text-left">
@@ -46,7 +50,7 @@ class LineBreakForm extends React.Component {
               { t('markdown_setting.Enable Line Break') }
               { t('markdown_setting.Enable Line Break') }
             </label>
             </label>
           </div>
           </div>
-          <p className="help-block">{ t('markdown_setting.Enable Line Break desc') }</p>
+          <p className="help-block" dangerouslySetInnerHTML={helpLineBreak} />
         </div>
         </div>
       </div>
       </div>
     );
     );
@@ -56,16 +60,18 @@ class LineBreakForm extends React.Component {
     const { t, markDownSettingContainer } = this.props;
     const { t, markDownSettingContainer } = this.props;
     const { isEnabledLinebreaksInComments } = markDownSettingContainer.state;
     const { isEnabledLinebreaksInComments } = markDownSettingContainer.state;
 
 
+    const helpLineBreakInComment = { __html: t('markdown_setting.Enable Line Break for comment desc') };
+
     return (
     return (
       <div className="form-group row">
       <div className="form-group row">
         <div className="col-xs-offset-4 col-xs-4 text-left">
         <div className="col-xs-offset-4 col-xs-4 text-left">
           <div className="checkbox checkbox-success" onChange={() => { markDownSettingContainer.setState({ isEnabledLinebreaksInComments: !isEnabledLinebreaksInComments }) }}>
           <div className="checkbox checkbox-success" onChange={() => { markDownSettingContainer.setState({ isEnabledLinebreaksInComments: !isEnabledLinebreaksInComments }) }}>
             <input type="checkbox" name="isEnabledLinebreaksInComments" checked={isEnabledLinebreaksInComments} />
             <input type="checkbox" name="isEnabledLinebreaksInComments" checked={isEnabledLinebreaksInComments} />
             <label>
             <label>
-              { t('markdown_setting.Enable Line Break for comment') }
+              { t('markdown_setting.Enable Line Break') }
             </label>
             </label>
           </div>
           </div>
-          <p className="help-block">{ t('markdown_setting.Enable Line Break for comment desc') }</p>
+          <p className="help-block" dangerouslySetInnerHTML={helpLineBreakInComment} />
         </div>
         </div>
       </div>
       </div>
     );
     );

+ 3 - 64
src/client/js/components/Admin/MarkdownSetting/PresentationForm.jsx

@@ -1,4 +1,4 @@
-import React, { Fragment } from 'react';
+import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 import { withTranslation } from 'react-i18next';
 
 
@@ -6,70 +6,10 @@ import { createSubscribedElement } from '../../UnstatedUtils';
 
 
 import AppContainer from '../../../services/AppContainer';
 import AppContainer from '../../../services/AppContainer';
 import MarkDownSettingContainer from '../../../services/MarkDownSettingContainer';
 import MarkDownSettingContainer from '../../../services/MarkDownSettingContainer';
+import PresentationLineBreakOptions from './PresentationLineBreakOptions';
 
 
 class PresentationForm extends React.Component {
 class PresentationForm extends React.Component {
 
 
-  renderLineBreakOptions() {
-    const { t, markDownSettingContainer } = this.props;
-    const { pageBreakOption, customRegularExpression } = markDownSettingContainer.state;
-
-    return (
-      <Fragment>
-        <div className="col-xs-3 radio radio-primary">
-          <input
-            type="radio"
-            id="pageBreakOption1"
-            checked={pageBreakOption === 1}
-            onChange={() => { markDownSettingContainer.setState({ pageBreakOption: 1 }) }}
-          />
-          <label htmlFor="pageBreakOption1">
-            <p className="font-weight-bold">{ t('markdown_setting.Preset one separator') }</p>
-            <div className="mt-3">
-              { t('markdown_setting.Preset one separator desc') }
-              <pre><code>{ t('markdown_setting.Preset one separator value') }</code></pre>
-            </div>
-          </label>
-        </div>
-
-        <div className="col-xs-3 radio radio-primary mt-3">
-          <input
-            type="radio"
-            id="pageBreakOption2"
-            checked={pageBreakOption === 2}
-            onChange={() => { markDownSettingContainer.setState({ pageBreakOption: 2 }) }}
-          />
-          <label htmlFor="pageBreakOption2">
-            <p className="font-weight-bold">{ t('markdown_setting.Preset two separator') }</p>
-            <div className="mt-3">
-              { t('markdown_setting.Preset two separator desc') }
-              <pre><code>{ t('markdown_setting.Preset two separator value') }</code></pre>
-            </div>
-          </label>
-        </div>
-
-        <div className="col-xs-3 radio radio-primary mt-3">
-          <input
-            type="radio"
-            id="pageBreakOption3"
-            checked={pageBreakOption === 3}
-            onChange={() => { markDownSettingContainer.setState({ pageBreakOption: 3 }) }}
-          />
-          <label htmlFor="pageBreakOption3">
-            <p className="font-weight-bold">{ t('markdown_setting.Custom separator') }</p>
-            <div className="mt-3">
-              { t('markdown_setting.Custom separator desc') }
-              <input
-                className="form-control"
-                value={customRegularExpression}
-                onChange={(e) => { markDownSettingContainer.setState({ customRegularExpression: e.target.value }) }}
-              />
-            </div>
-          </label>
-        </div>
-      </Fragment>
-    );
-  }
-
   render() {
   render() {
     const { t } = this.props;
     const { t } = this.props;
 
 
@@ -79,8 +19,7 @@ class PresentationForm extends React.Component {
         <label className="col-xs-3 control-label text-right">
         <label className="col-xs-3 control-label text-right">
           { t('markdown_setting.Page break setting') }
           { t('markdown_setting.Page break setting') }
         </label>
         </label>
-        {/* create option as component if increase */}
-        {this.renderLineBreakOptions()}
+        <PresentationLineBreakOptions />
         <div className="form-group my-3">
         <div className="form-group my-3">
           <div className="col-xs-offset-4 col-xs-5">
           <div className="col-xs-offset-4 col-xs-5">
             {/* TODO GW-220 create function */}
             {/* TODO GW-220 create function */}

+ 86 - 0
src/client/js/components/Admin/MarkdownSetting/PresentationLineBreakOptions.jsx

@@ -0,0 +1,86 @@
+import React, { Fragment } from 'react';
+import PropTypes from 'prop-types';
+import { withTranslation } from 'react-i18next';
+
+import { createSubscribedElement } from '../../UnstatedUtils';
+
+import AppContainer from '../../../services/AppContainer';
+import MarkDownSettingContainer from '../../../services/MarkDownSettingContainer';
+
+class PresentationLineBreakOptions extends React.Component {
+
+  render() {
+    const { t, markDownSettingContainer } = this.props;
+    const { pageBreakOption, customRegularExpression } = markDownSettingContainer.state;
+
+    return (
+      <Fragment>
+        <div className="col-xs-3 radio radio-primary">
+          <input
+            type="radio"
+            id="pageBreakOption1"
+            checked={pageBreakOption === 1}
+            onChange={() => { markDownSettingContainer.setState({ pageBreakOption: 1 }) }}
+          />
+          <label htmlFor="pageBreakOption1">
+            <p className="font-weight-bold">{ t('markdown_setting.Preset one separator') }</p>
+            <div className="mt-3">
+              { t('markdown_setting.Preset one separator desc') }
+              <pre><code>{ t('markdown_setting.Preset one separator value') }</code></pre>
+            </div>
+          </label>
+        </div>
+
+        <div className="col-xs-3 radio radio-primary mt-3">
+          <input
+            type="radio"
+            id="pageBreakOption2"
+            checked={pageBreakOption === 2}
+            onChange={() => { markDownSettingContainer.setState({ pageBreakOption: 2 }) }}
+          />
+          <label htmlFor="pageBreakOption2">
+            <p className="font-weight-bold">{ t('markdown_setting.Preset two separator') }</p>
+            <div className="mt-3">
+              { t('markdown_setting.Preset two separator desc') }
+              <pre><code>{ t('markdown_setting.Preset two separator value') }</code></pre>
+            </div>
+          </label>
+        </div>
+
+        <div className="col-xs-3 radio radio-primary mt-3">
+          <input
+            type="radio"
+            id="pageBreakOption3"
+            checked={pageBreakOption === 3}
+            onChange={() => { markDownSettingContainer.setState({ pageBreakOption: 3 }) }}
+          />
+          <label htmlFor="pageBreakOption3">
+            <p className="font-weight-bold">{ t('markdown_setting.Custom separator') }</p>
+            <div className="mt-3">
+              { t('markdown_setting.Custom separator desc') }
+              <input
+                className="form-control"
+                value={customRegularExpression}
+                onChange={(e) => { markDownSettingContainer.setState({ customRegularExpression: e.target.value }) }}
+              />
+            </div>
+          </label>
+        </div>
+      </Fragment>
+    );
+  }
+
+}
+
+const PresentationLineBreakOptionsWrapper = (props) => {
+  return createSubscribedElement(PresentationLineBreakOptions, props, [AppContainer, MarkDownSettingContainer]);
+};
+
+PresentationLineBreakOptions.propTypes = {
+  t: PropTypes.func.isRequired, // i18next
+  appContainer: PropTypes.instanceOf(AppContainer).isRequired,
+  markDownSettingContainer: PropTypes.instanceOf(MarkDownSettingContainer).isRequired,
+
+};
+
+export default withTranslation()(PresentationLineBreakOptionsWrapper);