mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-17 01:15:56 +08:00
parent
dc650c5368
commit
196ed8101b
@ -26,13 +26,15 @@ const PromptEditorHeightResizeWrap: FC<Props> = ({
|
|||||||
const [clientY, setClientY] = useState(0)
|
const [clientY, setClientY] = useState(0)
|
||||||
const [isResizing, setIsResizing] = useState(false)
|
const [isResizing, setIsResizing] = useState(false)
|
||||||
const [prevUserSelectStyle, setPrevUserSelectStyle] = useState(getComputedStyle(document.body).userSelect)
|
const [prevUserSelectStyle, setPrevUserSelectStyle] = useState(getComputedStyle(document.body).userSelect)
|
||||||
|
const [oldHeight, setOldHeight] = useState(height)
|
||||||
|
|
||||||
const handleStartResize = useCallback((e: React.MouseEvent<HTMLElement>) => {
|
const handleStartResize = useCallback((e: React.MouseEvent<HTMLElement>) => {
|
||||||
setClientY(e.clientY)
|
setClientY(e.clientY)
|
||||||
setIsResizing(true)
|
setIsResizing(true)
|
||||||
|
setOldHeight(height)
|
||||||
setPrevUserSelectStyle(getComputedStyle(document.body).userSelect)
|
setPrevUserSelectStyle(getComputedStyle(document.body).userSelect)
|
||||||
document.body.style.userSelect = 'none'
|
document.body.style.userSelect = 'none'
|
||||||
}, [])
|
}, [height])
|
||||||
|
|
||||||
const handleStopResize = useCallback(() => {
|
const handleStopResize = useCallback(() => {
|
||||||
setIsResizing(false)
|
setIsResizing(false)
|
||||||
@ -44,8 +46,7 @@ const PromptEditorHeightResizeWrap: FC<Props> = ({
|
|||||||
return
|
return
|
||||||
|
|
||||||
const offset = e.clientY - clientY
|
const offset = e.clientY - clientY
|
||||||
let newHeight = height + offset
|
let newHeight = oldHeight + offset
|
||||||
setClientY(e.clientY)
|
|
||||||
if (newHeight < minHeight)
|
if (newHeight < minHeight)
|
||||||
newHeight = minHeight
|
newHeight = minHeight
|
||||||
onHeightChange(newHeight)
|
onHeightChange(newHeight)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user