Merge pull request #28760 from overleaf/dp-hackathon-knip

Add Knip and remove a bunch of unused code

GitOrigin-RevId: 42ab99fc65973c883d2361e0027e7181767e714e
This commit is contained in:
David
2025-10-15 08:05:57 +00:00
committed by Copybot
parent 2c7c0caf07
commit 584572bb40
43 changed files with 600 additions and 672 deletions
@@ -1,12 +0,0 @@
import { EditorView } from '@codemirror/view'
import useCodeMirrorMeasurement from './use-codemirror-measurement'
// view.contentHeight, which is measured for us by CodeMirror and is what the
// gutters use, is sometimes a pixel or so short of the full height of the
// editor content, which leaves a small gap at the bottom, so use the DOM
// scrollHeight property instead.
const measureContentHeight = (view: EditorView) => view.contentDOM.scrollHeight
export default function useCodeMirrorContentHeight() {
return useCodeMirrorMeasurement('content-height', measureContentHeight)
}
@@ -1,30 +0,0 @@
import { useCallback, useState } from 'react'
import { useCodeMirrorViewContext } from '../components/codemirror-context'
import { EditorView } from '@codemirror/view'
import useEventListener from '../../../shared/hooks/use-event-listener'
export default function useCodeMirrorMeasurement(
key: string,
measure: (view: EditorView) => number
) {
const view = useCodeMirrorViewContext()
const [measurement, setMeasurement] = useState(() => measure(view))
useEventListener(
'editor:geometry-change',
useCallback(() => {
view.requestMeasure({
key,
read: () => measure(view),
write(value) {
// wrap the React state setter in a timeout so it doesn't run inside the CodeMirror update cycle
window.setTimeout(() => {
setMeasurement(value)
})
},
})
}, [view, measure, key])
)
return measurement
}