@platecms/delta-cast-util-to-plaintext 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platecms/delta-cast-util-to-plaintext",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Utility to convert CAST trees to plaintext.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -17,8 +17,8 @@
17
17
  "src/**/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@platecms/delta-cast": "1.2.0",
21
- "@platecms/delta-plate-resource-notation": "1.2.0",
20
+ "@platecms/delta-cast": "1.4.0",
21
+ "@platecms/delta-plate-resource-notation": "1.4.0",
22
22
  "class-transformer": "0.5.1",
23
23
  "reflect-metadata": "0.2.2",
24
24
  "tslib": "2.8.1",
@@ -106,22 +106,6 @@ describe("single nodes", () => {
106
106
  // Assert
107
107
  expect(expected).toEqual("Google");
108
108
  });
109
-
110
- it("should convert a content value suggestion from cast to plaintext", () => {
111
- // Arrange
112
- const cast: Root = c("root", [
113
- c("contentValueSuggestion", {
114
- prn: "prn:content-value:content-value",
115
- value: c("root", [c("paragraph", "Hello, world!")]),
116
- }),
117
- ]);
118
-
119
- // Act
120
- const expected = toPlaintext(cast);
121
-
122
- // Assert
123
- expect(expected).toEqual("Hello, world!");
124
- });
125
109
  });
126
110
 
127
111
  describe("nested nodes", () => {
package/src/lib/index.ts CHANGED
@@ -2,9 +2,9 @@ import {
2
2
  Blockquote,
3
3
  Bold,
4
4
  Root as CastRoot,
5
+ CastSuggestion,
5
6
  Code,
6
7
  Content,
7
- ContentValueSuggestion,
8
8
  ExternalLink,
9
9
  Heading,
10
10
  InternalLink,
@@ -45,8 +45,6 @@ const one = zwitch("type", {
45
45
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
46
46
  contentValue,
47
47
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
48
- contentValueSuggestion,
49
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
50
48
  bold,
51
49
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
52
50
  italic,
@@ -62,6 +60,8 @@ const one = zwitch("type", {
62
60
  internalLink: link,
63
61
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
64
62
  internalAnchorLink: link,
63
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
64
+ castSuggestion,
65
65
  },
66
66
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
67
67
  unknown: (value: unknown, _: object = {}) => defaultHandler(value as Content),
@@ -99,10 +99,6 @@ function contentValue(node: InterpolatedContentValue): string {
99
99
  return node.value ? toPlaintext(node.value) : "";
100
100
  }
101
101
 
102
- function contentValueSuggestion(node: ContentValueSuggestion): string {
103
- return node.value ? toPlaintext(node.value) : "";
104
- }
105
-
106
102
  function paragraph(node: Paragraph, state: object = {}): string {
107
103
  return all(node.children, state).join(separator);
108
104
  }
@@ -135,6 +131,10 @@ function link(node: ExternalLink | InternalLink): string {
135
131
  return all(node.children).join(separator);
136
132
  }
137
133
 
134
+ function castSuggestion(node: CastSuggestion): string {
135
+ return toPlaintext(node.original);
136
+ }
137
+
138
138
  function defaultHandler(node: Content): string {
139
139
  return `Unknown node type (${node.type})`;
140
140
  }