• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

worktile / slate-angular / ee7b5bb9-0ba9-4db2-a261-36a9f068c827

23 Dec 2025 02:29AM UTC coverage: 36.605% (-0.3%) from 36.904%
ee7b5bb9-0ba9-4db2-a261-36a9f068c827

Pull #329

circleci

pubuzhixing8
fix: list-render error
Pull Request #329: Pre rendering

382 of 1253 branches covered (30.49%)

Branch coverage included in aggregate %.

4 of 55 new or added lines in 2 files covered. (7.27%)

364 existing lines in 3 files now uncovered.

1080 of 2741 relevant lines covered (39.4%)

23.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

13.73
/packages/src/utils/virtual-scroll.ts
1
import { Element } from 'slate';
2
import { AngularEditor } from '../plugins/angular-editor';
3
import { VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT } from './environment';
4

5
export const ELEMENT_KEY_TO_HEIGHTS = new WeakMap<AngularEditor, Map<string, number>>();
1✔
6

7
export const EDITOR_TO_BUSINESS_TOP = new WeakMap<AngularEditor, number>();
1✔
8
export const EDITOR_TO_WIDTH = new WeakMap<AngularEditor, number>();
1✔
9

10
export const getBusinessTop = (editor: AngularEditor) => {
1✔
UNCOV
11
    return EDITOR_TO_BUSINESS_TOP.get(editor) ?? 0;
×
12
};
13

14
export const getRealHeightByElement = (
1✔
15
    editor: AngularEditor,
16
    element: Element,
17
    defaultHeight: number = VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT
×
18
) => {
19
    const isVisible = editor.isVisible(element);
×
20
    if (!isVisible) {
×
UNCOV
21
        return 0;
×
22
    }
23
    if (!element) {
×
UNCOV
24
        return defaultHeight;
×
25
    }
26
    const heights = ELEMENT_KEY_TO_HEIGHTS.get(editor);
×
27
    const key = AngularEditor.findKey(editor, element);
×
28
    const height = heights?.get(key.id);
×
29
    if (typeof height === 'number') {
×
UNCOV
30
        return height;
×
31
    }
32
    if (heights?.has(key.id)) {
×
UNCOV
33
        console.error('getBlockHeight: invalid height value', key.id, height);
×
34
    }
UNCOV
35
    return defaultHeight;
×
36
};
37

38
export const buildHeightsAndAccumulatedHeights = (editor: AngularEditor) => {
1✔
39
    const children = (editor.children || []) as Element[];
×
40
    const heights = new Array(children.length);
×
41
    const accumulatedHeights = new Array(children.length + 1);
×
42
    accumulatedHeights[0] = 0;
×
43
    for (let i = 0; i < children.length; i++) {
×
44
        const height = getRealHeightByElement(editor, children[i]);
×
45
        heights[i] = height;
×
UNCOV
46
        accumulatedHeights[i + 1] = accumulatedHeights[i] + height;
×
47
    }
UNCOV
48
    return { heights, accumulatedHeights };
×
49
};
50

51
export const scrollToElement = (editor: AngularEditor, element: Element, scrollTo: (scrollTop: number) => void) => {
1✔
52
    const children = editor.children;
×
53
    if (!children.length) {
×
UNCOV
54
        return;
×
55
    }
56
    const anchorIndex = children.findIndex(item => item === element);
×
57
    if (anchorIndex < 0) {
×
UNCOV
58
        return;
×
59
    }
60

61
    const { accumulatedHeights } = buildHeightsAndAccumulatedHeights(editor);
×
UNCOV
62
    scrollTo((accumulatedHeights[anchorIndex] ?? 0) + getBusinessTop(editor));
×
63
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc