mirror of
https://github.com/suren-atoyan/monaco-react.git
synced 2026-01-25 16:02:35 +00:00
add and properties; indicator whether to dispose the current original/modified model when the DiffEditor is unmounted or not
This commit is contained in:
parent
6e501b36b5
commit
cef5facec5
@ -16,6 +16,8 @@ function DiffEditor ({
|
||||
/* === */
|
||||
originalModelPath,
|
||||
modifiedModelPath,
|
||||
keepCurrentOriginalModel,
|
||||
keepCurrentModifiedModel,
|
||||
theme,
|
||||
loading,
|
||||
options,
|
||||
@ -128,10 +130,17 @@ function DiffEditor ({
|
||||
!isMonacoMounting && !isEditorReady && createEditor();
|
||||
}, [isMonacoMounting, isEditorReady, createEditor]);
|
||||
|
||||
const disposeEditor = () => {
|
||||
function disposeEditor() {
|
||||
const models = editorRef.current.getModel();
|
||||
models.original?.dispose();
|
||||
models.modified?.dispose();
|
||||
|
||||
if (!keepCurrentOriginalModel) {
|
||||
models.original?.dispose();
|
||||
}
|
||||
|
||||
if (!keepCurrentModifiedModel) {
|
||||
models.modified?.dispose();
|
||||
}
|
||||
|
||||
editorRef.current.dispose();
|
||||
}
|
||||
|
||||
@ -157,6 +166,8 @@ DiffEditor.propTypes = {
|
||||
/* === */
|
||||
originalModelPath: PropTypes.string,
|
||||
modifiedModelPath: PropTypes.string,
|
||||
keepCurrentOriginalModel: PropTypes.bool,
|
||||
keepCurrentModifiedModel: PropTypes.bool,
|
||||
theme: PropTypes.string,
|
||||
loading: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),
|
||||
options: PropTypes.object,
|
||||
@ -174,6 +185,8 @@ DiffEditor.defaultProps = {
|
||||
theme: 'light',
|
||||
loading: 'Loading...',
|
||||
options: {},
|
||||
keepCurrentOriginalModel: false,
|
||||
keepCurrentModifiedModel: false,
|
||||
/* === */
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user