mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 10:22:46 +00:00
update term adn condition
This commit is contained in:
@@ -13,6 +13,14 @@ const propTypes = {
|
|||||||
|
|
||||||
class TermsEditorDialog extends React.Component {
|
class TermsEditorDialog extends React.Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
isValueChanged: false,
|
||||||
|
};
|
||||||
|
this.editorRef = React.createRef();
|
||||||
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
title: gettext('Terms'),
|
title: gettext('Terms'),
|
||||||
};
|
};
|
||||||
@@ -22,20 +30,20 @@ class TermsEditorDialog extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
toggle = () => {
|
toggle = () => {
|
||||||
if (this.isContentChanged()) {
|
const { isValueChanged } = this.state;
|
||||||
|
if (isValueChanged) {
|
||||||
let currentContent = this.getCurrentContent();
|
let currentContent = this.getCurrentContent();
|
||||||
this.props.onCommit(currentContent);
|
this.props.onCommit(currentContent);
|
||||||
}
|
}
|
||||||
this.props.onCloseEditorDialog();
|
this.props.onCloseEditorDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
isContentChanged = () => {
|
onValueChanged = () => {
|
||||||
return this.simpleEditor.hasContentChange();
|
return this.setState({isValueChanged: true});
|
||||||
};
|
};
|
||||||
|
|
||||||
getCurrentContent = () => {
|
getCurrentContent = () => {
|
||||||
let markdownContent = this.simpleEditor.getMarkdown();
|
return this.editorRef.current.getValue();
|
||||||
return markdownContent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
setSimpleEditorRef = (editor) => {
|
setSimpleEditorRef = (editor) => {
|
||||||
@@ -58,8 +66,9 @@ class TermsEditorDialog extends React.Component {
|
|||||||
<ModalHeader className="conditions-editor-dialog-title" toggle={this.toggle}>{title}</ModalHeader>
|
<ModalHeader className="conditions-editor-dialog-title" toggle={this.toggle}>{title}</ModalHeader>
|
||||||
<ModalBody className={'conditions-editor-dialog-main'}>
|
<ModalBody className={'conditions-editor-dialog-main'}>
|
||||||
<SimpleEditor
|
<SimpleEditor
|
||||||
onRef={this.setSimpleEditorRef.bind(this)}
|
ref={this.editorRef}
|
||||||
value={content || ''}
|
value={content || ''}
|
||||||
|
onValueChanged={this.onValueChanged}
|
||||||
/>
|
/>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
Reference in New Issue
Block a user