@sanity/block-content-to-tree
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "@sanity/block-content-to-tree", | ||
"description": "Converts the flat Sanity block content structure into a generic tree structure for easier transformation into other formats.", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "umd": "umd/index.min.js", |
@@ -9,5 +9,5 @@ # block-content-to-tree-js | ||
## Usage | ||
## Quick example | ||
``` | ||
```js | ||
@@ -49,3 +49,3 @@ // The flat block content structure | ||
``` | ||
```js | ||
{ | ||
@@ -69,6 +69,65 @@ type: 'block', | ||
For more examples, see the tests. | ||
## Entities | ||
### Block (text) | ||
```js | ||
{ | ||
type: 'block', | ||
style: 'normal' // Text style | ||
mark: 'em', // Mark indicating all content is wrapped in bold. | ||
content: [ | ||
'Hello world! ', // Span with no marks or attributes (plain text). | ||
{ | ||
type: 'span', | ||
// Data attributes for this span | ||
attributes: {link: {href: 'http://...'}}, | ||
mark: 'strong', | ||
// The text content for the span | ||
// Always an array with a single plain text. | ||
// An array to keep format consistent with block.content. | ||
content: [ | ||
'I am a link!' | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
### List | ||
Root element | ||
```js | ||
{ | ||
type: 'list', | ||
itemStyle: 'bullet' // The list style | ||
// Items are blocks (see above) | ||
items: [ | ||
{block}, | ||
{block} | ||
] | ||
} | ||
``` | ||
### Custom blocks | ||
```js | ||
{ | ||
type: 'author' // Whatever, but never 'block' (built in type) | ||
attributes: { // Custom attributes for the type | ||
name: 'John Ronald Reuel Tolkien', | ||
} | ||
} | ||
``` | ||
## More information / examples | ||
Please see the tests. | ||
## License | ||
MIT-licensed |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53816
131