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

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

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

0.0
/src/mention/adapter/textarea.adapter.ts
1
import { MentionAdapter, MentionInputorElement, SeekQueryResult } from './adapter';
2
import { Mention, MentionDefaultDataItem } from '../interfaces';
3

UNCOV
4
export class TextareaMentionAdapter extends MentionAdapter {
×
5
    inputor: MentionInputorElement;
6

UNCOV
7
    constructor(inputor: MentionInputorElement) {
×
UNCOV
8
        super(inputor);
×
9
    }
10

UNCOV
11
    public seekQuery(event: Event, mention: Mention): SeekQueryResult {
×
UNCOV
12
        const selectionStart = this.inputor.selectionStart;
×
UNCOV
13
        const value = this.inputor.value.replace(/[\r\n]/g, ' ');
×
UNCOV
14
        // @123 | @456 => 0(start) => @123
×
UNCOV
15
        // @123 @456 | => 5(start) => @456
×
UNCOV
16
        const start = value.lastIndexOf(mention.trigger, selectionStart);
×
UNCOV
17
        const fistSpaceIndexFromStart = value.indexOf(' ', selectionStart);
×
18
        const end = fistSpaceIndexFromStart > -1 ? fistSpaceIndexFromStart : value.length;
19
        const termWithTrigger = value.substring(start, end);
20
        const startBeforeHasSpace = start > 0 && value[start - 1] === ' ';
21
        if ((startBeforeHasSpace || start === 0) && !termWithTrigger.includes(' ') && !termWithTrigger.includes(mention.trigger, 1)) {
22
            return {
23
                start: start,
UNCOV
24
                end: end,
×
25
                term: termWithTrigger.substring(mention.trigger.length)
26
            };
27
        } else {
UNCOV
28
            return null;
×
29
        }
×
30
    }
UNCOV
31

×
UNCOV
32
    public insertMention(item: MentionDefaultDataItem): string {
×
UNCOV
33
        if ((typeof ngDevMode === 'undefined' || ngDevMode) && !this.matchedMention) {
×
34
            throw new Error(`matchedMention is null`);
35
        }
36
        const insertValue = this.getInsertValue(item);
37
        const value: string = this.inputor.value;
UNCOV
38
        const newValue = [
×
UNCOV
39
            value.slice(0, this.matchedMention.query.start),
×
UNCOV
40
            insertValue,
×
41
            value.slice(this.matchedMention.query.end, value.length)
42
        ].join('');
UNCOV
43
        this.inputor.value = newValue;
×
44
        this.focus(this.matchedMention.query.start + insertValue.length);
×
45
        return newValue;
46
    }
UNCOV
47

×
48
    private getInsertValue(item: MentionDefaultDataItem) {
49
        if (this.matchedMention.mention.insertTransform) {
50
            return this.matchedMention.mention.insertTransform(item).trim() + ' ';
UNCOV
51
        } else {
×
UNCOV
52
            return `${this.matchedMention.mention.trigger}${item['name']}`.trim() + ' ';
×
53
        }
54
    }
55

×
56
    private focus(caretPosition?: number): void {
57
        this.inputor.focus();
58
        this.inputor.setSelectionRange(caretPosition, caretPosition);
59
    }
60

61
    private isEditable() {
62
        return !this.inputor.readOnly && !this.inputor.disabled;
63
    }
64
}
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