Browse Source

ensure that 'lineNumbers' option for CodeMirrorEditor moved to props from 'editorOptions'

Yuki Takei 7 years ago
parent
commit
7ad69ad134

+ 10 - 9
resource/js/components/PageComment/CommentForm.js

@@ -208,15 +208,16 @@ export default class CommentForm extends React.Component {
                 <div className="comment-write">
                 <div className="comment-write">
                   <Tabs activeKey={this.state.key} id="comment-form-tabs" onSelect={this.handleSelect} animation={false}>
                   <Tabs activeKey={this.state.key} id="comment-form-tabs" onSelect={this.handleSelect} animation={false}>
                     <Tab eventKey={1} title="Write">
                     <Tab eventKey={1} title="Write">
-                       <Editor ref="editor"
-                       value={this.state.comment}
-                       editorOptions={editorOptions}
-                       isMobile={this.props.crowi.isMobile}
-                       isUploadable={this.state.isUploadable}
-                       isUploadableFile={this.state.isUploadableFile}
-                       emojiStrategy={emojiStrategy}
-                       onChange={this.updateState}
-                       onUpload={this.onUpload}
+                      <Editor ref="editor"
+                        value={this.state.comment}
+                        editorOptions={editorOptions}
+                        lineNumbers={false}
+                        isMobile={this.props.crowi.isMobile}
+                        isUploadable={this.state.isUploadable}
+                        isUploadableFile={this.state.isUploadableFile}
+                        emojiStrategy={emojiStrategy}
+                        onChange={this.updateState}
+                        onUpload={this.onUpload}
                       />
                       />
                     </Tab>
                     </Tab>
                     { this.state.isMarkdown == true &&
                     { this.state.isMarkdown == true &&

+ 7 - 4
resource/js/components/PageEditor/CodeMirrorEditor.js

@@ -424,7 +424,7 @@ export default class CodeMirrorEditor extends AbstractEditor {
           mode: 'gfm',
           mode: 'gfm',
           theme: editorOptions.theme,
           theme: editorOptions.theme,
           styleActiveLine: editorOptions.styleActiveLine,
           styleActiveLine: editorOptions.styleActiveLine,
-          lineNumbers: editorOptions.lineNumbers,
+          lineNumbers: this.props.lineNumbers,
           tabSize: 4,
           tabSize: 4,
           indentUnit: 4,
           indentUnit: 4,
           lineWrapping: true,
           lineWrapping: true,
@@ -433,8 +433,8 @@ export default class CodeMirrorEditor extends AbstractEditor {
           matchBrackets: true,
           matchBrackets: true,
           matchTags: {bothTags: true},
           matchTags: {bothTags: true},
           // folding
           // folding
-          foldGutter: (editorOptions.lineNumbers ? true : false),
-          gutters: (editorOptions.lineNumbers ? ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'] : []),
+          foldGutter: this.props.lineNumbers,
+          gutters: this.props.lineNumbers ? ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'] : [],
           // match-highlighter, matchesonscrollbar, annotatescrollbar options
           // match-highlighter, matchesonscrollbar, annotatescrollbar options
           highlightSelectionMatches: {annotateScrollbar: true},
           highlightSelectionMatches: {annotateScrollbar: true},
           // markdown mode options
           // markdown mode options
@@ -482,5 +482,8 @@ export default class CodeMirrorEditor extends AbstractEditor {
 
 
 CodeMirrorEditor.propTypes = Object.assign({
 CodeMirrorEditor.propTypes = Object.assign({
   emojiStrategy: PropTypes.object,
   emojiStrategy: PropTypes.object,
+  lineNumbers: PropTypes.bool,
 }, AbstractEditor.propTypes);
 }, AbstractEditor.propTypes);
-
+CodeMirrorEditor.defaultProps = {
+  lineNumbers: true,
+};