• 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

4.55
/packages/src/components/leaves/leaves.component.ts
1
import {
2
    AfterViewInit,
3
    ChangeDetectionStrategy,
4
    Component,
5
    Input,
6
    OnChanges,
7
    OnInit,
8
    QueryList,
9
    SimpleChanges,
10
    ViewChildren
11
} from '@angular/core';
12
import { Text } from 'slate';
13
import { SlateLeafContext, SlateTextContext, SlateViewContext } from '../../view/context';
14
import { ViewContainer } from '../../view/container';
15
import { SlateLeaf } from '../leaf/leaf.component';
16
import { isDecoratorRangeListEqual } from '../../utils/range-list';
17
import { NgFor } from '@angular/common';
18

19
@Component({
20
    selector: 'slate-leaves',
21
    template: `<slate-leaf
22
        [context]="context"
23
        [viewContext]="viewContext"
24
        *ngFor="let context of leafContexts; trackBy: trackBy"
25
    ></slate-leaf>`,
26
    changeDetection: ChangeDetectionStrategy.OnPush,
27
    standalone: true,
28
    imports: [NgFor, SlateLeaf]
29
})
30
export class SlateLeaves extends ViewContainer<SlateLeaf> implements OnInit, AfterViewInit, OnChanges {
1✔
UNCOV
31
    initialized = false;
×
32
    leafContexts: SlateLeafContext[];
33
    leaves: Text[];
34

35
    @Input() context: SlateTextContext;
36

37
    @ViewChildren(SlateLeaf, { read: SlateLeaf })
38
    childrenComponent: QueryList<SlateLeaf>;
39

40
    ngOnInit() {
UNCOV
41
        this.leaves = Text.decorations(this.context.text, this.context.decorations);
×
UNCOV
42
        this.leafContexts = this.getLeafContexts();
×
UNCOV
43
        this.initialized = true;
×
44
    }
45

46
    getLeafContexts() {
UNCOV
47
        return this.leaves.map((leaf, index) => {
×
UNCOV
48
            return {
×
49
                leaf,
50
                text: this.context.text,
51
                parent: this.context.parent,
52
                index,
53
                isLast: this.context.isLast && index === this.leaves.length - 1
×
54
            };
55
        });
56
    }
57

58
    ngOnChanges(simpleChanges: SimpleChanges) {
UNCOV
59
        if (!this.initialized) {
×
UNCOV
60
            return;
×
61
        }
UNCOV
62
        const context = simpleChanges['context'];
×
UNCOV
63
        const previousValue: SlateTextContext = context.previousValue;
×
UNCOV
64
        const currentValue: SlateTextContext = context.currentValue;
×
UNCOV
65
        if (previousValue.text !== currentValue.text || !isDecoratorRangeListEqual(previousValue.decorations, currentValue.decorations)) {
×
UNCOV
66
            this.leaves = Text.decorations(this.context.text, this.context.decorations);
×
67
        }
UNCOV
68
        this.leafContexts = this.getLeafContexts();
×
69
    }
70

71
    trackBy(index, item) {
UNCOV
72
        return index;
×
73
    }
74
}
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