feat(ui): allow customizing min height of code editor (#9920)

Requirement for https://github.com/payloadcms/payload/pull/9645.

Dynamic code field resizing currently is broken for line-breaks - need
to address that in a future PR.
This commit is contained in:
Alessio Gravili
2024-12-11 23:31:39 -07:00
committed by GitHub
parent c8046cade7
commit bae2fe535e
2 changed files with 8 additions and 4 deletions

View File

@@ -13,11 +13,11 @@ const Editor = (EditorImport.default || EditorImport) as unknown as typeof Edito
const baseClass = 'code-editor'
const CodeEditor: React.FC<Props> = (props) => {
const { className, maxHeight, options, readOnly, ...rest } = props
const [dynamicHeight, setDynamicHeight] = useState(20)
const { theme } = useTheme()
const { className, maxHeight, minHeight, options, readOnly, ...rest } = props
const MIN_HEIGHT = minHeight ?? 56 // equivalent to 3 lines
const MIN_HEIGHT = 56 // equivalent to 3 lines
const [dynamicHeight, setDynamicHeight] = useState(MIN_HEIGHT)
const { theme } = useTheme()
const classes = [
baseClass,

View File

@@ -2,5 +2,9 @@ import type { EditorProps } from '@monaco-editor/react'
export type Props = {
maxHeight?: number
/**
* @default 56 (3 lines)
*/
minHeight?: number
readOnly?: boolean
} & EditorProps