overleaf/services/web/frontend/js/features/source-editor/extensions/geometry-change-event.ts
Alf Eaton d40de2018c Remove Angular/Pug review panel code (#15935)
GitOrigin-RevId: de782d4b47d987f6434a34bea487568b269e8d85
2023-11-29 09:04:13 +00:00

13 lines
442 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 = () =>
EditorView.updateListener.of(update => {
if (update.geometryChanged) {
window.dispatchEvent(new CustomEvent('editor:geometry-change'))
}
})