• 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/editable.adapter.ts
1
import { MentionAdapter, MentionInputorElement, SeekQueryResult } from './adapter';
2
import { Mention, MentionDefaultDataItem } from '../interfaces';
3

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

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

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

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

×
45
    private getInsertValue(item: MentionDefaultDataItem) {
46
        if (this.matchedMention.mention.insertTransform) {
47
            return this.matchedMention.mention.insertTransform(item).trim() + ' ';
48
        } else {
49
            return `${this.matchedMention.mention.trigger}${item['name']}`.trim() + ' ';
50
        }
51
    }
52
}
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