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

marekdedic / prosemirror-remark / 14286065237

05 Apr 2025 09:44PM UTC coverage: 86.92% (+5.3%) from 81.604%
14286065237

push

github

web-flow
Merge pull request #509 from marekdedic/vitest

Switched to vitest

197 of 211 branches covered (93.36%)

1442 of 1659 relevant lines covered (86.92%)

9.65 hits per line

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

78.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";
1✔
11
import { createProseMirrorNode, NodeExtension } from "prosemirror-unified";
1✔
12

13
/**
14
 * @public
15
 */
16
export class BreakExtension extends NodeExtension<Break> {
1✔
17
  public override proseMirrorKeymap(
1✔
18
    proseMirrorSchema: Schema<string, string>,
5✔
19
  ): Record<string, Command> {
5✔
20
    const command = chainCommands(exitCode, (state, dispatch) => {
5✔
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
    });
5✔
32

33
    const isMac =
5✔
34
      typeof navigator !== "undefined"
5✔
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
5!
36
        : false;
×
37

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

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

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

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

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

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