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

worktile / slate-angular / c3b70b25-6ca6-4aa8-8c87-7d255610ab6b

03 Nov 2023 06:45AM UTC coverage: 44.222% (-1.9%) from 46.148%
c3b70b25-6ca6-4aa8-8c87-7d255610ab6b

Pull #241

circleci

pubuzhixing8
feat: xxx
Pull Request #241: View loop manager

380 of 1042 branches covered (0.0%)

Branch coverage included in aggregate %.

244 of 330 new or added lines in 7 files covered. (73.94%)

111 existing lines in 6 files now uncovered.

925 of 1909 relevant lines covered (48.45%)

38.02 hits per line

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

9.09
/packages/src/utils/lines.ts
1
/**
2
 * Utilities for single-line deletion
3
 */
4

5
import { Range, Editor } from 'slate';
6
import { AngularEditor } from '../plugins/angular-editor';
7

8
const doRectsIntersect = (rect: DOMRect, compareRect: DOMRect) => {
1✔
9
    const middle = (compareRect.top + compareRect.bottom) / 2;
×
10

11
    return rect.top <= middle && rect.bottom >= middle;
×
12
};
13

14
const areRangesSameLine = (editor: AngularEditor, range1: Range, range2: Range) => {
1✔
15
    const rect1 = AngularEditor.toDOMRange(editor, range1).getBoundingClientRect();
×
16
    const rect2 = AngularEditor.toDOMRange(editor, range2).getBoundingClientRect();
×
17

18
    return doRectsIntersect(rect1, rect2) && doRectsIntersect(rect2, rect1);
×
19
};
20

21
/**
22
 * A helper utility that returns the end portion of a `Range`
23
 * which is located on a single line.
24
 *
25
 * @param {Editor} editor The editor object to compare against
26
 * @param {Range} parentRange The parent range to compare against
27
 * @returns {Range} A valid portion of the parentRange which is one a single line
28
 */
29
export const findCurrentLineRange = (editor: AngularEditor, parentRange: Range): Range => {
1✔
30
    const parentRangeBoundary = Editor.range(editor, Range.end(parentRange));
×
31
    const positions = Array.from(Editor.positions(editor, { at: parentRange }));
×
32

33
    let left = 0;
×
34
    let right = positions.length;
×
35
    let middle = Math.floor(right / 2);
×
36

37
    if (areRangesSameLine(editor, Editor.range(editor, positions[left]), parentRangeBoundary)) {
×
38
        return Editor.range(editor, positions[left], parentRangeBoundary);
×
39
    }
40

41
    if (positions.length < 2) {
×
42
        return Editor.range(editor, positions[positions.length - 1], parentRangeBoundary);
×
43
    }
44

45
    while (middle !== positions.length && middle !== left) {
×
46
        if (areRangesSameLine(editor, Editor.range(editor, positions[middle]), parentRangeBoundary)) {
×
47
            right = middle;
×
48
        } else {
49
            left = middle;
×
50
        }
51

52
        middle = Math.floor((left + right) / 2);
×
53
    }
54

55
    return Editor.range(editor, positions[right], parentRangeBoundary);
×
56
};
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

© 2025 Coveralls, Inc