fix: prevent history from crashing due to missing EditorView (#3257)

* put the editor into read only mode when examining history
This commit is contained in:
Nan Yu
2022-03-16 15:01:25 -07:00
committed by GitHub
parent d1b28499c6
commit ac2a124714
2 changed files with 7 additions and 3 deletions

View File

@@ -118,7 +118,7 @@ export type Props = {
/** Callback when user uses cancel key combo */ /** Callback when user uses cancel key combo */
onCancel?: () => void; onCancel?: () => void;
/** Callback when user changes editor content */ /** Callback when user changes editor content */
onChange?: (value: () => string) => void; onChange?: (value: () => string | undefined) => void;
/** Callback when a file upload begins */ /** Callback when a file upload begins */
onFileUploadStart?: () => void; onFileUploadStart?: () => void;
/** Callback when a file upload ends */ /** Callback when a file upload ends */
@@ -629,7 +629,7 @@ export class Editor extends React.PureComponent<
} }
this.props.onChange(() => { this.props.onChange(() => {
return this.value(); return this.view ? this.value() : undefined;
}); });
}; };

View File

@@ -272,7 +272,11 @@ class DataLoader extends React.Component<Props> {
revision, revision,
abilities, abilities,
isEditing: this.isEditing, isEditing: this.isEditing,
readOnly: !this.isEditing || !abilities.update || document.isArchived, readOnly:
!this.isEditing ||
!abilities.update ||
document.isArchived ||
!!revisionId,
onSearchLink: this.onSearchLink, onSearchLink: this.onSearchLink,
onCreateLink: this.onCreateLink, onCreateLink: this.onCreateLink,
sharedTree: this.sharedTree, sharedTree: this.sharedTree,