mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #31937 from overleaf/mj-cache-equation-height
[web] Cache equation height in visual editor GitOrigin-RevId: d10c65a904d6d803f1cf006c18ee69b88ec66210
This commit is contained in:
committed by
Copybot
parent
bb3e1286db
commit
8c7fe88c8c
@@ -4,6 +4,7 @@ import { placeSelectionInsideBlock } from '../selection'
|
||||
|
||||
export class MathWidget extends WidgetType {
|
||||
destroyed = false
|
||||
cachedHeight: number | undefined = undefined
|
||||
|
||||
constructor(
|
||||
public math: string,
|
||||
@@ -76,7 +77,7 @@ export class MathWidget extends WidgetType {
|
||||
}
|
||||
|
||||
get estimatedHeight() {
|
||||
return this.math.split('\n').length * 40
|
||||
return this.cachedHeight ?? this.math.split('\n').length * 40
|
||||
}
|
||||
|
||||
coordsAt(element: HTMLElement) {
|
||||
@@ -111,5 +112,6 @@ export class MathWidget extends WidgetType {
|
||||
})
|
||||
element.replaceChildren(math)
|
||||
element.style.height = 'auto'
|
||||
this.cachedHeight = element.offsetHeight
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user