Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/src/components/editable/editable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { TRIPLE_CLICK, EDITOR_TO_ON_CHANGE } from 'slate-dom';
import { BaseElementComponent } from '../../view/base';
import { BaseElementFlavour } from '../../view/flavour/element';
import { SlateVirtualScrollConfig, VirtualViewResult } from '../../types';
import { getBlockCardByNativeElement } from '../block-card/block-card';

export const JUST_NOW_UPDATED_VIRTUAL_VIEW = new WeakMap<AngularEditor, boolean>();

Expand Down Expand Up @@ -159,6 +160,7 @@ export class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewChe
if (this.listRender.initialized) {
this.listRender.update(virtualView.renderedChildren, this.editor, this.context);
}
this.updateBlockCardMinheight(virtualView);
this.scheduleMeasureVisibleHeights();
});
}
Expand Down Expand Up @@ -672,6 +674,20 @@ export class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewChe
};
}

private updateBlockCardMinheight(virtualView: VirtualViewResult) {
const children = (this.editor.children || []) as Element[];
virtualView.visibleIndexes.forEach(index => {
const node = children[index];
const view = ELEMENT_TO_COMPONENT.get(node);
const block = getBlockCardByNativeElement(
(view as BaseElementComponent | BaseElementFlavour).viewContainerRef.element.nativeElement
);
if (block) {
block.style.minHeight = virtualView.heights[index] + 'px';
}
});
}

private applyVirtualView(virtualView: VirtualViewResult) {
this.renderedChildren = virtualView.renderedChildren;
this.changeVirtualHeight(virtualView.top, virtualView.bottom);
Expand Down Expand Up @@ -845,7 +861,7 @@ export class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewChe
if (!view) {
return;
}
const prevHeight = this.measuredHeights.get(key.id);
const prevHeight = this.measuredHeights.get(key.id) ?? VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT;
const ret = (view as BaseElementComponent | BaseElementFlavour).getRealHeight();
if (ret instanceof Promise) {
ret.then(height => {
Expand Down