client/src/components/NoteInput.js
changeset 157 5c3af4f10e92
parent 143 cfcbf4bc66f1
child 161 a642639dbc07
equal deleted inserted replaced
156:384f4539b76a 157:5c3af4f10e92
    12     finishedAt: null,
    12     finishedAt: null,
    13   }
    13   }
    14 
    14 
    15   onEditorChange = (e) => {
    15   onEditorChange = (e) => {
    16     this.setState({
    16     this.setState({
    17       buttonDisabled: e.state.document.length === 0,
    17       buttonDisabled: e.value.document === 0,
    18       startedAt: e.startedAt,
    18       startedAt: e.startedAt,
    19       finishedAt: e.finishedAt
    19       finishedAt: e.finishedAt
    20     });
    20     });
    21   }
    21   }
    22 
    22 
    24 
    24 
    25     const plain = this.refs.editor.asPlain();
    25     const plain = this.refs.editor.asPlain();
    26     const raw = this.refs.editor.asRaw();
    26     const raw = this.refs.editor.asRaw();
    27     const html = this.refs.editor.asHtml();
    27     const html = this.refs.editor.asHtml();
    28     const categories = this.refs.editor.asCategories();
    28     const categories = this.refs.editor.asCategories();
    29     const marginComment = this.marginComment.value;
    29     // const marginComment = this.marginComment.value;
    30 
    30 
    31     this.props.addNote(this.props.session, {
    31     this.props.addNote(this.props.session, {
    32       plain: plain,
    32       plain: plain,
    33       raw: raw,
    33       raw: raw,
    34       html: html,
    34       html: html,
    35       startedAt: this.state.startedAt,
    35       startedAt: this.state.startedAt,
    36       finishedAt: now(),
    36       finishedAt: now(),
    37       categories: categories,
    37       categories: categories,
    38       marginComment: marginComment,
    38       // marginComment: marginComment,
    39     });
    39     });
    40 
    40 
    41     this.refs.editor.clear();
    41     this.refs.editor.clear();
    42     setTimeout(() => this.refs.editor.focus(), 250);
    42     setTimeout(() => this.refs.editor.focus(), 250);
    43   }
    43   }
    52   }
    52   }
    53 
    53 
    54   render() {
    54   render() {
    55     return (
    55     return (
    56       <form>
    56       <form>
    57         <div className="editor">
    57         <div className="editor p-3 mb-3">
    58           <div className="editor-left">
    58           <div className="editor-left w-100 border-0 pl-3 pb-3 sticky-bottom">
    59             <SlateEditor ref="editor"
    59             <SlateEditor ref="editor"
    60               onChange={this.onEditorChange}
    60               onChange={this.onEditorChange}
    61               onEnterKeyDown={this.onAddNoteClick}
    61               onEnterKeyDown={this.onAddNoteClick}
    62               onButtonClick={this.onAddNoteClick}
    62               onButtonClick={this.onAddNoteClick}
    63               onCheckboxChange={this.onCheckboxChange}
    63               onCheckboxChange={this.onCheckboxChange}
    64               isChecked={this.props.autoSubmit}
    64               isChecked={this.props.autoSubmit}
    65               isButtonDisabled={this.state.buttonDisabled}
    65               isButtonDisabled={this.state.buttonDisabled}
    66               annotationCategories={ this.props.annotationCategories } />
    66               annotationCategories={ this.props.annotationCategories } />
       
    67 
    67           </div>
    68           </div>
    68           <div className="editor-right">
    69           {/* <div className="editor-right w-25 pl-2 border-0 sticky-bottom">
    69             <input type="textarea" className="form-control"
    70             <input type="textarea" className="form-control h-100"
    70               name="margin"
    71               name="margin"
    71               placeholder="Enter a margin comment for your note"
    72               placeholder="Espace de commentaire pour votre note"
    72               // inputRef={ ref => { this.marginComment = ref; } }
    73               // inputRef={ ref => { this.marginComment = ref; } }
    73               ref={(marginComment) => { this.marginComment = marginComment; }}
    74               ref={(marginComment) => { this.marginComment = marginComment; }}
    74             />
    75             />
    75           </div>
    76           </div> */}
    76         </div>
    77         </div>
    77       </form>
    78       </form>
    78     );
    79     );
    79   }
    80   }
    80 }
    81 }