You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
♻️ Move block lexicon defs to reusable namespace (#48)
* ♻️ Move block lexicon defs to reusable namespace
Place block type definitions in `pub.oxa.blocks.defs` and generate them at `lexicon/blocks/defs.json` instead of nesting them under the document lexicon. Update generated refs, conversion code, tests, docs, and examples to use the new block namespace.\n\nThis makes the block schema easier to reuse from other document lexicons rather than tying it to `pub.oxa.document.document`. For example, `pub.oxa.blocks.defs#block` can be referenced from an open `content` property in another record schema such as `site.standard.document`.\n\nCo-authored-by: Stencila <47797644+stencila[bot]@users.noreply.github.com>
* chore(*): update formatted/generated files [skip ci]
* ♻️ Simplify document lexicon id to `pub.oxa.document`
Simplify the document record NSID from `pub.oxa.document.document` to
`pub.oxa.document`, consistent with the naming convention used by
`site.standard.document` and others. This is possible now that block
type definitions have been moved to their own `pub.oxa.blocks.defs`
namespace.
Co-authored-by: Stencila <47797644+stencila[bot]@users.noreply.github.com>
* chore(*): update formatted/generated files [skip ci]
* Move generated file
---------
Co-authored-by: Stencila <47797644+stencila[bot]@users.noreply.github.com>
|`lexicon/document/document.json`|`pub.oxa.document.document`| The `Document` record type — the root object stored in a PDS |
27
-
|`lexicon/document/defs.json`|`pub.oxa.document.defs`| Block-level type definitions (`paragraph`, `heading`, `richText`) and the `block` union |
26
+
|`lexicon/document/document.json`|`pub.oxa.document`| The `Document` record type — the root object stored in a PDS |
27
+
|`lexicon/blocks/defs.json`|`pub.oxa.blocks.defs`| Block-level type definitions (`paragraph`, `heading`, `richText`) and the `block` union |
28
28
|`lexicon/richtext/facet.json`|`pub.oxa.richtext.facet`| Facet annotations for inline formatting (`emphasis`, `strong`, `byteSlice`) |
29
29
30
30
A `Document` record contains an array of `children` (blocks). Each block carries a `text` string and an optional `facets` array that annotates ranges of that text with formatting features.
@@ -112,7 +112,7 @@ AT Protocol [uses facets instead of a tree](https://www.pfrazee.com/blog/why-fac
112
112
113
113
```json
114
114
{
115
-
"$type": "pub.oxa.document.defs#paragraph",
115
+
"$type": "pub.oxa.blocks.defs#paragraph",
116
116
"text": "This is bold and italic text.",
117
117
"facets": [
118
118
{
@@ -201,16 +201,16 @@ Produces:
201
201
202
202
```json
203
203
{
204
-
"$type": "pub.oxa.document.document",
204
+
"$type": "pub.oxa.document",
205
205
"children": [
206
206
{
207
-
"$type": "pub.oxa.document.defs#heading",
207
+
"$type": "pub.oxa.blocks.defs#heading",
208
208
"level": 1,
209
209
"text": "Hello",
210
210
"facets": []
211
211
},
212
212
{
213
-
"$type": "pub.oxa.document.defs#paragraph",
213
+
"$type": "pub.oxa.blocks.defs#paragraph",
214
214
"text": "Some emphasized text.",
215
215
"facets": [
216
216
{
@@ -265,8 +265,8 @@ The lexicon files are generated from the OXA YAML schema definitions by the code
265
265
1. Loads the merged OXA JSON Schema.
266
266
2. Classifies each type as inline or block based on the `Inline` and `Block` union definitions.
267
267
3. Maps inline types to facet features in `pub.oxa.richtext.facet` (excluding `Text`, which becomes the plain text string).
268
-
4. Maps block types to object definitions in `pub.oxa.document.defs`, replacing their inline `children` arrays with `text` + `facets` pairs.
269
-
5. Emits the `Document` record type in `pub.oxa.document.document`.
268
+
4. Maps block types to object definitions in `pub.oxa.blocks.defs`, replacing their inline `children` arrays with `text` + `facets` pairs.
269
+
5. Emits the `Document` record type in `pub.oxa.document`.
270
270
271
271
To regenerate the lexicon after changing the schema:
Copy file name to clipboardExpand all lines: examples/rfc0003.atproto.json
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
{
2
-
"$type": "pub.oxa.document.document",
2
+
"$type": "pub.oxa.document",
3
3
"title": {
4
4
"text": "Water Dissociation: H2O → H+ + OH−",
5
5
"facets": [
@@ -19,13 +19,13 @@
19
19
},
20
20
"children": [
21
21
{
22
-
"$type": "pub.oxa.document.defs#heading",
22
+
"$type": "pub.oxa.blocks.defs#heading",
23
23
"text": "Introduction",
24
24
"facets": [],
25
25
"level": 1
26
26
},
27
27
{
28
-
"$type": "pub.oxa.document.defs#paragraph",
28
+
"$type": "pub.oxa.blocks.defs#paragraph",
29
29
"text": "Water (H2O) undergoes autoionization, a process in which a water molecule donates a proton to another. The equilibrium constant for this reaction, Kw, is approximately 10−14 at 25 °C.",
"text": "This example demonstrates every node type from RFC0003: Heading, Paragraph, Code, ThematicBreak, Text, Emphasis, Strong, Superscript, Subscript, and InlineCode.",
0 commit comments