overleaf/services/web/frontend/js/features/source-editor/extensions/geometry-change-event.ts

14 lines
442 B
TypeScript
Raw Normal View History

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'))
}
})