@platecms/delta-cast-util-from-slate 0.13.0 → 1.3.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.
Files changed (2) hide show
  1. package/package.json +9 -8
  2. package/src/lib/index.ts +19 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platecms/delta-cast-util-from-slate",
3
- "version": "0.13.0",
3
+ "version": "1.3.0",
4
4
  "description": "Utility to convert slate nodes to a CAST tree.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -17,20 +17,21 @@
17
17
  "src/**/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@platecms/delta-cast": "0.13.0",
21
- "@platecms/delta-castscript": "0.13.0",
22
- "@platecms/delta-client": "0.13.0",
23
- "@platecms/delta-plate-resource-notation": "0.13.0",
20
+ "@platecms/delta-cast": "1.3.0",
21
+ "@platecms/delta-castscript": "1.3.0",
22
+ "@platecms/delta-client": "1.3.0",
23
+ "@platecms/delta-plate-resource-notation": "1.3.0",
24
24
  "@graphql-typed-document-node/core": "3.2.0",
25
25
  "class-transformer": "0.5.1",
26
26
  "graphql": "16.11.0",
27
- "lodash": "4.17.21",
28
27
  "reflect-metadata": "0.2.2",
29
28
  "slate": "0.118.0",
30
- "slate-react": "0.117.4",
31
29
  "tslib": "2.8.1",
32
30
  "zwitch": "2.0.4",
33
31
  "@apollo/client": "3.13.9",
34
- "defu": "6.1.4"
32
+ "defu": "6.1.4",
33
+ "axios": "1.11.0",
34
+ "uuid": "11.1.0",
35
+ "@faker-js/faker": "9.9.0"
35
36
  }
36
37
  }
package/src/lib/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Content, InlineContent, ListItem, Root, Text } from "@platecms/delta-cast";
1
+ import { CastSuggestion, Content, InlineContent, ListItem, Root, Text } from "@platecms/delta-cast";
2
2
  import { Descendant } from "slate";
3
3
  import { wrapNode } from "./utils/wrapNode";
4
4
  import { zwitch } from "zwitch";
@@ -12,6 +12,7 @@ import {
12
12
  ListElement,
13
13
  ListItemElement,
14
14
  ParagraphElement,
15
+ Suggestion,
15
16
  } from "@platecms/delta-client/slate";
16
17
  import { compact } from "../schema/lib/utils";
17
18
  export function fromSlate(value: Descendant[]): Root {
@@ -24,7 +25,7 @@ export function fromSlate(value: Descendant[]): Root {
24
25
 
25
26
  const handleNode = zwitch("type", {
26
27
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
27
- handlers: { paragraph, heading, list, listItem, blockquote, code, contentValue, link },
28
+ handlers: { paragraph, heading, list, listItem, blockquote, code, contentValue, link, suggestion },
28
29
  });
29
30
 
30
31
  function all(nodes: Descendant[], state: object = {}): Content[] {
@@ -127,6 +128,22 @@ function contentValue(node: ContentValueElement): Content {
127
128
  };
128
129
  }
129
130
 
131
+ function suggestion(node: Suggestion): CastSuggestion {
132
+ return {
133
+ type: "castSuggestion",
134
+ original: node.original,
135
+ suggested: {
136
+ prn: node.suggested.prn,
137
+ type: "contentValue",
138
+ value: node.suggested.root,
139
+ },
140
+ message: node.message,
141
+ method: node.method,
142
+ startIndex: node.startIndex,
143
+ endIndex: node.endIndex,
144
+ };
145
+ }
146
+
130
147
  function extractText(nodes: DeltaLeaf[]): Text[] {
131
148
  return compact(
132
149
  nodes.map((node) => {