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

worktile / slate-angular / 2241d398-cf7c-4f79-b1b3-923ba1e05d17

11 Jul 2025 07:46AM UTC coverage: 48.44%. Remained the same
2241d398-cf7c-4f79-b1b3-923ba1e05d17

push

circleci

pubuzhixing8
build: release 19.1.0-next.3

364 of 925 branches covered (39.35%)

Branch coverage included in aggregate %.

940 of 1767 relevant lines covered (53.2%)

44.6 hits per line

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

16.67
/packages/src/utils/dom.ts
1
import { DOMNode, DOMText, isDOMElement, isDOMNode } from 'slate-dom';
2

3
export const SlateFragmentAttributeKey = 'data-slate-angular-fragment';
1✔
4

5
/**
6
 * Get x-slate-fragment attribute from data-slate-angular-fragment
7
 */
8
const catchSlateFragment = /data-slate-angular-fragment="(.+?)"/m;
1✔
9
export const getSlateFragmentAttribute = (htmlData: string): string | void => {
1✔
10
    const [, fragment] = htmlData.match(catchSlateFragment) || [];
×
11
    return fragment;
×
12
};
13

14
/**
15
 * Check if a DOM node is an element node.
16
 */
17
export const isDOMText = (value: any): value is DOMText => {
1✔
18
    return isDOMNode(value) && value.nodeType === 3;
×
19
};
20

21
/**
22
 * Get a plaintext representation of the content of a node, accounting for block
23
 * elements which get a newline appended.
24
 *
25
 * The domNode must be attached to the DOM.
26
 */
27
export const getPlainText = (domNode: DOMNode) => {
1✔
28
    let text = '';
×
29

30
    if (isDOMText(domNode) && domNode.nodeValue) {
×
31
        return domNode.nodeValue;
×
32
    }
33

34
    if (isDOMElement(domNode)) {
×
35
        for (const childNode of Array.from(domNode.childNodes)) {
×
36
            text += getPlainText(childNode);
×
37
        }
38

39
        const display = getComputedStyle(domNode).getPropertyValue('display');
×
40

41
        if (display === 'block' || display === 'list' || domNode.tagName === 'BR') {
×
42
            text += '\n';
×
43
        }
44
    }
45

46
    return text;
×
47
};
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