mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Editor Redesign Cleanup: main layout, toolbar, and rail (#31031)
* feat: integrate main layout, toolbar, and rail from redesign into main ide-react folder * feat: remove additional files no longer used after ide redesign GitOrigin-RevId: 8fd77f63cb9c67be91995a9dde13b0fe2376d80f
This commit is contained in:
committed by
Copybot
parent
c790449196
commit
fc8d564320
@@ -1,50 +0,0 @@
|
||||
import { useLayoutContext } from '@/shared/context/layout-context'
|
||||
import useCollapsiblePanel from '@/features/ide-react/hooks/use-collapsible-panel'
|
||||
import useDebounce from '@/shared/hooks/use-debounce'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { ImperativePanelHandle } from 'react-resizable-panels'
|
||||
|
||||
export const useChatPane = () => {
|
||||
const { chatIsOpen: isOpen, setChatIsOpen: setIsOpen } = useLayoutContext()
|
||||
const [resizing, setResizing] = useState(false)
|
||||
const panelRef = useRef<ImperativePanelHandle>(null)
|
||||
|
||||
// Keep track of a debounced local state variable for panel openness and
|
||||
// only update the external openness state when the debounced value changes.
|
||||
// This prevents successive calls to onCollapse and onExpand from
|
||||
// react-resizable-panels updating the openness state multiple times in quick
|
||||
// succession, which causes confusing behaviour that is different in React 17
|
||||
// and 18. Collapsing the chat pane on initialization is necessary because
|
||||
// react-resizable-panels does not provide a way to specify both that a panel
|
||||
// should be collapsed and a default size for the panel when expanded.
|
||||
const [localIsOpen, setLocalIsOpen] = useState(isOpen)
|
||||
const debouncedLocalIsOpen = useDebounce(localIsOpen, 100)
|
||||
|
||||
useCollapsiblePanel(isOpen, panelRef)
|
||||
|
||||
const togglePane = useCallback(() => {
|
||||
setIsOpen(value => !value)
|
||||
}, [setIsOpen])
|
||||
|
||||
const handlePaneExpand = useCallback(() => {
|
||||
setLocalIsOpen(true)
|
||||
}, [])
|
||||
|
||||
const handlePaneCollapse = useCallback(() => {
|
||||
setLocalIsOpen(false)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
setIsOpen(debouncedLocalIsOpen)
|
||||
}, [debouncedLocalIsOpen, setIsOpen])
|
||||
|
||||
return {
|
||||
isOpen,
|
||||
panelRef,
|
||||
resizing,
|
||||
setResizing,
|
||||
togglePane,
|
||||
handlePaneExpand,
|
||||
handlePaneCollapse,
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
import {
|
||||
RailTabKey,
|
||||
useRailContext,
|
||||
} from '@/features/ide-redesign/contexts/rail-context'
|
||||
} from '@/features/ide-react/context/rail-context'
|
||||
|
||||
function createEditingSessionHeartbeatData(
|
||||
editorType: EditorType,
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { useCallback, useRef, useState } from 'react'
|
||||
import useCollapsiblePanel from '@/features/ide-react/hooks/use-collapsible-panel'
|
||||
import { ImperativePanelHandle } from 'react-resizable-panels'
|
||||
|
||||
export const useSidebarPane = () => {
|
||||
const [isOpen, setIsOpen] = useState(true)
|
||||
const [resizing, setResizing] = useState(false)
|
||||
const panelRef = useRef<ImperativePanelHandle>(null)
|
||||
useCollapsiblePanel(isOpen, panelRef)
|
||||
|
||||
const togglePane = useCallback(() => {
|
||||
setIsOpen(value => !value)
|
||||
}, [])
|
||||
|
||||
const handlePaneExpand = useCallback(() => {
|
||||
setIsOpen(true)
|
||||
}, [])
|
||||
|
||||
const handlePaneCollapse = useCallback(() => {
|
||||
setIsOpen(false)
|
||||
}, [])
|
||||
|
||||
return {
|
||||
isOpen,
|
||||
setIsOpen,
|
||||
panelRef,
|
||||
togglePane,
|
||||
handlePaneExpand,
|
||||
handlePaneCollapse,
|
||||
resizing,
|
||||
setResizing,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user