Merge pull request #13597 from overleaf/ae-request-measure-view

[visual] Call view.requestMeasure in updateDOM if height could change

GitOrigin-RevId: eac77962d3edffd3ce3220c7948373bc38e6d727
This commit is contained in:
Alf Eaton 2023-07-04 09:13:08 +01:00 committed by Copybot
parent a716a500c5
commit 1d33231392
6 changed files with 14 additions and 8 deletions

View file

@ -202,8 +202,9 @@ class TopPaddingWidget extends WidgetType {
return this.height === widget.height
}
updateDOM(element: HTMLElement): boolean {
updateDOM(element: HTMLElement, view: EditorView): boolean {
element.style.height = this.height + 'px'
view.requestMeasure()
return true
}
}

View file

@ -37,6 +37,7 @@ export class EditableGraphicsWidget extends GraphicsWidget {
return true
}
this.renderGraphic(element, view)
view.requestMeasure()
return true
}

View file

@ -32,6 +32,7 @@ export class EditableInlineGraphicsWidget extends EditableGraphicsWidget {
// We need to make sure these are updated, as `renderGraphic` in the base
// class will update them on the inner element.
this.updateElementData(element)
view.requestMeasure()
return true
}

View file

@ -55,6 +55,7 @@ export class GraphicsWidget extends WidgetType {
return true
}
this.renderGraphic(element, view)
view.requestMeasure()
return true
}

View file

@ -38,12 +38,13 @@ export class MakeTitleWidget extends WidgetType {
])
}
// TODO: needs view
// updateDOM(element: HTMLElement): boolean {
// this.destroyed = false
// this.buildContent(view, element)
// return true
// }
updateDOM(element: HTMLElement, view: EditorView): boolean {
this.destroyed = false
element.textContent = ''
this.buildContent(view, element)
view.requestMeasure()
return true
}
ignoreEvent(event: Event) {
return event.type !== 'mouseup'

View file

@ -29,11 +29,12 @@ export class MathWidget extends WidgetType {
return widget.math === this.math && widget.displayMode === this.displayMode
}
updateDOM(element: HTMLElement) {
updateDOM(element: HTMLElement, view: EditorView) {
this.destroyed = false
this.renderMath(element).catch(() => {
element.classList.add('ol-cm-math-error')
})
view.requestMeasure()
return true
}