client/src/components/NoteInput.js
changeset 173 0e6703cd0968
parent 171 03334a31130a
child 191 3f71ad81a5a9
equal deleted inserted replaced
172:4b780ebbedc6 173:0e6703cd0968
    26       startedAt: e.startedAt,
    26       startedAt: e.startedAt,
    27       finishedAt: e.finishedAt
    27       finishedAt: e.finishedAt
    28     });
    28     });
    29   }
    29   }
    30 
    30 
    31   onAddNoteClick = () => {
    31   submitNote = () => {
    32 
    32 
    33     const plain = this.editor.asPlain();
    33     const plain = this.editor.asPlain();
    34     const raw = this.editor.asRaw();
    34     const raw = this.editor.asRaw();
    35     const html = this.editor.asHtml();
    35     const html = this.editor.asHtml();
    36     const categories = this.editor.asCategories();
    36     const categories = this.editor.asCategories();
    50 
    50 
    51     this.editor.clear();
    51     this.editor.clear();
    52     setTimeout(() => this.editor.focus(), 250);
    52     setTimeout(() => this.editor.focus(), 250);
    53   }
    53   }
    54 
    54 
    55   onCheckboxChange = (e) => {
       
    56     this.props.setAutoSubmit(e.target.checked);
       
    57   }
       
    58 
       
    59   componentDidMount() {
    55   componentDidMount() {
    60     if(this.editor) {
    56     if(this.editor) {
    61       const text = this.editor.asPlain();
    57       const text = this.editor.asPlain();
    62       this.setState({ buttonDisabled: text.length === 0 });
    58       this.setState({ buttonDisabled: text.length === 0 });
    63     }
    59     }
    68       <form>
    64       <form>
    69         <div className="editor mb-3">
    65         <div className="editor mb-3">
    70           <div className="editor-left sticky-bottom px-2">
    66           <div className="editor-left sticky-bottom px-2">
    71             <SlateEditor editorRef={this.editorInst}
    67             <SlateEditor editorRef={this.editorInst}
    72               onChange={this.onEditorChange}
    68               onChange={this.onEditorChange}
    73               onEnterKeyDown={this.onAddNoteClick}
    69               submitNote={this.submitNote}
    74               onButtonClick={this.onAddNoteClick}
       
    75               onCheckboxChange={this.onCheckboxChange}
       
    76               isChecked={this.props.autoSubmit}
       
    77               isButtonDisabled={this.state.buttonDisabled}
    70               isButtonDisabled={this.state.buttonDisabled}
    78               annotationCategories={ this.props.annotationCategories } />
    71               annotationCategories={ this.props.annotationCategories } />
    79 
    72 
    80           </div>
    73           </div>
    81           {/* <div className="editor-right w-25 pl-2 border-0 sticky-bottom">
    74           {/* <div className="editor-right w-25 pl-2 border-0 sticky-bottom">