-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PullRequest: 310 Fixes oceanbase/odc#816
Merge branch 'feat/dev-4.2.4-odc-816 of git@code.alipay.com:oceanbase/oceanbase-developer-center.git into dev-4.2.4 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/310 Signed-off-by: 晓康 <xxk268858@oceanbase.com> * wip: api debug * wip: api debug * feat: append filters to DatabaseSelect * Fixes oceanbase/odc#816 * fix: modify comparisionResult's return value
- Loading branch information
1 parent
251a0c0
commit fefbaa4
Showing
30 changed files
with
1,586 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import * as monaco from 'monaco-editor'; | ||
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'; | ||
import styles from './index.less'; | ||
import { SettingStore } from '@/store/setting'; | ||
import { inject, observer } from 'mobx-react'; | ||
import classNames from 'classnames'; | ||
|
||
export interface IDiffEditor { | ||
settingStore?: SettingStore; | ||
language?: string; | ||
source: string; | ||
modifie: string; | ||
defaultSplit?: boolean; | ||
theme?: string; | ||
} | ||
export interface IDiffEditorInstance { | ||
/** @description 切换显示模式,默认为split模式 */ | ||
switchSplit: (v: boolean) => void; | ||
} | ||
const DiffEditor = inject('settingStore')( | ||
observer( | ||
forwardRef((props: IDiffEditor, ref: React.Ref<IDiffEditorInstance>) => { | ||
const { | ||
settingStore, | ||
source = null, | ||
modifie = null, | ||
language = 'sql', | ||
defaultSplit = true, | ||
theme, | ||
} = props; | ||
const domRef = useRef<HTMLDivElement | null>(null); | ||
const editorRef = useRef<monaco.editor.IStandaloneDiffEditor>(); | ||
const settingTheme = settingStore.theme.editorTheme; | ||
const [split, setSplit] = useState<boolean>(defaultSplit); | ||
useImperativeHandle(ref, () => ({ | ||
switchSplit: (v: boolean) => { | ||
setSplit(v); | ||
}, | ||
})); | ||
const themeValue = useMemo(() => { | ||
if (!theme) { | ||
return settingTheme; | ||
} | ||
return theme; | ||
}, [theme, settingTheme]); | ||
const initEditor = async () => { | ||
const originalModel = monaco.editor.createModel(source, language); | ||
const modifiedModel = monaco.editor.createModel(modifie, language); | ||
editorRef.current = monaco.editor.createDiffEditor(domRef.current, { | ||
theme: themeValue, | ||
minimap: { enabled: false }, | ||
renderOverviewRuler: false, | ||
automaticLayout: true, | ||
unicodeHighlight: { | ||
invisibleCharacters: false, | ||
ambiguousCharacters: false, | ||
}, | ||
lineNumbersMinChars: 4, | ||
lineNumbers: 'on', | ||
readOnly: true, | ||
renderSideBySide: true, | ||
originalEditable: false, | ||
}); | ||
editorRef.current?.setModel({ | ||
original: originalModel, | ||
modified: modifiedModel, | ||
}); | ||
}; | ||
useEffect(() => { | ||
if (editorRef.current) { | ||
editorRef.current.updateOptions({ | ||
renderSideBySide: split, | ||
}); | ||
} else { | ||
initEditor(); | ||
} | ||
return () => { | ||
if (editorRef.current) { | ||
editorRef.current?.dispose(); | ||
} | ||
}; | ||
}, [split]); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<div ref={domRef} className={styles.editor}></div> | ||
</div> | ||
); | ||
}), | ||
), | ||
); | ||
export default DiffEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.