mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:58:05 +08:00
fix: diffEditor 撤销问题 (#2440)
This commit is contained in:
parent
a37d93cb27
commit
c9786ce72a
@ -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') {
|
||||
|
@ -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>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user