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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 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

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

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

11
    public seekQuery(event: Event, mention: Mention): SeekQueryResult {
×
12
        const selectionStart = this.inputor.selectionStart;
×
13
        const value = this.inputor.value.replace(/[\r\n]/g, ' ');
×
14
        // @123 | @456 => 0(start) => @123
×
15
        // @123 @456 | => 5(start) => @456
×
16
        const start = value.lastIndexOf(mention.trigger, selectionStart);
×
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,
24
                end: end,
×
25
                term: termWithTrigger.substring(mention.trigger.length)
26
            };
27
        } else {
28
            return null;
×
29
        }
×
30
    }
31

×
32
    public insertMention(item: MentionDefaultDataItem): string {
×
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;
38
        const newValue = [
×
39
            value.slice(0, this.matchedMention.query.start),
×
40
            insertValue,
×
41
            value.slice(this.matchedMention.query.end, value.length)
42
        ].join('');
43
        this.inputor.value = newValue;
×
44
        this.focus(this.matchedMention.query.start + insertValue.length);
×
45
        return newValue;
46
    }
47

×
48
    private getInsertValue(item: MentionDefaultDataItem) {
49
        if (this.matchedMention.mention.insertTransform) {
50
            return this.matchedMention.mention.insertTransform(item).trim() + ' ';
51
        } else {
×
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