• 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

88.46
/src/syntax-extensions/ImageReferenceExtension.ts
1
import type { ImageReference } from "mdast";
2
import type { Node as ProseMirrorNode, Schema } from "prosemirror-model";
3

4
import { type Extension, NodeExtension } from "prosemirror-unified";
6✔
5

6
import {
6✔
7
  DefinitionExtension,
8
  type DefinitionExtensionContext,
9
} from "./DefinitionExtension";
10
import { ImageExtension } from "./ImageExtension";
6✔
11

12
/**
13
 * @public
14
 */
15
export interface ImageReferenceExtensionContext {
16
  proseMirrorNodes: Record<string, ProseMirrorNode>;
17
}
18

19
/**
20
 * @public
21
 */
22
export class ImageReferenceExtension extends NodeExtension<ImageReference> {
6✔
23
  public override dependencies(): Array<Extension> {
24
    return [new DefinitionExtension(), new ImageExtension()];
10✔
25
  }
26

27
  public override postUnistToProseMirrorHook(
28
    context: Partial<{
29
      DefinitionExtension: DefinitionExtensionContext;
30
      ImageReferenceExtension: ImageReferenceExtensionContext;
31
    }>,
32
  ): void {
33
    if (
14✔
34
      context.ImageReferenceExtension === undefined ||
14✔
35
      context.DefinitionExtension === undefined
36
    ) {
37
      return;
2✔
38
    }
39
    for (const id in context.ImageReferenceExtension.proseMirrorNodes) {
12✔
40
      if (!(id in context.DefinitionExtension.definitions)) {
12!
NEW
41
        continue;
×
42
      }
43
      const definition = context.DefinitionExtension.definitions[id];
12✔
44
      const attrs = context.ImageReferenceExtension.proseMirrorNodes[id]
12✔
45
        .attrs as Record<
46
        string,
47
        // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Attrs can be any
48
        any
49
      >;
50
      attrs.src = definition.url;
12✔
51
      if (definition.title !== undefined) {
12✔
52
        attrs.title = definition.title;
6✔
53
      }
54
    }
55
  }
56

57
  public override proseMirrorNodeName(): null {
58
    return null;
176✔
59
  }
60

61
  public override proseMirrorNodeSpec(): null {
62
    return null;
10✔
63
  }
64

65
  public override proseMirrorNodeToUnistNodes(): Array<ImageReference> {
NEW
66
    return [];
×
67
  }
68

69
  public override unistNodeName(): "imageReference" {
70
    return "imageReference";
70✔
71
  }
72

73
  public override unistNodeToProseMirrorNodes(
74
    node: ImageReference,
75
    proseMirrorSchema: Schema<string, string>,
76
    convertedChildren: Array<ProseMirrorNode>,
77
    context: Partial<{
78
      ImageReferenceExtension: ImageReferenceExtensionContext;
79
    }>,
80
  ): Array<ProseMirrorNode> {
81
    const proseMirrorNode = proseMirrorSchema.nodes.image.createAndFill(
14✔
82
      { alt: node.alt, src: "", title: node.label },
83
      convertedChildren,
84
    );
85
    if (proseMirrorNode === null) {
14!
86
      return [];
×
87
    }
88
    if (context.ImageReferenceExtension === undefined) {
14✔
89
      context.ImageReferenceExtension = { proseMirrorNodes: {} };
14✔
90
    }
91
    context.ImageReferenceExtension.proseMirrorNodes[node.identifier] =
14✔
92
      proseMirrorNode;
93
    return [proseMirrorNode];
14✔
94
  }
95
}
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