1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-07 18:03:48 +00:00

update term adn condition

This commit is contained in:
杨顺强
2023-12-07 14:20:29 +08:00
parent e14abd1be9
commit 551213c429

View File

@@ -13,6 +13,14 @@ const propTypes = {
class TermsEditorDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
isValueChanged: false,
};
this.editorRef = React.createRef();
}
static defaultProps = {
title: gettext('Terms'),
};
@@ -22,20 +30,20 @@ class TermsEditorDialog extends React.Component {
};
toggle = () => {
if (this.isContentChanged()) {
const { isValueChanged } = this.state;
if (isValueChanged) {
let currentContent = this.getCurrentContent();
this.props.onCommit(currentContent);
}
this.props.onCloseEditorDialog();
};
isContentChanged = () => {
return this.simpleEditor.hasContentChange();
onValueChanged = () => {
return this.setState({isValueChanged: true});
};
getCurrentContent = () => {
let markdownContent = this.simpleEditor.getMarkdown();
return markdownContent;
return this.editorRef.current.getValue();
};
setSimpleEditorRef = (editor) => {
@@ -58,8 +66,9 @@ class TermsEditorDialog extends React.Component {
<ModalHeader className="conditions-editor-dialog-title" toggle={this.toggle}>{title}</ModalHeader>
<ModalBody className={'conditions-editor-dialog-main'}>
<SimpleEditor
onRef={this.setSimpleEditorRef.bind(this)}
ref={this.editorRef}
value={content || ''}
onValueChanged={this.onValueChanged}
/>
</ModalBody>
</Modal>