2023-12-15 04:19:42 -05:00
|
|
|
import React, { useEffect } from 'react'
|
2020-06-29 09:05:08 -04:00
|
|
|
import classNames from 'classnames'
|
2020-09-03 05:23:34 -04:00
|
|
|
|
2020-09-01 04:09:04 -04:00
|
|
|
import OutlineRoot from './outline-root'
|
2020-09-16 04:53:29 -04:00
|
|
|
import withErrorBoundary from '../../../infrastructure/error-boundary'
|
2024-02-01 04:41:12 -05:00
|
|
|
import { OutlineToggleButton } from '@/features/outline/components/outline-toggle-button'
|
2020-06-29 09:05:08 -04:00
|
|
|
|
2024-01-26 04:23:48 -05:00
|
|
|
const OutlinePane = React.memo<{
|
|
|
|
isTexFile: boolean
|
|
|
|
outline: any[]
|
|
|
|
jumpToLine(line: number): void
|
|
|
|
onToggle(value: boolean): void
|
|
|
|
eventTracking: any
|
|
|
|
highlightedLine?: number
|
|
|
|
show: boolean
|
|
|
|
isPartial?: boolean
|
|
|
|
expanded?: boolean
|
|
|
|
toggleExpanded: () => void
|
|
|
|
}>(function OutlinePane({
|
2020-07-16 10:04:04 -04:00
|
|
|
isTexFile,
|
|
|
|
outline,
|
|
|
|
jumpToLine,
|
|
|
|
onToggle,
|
2021-04-27 03:52:58 -04:00
|
|
|
highlightedLine,
|
2022-11-08 11:45:19 -05:00
|
|
|
isPartial = false,
|
2023-12-15 04:19:42 -05:00
|
|
|
expanded,
|
|
|
|
toggleExpanded,
|
2020-07-16 10:04:04 -04:00
|
|
|
}) {
|
2024-01-26 04:23:48 -05:00
|
|
|
const isOpen = Boolean(isTexFile && expanded)
|
2020-07-16 06:09:01 -04:00
|
|
|
|
2020-12-15 05:23:54 -05:00
|
|
|
useEffect(() => {
|
|
|
|
onToggle(isOpen)
|
2021-01-07 09:22:19 -05:00
|
|
|
}, [isOpen, onToggle])
|
2020-06-29 09:05:08 -04:00
|
|
|
|
|
|
|
const headerClasses = classNames('outline-pane', {
|
2021-04-27 03:52:58 -04:00
|
|
|
'outline-pane-disabled': !isTexFile,
|
2020-06-29 09:05:08 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={headerClasses}>
|
|
|
|
<header className="outline-header">
|
2024-02-01 04:41:12 -05:00
|
|
|
<OutlineToggleButton
|
|
|
|
toggleExpanded={toggleExpanded}
|
|
|
|
expanded={expanded}
|
|
|
|
isOpen={isOpen}
|
|
|
|
isPartial={isPartial}
|
|
|
|
isTexFile={isTexFile}
|
|
|
|
/>
|
2020-06-29 09:05:08 -04:00
|
|
|
</header>
|
2023-12-15 04:19:42 -05:00
|
|
|
{isOpen && (
|
2020-06-29 09:05:08 -04:00
|
|
|
<div className="outline-body">
|
2020-07-28 05:37:46 -04:00
|
|
|
<OutlineRoot
|
|
|
|
outline={outline}
|
|
|
|
jumpToLine={jumpToLine}
|
|
|
|
highlightedLine={highlightedLine}
|
|
|
|
/>
|
2020-06-29 09:05:08 -04:00
|
|
|
</div>
|
2023-12-15 04:19:42 -05:00
|
|
|
)}
|
2020-06-29 09:05:08 -04:00
|
|
|
</div>
|
|
|
|
)
|
2021-06-21 06:02:38 -04:00
|
|
|
})
|
2020-06-29 09:05:08 -04:00
|
|
|
|
2020-09-16 04:53:29 -04:00
|
|
|
export default withErrorBoundary(OutlinePane)
|