@platecms/delta-cast 1.15.3 → 1.16.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/README.md +295 -25
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,48 +10,318 @@ that adheres to the [**Unified collective**](https://github.com/unifiedjs/unifie
|
|
|
10
10
|
The schema is defined in [schema.ts](src/lib/schemas/schema.ts), and is rendered into JSON Schema format
|
|
11
11
|
in [schema.json](src/lib/schemas/schema.json).
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Node types
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
CAST nodes follow the unist tree model. Each document has a single `root`. Block nodes make up the document structure.
|
|
16
|
+
Inline nodes appear inside block (and some inline) parents.
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
- `validateCast`: Validates any input against the schema. Throws `InvalidCastError` if the input is invalid.
|
|
18
|
+
### Root
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
#### `root`
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
The root of a CAST document. Every document has exactly one root. Children may be any `Content` (block content, inline
|
|
23
|
+
content, or `castSuggestion`).
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"type": "root",
|
|
28
|
+
"children": [
|
|
29
|
+
{
|
|
30
|
+
"type": "paragraph",
|
|
31
|
+
"children": [{ "type": "text", "value": "Hello world" }]
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Block content
|
|
38
|
+
|
|
39
|
+
#### `paragraph`
|
|
40
|
+
|
|
41
|
+
A paragraph of inline content.
|
|
42
|
+
|
|
43
|
+
- **`children`**: `InlineContent[]`
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"type": "paragraph",
|
|
48
|
+
"children": [{ "type": "text", "value": "Hello, world!" }]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
#### `heading`
|
|
26
53
|
|
|
27
|
-
|
|
28
|
-
them in the editor.
|
|
54
|
+
A heading.
|
|
29
55
|
|
|
30
|
-
|
|
56
|
+
- **`level`**: `1 | 2 | 3 | 4 | 5 | 6`
|
|
57
|
+
- **`children`**: `InlineContent[]`
|
|
31
58
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"type": "heading",
|
|
62
|
+
"level": 1,
|
|
63
|
+
"children": [{ "type": "text", "value": "Heading" }]
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### `list`
|
|
68
|
+
|
|
69
|
+
An ordered or unordered list. Children must be `listItem` nodes only.
|
|
35
70
|
|
|
36
|
-
|
|
71
|
+
- **`ordered`**: whether the list is ordered
|
|
72
|
+
- **`start`**: optional start number for an ordered list
|
|
73
|
+
- **`children`**: `ListItem[]`
|
|
37
74
|
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
type:
|
|
41
|
-
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"type": "list",
|
|
78
|
+
"ordered": true,
|
|
79
|
+
"start": 1,
|
|
80
|
+
"children": [
|
|
42
81
|
{
|
|
43
|
-
type:
|
|
44
|
-
children: [
|
|
45
|
-
{ type: 'text', value: 'Hello, world!' }
|
|
46
|
-
]
|
|
82
|
+
"type": "listItem",
|
|
83
|
+
"children": [{ "type": "text", "value": "Item" }]
|
|
47
84
|
}
|
|
48
85
|
]
|
|
49
86
|
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### `listItem`
|
|
90
|
+
|
|
91
|
+
A single item in a list. Only used as a child of `list`.
|
|
92
|
+
|
|
93
|
+
- **`children`**: `InlineContent[]`
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"type": "listItem",
|
|
98
|
+
"children": [{ "type": "text", "value": "Item" }]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### `blockquote`
|
|
103
|
+
|
|
104
|
+
A block quotation of inline content.
|
|
105
|
+
|
|
106
|
+
- **`children`**: `InlineContent[]`
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"type": "blockquote",
|
|
111
|
+
"children": [{ "type": "text", "value": "Blockquote text" }]
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### `code`
|
|
116
|
+
|
|
117
|
+
A code block. Children must be `text` nodes.
|
|
118
|
+
|
|
119
|
+
- **`lang`**: optional language of the code block
|
|
120
|
+
- **`children`**: `Text[]`
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"type": "code",
|
|
125
|
+
"lang": "javascript",
|
|
126
|
+
"children": [{ "type": "text", "value": "console.log('Hello, world!');" }]
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Inline content
|
|
131
|
+
|
|
132
|
+
#### `text`
|
|
133
|
+
|
|
134
|
+
A text literal.
|
|
135
|
+
|
|
136
|
+
- **`value`**: string
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"type": "text",
|
|
141
|
+
"value": "Hello, world!"
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### `bold`
|
|
146
|
+
|
|
147
|
+
Bold formatting. Children are inline content.
|
|
148
|
+
|
|
149
|
+
- **`children`**: `InlineContent[]`
|
|
50
150
|
|
|
51
|
-
|
|
52
|
-
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"type": "bold",
|
|
154
|
+
"children": [{ "type": "text", "value": "Bold text" }]
|
|
155
|
+
}
|
|
53
156
|
```
|
|
54
157
|
|
|
158
|
+
#### `italic`
|
|
159
|
+
|
|
160
|
+
Italic formatting. Children are inline content.
|
|
161
|
+
|
|
162
|
+
- **`children`**: `InlineContent[]`
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"type": "italic",
|
|
167
|
+
"children": [{ "type": "text", "value": "Italic text" }]
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### `underline`
|
|
172
|
+
|
|
173
|
+
Underline formatting. Children are inline content.
|
|
174
|
+
|
|
175
|
+
- **`children`**: `InlineContent[]`
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"type": "underline",
|
|
180
|
+
"children": [{ "type": "text", "value": "Underline text" }]
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### `strikethrough`
|
|
185
|
+
|
|
186
|
+
Strikethrough formatting. Children are inline content.
|
|
187
|
+
|
|
188
|
+
- **`children`**: `InlineContent[]`
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"type": "strikethrough",
|
|
193
|
+
"children": [{ "type": "text", "value": "Strikethrough text" }]
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
#### `highlight`
|
|
198
|
+
|
|
199
|
+
Highlight formatting. Children are inline content.
|
|
200
|
+
|
|
201
|
+
- **`children`**: `InlineContent[]`
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"type": "highlight",
|
|
206
|
+
"children": [{ "type": "text", "value": "Highlight text" }]
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
#### `inlineCode`
|
|
211
|
+
|
|
212
|
+
An inline code literal.
|
|
213
|
+
|
|
214
|
+
- **`value`**: string
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"type": "inlineCode",
|
|
219
|
+
"value": "code"
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### `contentValue`
|
|
224
|
+
|
|
225
|
+
An interpolated Content Value. The referenced value is stored elsewhere and inserted into the document at request-time.
|
|
226
|
+
Nested CAST trees on `value` are not normalized.
|
|
227
|
+
|
|
228
|
+
- **`prn`**: PRN of the referenced Content Value
|
|
229
|
+
- **`value`**: optional nested CAST tree (`root`) of the referenced Content Value.
|
|
230
|
+
|
|
231
|
+
**CAST example**
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"type": "contentValue",
|
|
235
|
+
"prn": "prn:plate-dev:1234:cms:test:abcd",
|
|
236
|
+
"value": {
|
|
237
|
+
"type": "root",
|
|
238
|
+
"children": [
|
|
239
|
+
{
|
|
240
|
+
"type": "paragraph",
|
|
241
|
+
"children": [{ "type": "text", "value": "Resolved value" }]
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Create input**
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"type": "contentValue",
|
|
252
|
+
"prn": "prn:plate-dev:1234:cms:test:abcd",
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### `externalLink`
|
|
257
|
+
|
|
258
|
+
A link to an external URL. Children must be `text` nodes.
|
|
259
|
+
|
|
260
|
+
- **`url`**: URL of the link
|
|
261
|
+
- **`target`**: optional `"_parent" | "_top" | "blank" | "self"`
|
|
262
|
+
- **`children`**: `Text[]`
|
|
263
|
+
|
|
264
|
+
```json
|
|
265
|
+
{
|
|
266
|
+
"type": "externalLink",
|
|
267
|
+
"url": "https://www.google.com",
|
|
268
|
+
"target": "blank",
|
|
269
|
+
"children": [{ "type": "text", "value": "External link" }]
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### `internalLink`
|
|
274
|
+
|
|
275
|
+
A link to a Path Part or Grid Placement. Children must be `text` nodes. `url` is always defined when retrieving an
|
|
276
|
+
internal link, but is not required when saving one.
|
|
277
|
+
|
|
278
|
+
- **`prn`**: PRN of the referenced Path Part or Grid Placement
|
|
279
|
+
- **`url`**: optional URL (channel and path part, optionally with a grid placement reference such as `#anchor-name`)
|
|
280
|
+
- **`target`**: optional `"_parent" | "_top" | "blank" | "self"`
|
|
281
|
+
- **`children`**: `Text[]`
|
|
282
|
+
|
|
283
|
+
**CAST example**
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"type": "internalLink",
|
|
287
|
+
"prn": "prn:plate-dev:1234:cms:test:abcd",
|
|
288
|
+
"url": "https://www.example.test",
|
|
289
|
+
"target": "self",
|
|
290
|
+
"children": [{ "type": "text", "value": "Internal link" }]
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"type": "internalLink",
|
|
297
|
+
"prn": "prn:plate-dev:1234:cms:test:abcd#grid-placement",
|
|
298
|
+
"url": "https://www.example.test",
|
|
299
|
+
"target": "self",
|
|
300
|
+
"children": [{ "type": "text", "value": "Internal link" }]
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Create input**
|
|
305
|
+
URL is ommitted here as it generated by the system to keep it up to date.
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"type": "internalLink",
|
|
309
|
+
"prn": "prn:plate-dev:1234:cms:test:abcd",
|
|
310
|
+
"target": "self",
|
|
311
|
+
"children": [{ "type": "text", "value": "Internal link" }]
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
# Utilities
|
|
316
|
+
|
|
317
|
+
Related packages for converting, rendering, and authoring CAST trees:
|
|
318
|
+
|
|
319
|
+
- [cast-util-from-slate](../cast-util-from-slate/README.md) — convert Slate editor documents to CAST
|
|
320
|
+
- [cast-util-to-slate](../cast-util-to-slate/README.md) — convert CAST trees to Slate editor documents
|
|
321
|
+
- [cast-util-to-hast](../cast-util-to-hast/README.md) — convert CAST trees to HAST
|
|
322
|
+
- [cast-util-to-html](../cast-util-to-html/README.md) — convert CAST trees to sanitized HTML (via HAST)
|
|
323
|
+
- [cast-util-to-plaintext](../cast-util-to-plaintext/README.md) — convert CAST trees to plaintext
|
|
324
|
+
- [castscript](../castscript/README.md) — scriptable helper for building CAST trees
|
|
55
325
|
|
|
56
326
|
# Normalization
|
|
57
327
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platecms/delta-cast",
|
|
3
3
|
"description": "Package containing the definition of CAST",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.0",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"tslib": "2.8.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@platecms/delta-plate-resource-notation": "1.
|
|
25
|
+
"@platecms/delta-plate-resource-notation": "1.16.0"
|
|
26
26
|
}
|
|
27
27
|
}
|