mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 17:03:08 -05:00
16 lines
515 B
TypeScript
16 lines
515 B
TypeScript
|
import { EditorView } from '@codemirror/view'
|
||
|
|
||
|
/**
|
||
|
* An extension that triggers a custom DOM event whenever the editor geometry
|
||
|
* changes. This is used to synchronize the editor content and review panel
|
||
|
* height in "Current file" mode.
|
||
|
*/
|
||
|
export const geometryChangeEvent = (reactReviewPanel: boolean) =>
|
||
|
reactReviewPanel
|
||
|
? EditorView.updateListener.of(update => {
|
||
|
if (update.geometryChanged) {
|
||
|
window.dispatchEvent(new CustomEvent('editor:geometry-change'))
|
||
|
}
|
||
|
})
|
||
|
: []
|