From 551213c4292d5acd4d96accc506a9d950f532af7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E9=A1=BA=E5=BC=BA?= <978987373@qq.com>
Date: Thu, 7 Dec 2023 14:20:29 +0800
Subject: [PATCH] update term adn condition
---
.../components/dialog/terms-editor-dialog.js | 21 +++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/frontend/src/components/dialog/terms-editor-dialog.js b/frontend/src/components/dialog/terms-editor-dialog.js
index cb177a71b4..788469aaba 100644
--- a/frontend/src/components/dialog/terms-editor-dialog.js
+++ b/frontend/src/components/dialog/terms-editor-dialog.js
@@ -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 {
{title}