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

marekdedic / prosemirror-remark / 10672399463

02 Sep 2024 07:53PM UTC coverage: 82.311%. Remained the same
10672399463

push

github

web-flow
Merge pull request #363 from marekdedic/eslint-v9

Updated eslint to v9

65 of 115 branches covered (56.52%)

128 of 154 new or added lines in 22 files covered. (83.12%)

1 existing line in 1 file now uncovered.

349 of 424 relevant lines covered (82.31%)

26.65 hits per line

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

73.33
/src/syntax-extensions/BreakExtension.ts
1
import type { Break } from "mdast";
2
import type {
3
  DOMOutputSpec,
4
  NodeSpec,
5
  Node as ProseMirrorNode,
6
  Schema,
7
} from "prosemirror-model";
8
import type { Command } from "prosemirror-state";
9

10
import { chainCommands, exitCode } from "prosemirror-commands";
6✔
11
import { createProseMirrorNode, NodeExtension } from "prosemirror-unified";
6✔
12

13
/**
14
 * @public
15
 */
16
export class BreakExtension extends NodeExtension<Break> {
6✔
17
  public override proseMirrorKeymap(
18
    proseMirrorSchema: Schema<string, string>,
19
  ): Record<string, Command> {
20
    const command = chainCommands(exitCode, (state, dispatch) => {
10✔
21
      if (dispatch) {
×
22
        dispatch(
×
23
          state.tr
24
            .replaceSelectionWith(
25
              proseMirrorSchema.nodes[this.proseMirrorNodeName()].create(),
26
            )
27
            .scrollIntoView(),
28
        );
29
      }
30
      return true;
×
31
    });
32

33
    const isMac =
34
      typeof navigator !== "undefined"
10!
35
        ? /Mac|iP(hone|[oa]d)/u.test(navigator.platform) // eslint-disable-line @typescript-eslint/no-deprecated -- In the tested systems, it will be defined
36
        : false;
37

38
    return {
10✔
39
      "Mod-Enter": command,
40
      "Shift-Enter": command,
41
      ...(isMac && { "Ctrl-Enter": command }),
5!
42
    };
43
  }
44

45
  public override proseMirrorNodeName(): string {
46
    return "hard_break";
186✔
47
  }
48

49
  public override proseMirrorNodeSpec(): NodeSpec {
50
    return {
10✔
51
      group: "inline",
52
      inline: true,
53
      parseDOM: [{ tag: "br" }],
54
      selectable: false,
55
      toDOM(): DOMOutputSpec {
NEW
56
        return ["br"];
×
57
      },
58
    };
59
  }
60

61
  public override proseMirrorNodeToUnistNodes(): Array<Break> {
62
    return [{ type: this.unistNodeName() }];
6✔
63
  }
64

65
  public override unistNodeName(): "break" {
66
    return "break";
168✔
67
  }
68

69
  public override unistNodeToProseMirrorNodes(
70
    _node: Break,
71
    proseMirrorSchema: Schema<string, string>,
72
    convertedChildren: Array<ProseMirrorNode>,
73
  ): Array<ProseMirrorNode> {
74
    return createProseMirrorNode(
6✔
75
      this.proseMirrorNodeName(),
76
      proseMirrorSchema,
77
      convertedChildren,
78
    );
79
  }
80
}
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

© 2026 Coveralls, Inc