Преглед изворни кода

Add estimated height to some block widget decorations (#16485)

GitOrigin-RevId: f59da18228e038b1295ccc0128a33acd2de4f9f9
Alf Eaton пре 2 година
родитељ
комит
4bca3de8d2

+ 2 - 2
services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/end-document.ts

@@ -21,7 +21,7 @@ export class EndDocumentWidget extends WidgetType {
     return true
   }
 
-  updateDOM(): boolean {
-    return true
+  get estimatedHeight() {
+    return 30
   }
 }

+ 4 - 0
services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/preamble.ts

@@ -84,6 +84,10 @@ export class PreambleWidget extends WidgetType {
     return this.expanded === other.expanded
   }
 
+  get estimatedHeight() {
+    return this.expanded ? -1 : 54
+  }
+
   getToggleText(view: EditorView) {
     if (this.expanded) {
       return view.state.phrase(`hide_document_preamble`)

+ 4 - 0
services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/tabular.tsx

@@ -59,6 +59,10 @@ export class TabularWidget extends WidgetType {
     return true
   }
 
+  get estimatedHeight() {
+    return this.parsedTableData.table.rows.length * 50
+  }
+
   destroy(element: HTMLElement) {
     ReactDOM.unmountComponentAtNode(element)
   }