fix: diffEditor 撤销问题 (#2440)

This commit is contained in:
RickCole 2021-08-26 17:46:03 +08:00 committed by GitHub
parent a37d93cb27
commit c9786ce72a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -83,6 +83,7 @@ export interface EditorProps extends LocaleProps {
classnames: ClassNamesFn;
context?: any;
style?: any;
isDiffEditor?: boolean;
onFocus?: () => void;
onBlur?: () => void;
editorDidMount?: (editor: any, monaco: any) => void;
@ -119,7 +120,11 @@ export class Editor extends React.Component<EditorProps, any> {
}
componentDidUpdate(prevProps: EditorProps) {
if (this.props.value !== this.currentValue && this.editor) {
if (
this.props.value !== this.currentValue &&
this.editor &&
!this.props.isDiffEditor
) {
let value = String(this.props.value);
if (this.props.language === 'json') {

View File

@ -124,7 +124,6 @@ export class DiffEditor extends React.Component<DiffEditorProps, any> {
if (
this.originalEditor &&
diffValue &&
(diffValue !== prevProps.diffValue || data !== prevProps.data)
) {
this.originalEditor.getModel().setValue(
@ -144,7 +143,6 @@ export class DiffEditor extends React.Component<DiffEditorProps, any> {
if (
this.modifiedEditor &&
value &&
value !== prevProps.value &&
!this.state.focused
) {
@ -263,6 +261,7 @@ export class DiffEditor extends React.Component<DiffEditorProps, any> {
...options,
readOnly: disabled
}}
isDiffEditor
/>
</div>
);