overleaf/services/web/frontend/js/features/source-editor/extensions/geometry-change-event.ts
ilkin-overleaf 15db0ce4e3 Merge pull request #13492 from overleaf/td-review-panel-sync-height
Add hook for synchronizing review panel height with editor content height

GitOrigin-RevId: ef0a96ef4e77e7858b28f6f65254a4b0c1e778ea
2023-07-17 10:39:29 +00:00

15 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'))
}
})
: []