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

worktile / slate-angular / 6659122c-e261-4b71-8a4c-31a76811ea45

pending completion
6659122c-e261-4b71-8a4c-31a76811ea45

Pull #226

circleci

pubuzhixing8
chore(core): update note
Pull Request #226: Android input handing

268 of 892 branches covered (30.04%)

Branch coverage included in aggregate %.

46 of 46 new or added lines in 2 files covered. (100.0%)

682 of 1526 relevant lines covered (44.69%)

29.63 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