diff --git a/docs/guides/data-model.md b/docs/guides/data-model.md
index d4c9e81ab..3046a57b5 100644
--- a/docs/guides/data-model.md
+++ b/docs/guides/data-model.md
@@ -22,8 +22,8 @@ Specifically, Slate's models are [`Immutable.Record`](https://facebook.github.io
```js
const block = Block.create({ type: 'paragraph' })
-block.kind // "block"
-block.type // "paragraph"
+block.object // "block"
+block.type // "paragraph"
```
But for updating values, you'll need to use the [`Immutable.Record` API](https://facebook.github.io/immutable-js/docs/#/Record/set).
diff --git a/docs/guides/rendering.md b/docs/guides/rendering.md
index dcaf5bd58..7570e60b2 100644
--- a/docs/guides/rendering.md
+++ b/docs/guides/rendering.md
@@ -94,7 +94,7 @@ However sometimes you want to customize things. Or maybe you want to render plac
```js
function renderPlaceholder(props) {
const { node, editor } = props
- if (node.kind != 'block') return
+ if (node.object != 'block') return
if (node.type != 'caption') return
if (node.text != '') return
diff --git a/docs/guides/schemas.md b/docs/guides/schemas.md
index 05a6ee7ff..e19e3f5af 100644
--- a/docs/guides/schemas.md
+++ b/docs/guides/schemas.md
@@ -24,7 +24,7 @@ const schema = {
blocks: {
paragraph: {
nodes: [
- { kinds: ['text'] }
+ { objects: ['text'] }
]
},
image: {
@@ -93,13 +93,13 @@ When you define a `validateNode` function, you either return nothing if the node
```js
function validateNode(node) {
- if (node.kind != 'block') return
+ if (node.object != 'block') return
if (node.isVoid) return
const { nodes } = node
if (nodes.size != 3) return
- if (nodes.first().kind != 'text') return
- if (nodes.last().kind != 'text') return
+ if (nodes.first().object != 'text') return
+ if (nodes.last().object != 'text') return
return (change) => {
change.removeNodeByKey(node.key)
diff --git a/docs/reference/slate-html-serializer/index.md b/docs/reference/slate-html-serializer/index.md
index 3f23a4043..82fc00dd6 100644
--- a/docs/reference/slate-html-serializer/index.md
+++ b/docs/reference/slate-html-serializer/index.md
@@ -86,28 +86,28 @@ The object should be one of:
```js
{
- kind: 'block',
+ object: 'block',
type: String,
data: Object,
nodes: next(...)
}
{
- kind: 'inline',
+ object: 'inline',
type: String,
data: Object,
nodes: next(...)
}
{
- kind: 'mark',
+ object: 'mark',
type: String,
data: Object,
nodes: next(...)
}
{
- kind: 'text',
+ object: 'text',
leaves: Array
}
```
@@ -118,8 +118,8 @@ The object should be one of:
The `serialize` function should return a React element representing the serialized HTML, or nothing if the rule in question doesn't know how to serialize the object, in which case the next rule in the stack will be attempted.
-The function will be called with either a `Node`, a `Mark`, or a special `String` immutable object, with a `kind: 'string'` property and a `text` property containing the text string.
+The function will be called with either a `Node`, a `Mark`, or a special `String` immutable object, with a `object: 'string'` property and a `text` property containing the text string.
### Default Text Rule
-The HTML serializer includes a default rule to handle "normal text". That is, a final rule exists to serialize `kind: 'string'` text (replacing line feed characters with `
`), and to deserialize text inversely. To avoid this default handling simply provide your own `deserialize` and `serialize` rules for text.
+The HTML serializer includes a default rule to handle "normal text". That is, a final rule exists to serialize `object: 'string'` text (replacing line feed characters with `
`), and to deserialize text inversely. To avoid this default handling simply provide your own `deserialize` and `serialize` rules for text.
diff --git a/docs/reference/slate/block.md b/docs/reference/slate/block.md
index ae43d1a87..020ea01f0 100644
--- a/docs/reference/slate/block.md
+++ b/docs/reference/slate/block.md
@@ -39,7 +39,7 @@ Note that even though a node may be "void", it will still contain a single, empt
A unique identifier for the node.
-### `kind`
+### `object`
`String`
An immutable string value of `'block'` for easily separating this node from [`Inline`](./inline.md) or [`Text`](./text.md) nodes.
diff --git a/docs/reference/slate/change.md b/docs/reference/slate/change.md
index e49effffd..391c95ee1 100644
--- a/docs/reference/slate/change.md
+++ b/docs/reference/slate/change.md
@@ -12,7 +12,7 @@ All changes are performed through `Change` objects, so that a history of changes
## Properties
-### `kind`
+### `object`
`String`
A string with a value of `'change'`.
diff --git a/docs/reference/slate/character.md b/docs/reference/slate/character.md
index ae73ccb88..d18951259 100644
--- a/docs/reference/slate/character.md
+++ b/docs/reference/slate/character.md
@@ -19,7 +19,7 @@ Character({
})
```
-### `kind`
+### `object`
`String`
A string with a value of `'character'`.
diff --git a/docs/reference/slate/document.md b/docs/reference/slate/document.md
index b198533c1..9a9e4f2fe 100644
--- a/docs/reference/slate/document.md
+++ b/docs/reference/slate/document.md
@@ -23,7 +23,7 @@ Document({
### `data`
`Immutable.Map`
-### `kind`
+### `object`
`String`
An immutable string value of `'document'` for easily separating this node from [`Block`](./block.md), [`Inline`](./inline.md) or [`Text`](./text.md) nodes.
diff --git a/docs/reference/slate/inline.md b/docs/reference/slate/inline.md
index 6daec1b8d..7b66b28ec 100644
--- a/docs/reference/slate/inline.md
+++ b/docs/reference/slate/inline.md
@@ -39,7 +39,7 @@ Note that even though a node may be "void", it will still contain a single, empt
A unique identifier for the node.
-### `kind`
+### `object`
`String`
An immutable string value of `'inline'` for easily separating this node from [`Block`](./block.md) or [`Text`](./text.md) nodes.
diff --git a/docs/reference/slate/mark.md b/docs/reference/slate/mark.md
index 2454c428d..b4ac6af0c 100644
--- a/docs/reference/slate/mark.md
+++ b/docs/reference/slate/mark.md
@@ -22,7 +22,7 @@ Mark({
A map of [`Data`](./data.md).
-### `kind`
+### `object`
`String`
A string with a value of `'mark'`.
diff --git a/docs/reference/slate/node.md b/docs/reference/slate/node.md
index 2f81a2f9f..792e49e4d 100644
--- a/docs/reference/slate/node.md
+++ b/docs/reference/slate/node.md
@@ -15,16 +15,16 @@ By default, keys are **not** meant to be long-lived unique identifiers for nodes
If you want to make your keys uniqueness long-lived, you'll need to supply your own key generating function via the [`setKeyGenerator`](./utils.md#setkeygenerator) util.
-### `kind`
-`String`
-
-An immutable string value of `'document'`, `'block'`, `'inline'` or `'text'` for easily separating this node from [`Inline`](./inline.md) or [`Text`](./text.md) nodes.
-
### `nodes`
`Immutable.List`
A list of child nodes. Defaults to a list with a single text node child.
+### `object`
+`String`
+
+An immutable string value of `'document'`, `'block'`, `'inline'` or `'text'` for easily separating this node from [`Inline`](./inline.md) or [`Text`](./text.md) nodes.
+
## Computed Properties
diff --git a/docs/reference/slate/range.md b/docs/reference/slate/range.md
index 0b28cbd1e..d1055f4d1 100644
--- a/docs/reference/slate/range.md
+++ b/docs/reference/slate/range.md
@@ -55,7 +55,7 @@ Whether the range is backward. A range is considered "backward" when its focus p
Whether the range currently has focus.
-### `kind`
+### `object`
`String`
A string with a value of `'range'`.
diff --git a/docs/reference/slate/schema.md b/docs/reference/slate/schema.md
index 69231d1ad..dd5ae5090 100644
--- a/docs/reference/slate/schema.md
+++ b/docs/reference/slate/schema.md
@@ -55,7 +55,7 @@ A dictionary of blocks by type, each with its own set of validation rules.
inlines: {
emoji: {
isVoid: true,
- nodes: [{ kinds: ['text'] }]
+ nodes: [{ objects: ['text'] }]
},
}
}
@@ -103,7 +103,7 @@ A dictionary of data attributes and their corresponding validation functions. Th
}
```
-Will validate the first child node. The `first` definition can declare `kinds` and `types` properties.
+Will validate the first child node. The `first` definition can declare `objects` and `types` properties.
### `isVoid`
`Boolean`
@@ -125,7 +125,7 @@ Will validate a node's `isVoid` property.
}
```
-Will validate the last child node. The `last` definition can declare `kinds` and `types` properties.
+Will validate the last child node. The `last` definition can declare `objects` and `types` properties.
### `nodes`
`Array`
@@ -139,7 +139,7 @@ Will validate the last child node. The `last` definition can declare `kinds` and
}
```
-Will validate a node's children. The `nodes` definitions can declare the `kinds`, `types`, `min` and `max` properties.
+Will validate a node's children. The `nodes` definitions can declare the `objects`, `types`, `min` and `max` properties.
> 🤖 The `nodes` array is order-sensitive! The example above will require that the first node be either an `image` or `video`, and that it be followed by one or more `paragraph` nodes.
@@ -149,7 +149,7 @@ Will validate a node's children. The `nodes` definitions can declare the `kinds`
```js
{
normalize: (change, reason, context) => {
- case 'child_kind_invalid':
+ case 'child_object_invalid':
change.wrapBlockByKey(context.child.key, 'paragraph')
return
case 'child_type_invalid':
@@ -172,7 +172,7 @@ For more information on the arguments passed to `normalize`, see the [Invalid Re
}
```
-Will validate a node's parent. The parent definition can declare the `kinds` and/or `types` properties.
+Will validate a node's parent. The parent definition can declare the `objects` and/or `types` properties.
### `text`
`Array`
@@ -216,7 +216,7 @@ Returns a JSON representation of the schema.
When supplying your own `normalize` property for a schema rule, it will be called with `(change, reason, context)`. The `reason` will be one of a set of reasons, and `context` will vary depending on the reason. Here's the full set:
-### `child_kind_invalid`
+### `child_object_invalid`
```js
{
@@ -259,7 +259,7 @@ When supplying your own `normalize` property for a schema rule, it will be calle
}
```
-### `first_child_kind_invalid`
+### `first_child_object_invalid`
```js
{
@@ -279,7 +279,7 @@ When supplying your own `normalize` property for a schema rule, it will be calle
}
```
-### `last_child_kind_invalid`
+### `last_child_object_invalid`
```js
{
@@ -319,7 +319,7 @@ When supplying your own `normalize` property for a schema rule, it will be calle
}
```
-### `node_kind_invalid`
+### `node_object_invalid`
```js
{
@@ -348,7 +348,7 @@ When supplying your own `normalize` property for a schema rule, it will be calle
}
```
-### `parent_kind_invalid`
+### `parent_object_invalid`
```js
{
diff --git a/docs/reference/slate/text.md b/docs/reference/slate/text.md
index 6f8e06121..e357419c3 100644
--- a/docs/reference/slate/text.md
+++ b/docs/reference/slate/text.md
@@ -26,7 +26,7 @@ A list of [`Characters`](./character.md) with associated [`Marks`](./mark.md) th
A unique identifier for the node.
-### `kind`
+### `object`
`String`
An immutable string value of `'text'` for easily separating this node from [`Inline`](./inline.md) or [`Block`](./block.md) nodes.
diff --git a/docs/reference/slate/value.md b/docs/reference/slate/value.md
index c18e7032b..e33d23d3f 100644
--- a/docs/reference/slate/value.md
+++ b/docs/reference/slate/value.md
@@ -45,7 +45,7 @@ The current document of the value.
An object that stores the history of changes.
-### `kind`
+### `object`
`String`
A string with a value of `'value'`.
diff --git a/docs/walkthroughs/installing-slate.md b/docs/walkthroughs/installing-slate.md
index 8cfd1ce57..7384d51cc 100644
--- a/docs/walkthroughs/installing-slate.md
+++ b/docs/walkthroughs/installing-slate.md
@@ -36,11 +36,11 @@ const initialValue = Value.fromJSON({
document: {
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'A line of text in a paragraph.'
@@ -66,11 +66,11 @@ const initialValue = Value.fromJSON({
document: {
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'A line of text in a paragraph.'
diff --git a/docs/walkthroughs/saving-and-loading-html-content.md b/docs/walkthroughs/saving-and-loading-html-content.md
index 683ee1da4..1d738a64a 100644
--- a/docs/walkthroughs/saving-and-loading-html-content.md
+++ b/docs/walkthroughs/saving-and-loading-html-content.md
@@ -54,7 +54,7 @@ const rules = [
deserialize(el, next) {
if (el.tagName.toLowerCase() == 'p') {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes)
}
@@ -76,15 +76,15 @@ const rules = [
deserialize(el, next) {
if (el.tagName.toLowerCase() == 'p') {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes)
}
}
},
// Add a serializing function property to our rule...
- serialize(object, children) {
- if (object.kind == 'block' && object.type == 'paragraph') {
+ serialize(obj, children) {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return
{children}
}
}
@@ -115,15 +115,15 @@ const rules = [
const type = BLOCK_TAGS[el.tagName.toLowerCase()]
if (!type) return
return {
- kind: 'block',
+ object: 'block',
type: type,
nodes: next(el.childNodes)
}
},
// Switch serialize to handle more blocks...
- serialize(object, children) {
- if (object.kind != 'block') return
- switch (object.type) {
+ serialize(obj, children) {
+ if (obj.object != 'block') return
+ switch (obj.type) {
case 'paragraph': return {children}
case 'quote': return {children}
case 'code': return {children}
@@ -160,14 +160,14 @@ const rules = [
const type = BLOCK_TAGS[el.tagName.toLowerCase()]
if (!type) return
return {
- kind: 'block',
+ object: 'block',
type: type,
nodes: next(el.childNodes)
}
},
- serialize(object, children) {
- if (object.kind != 'block') return
- switch (object.type) {
+ serialize(obj, children) {
+ if (obj.object != 'block') return
+ switch (obj.type) {
case 'code': return {children}
case 'paragraph': return {children}
case 'quote': return {children}
@@ -180,14 +180,14 @@ const rules = [
const type = MARK_TAGS[el.tagName.toLowerCase()]
if (!type) return
return {
- kind: 'mark',
+ object: 'mark',
type: type,
nodes: next(el.childNodes)
}
},
- serialize(object, children) {
- if (object.kind != 'mark') return
- switch (object.type) {
+ serialize(obj, children) {
+ if (obj.object != 'mark') return
+ switch (obj.type) {
case 'bold': return {children}
case 'italic': return {children}
case 'underline': return {children}
diff --git a/docs/walkthroughs/saving-to-a-database.md b/docs/walkthroughs/saving-to-a-database.md
index 93b4b106c..aae291904 100644
--- a/docs/walkthroughs/saving-to-a-database.md
+++ b/docs/walkthroughs/saving-to-a-database.md
@@ -19,11 +19,11 @@ const initialValue = Value.fromJSON({
document: {
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'A line of text in a paragraph.'
@@ -69,11 +69,11 @@ const initialValue = Value.fromJSON({
document: {
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'A line of text in a paragraph.'
@@ -123,11 +123,11 @@ const initialValue = Value.fromJSON(existingValue || {
document: {
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'A line of text in a paragraph.'
@@ -175,11 +175,11 @@ const initialValue = Value.fromJSON(existingValue || {
document: {
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'A line of text in a paragraph.'
diff --git a/examples/check-lists/value.json b/examples/check-lists/value.json
index 4a88e768c..2ffcd7688 100644
--- a/examples/check-lists/value.json
+++ b/examples/check-lists/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "With Slate you can build complex block types that have their own embedded content and behaviors, like rendering checkboxes inside check list items!"
@@ -16,14 +16,14 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "check-list-item",
"data": {
"checked": true,
},
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Slide to the left."
@@ -33,14 +33,14 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "check-list-item",
"data": {
"checked": true,
},
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Slide to the right."
@@ -50,14 +50,14 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "check-list-item",
"data": {
"checked": false,
},
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Criss-cross."
@@ -67,14 +67,14 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "check-list-item",
"data": {
"checked": true,
},
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Criss-cross!"
@@ -84,14 +84,14 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "check-list-item",
"data": {
"checked": false,
},
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Cha cha real smooth…"
@@ -101,14 +101,14 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "check-list-item",
"data": {
"checked": false,
},
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Let's go to work!"
@@ -118,11 +118,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out for yourself!"
diff --git a/examples/code-highlighting/value.json b/examples/code-highlighting/value.json
index f71eae6c3..4851f2188 100644
--- a/examples/code-highlighting/value.json
+++ b/examples/code-highlighting/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "There are certain behaviors that require rendering dynamic marks on string of text, like rendering code highlighting. For example:"
@@ -16,18 +16,18 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code",
"data": {
"language": "js"
},
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "// A simple FizzBuzz implementation."
@@ -37,11 +37,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "for (var i = 1; i <= 100; i++) {"
@@ -51,11 +51,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " if (i % 15 == 0) {"
@@ -65,11 +65,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " console.log('Fizz Buzz');"
@@ -79,11 +79,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " } else if (i % 5 == 0) {"
@@ -93,11 +93,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " console.log('Buzz');"
@@ -107,11 +107,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " } else if (i % 3 == 0) {"
@@ -121,11 +121,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " console.log('Fizz');"
@@ -135,11 +135,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " } else {"
@@ -149,11 +149,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " console.log(i);"
@@ -163,11 +163,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": " }"
@@ -177,11 +177,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "code_line",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "}"
@@ -193,11 +193,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out for yourself!"
diff --git a/examples/embeds/value.json b/examples/embeds/value.json
index 7017438f1..6b69d2ad7 100644
--- a/examples/embeds/value.json
+++ b/examples/embeds/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "In addition to simple image nodes, you can actually create complex embedded nodes. For example, this one contains an input element that lets you change the video being rendered!"
@@ -16,7 +16,7 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "video",
"isVoid": true,
"data": {
@@ -24,11 +24,11 @@
}
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out! If you want another good video URL to try, go with: https://www.youtube.com/embed/6Ejga4kJUts"
diff --git a/examples/emojis/value.json b/examples/emojis/value.json
index 01634d28f..73bb21c6a 100644
--- a/examples/emojis/value.json
+++ b/examples/emojis/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "In addition to block nodes, you can create inline void nodes, like "
@@ -14,7 +14,7 @@
]
},
{
- "kind": "inline",
+ "object": "inline",
"type": "emoji",
"isVoid": true,
"data": {
@@ -22,7 +22,7 @@
}
},
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "!"
@@ -32,11 +32,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "inline",
+ "object": "inline",
"type": "emoji",
"isVoid": true,
"data": {
@@ -46,11 +46,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "This example shows emojis in action."
diff --git a/examples/forced-layout/value.json b/examples/forced-layout/value.json
index e3791e8d3..a6b0feb0f 100644
--- a/examples/forced-layout/value.json
+++ b/examples/forced-layout/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "title",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Enforce Your Layout!"
@@ -16,11 +16,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "This example shows how to enforce your layout with schema-specific rules. This document will always have a title block at the top and at least one paragraph in the body. Try deleting them and see what happens!"
diff --git a/examples/history/value.json b/examples/history/value.json
index 39742c1aa..92f55d0ff 100644
--- a/examples/history/value.json
+++ b/examples/history/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Slate editors save all changes to an internal \"history\" automatically, so you don't need to implement undo/redo yourself. And the editor automatically binds to the browser's default undo/redo keyboard shortcuts."
@@ -16,11 +16,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out for yourself! Make any changes you'd like then press \"cmd+z\"."
diff --git a/examples/hovering-menu/value.json b/examples/hovering-menu/value.json
index 190130217..3b6fd13a4 100644
--- a/examples/hovering-menu/value.json
+++ b/examples/hovering-menu/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "This example shows how you can make a hovering menu appear above your content, which you can use to make text "
@@ -38,11 +38,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out yourself! Just "
diff --git a/examples/huge-document/index.js b/examples/huge-document/index.js
index 76739208c..6aba88dfc 100644
--- a/examples/huge-document/index.js
+++ b/examples/huge-document/index.js
@@ -21,16 +21,16 @@ const json = {
for (let h = 0; h < HEADINGS; h++) {
nodes.push({
- kind: 'block',
+ object: 'block',
type: 'heading',
- nodes: [{ kind: 'text', leaves: [{ text: faker.lorem.sentence() }] }]
+ nodes: [{ object: 'text', leaves: [{ text: faker.lorem.sentence() }] }]
})
for (let p = 0; p < PARAGRAPHS; p++) {
nodes.push({
- kind: 'block',
+ object: 'block',
type: 'paragraph',
- nodes: [{ kind: 'text', leaves: [{ text: faker.lorem.paragraph() }] }]
+ nodes: [{ object: 'text', leaves: [{ text: faker.lorem.paragraph() }] }]
})
}
}
diff --git a/examples/images/value.json b/examples/images/value.json
index ccaa236a3..11286d967 100644
--- a/examples/images/value.json
+++ b/examples/images/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "In addition to nodes that contain editable text, you can also create other types of nodes, like images or videos."
@@ -16,7 +16,7 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "image",
"isVoid": true,
"data": {
@@ -24,11 +24,11 @@
}
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "This example shows images in action. It features two ways to add images. You can either add an image via the toolbar icon above, or if you want in on a little secret, copy an image URL to your keyboard and paste it anywhere in the editor!"
diff --git a/examples/links/value.json b/examples/links/value.json
index eeb77e78c..0285dcbcc 100644
--- a/examples/links/value.json
+++ b/examples/links/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "In addition to block nodes, you can create inline nodes, like "
@@ -14,14 +14,14 @@
]
},
{
- "kind": "inline",
+ "object": "inline",
"type": "link",
"data": {
"href": "https://en.wikipedia.org/wiki/Hypertext"
},
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "hyperlinks"
@@ -31,7 +31,7 @@
]
},
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "!"
@@ -41,11 +41,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "This example shows hyperlinks in action. It features two ways to add links. You can either add a link via the toolbar icon above, or if you want in on a little secret, copy a URL to your keyboard and paste it while a range of text is selected."
diff --git a/examples/markdown-preview/index.js b/examples/markdown-preview/index.js
index 440b0f9cc..01aeb9fd0 100644
--- a/examples/markdown-preview/index.js
+++ b/examples/markdown-preview/index.js
@@ -114,7 +114,7 @@ class MarkdownPreview extends React.Component {
*/
decorateNode(node) {
- if (node.kind != 'block') return
+ if (node.object != 'block') return
const string = node.text
const texts = node.getTexts().toArray()
diff --git a/examples/markdown-shortcuts/value.json b/examples/markdown-shortcuts/value.json
index a20bc38cb..f31ac4205 100644
--- a/examples/markdown-shortcuts/value.json
+++ b/examples/markdown-shortcuts/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "The editor gives you full control over the logic you can add. For example, it's fairly common to want to add markdown-like shortcuts to editors. So that, when you start a line with \"> \" you get a blockquote that looks like this:"
@@ -16,11 +16,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "block-quote",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "A wise quote."
@@ -30,11 +30,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Order when you start a line with \"## \" you get a level-two heading, like this:"
@@ -44,11 +44,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "heading-two",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out!"
@@ -58,11 +58,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out for yourself! Try starting a new line with \">\", \"-\", or \"#\"s."
diff --git a/examples/paste-html/index.js b/examples/paste-html/index.js
index 1d87b7953..f63bc9fb9 100644
--- a/examples/paste-html/index.js
+++ b/examples/paste-html/index.js
@@ -53,7 +53,7 @@ const RULES = [
const block = BLOCK_TAGS[el.tagName.toLowerCase()]
if (!block) return
return {
- kind: 'block',
+ object: 'block',
type: block,
nodes: next(el.childNodes)
}
@@ -64,7 +64,7 @@ const RULES = [
const mark = MARK_TAGS[el.tagName.toLowerCase()]
if (!mark) return
return {
- kind: 'mark',
+ object: 'mark',
type: mark,
nodes: next(el.childNodes)
}
@@ -80,7 +80,7 @@ const RULES = [
: el.childNodes
return {
- kind: 'block',
+ object: 'block',
type: 'code',
nodes: next(childNodes)
}
@@ -91,7 +91,7 @@ const RULES = [
deserialize(el, next) {
if (el.tagName.toLowerCase() != 'img') return
return {
- kind: 'block',
+ object: 'block',
type: 'image',
isVoid: true,
nodes: next(el.childNodes),
@@ -106,7 +106,7 @@ const RULES = [
deserialize(el, next) {
if (el.tagName.toLowerCase() != 'a') return
return {
- kind: 'inline',
+ object: 'inline',
type: 'link',
nodes: next(el.childNodes),
data: {
diff --git a/examples/paste-html/value.json b/examples/paste-html/value.json
index 9ccedd098..f5478f846 100644
--- a/examples/paste-html/value.json
+++ b/examples/paste-html/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "By default, pasting content into a Slate editor will use the content's plain text representation. This is fine for some use cases, but sometimes you want to actually be able to paste in content and have it parsed into blocks and links and things. To do this, you need to add a parser that triggers on paste. This is an example of doing exactly that!"
@@ -16,11 +16,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out for yourself! Copy and paste some HTML content from another site into this editor."
diff --git a/examples/rich-text/value.json b/examples/rich-text/value.json
index 3ed1c5322..359785c90 100644
--- a/examples/rich-text/value.json
+++ b/examples/rich-text/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "This is editable "
@@ -49,11 +49,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Since it's rich text, you can do things like turn a selection of text "
@@ -73,11 +73,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "block-quote",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "A wise quote."
@@ -87,11 +87,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out for yourself!"
diff --git a/examples/rtl/value.json b/examples/rtl/value.json
index 3c2d22540..fa0655d9b 100644
--- a/examples/rtl/value.json
+++ b/examples/rtl/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Slate supports both left-to-right text editing (English, French, etc.) and right-to-left text editing (Arabic, Hebrew, etc.) which it automatically detects. Here's an example featuring excerpts from Khalil Gibran:"
@@ -16,11 +16,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "block-quote",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Et un jeune dit : parle-nous de l'amitié.\nEt il répondit, disant :\nVotre ami est votre besoin qui a trouvé une réponse.\nIl est le champ que vous semez avec amour et moissonnez avec reconnaissance.\nIl est votre table et votre foyer."
@@ -30,11 +30,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "block-quote",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "ثم قال له شاب: هات حدثناعن الصداقة.\nفأجاب و قال:\nإن صديقك هو كفاية حاجاتك.\nهو حقك الذي تزرعه بالمحبة و تحصده بالشكر.\nهو مائدتك و موقدك."
@@ -44,11 +44,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "block-quote",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "And a youth said, \"Speak to us of Friendship.\"\nYour friend is your needs answered.\nHe is your field which you sow with love and reap with thanksgiving.\nAnd he is your board and your fireside."
@@ -58,11 +58,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out for yourself!"
diff --git a/examples/search-highlighting/value.json b/examples/search-highlighting/value.json
index d66f4de4c..d56ea1e29 100644
--- a/examples/search-highlighting/value.json
+++ b/examples/search-highlighting/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "This is editable text that you can search. As you search, it looks for matching strings of text, and adds \"decoration\" marks to them in realtime."
@@ -16,11 +16,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Try it out for yourself by typing in the search box above!"
diff --git a/examples/state.json b/examples/state.json
deleted file mode 100644
index f11444d13..000000000
--- a/examples/state.json
+++ /dev/null
@@ -1,74 +0,0 @@
-{
- "nodes": [
- {
- "kind": "block",
- "type": "paragraph",
- "nodes": [
- {
- "kind": "text",
- "leaves": [
- {
- "text": "The editor gives you full control over the logic you can add. For example, it's fairly common to want to add markdown-like shortcuts to editors. So that, when you start a line with \"> \" you get a blockquote that looks like this:"
- }
- ]
- }
- ]
- },
- {
- "kind": "block",
- "type": "block-quote",
- "nodes": [
- {
- "kind": "text",
- "leaves": [
- {
- "text": "A wise quote."
- }
- ]
- }
- ]
- },
- {
- "kind": "block",
- "type": "paragraph",
- "nodes": [
- {
- "kind": "text",
- "leaves": [
- {
- "text": "Order when you start a line with \"## \" you get a level-two heading, like this:"
- }
- ]
- }
- ]
- },
- {
- "kind": "block",
- "type": "heading-two",
- "nodes": [
- {
- "kind": "text",
- "leaves": [
- {
- "text": "Try it out!"
- }
- ]
- }
- ]
- },
- {
- "kind": "block",
- "type": "paragraph",
- "nodes": [
- {
- "kind": "text",
- "leaves": [
- {
- "text": "Try it out for yourself! Try starting a new line with \">\", \"-\", or \"#\"s."
- }
- ]
- }
- ]
- }
- ]
-}
diff --git a/examples/syncing-operations/value.json b/examples/syncing-operations/value.json
index f59d8826f..bca24cf70 100644
--- a/examples/syncing-operations/value.json
+++ b/examples/syncing-operations/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "These two editors are kept "
@@ -27,11 +27,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "They achieve this by sending any document-altering operations to each other whenever a change occurs, and then applying them locally with "
@@ -52,11 +52,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Note: ",
diff --git a/examples/tables/value.json b/examples/tables/value.json
index 8ac2e3644..dea99cfb7 100644
--- a/examples/tables/value.json
+++ b/examples/tables/value.json
@@ -2,11 +2,11 @@
"document": {
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Since the editor is based on a recursive tree model, similar to an HTML document, you can create complex nested structures, like tables:"
@@ -16,19 +16,19 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table",
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "table-row",
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": ""
@@ -38,11 +38,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Human",
@@ -57,11 +57,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Dog",
@@ -76,11 +76,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "Cat",
@@ -97,15 +97,15 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-row",
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "# of Feet",
@@ -120,11 +120,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "2"
@@ -134,11 +134,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "4"
@@ -148,11 +148,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "4"
@@ -164,15 +164,15 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-row",
"nodes": [
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "# of Lives",
@@ -187,11 +187,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "1"
@@ -201,11 +201,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "1"
@@ -215,11 +215,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "table-cell",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "9"
@@ -233,11 +233,11 @@
]
},
{
- "kind": "block",
+ "object": "block",
"type": "paragraph",
"nodes": [
{
- "kind": "text",
+ "object": "text",
"leaves": [
{
"text": "This table is just a basic example of rendering a table, and it doesn\'t have fancy functionality. But you could augment it to add support for navigating with arrow keys, displaying table headers, adding column and rows, or even formulas if you wanted to get really crazy!"
diff --git a/package.json b/package.json
index 3dc1204f2..790806955 100644
--- a/package.json
+++ b/package.json
@@ -80,7 +80,7 @@
"open": "open http://localhost:8080/dev.html",
"release": "yarn run test && yarn run lint && lerna publish && yarn run gh-pages",
"start": "http-server ./examples",
- "test": "mocha --compilers js:babel-core/register ./packages/*/test/index.js",
+ "test": "mocha --require babel-core/register ./packages/*/test/index.js",
"watch": "npm-run-all --parallel --print-label watch:examples watch:packages start",
"watch:examples": "watchify --debug --transform babelify ./examples/index.js -o ./examples/build.dev.js -v",
"watch:packages": "lerna run --parallel watch"
diff --git a/packages/slate-html-serializer/benchmark/html-serializer/deserialize.js b/packages/slate-html-serializer/benchmark/html-serializer/deserialize.js
index 094a77c4b..af99db3de 100644
--- a/packages/slate-html-serializer/benchmark/html-serializer/deserialize.js
+++ b/packages/slate-html-serializer/benchmark/html-serializer/deserialize.js
@@ -10,7 +10,7 @@ const html = new Html({
rules: [
{
serialize(obj, children) {
- switch (obj.kind) {
+ switch (obj.object) {
case 'block': {
switch (obj.type) {
case 'paragraph': return React.createElement('p', {}, children)
diff --git a/packages/slate-html-serializer/benchmark/html-serializer/serialize.js b/packages/slate-html-serializer/benchmark/html-serializer/serialize.js
index e3cf98973..18a06a0a2 100644
--- a/packages/slate-html-serializer/benchmark/html-serializer/serialize.js
+++ b/packages/slate-html-serializer/benchmark/html-serializer/serialize.js
@@ -11,7 +11,7 @@ const html = new Html({
rules: [
{
serialize(obj, children) {
- switch (obj.kind) {
+ switch (obj.object) {
case 'block': {
switch (obj.type) {
case 'paragraph': return React.createElement('p', {}, children)
diff --git a/packages/slate-html-serializer/src/index.js b/packages/slate-html-serializer/src/index.js
index 170188a4a..69f1ef6e4 100644
--- a/packages/slate-html-serializer/src/index.js
+++ b/packages/slate-html-serializer/src/index.js
@@ -12,7 +12,7 @@ import { Record } from 'immutable'
*/
const String = new Record({
- kind: 'string',
+ object: 'string',
text: ''
})
@@ -28,9 +28,9 @@ const TEXT_RULE = {
deserialize(el) {
if (el.tagName && el.tagName.toLowerCase() === 'br') {
return {
- kind: 'text',
+ object: 'text',
leaves: [{
- kind: 'leaf',
+ object: 'leaf',
text: '\n'
}]
}
@@ -40,9 +40,9 @@ const TEXT_RULE = {
if (el.nodeValue && el.nodeValue.match(//)) return
return {
- kind: 'text',
+ object: 'text',
leaves: [{
- kind: 'leaf',
+ object: 'leaf',
text: el.nodeValue
}]
}
@@ -50,7 +50,7 @@ const TEXT_RULE = {
},
serialize(obj, children) {
- if (obj.kind === 'string') {
+ if (obj.object === 'string') {
return children
.split('\n')
.reduce((array, text, i) => {
@@ -129,19 +129,19 @@ class Html {
// COMPAT: ensure that all top-level inline nodes are wrapped into a block.
nodes = nodes.reduce((memo, node, i, original) => {
- if (node.kind == 'block') {
+ if (node.object == 'block') {
memo.push(node)
return memo
}
- if (i > 0 && original[i - 1].kind != 'block') {
+ if (i > 0 && original[i - 1].object != 'block') {
const block = memo[memo.length - 1]
block.nodes.push(node)
return memo
}
const block = {
- kind: 'block',
+ object: 'block',
data: {},
isVoid: false,
...defaultBlock,
@@ -155,16 +155,16 @@ class Html {
// TODO: pretty sure this is no longer needed.
if (nodes.length == 0) {
nodes = [{
- kind: 'block',
+ object: 'block',
data: {},
isVoid: false,
...defaultBlock,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
@@ -175,9 +175,9 @@ class Html {
}
const json = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes,
}
@@ -257,7 +257,7 @@ class Html {
continue
} else if (ret === null) {
return null
- } else if (ret.kind == 'mark') {
+ } else if (ret.object == 'mark') {
node = this.deserializeMark(ret)
} else {
node = ret
@@ -280,11 +280,11 @@ class Html {
const { type, data } = mark
const applyMark = (node) => {
- if (node.kind == 'mark') {
+ if (node.object == 'mark') {
return this.deserializeMark(node)
}
- else if (node.kind == 'text') {
+ else if (node.object == 'text') {
node.leaves = node.leaves.map((leaf) => {
leaf.marks = leaf.marks || []
leaf.marks.push({ type, data })
@@ -334,7 +334,7 @@ class Html {
*/
serializeNode = (node) => {
- if (node.kind === 'text') {
+ if (node.object === 'text') {
const leaves = node.getLeaves()
return leaves.map(this.serializeLeaf)
}
diff --git a/packages/slate-html-serializer/test/deserialize/block-nested.js b/packages/slate-html-serializer/test/deserialize/block-nested.js
index 49f885ae6..c9fa2e8ad 100644
--- a/packages/slate-html-serializer/test/deserialize/block-nested.js
+++ b/packages/slate-html-serializer/test/deserialize/block-nested.js
@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'blockquote': {
return {
- kind: 'block',
+ object: 'block',
type: 'quote',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/block-no-children.js b/packages/slate-html-serializer/test/deserialize/block-no-children.js
index 3aa1591e1..d7736e3f9 100644
--- a/packages/slate-html-serializer/test/deserialize/block-no-children.js
+++ b/packages/slate-html-serializer/test/deserialize/block-no-children.js
@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/block-with-data.js b/packages/slate-html-serializer/test/deserialize/block-with-data.js
index 80293c056..75723ddfb 100644
--- a/packages/slate-html-serializer/test/deserialize/block-with-data.js
+++ b/packages/slate-html-serializer/test/deserialize/block-with-data.js
@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: { thing: 'value' },
nodes: next(el.childNodes),
diff --git a/packages/slate-html-serializer/test/deserialize/block-with-is-void.js b/packages/slate-html-serializer/test/deserialize/block-with-is-void.js
index 47038db7a..fa67eec0e 100644
--- a/packages/slate-html-serializer/test/deserialize/block-with-is-void.js
+++ b/packages/slate-html-serializer/test/deserialize/block-with-is-void.js
@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'img': {
return {
- kind: 'block',
+ object: 'block',
type: 'image',
isVoid: true,
}
diff --git a/packages/slate-html-serializer/test/deserialize/block.js b/packages/slate-html-serializer/test/deserialize/block.js
index 9fd4998a8..695fb800b 100644
--- a/packages/slate-html-serializer/test/deserialize/block.js
+++ b/packages/slate-html-serializer/test/deserialize/block.js
@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/default-block.js b/packages/slate-html-serializer/test/deserialize/default-block.js
index 94aad88fd..6e3c819ef 100644
--- a/packages/slate-html-serializer/test/deserialize/default-block.js
+++ b/packages/slate-html-serializer/test/deserialize/default-block.js
@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/html-comment.js b/packages/slate-html-serializer/test/deserialize/html-comment.js
index 5a1e782eb..b6e9bb112 100644
--- a/packages/slate-html-serializer/test/deserialize/html-comment.js
+++ b/packages/slate-html-serializer/test/deserialize/html-comment.js
@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/inline-nested.js b/packages/slate-html-serializer/test/deserialize/inline-nested.js
index 89f191d08..0ebb3646c 100644
--- a/packages/slate-html-serializer/test/deserialize/inline-nested.js
+++ b/packages/slate-html-serializer/test/deserialize/inline-nested.js
@@ -10,21 +10,21 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'a': {
return {
- kind: 'inline',
+ object: 'inline',
type: 'link',
nodes: next(el.childNodes),
}
}
case 'span': {
return {
- kind: 'inline',
+ object: 'inline',
type: 'hashtag',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/inline-no-children.js b/packages/slate-html-serializer/test/deserialize/inline-no-children.js
index df5a26b3a..bd659b25f 100644
--- a/packages/slate-html-serializer/test/deserialize/inline-no-children.js
+++ b/packages/slate-html-serializer/test/deserialize/inline-no-children.js
@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'a': {
return {
- kind: 'inline',
+ object: 'inline',
type: 'link',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/inline-with-data.js b/packages/slate-html-serializer/test/deserialize/inline-with-data.js
index 7b09767f4..ca3c58ee2 100644
--- a/packages/slate-html-serializer/test/deserialize/inline-with-data.js
+++ b/packages/slate-html-serializer/test/deserialize/inline-with-data.js
@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'a': {
return {
- kind: 'inline',
+ object: 'inline',
type: 'link',
data: { thing: 'value' },
nodes: next(el.childNodes),
diff --git a/packages/slate-html-serializer/test/deserialize/inline-with-is-void.js b/packages/slate-html-serializer/test/deserialize/inline-with-is-void.js
index 8b71cf711..6482a6cfc 100644
--- a/packages/slate-html-serializer/test/deserialize/inline-with-is-void.js
+++ b/packages/slate-html-serializer/test/deserialize/inline-with-is-void.js
@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'img': {
return {
- kind: 'inline',
+ object: 'inline',
type: 'emoji',
isVoid: true,
nodes: next(el.childNodes),
diff --git a/packages/slate-html-serializer/test/deserialize/inline.js b/packages/slate-html-serializer/test/deserialize/inline.js
index 1903cda63..d68238462 100644
--- a/packages/slate-html-serializer/test/deserialize/inline.js
+++ b/packages/slate-html-serializer/test/deserialize/inline.js
@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'a': {
return {
- kind: 'inline',
+ object: 'inline',
type: 'link',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/mark-adjacent.js b/packages/slate-html-serializer/test/deserialize/mark-adjacent.js
index bc8ae75ed..93c3ddf43 100644
--- a/packages/slate-html-serializer/test/deserialize/mark-adjacent.js
+++ b/packages/slate-html-serializer/test/deserialize/mark-adjacent.js
@@ -10,21 +10,21 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
- kind: 'mark',
+ object: 'mark',
type: 'bold',
nodes: next(el.childNodes),
}
}
case 'em': {
return {
- kind: 'mark',
+ object: 'mark',
type: 'italic',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/mark-nested.js b/packages/slate-html-serializer/test/deserialize/mark-nested.js
index 27e94b029..6639cd7db 100644
--- a/packages/slate-html-serializer/test/deserialize/mark-nested.js
+++ b/packages/slate-html-serializer/test/deserialize/mark-nested.js
@@ -10,21 +10,21 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
- kind: 'mark',
+ object: 'mark',
type: 'bold',
nodes: next(el.childNodes),
}
}
case 'em': {
return {
- kind: 'mark',
+ object: 'mark',
type: 'italic',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/mark-with-data.js b/packages/slate-html-serializer/test/deserialize/mark-with-data.js
index 5a6076e60..af7468b7c 100644
--- a/packages/slate-html-serializer/test/deserialize/mark-with-data.js
+++ b/packages/slate-html-serializer/test/deserialize/mark-with-data.js
@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
- kind: 'mark',
+ object: 'mark',
type: 'bold',
data: { thing: 'value' },
nodes: next(el.childNodes),
diff --git a/packages/slate-html-serializer/test/deserialize/mark.js b/packages/slate-html-serializer/test/deserialize/mark.js
index c81be7b4f..4b8d1f193 100644
--- a/packages/slate-html-serializer/test/deserialize/mark.js
+++ b/packages/slate-html-serializer/test/deserialize/mark.js
@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
- kind: 'mark',
+ object: 'mark',
type: 'bold',
nodes: next(el.childNodes),
}
diff --git a/packages/slate-html-serializer/test/deserialize/multiple-matching-rules.js b/packages/slate-html-serializer/test/deserialize/multiple-matching-rules.js
index 5e15324b7..e2a3bda38 100644
--- a/packages/slate-html-serializer/test/deserialize/multiple-matching-rules.js
+++ b/packages/slate-html-serializer/test/deserialize/multiple-matching-rules.js
@@ -8,7 +8,7 @@ export const config = {
{
deserialize(el, next) {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
}
}
@@ -16,7 +16,7 @@ export const config = {
{
deserialize(el, next) {
return {
- kind: 'block',
+ object: 'block',
type: 'quote',
}
}
diff --git a/packages/slate-html-serializer/test/deserialize/no-next.js b/packages/slate-html-serializer/test/deserialize/no-next.js
index 7791b9cb6..7314513a4 100644
--- a/packages/slate-html-serializer/test/deserialize/no-next.js
+++ b/packages/slate-html-serializer/test/deserialize/no-next.js
@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(),
}
diff --git a/packages/slate-html-serializer/test/deserialize/skip-element.js b/packages/slate-html-serializer/test/deserialize/skip-element.js
index 3821d3ee8..4760bd96f 100644
--- a/packages/slate-html-serializer/test/deserialize/skip-element.js
+++ b/packages/slate-html-serializer/test/deserialize/skip-element.js
@@ -13,14 +13,14 @@ export const config = {
}
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'img': {
return {
- kind: 'block',
+ object: 'block',
type: 'image',
isVoid: true,
}
diff --git a/packages/slate-html-serializer/test/deserialize/to-json.js b/packages/slate-html-serializer/test/deserialize/to-json.js
index c1cd05721..ce760d836 100644
--- a/packages/slate-html-serializer/test/deserialize/to-json.js
+++ b/packages/slate-html-serializer/test/deserialize/to-json.js
@@ -6,7 +6,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
@@ -22,20 +22,20 @@ export const input = `
`.trim()
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
}
]
diff --git a/packages/slate-html-serializer/test/serialize/block-nested.js b/packages/slate-html-serializer/test/serialize/block-nested.js
index f8086eea9..533f95fc1 100644
--- a/packages/slate-html-serializer/test/serialize/block-nested.js
+++ b/packages/slate-html-serializer/test/serialize/block-nested.js
@@ -7,7 +7,7 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind != 'block') return
+ if (obj.object != 'block') return
switch (obj.type) {
case 'paragraph': return React.createElement('p', {}, children)
case 'quote': return React.createElement('blockquote', {}, children)
diff --git a/packages/slate-html-serializer/test/serialize/block-with-data.js b/packages/slate-html-serializer/test/serialize/block-with-data.js
index e2659582f..1b0b4299a 100644
--- a/packages/slate-html-serializer/test/serialize/block-with-data.js
+++ b/packages/slate-html-serializer/test/serialize/block-with-data.js
@@ -7,7 +7,7 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', { 'data-thing': obj.data.get('thing') }, children)
}
}
diff --git a/packages/slate-html-serializer/test/serialize/block-with-is-void.js b/packages/slate-html-serializer/test/serialize/block-with-is-void.js
index 09816ad71..c78a6287c 100644
--- a/packages/slate-html-serializer/test/serialize/block-with-is-void.js
+++ b/packages/slate-html-serializer/test/serialize/block-with-is-void.js
@@ -7,7 +7,7 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'image') {
+ if (obj.object == 'block' && obj.type == 'image') {
return React.createElement('img')
}
}
diff --git a/packages/slate-html-serializer/test/serialize/block-with-mark.js b/packages/slate-html-serializer/test/serialize/block-with-mark.js
index 8db81b998..ff3662e1c 100644
--- a/packages/slate-html-serializer/test/serialize/block-with-mark.js
+++ b/packages/slate-html-serializer/test/serialize/block-with-mark.js
@@ -7,11 +7,11 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
- if (obj.kind == 'mark' && obj.type == 'bold') {
+ if (obj.object == 'mark' && obj.type == 'bold') {
return React.createElement('strong', {}, children)
}
}
diff --git a/packages/slate-html-serializer/test/serialize/block.js b/packages/slate-html-serializer/test/serialize/block.js
index 6e027d779..aca85bb5c 100644
--- a/packages/slate-html-serializer/test/serialize/block.js
+++ b/packages/slate-html-serializer/test/serialize/block.js
@@ -7,7 +7,7 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
}
diff --git a/packages/slate-html-serializer/test/serialize/inline-nested.js b/packages/slate-html-serializer/test/serialize/inline-nested.js
index 491e58da0..9aedffe4a 100644
--- a/packages/slate-html-serializer/test/serialize/inline-nested.js
+++ b/packages/slate-html-serializer/test/serialize/inline-nested.js
@@ -7,15 +7,15 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
- if (obj.kind == 'inline' && obj.type == 'link') {
+ if (obj.object == 'inline' && obj.type == 'link') {
return React.createElement('a', {}, children)
}
- if (obj.kind == 'inline' && obj.type == 'hashtag') {
+ if (obj.object == 'inline' && obj.type == 'hashtag') {
return React.createElement('span', {}, children)
}
}
diff --git a/packages/slate-html-serializer/test/serialize/inline-with-data.js b/packages/slate-html-serializer/test/serialize/inline-with-data.js
index b56df68d0..4a9fab864 100644
--- a/packages/slate-html-serializer/test/serialize/inline-with-data.js
+++ b/packages/slate-html-serializer/test/serialize/inline-with-data.js
@@ -7,11 +7,11 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
- if (obj.kind == 'inline' && obj.type == 'link') {
+ if (obj.object == 'inline' && obj.type == 'link') {
return React.createElement('a', { href: obj.data.get('href') }, children)
}
}
diff --git a/packages/slate-html-serializer/test/serialize/inline-with-is-void.js b/packages/slate-html-serializer/test/serialize/inline-with-is-void.js
index 9ccf75aaa..ed951c904 100644
--- a/packages/slate-html-serializer/test/serialize/inline-with-is-void.js
+++ b/packages/slate-html-serializer/test/serialize/inline-with-is-void.js
@@ -7,11 +7,11 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
- if (obj.kind == 'inline' && obj.type == 'emoji') {
+ if (obj.object == 'inline' && obj.type == 'emoji') {
return React.createElement('img')
}
}
diff --git a/packages/slate-html-serializer/test/serialize/inline-with-mark.js b/packages/slate-html-serializer/test/serialize/inline-with-mark.js
index 964e125fd..2b22107eb 100644
--- a/packages/slate-html-serializer/test/serialize/inline-with-mark.js
+++ b/packages/slate-html-serializer/test/serialize/inline-with-mark.js
@@ -7,15 +7,15 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
- if (obj.kind == 'inline' && obj.type == 'link') {
+ if (obj.object == 'inline' && obj.type == 'link') {
return React.createElement('a', {}, children)
}
- if (obj.kind == 'mark' && obj.type == 'bold') {
+ if (obj.object == 'mark' && obj.type == 'bold') {
return React.createElement('strong', {}, children)
}
}
diff --git a/packages/slate-html-serializer/test/serialize/inline.js b/packages/slate-html-serializer/test/serialize/inline.js
index 09f87e9a6..4c625f509 100644
--- a/packages/slate-html-serializer/test/serialize/inline.js
+++ b/packages/slate-html-serializer/test/serialize/inline.js
@@ -7,11 +7,11 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
- if (obj.kind == 'inline' && obj.type == 'link') {
+ if (obj.object == 'inline' && obj.type == 'link') {
return React.createElement('a', {}, children)
}
}
diff --git a/packages/slate-html-serializer/test/serialize/multiple-rules.js b/packages/slate-html-serializer/test/serialize/multiple-rules.js
index 9884d2b34..549f7d8d5 100644
--- a/packages/slate-html-serializer/test/serialize/multiple-rules.js
+++ b/packages/slate-html-serializer/test/serialize/multiple-rules.js
@@ -11,7 +11,7 @@ export const rules = [
},
{
serialize(obj, children) {
- if (obj.kind == 'block' && obj.type == 'paragraph') {
+ if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
}
diff --git a/packages/slate-hyperscript/src/index.js b/packages/slate-hyperscript/src/index.js
index c21bb7e13..caa67803b 100644
--- a/packages/slate-hyperscript/src/index.js
+++ b/packages/slate-hyperscript/src/index.js
@@ -270,15 +270,15 @@ function resolveCreators(options) {
}
/**
- * Normalize a node creator with `key` and `value`, of `kind`.
+ * Normalize a node creator with `key` and `value`, of `object`.
*
* @param {String} key
* @param {Function|Object|String} value
- * @param {String} kind
+ * @param {String} object
* @return {Function}
*/
-function normalizeNode(key, value, kind) {
+function normalizeNode(key, value, object) {
if (typeof value == 'function') {
return value
}
@@ -292,7 +292,7 @@ function normalizeNode(key, value, kind) {
const { key: attrKey, ...rest } = attributes
const attrs = {
...value,
- kind,
+ object,
key: attrKey,
data: {
...(value.data || {}),
@@ -300,11 +300,11 @@ function normalizeNode(key, value, kind) {
}
}
- return CREATORS[kind](tagName, attrs, children)
+ return CREATORS[object](tagName, attrs, children)
}
}
- throw new Error(`Slate hyperscript ${kind} creators can be either functions, objects or strings, but you passed: ${value}`)
+ throw new Error(`Slate hyperscript ${object} creators can be either functions, objects or strings, but you passed: ${value}`)
}
/**
diff --git a/packages/slate-plain-serializer/src/index.js b/packages/slate-plain-serializer/src/index.js
index c608fef8b..4856d045a 100644
--- a/packages/slate-plain-serializer/src/index.js
+++ b/packages/slate-plain-serializer/src/index.js
@@ -28,22 +28,22 @@ function deserialize(string, options = {}) {
defaultMarks = defaultMarks.map(Mark.createProperties)
const json = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: string.split('\n').map((line) => {
return {
...defaultBlock,
- kind: 'block',
+ object: 'block',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: line,
marks: defaultMarks,
}
@@ -79,8 +79,8 @@ function serialize(value) {
function serializeNode(node) {
if (
- (node.kind == 'document') ||
- (node.kind == 'block' && Block.isBlockList(node.nodes))
+ (node.object == 'document') ||
+ (node.object == 'block' && Block.isBlockList(node.nodes))
) {
return node.nodes.map(serializeNode).join('\n')
} else {
diff --git a/packages/slate-plain-serializer/test/deserialize/to-json.js b/packages/slate-plain-serializer/test/deserialize/to-json.js
index cee2acd23..28e674a3d 100644
--- a/packages/slate-plain-serializer/test/deserialize/to-json.js
+++ b/packages/slate-plain-serializer/test/deserialize/to-json.js
@@ -4,22 +4,22 @@ one
`.trim()
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'line',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
diff --git a/packages/slate-react/src/components/node.js b/packages/slate-react/src/components/node.js
index 275b1fc6a..c2c66820c 100644
--- a/packages/slate-react/src/components/node.js
+++ b/packages/slate-react/src/components/node.js
@@ -131,7 +131,7 @@ class Node extends React.Component {
// If it's a block node with inline children, add the proper `dir` attribute
// for text direction.
- if (node.kind == 'block' && node.nodes.first().kind != 'block') {
+ if (node.object == 'block' && node.nodes.first().object != 'block') {
const direction = node.getTextDirection()
if (direction == 'rtl') attributes.dir = 'rtl'
}
@@ -170,11 +170,11 @@ class Node extends React.Component {
renderNode = (child, isSelected) => {
const { block, decorations, editor, node, readOnly } = this.props
const { stack } = editor
- const Component = child.kind == 'text' ? Text : Node
+ const Component = child.object == 'text' ? Text : Node
const decs = decorations.concat(node.getDecorations(stack))
return (
{children}
}
@@ -631,7 +631,7 @@ function AfterPlugin() {
const { editor, node } = props
if (!editor.props.placeholder) return
if (editor.state.isComposing) return
- if (node.kind != 'block') return
+ if (node.object != 'block') return
if (!Text.isTextList(node.nodes)) return
if (node.text != '') return
if (editor.value.document.getBlocks().size > 1) return
diff --git a/packages/slate-react/src/utils/get-event-range.js b/packages/slate-react/src/utils/get-event-range.js
index 025b48964..749cf4320 100644
--- a/packages/slate-react/src/utils/get-event-range.js
+++ b/packages/slate-react/src/utils/get-event-range.js
@@ -30,7 +30,7 @@ function getEventRange(event, value) {
// closest to.
if (node.isVoid) {
const rect = target.getBoundingClientRect()
- const isPrevious = node.kind == 'inline'
+ const isPrevious = node.object == 'inline'
? x - rect.left < rect.left + rect.width - x
: y - rect.top < rect.top + rect.height - y
diff --git a/packages/slate/benchmark/models/from-json.js b/packages/slate/benchmark/models/from-json.js
index 20cf7357f..6b4ca1abc 100644
--- a/packages/slate/benchmark/models/from-json.js
+++ b/packages/slate/benchmark/models/from-json.js
@@ -9,15 +9,15 @@ export default function (json) {
export const input = {
document: {
nodes: Array.from(Array(10)).map(() => ({
- kind: 'block',
+ object: 'block',
type: 'quote',
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'This is editable ',
diff --git a/packages/slate/src/changes/at-range.js b/packages/slate/src/changes/at-range.js
index 88378c840..f5823b356 100644
--- a/packages/slate/src/changes/at-range.js
+++ b/packages/slate/src/changes/at-range.js
@@ -299,7 +299,7 @@ Changes.deleteLineBackwardAtRange = (change, range, options) => {
const startWithVoidInline = (
startBlock.nodes.size > 1 &&
startBlock.nodes.get(0).text == '' &&
- startBlock.nodes.get(1).kind == 'inline'
+ startBlock.nodes.get(1).object == 'inline'
)
let o = offset + startOffset
@@ -992,7 +992,7 @@ Changes.splitBlockAtRange = (change, range, height = 1, options = {}) => {
let parent = document.getClosestBlock(node.key)
let h = 0
- while (parent && parent.kind == 'block' && h < height) {
+ while (parent && parent.object == 'block' && h < height) {
node = parent
parent = document.getClosestBlock(parent.key)
h++
@@ -1026,7 +1026,7 @@ Changes.splitInlineAtRange = (change, range, height = Infinity, options = {}) =>
let parent = document.getClosestInline(node.key)
let h = 0
- while (parent && parent.kind == 'inline' && h < height) {
+ while (parent && parent.object == 'inline' && h < height) {
node = parent
parent = document.getClosestInline(parent.key)
h++
@@ -1084,7 +1084,7 @@ Changes.unwrapBlockAtRange = (change, range, properties, options = {}) => {
const wrappers = blocks
.map((block) => {
return document.getClosest(block.key, (parent) => {
- if (parent.kind != 'block') return false
+ if (parent.object != 'block') return false
if (properties.type != null && parent.type != properties.type) return false
if (properties.isVoid != null && parent.isVoid != properties.isVoid) return false
if (properties.data != null && !parent.data.isSuperset(properties.data)) return false
@@ -1176,7 +1176,7 @@ Changes.unwrapInlineAtRange = (change, range, properties, options = {}) => {
const inlines = texts
.map((text) => {
return document.getClosest(text.key, (parent) => {
- if (parent.kind != 'inline') return false
+ if (parent.object != 'inline') return false
if (properties.type != null && parent.type != properties.type) return false
if (properties.isVoid != null && parent.isVoid != properties.isVoid) return false
if (properties.data != null && !parent.data.isSuperset(properties.data)) return false
diff --git a/packages/slate/src/changes/by-key.js b/packages/slate/src/changes/by-key.js
index d3bf33892..791f52259 100644
--- a/packages/slate/src/changes/by-key.js
+++ b/packages/slate/src/changes/by-key.js
@@ -179,7 +179,7 @@ Changes.mergeNodeByKey = (change, key, options = {}) => {
throw new Error(`Unable to merge node with key "${key}", no previous key.`)
}
- const position = previous.kind == 'text' ? previous.text.length : previous.nodes.size
+ const position = previous.object == 'text' ? previous.text.length : previous.nodes.size
change.applyOperation({
type: 'merge_node',
@@ -300,7 +300,7 @@ Changes.removeAllMarksByKey = (change, key, options = {}) => {
const { state } = change
const { document } = state
const node = document.getNode(key)
- const texts = node.kind === 'text' ? [node] : node.getTextsAsArray()
+ const texts = node.object === 'text' ? [node] : node.getTextsAsArray()
texts.forEach((text) => {
text.getMarksAsArray().forEach((mark) => {
@@ -711,12 +711,12 @@ Changes.wrapNodeByKey = (change, key, parent) => {
parent = Node.create(parent)
parent = parent.set('nodes', parent.nodes.clear())
- if (parent.kind == 'block') {
+ if (parent.object == 'block') {
change.wrapBlockByKey(key, parent)
return
}
- if (parent.kind == 'inline') {
+ if (parent.object == 'inline') {
change.wrapInlineByKey(key, parent)
return
}
diff --git a/packages/slate/src/changes/on-selection.js b/packages/slate/src/changes/on-selection.js
index 2853fb294..9f6af8b70 100644
--- a/packages/slate/src/changes/on-selection.js
+++ b/packages/slate/src/changes/on-selection.js
@@ -346,7 +346,7 @@ const DIRECTIONS = [
'Previous',
]
-const KINDS = [
+const OBJECTS = [
'Block',
'Inline',
'Text',
@@ -365,10 +365,10 @@ PREFIXES.forEach((prefix) => {
edges.forEach((edge) => {
const method = `${prefix}${edge}Of`
- KINDS.forEach((kind) => {
- const getNode = kind == 'Text' ? 'getNode' : `getClosest${kind}`
+ OBJECTS.forEach((object) => {
+ const getNode = object == 'Text' ? 'getNode' : `getClosest${object}`
- Changes[`${method}${kind}`] = (change) => {
+ Changes[`${method}${object}`] = (change) => {
const { value } = change
const { document, selection } = value
const node = document[getNode](selection.startKey)
@@ -377,10 +377,10 @@ PREFIXES.forEach((prefix) => {
}
DIRECTIONS.forEach((direction) => {
- const getDirectionNode = `get${direction}${kind}`
+ const getDirectionNode = `get${direction}${object}`
const directionKey = direction == 'Next' ? 'startKey' : 'endKey'
- Changes[`${method}${direction}${kind}`] = (change) => {
+ Changes[`${method}${direction}${object}`] = (change) => {
const { value } = change
const { document, selection } = value
const node = document[getNode](selection[directionKey])
diff --git a/packages/slate/src/changes/with-schema.js b/packages/slate/src/changes/with-schema.js
index 879fd7209..ce0595497 100644
--- a/packages/slate/src/changes/with-schema.js
+++ b/packages/slate/src/changes/with-schema.js
@@ -63,7 +63,7 @@ Changes.normalizeNodeByKey = (change, key) => {
*/
function normalizeNodeAndChildren(change, node, schema) {
- if (node.kind == 'text') {
+ if (node.object == 'text') {
normalizeNode(change, node, schema)
return
}
@@ -124,7 +124,7 @@ function normalizeNodeAndChildren(change, node, schema) {
function refindNode(change, node) {
const { value } = change
const { document } = value
- return node.kind == 'document'
+ return node.object == 'document'
? document
: document.getDescendant(node.key)
}
diff --git a/packages/slate/src/constants/core-schema-rules.js b/packages/slate/src/constants/core-schema-rules.js
index 746abfd00..ba54e78bd 100644
--- a/packages/slate/src/constants/core-schema-rules.js
+++ b/packages/slate/src/constants/core-schema-rules.js
@@ -19,8 +19,8 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
- if (node.kind != 'document') return
- const invalids = node.nodes.filter(n => n.kind != 'block')
+ if (node.object != 'document') return
+ const invalids = node.nodes.filter(n => n.object != 'block')
if (!invalids.size) return
return (change) => {
@@ -39,11 +39,11 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
- if (node.kind != 'block') return
+ if (node.object != 'block') return
const first = node.nodes.first()
if (!first) return
- const kinds = first.kind == 'block' ? ['block'] : ['inline', 'text']
- const invalids = node.nodes.filter(n => !kinds.includes(n.kind))
+ const objects = first.object == 'block' ? ['block'] : ['inline', 'text']
+ const invalids = node.nodes.filter(n => !objects.includes(n.object))
if (!invalids.size) return
return (change) => {
@@ -62,8 +62,8 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
- if (node.kind != 'inline') return
- const invalids = node.nodes.filter(n => n.kind != 'inline' && n.kind != 'text')
+ if (node.object != 'inline') return
+ const invalids = node.nodes.filter(n => n.object != 'inline' && n.object != 'text')
if (!invalids.size) return
return (change) => {
@@ -82,7 +82,7 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
- if (node.kind != 'block' && node.kind != 'inline') return
+ if (node.object != 'block' && node.object != 'inline') return
if (node.nodes.size > 0) return
return (change) => {
@@ -101,7 +101,7 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (!node.isVoid) return
- if (node.kind != 'block' && node.kind != 'inline') return
+ if (node.object != 'block' && node.object != 'inline') return
if (node.text == ' ' && node.nodes.size == 1) return
return (change) => {
@@ -130,8 +130,8 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
- if (node.kind != 'block') return
- const invalids = node.nodes.filter(n => n.kind == 'inline' && n.text == '')
+ if (node.object != 'block') return
+ const invalids = node.nodes.filter(n => n.object == 'inline' && n.text == '')
if (!invalids.size) return
return (change) => {
@@ -158,16 +158,16 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
- if (node.kind != 'block' && node.kind != 'inline') return
+ if (node.object != 'block' && node.object != 'inline') return
const invalids = node.nodes.reduce((list, child, index) => {
- if (child.kind !== 'inline') return list
+ if (child.object !== 'inline') return list
const prev = index > 0 ? node.nodes.get(index - 1) : null
const next = node.nodes.get(index + 1)
// We don't test if "prev" is inline, since it has already been processed in the loop
const insertBefore = !prev
- const insertAfter = !next || (next.kind == 'inline')
+ const insertAfter = !next || (next.object == 'inline')
if (insertAfter || insertBefore) {
list = list.push({ insertAfter, insertBefore, index })
@@ -205,13 +205,13 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
- if (node.kind != 'block' && node.kind != 'inline') return
+ if (node.object != 'block' && node.object != 'inline') return
const invalids = node.nodes
.map((child, i) => {
const next = node.nodes.get(i + 1)
- if (child.kind != 'text') return
- if (!next || next.kind != 'text') return
+ if (child.object != 'text') return
+ if (!next || next.object != 'text') return
return next
})
.filter(Boolean)
@@ -236,25 +236,25 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
- if (node.kind != 'block' && node.kind != 'inline') return
+ if (node.object != 'block' && node.object != 'inline') return
const { nodes } = node
if (nodes.size <= 1) return
const invalids = nodes.filter((desc, i) => {
- if (desc.kind != 'text') return
+ if (desc.object != 'text') return
if (desc.text.length > 0) return
const prev = i > 0 ? nodes.get(i - 1) : null
const next = nodes.get(i + 1)
// If it's the first node, and the next is a void, preserve it.
- if (!prev && next.kind == 'inline') return
+ if (!prev && next.object == 'inline') return
// It it's the last node, and the previous is an inline, preserve it.
- if (!next && prev.kind == 'inline') return
+ if (!next && prev.object == 'inline') return
// If it's surrounded by inlines, preserve it.
- if (next && prev && next.kind == 'inline' && prev.kind == 'inline') return
+ if (next && prev && next.object == 'inline' && prev.object == 'inline') return
// Otherwise, remove it.
return true
diff --git a/packages/slate/src/models/block.js b/packages/slate/src/models/block.js
index 88ffa5087..fb7b956ae 100644
--- a/packages/slate/src/models/block.js
+++ b/packages/slate/src/models/block.js
@@ -10,6 +10,7 @@ import './document'
*/
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, Map, Record } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -141,15 +142,20 @@ class Block extends Record(DEFAULTS) {
}
/**
- * Get the node's kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'block'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Check if the block is empty.
*
@@ -179,7 +185,7 @@ class Block extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
- kind: this.kind,
+ object: this.object,
type: this.type,
isVoid: this.isVoid,
data: this.data.toJSON(),
diff --git a/packages/slate/src/models/change.js b/packages/slate/src/models/change.js
index 6bae46d01..2596c43ec 100644
--- a/packages/slate/src/models/change.js
+++ b/packages/slate/src/models/change.js
@@ -1,6 +1,7 @@
import Debug from 'debug'
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import pick from 'lodash/pick'
import { List } from 'immutable'
@@ -51,15 +52,20 @@ class Change {
}
/**
- * Get the kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'change'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Apply an `operation` to the current value, saving the operation to the
* history if needed.
diff --git a/packages/slate/src/models/character.js b/packages/slate/src/models/character.js
index 6509c1d3b..b8a3572aa 100644
--- a/packages/slate/src/models/character.js
+++ b/packages/slate/src/models/character.js
@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, Record, Set } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -120,15 +121,20 @@ class Character extends Record(DEFAULTS) {
}
/**
- * Get the kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'character'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Return a JSON representation of the character.
*
@@ -137,7 +143,7 @@ class Character extends Record(DEFAULTS) {
toJSON() {
const object = {
- kind: this.kind,
+ object: this.object,
text: this.text,
marks: this.marks.toArray().map(m => m.toJSON()),
}
diff --git a/packages/slate/src/models/document.js b/packages/slate/src/models/document.js
index 575d7da8e..a316520f1 100644
--- a/packages/slate/src/models/document.js
+++ b/packages/slate/src/models/document.js
@@ -11,6 +11,7 @@ import './inline'
*/
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, Map, Record } from 'immutable'
import Node from './node'
@@ -105,15 +106,20 @@ class Document extends Record(DEFAULTS) {
}
/**
- * Get the node's kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'document'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Check if the document is empty.
*
@@ -143,7 +149,7 @@ class Document extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
- kind: this.kind,
+ object: this.object,
data: this.data.toJSON(),
nodes: this.nodes.toArray().map(n => n.toJSON(options)),
}
diff --git a/packages/slate/src/models/history.js b/packages/slate/src/models/history.js
index cdd0b8c63..f36dd6d96 100644
--- a/packages/slate/src/models/history.js
+++ b/packages/slate/src/models/history.js
@@ -2,6 +2,7 @@
import Debug from 'debug'
import isEqual from 'lodash/isEqual'
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, Record, Stack } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -91,15 +92,20 @@ class History extends Record(DEFAULTS) {
}
/**
- * Get the kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'history'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Save an `operation` into the history.
*
@@ -161,7 +167,7 @@ class History extends Record(DEFAULTS) {
toJSON() {
const object = {
- kind: this.kind,
+ object: this.object,
redos: this.redos.toJSON(),
undos: this.undos.toJSON(),
}
diff --git a/packages/slate/src/models/inline.js b/packages/slate/src/models/inline.js
index 17357342d..6bcea0e60 100644
--- a/packages/slate/src/models/inline.js
+++ b/packages/slate/src/models/inline.js
@@ -10,6 +10,7 @@ import './document'
*/
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, Map, Record } from 'immutable'
import Node from './node'
@@ -141,15 +142,20 @@ class Inline extends Record(DEFAULTS) {
}
/**
- * Get the node's kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'inline'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Check if the inline is empty.
*
@@ -179,7 +185,7 @@ class Inline extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
- kind: this.kind,
+ object: this.object,
type: this.type,
isVoid: this.isVoid,
data: this.data.toJSON(),
diff --git a/packages/slate/src/models/leaf.js b/packages/slate/src/models/leaf.js
index f81ed85b1..8aabad780 100644
--- a/packages/slate/src/models/leaf.js
+++ b/packages/slate/src/models/leaf.js
@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, Record, Set } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -114,15 +115,20 @@ class Leaf extends Record(DEFAULTS) {
}
/**
- * Get the node's kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'leaf'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Return leaf as a list of characters
*
@@ -151,7 +157,7 @@ class Leaf extends Record(DEFAULTS) {
toJSON() {
const object = {
- kind: this.kind,
+ object: this.object,
text: this.text,
marks: this.marks.toArray().map(m => m.toJSON()),
}
diff --git a/packages/slate/src/models/mark.js b/packages/slate/src/models/mark.js
index fd0c949ba..5f6792597 100644
--- a/packages/slate/src/models/mark.js
+++ b/packages/slate/src/models/mark.js
@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { Map, Record, Set } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -151,13 +152,18 @@ class Mark extends Record(DEFAULTS) {
}
/**
- * Get the kind.
+ * Object.
*/
- get kind() {
+ get object() {
return 'mark'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Get the component for the node from a `schema`.
*
@@ -177,7 +183,7 @@ class Mark extends Record(DEFAULTS) {
toJSON() {
const object = {
- kind: this.kind,
+ object: this.object,
type: this.type,
data: this.data.toJSON(),
}
diff --git a/packages/slate/src/models/node.js b/packages/slate/src/models/node.js
index 81ea17f73..544c9f979 100644
--- a/packages/slate/src/models/node.js
+++ b/packages/slate/src/models/node.js
@@ -1,6 +1,7 @@
import direction from 'direction'
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, OrderedSet, Set } from 'immutable'
import Block from './block'
@@ -37,13 +38,20 @@ class Node {
}
if (isPlainObject(attrs)) {
- switch (attrs.kind) {
+ let { object } = attrs
+
+ if (!object && attrs.kind) {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ object = attrs.kind
+ }
+
+ switch (object) {
case 'block': return Block.create(attrs)
case 'document': return Document.create(attrs)
case 'inline': return Inline.create(attrs)
case 'text': return Text.create(attrs)
default: {
- throw new Error('`Node.create` requires a `kind` string.')
+ throw new Error('`Node.create` requires a `object` string.')
}
}
}
@@ -99,22 +107,27 @@ class Node {
}
/**
- * Create a `Node` from a JSON `object`.
+ * Create a `Node` from a JSON `value`.
*
- * @param {Object} object
+ * @param {Object} value
* @return {Node}
*/
- static fromJSON(object) {
- const { kind } = object
+ static fromJSON(value) {
+ let { object } = value
- switch (kind) {
- case 'block': return Block.fromJSON(object)
- case 'document': return Document.fromJSON(object)
- case 'inline': return Inline.fromJSON(object)
- case 'text': return Text.fromJSON(object)
+ if (!object && value.kind) {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ object = value.kind
+ }
+
+ switch (object) {
+ case 'block': return Block.fromJSON(value)
+ case 'document': return Document.fromJSON(value)
+ case 'inline': return Inline.fromJSON(value)
+ case 'text': return Text.fromJSON(value)
default: {
- throw new Error(`\`Node.fromJSON\` requires a \`kind\` of either 'block', 'document', 'inline' or 'text', but you passed: ${kind}`)
+ throw new Error(`\`Node.fromJSON\` requires an \`object\` of either 'block', 'document', 'inline' or 'text', but you passed: ${value}`)
}
}
}
@@ -297,7 +310,7 @@ class Node {
return false
}
- if (child.kind != 'text') {
+ if (child.object != 'text') {
ret = child.forEachDescendant(iterator)
return ret
}
@@ -321,7 +334,7 @@ class Node {
let ancestors
this.nodes.find((node) => {
- if (node.kind == 'text') return false
+ if (node.object == 'text') return false
ancestors = node.getAncestors(key)
return ancestors
})
@@ -352,7 +365,7 @@ class Node {
getBlocksAsArray() {
return this.nodes.reduce((array, child) => {
- if (child.kind != 'block') return array
+ if (child.object != 'block') return array
if (!child.isLeafBlock()) return array.concat(child.getBlocksAsArray())
array.push(child)
return array
@@ -418,7 +431,7 @@ class Node {
getBlocksByTypeAsArray(type) {
return this.nodes.reduce((array, node) => {
- if (node.kind != 'block') {
+ if (node.object != 'block') {
return array
} else if (node.isLeafBlock() && node.type == type) {
array.push(node)
@@ -448,7 +461,7 @@ class Node {
getCharactersAsArray() {
return this.nodes.reduce((arr, node) => {
- return node.kind == 'text'
+ return node.object == 'text'
? arr.concat(node.characters.toArray())
: arr.concat(node.getCharactersAsArray())
}, [])
@@ -527,7 +540,7 @@ class Node {
*/
getClosestBlock(key) {
- return this.getClosest(key, parent => parent.kind == 'block')
+ return this.getClosest(key, parent => parent.object == 'block')
}
/**
@@ -538,7 +551,7 @@ class Node {
*/
getClosestInline(key) {
- return this.getClosest(key, parent => parent.kind == 'inline')
+ return this.getClosest(key, parent => parent.object == 'inline')
}
/**
@@ -627,7 +640,7 @@ class Node {
const found = this.nodes.find((node) => {
if (node.key === key) {
return node
- } else if (node.kind !== 'text') {
+ } else if (node.object !== 'text') {
descendantFound = node.getDescendant(key)
return descendantFound
} else {
@@ -667,7 +680,7 @@ class Node {
let descendantFound = null
const found = this.nodes.find((node) => {
- if (node.kind == 'text') return true
+ if (node.object == 'text') return true
descendantFound = node.getFirstText()
return descendantFound
})
@@ -700,7 +713,7 @@ class Node {
while (parent = node.getParent(child.key)) {
const index = parent.nodes.indexOf(child)
- const position = child.kind == 'text'
+ const position = child.object == 'text'
? startOffset
: child.nodes.indexOf(previous)
@@ -714,7 +727,7 @@ class Node {
while (parent = node.getParent(child.key)) {
const index = parent.nodes.indexOf(child)
- const position = child.kind == 'text'
+ const position = child.object == 'text'
? startKey == endKey ? endOffset - startOffset : endOffset
: child.nodes.indexOf(previous)
@@ -766,7 +779,7 @@ class Node {
*/
getFurthestBlock(key) {
- return this.getFurthest(key, node => node.kind == 'block')
+ return this.getFurthest(key, node => node.object == 'block')
}
/**
@@ -777,7 +790,7 @@ class Node {
*/
getFurthestInline(key) {
- return this.getFurthest(key, node => node.kind == 'inline')
+ return this.getFurthest(key, node => node.object == 'inline')
}
/**
@@ -791,7 +804,7 @@ class Node {
key = assertKey(key)
return this.nodes.find((node) => {
if (node.key == key) return true
- if (node.kind == 'text') return false
+ if (node.object == 'text') return false
return node.hasDescendant(key)
})
}
@@ -841,7 +854,7 @@ class Node {
let array = []
this.nodes.forEach((child) => {
- if (child.kind == 'text') return
+ if (child.object == 'text') return
if (child.isLeafInline()) {
array.push(child)
} else {
@@ -903,7 +916,7 @@ class Node {
getInlinesByTypeAsArray(type) {
return this.nodes.reduce((inlines, node) => {
- if (node.kind == 'text') {
+ if (node.object == 'text') {
return inlines
} else if (node.isLeafInline() && node.type == type) {
inlines.push(node)
@@ -951,7 +964,7 @@ class Node {
let descendantFound = null
const found = this.nodes.findLast((node) => {
- if (node.kind == 'text') return true
+ if (node.object == 'text') return true
descendantFound = node.getLastText()
return descendantFound
})
@@ -1142,7 +1155,7 @@ class Node {
getMarksByTypeAsArray(type) {
return this.nodes.reduce((array, node) => {
- return node.kind == 'text'
+ return node.object == 'text'
? array.concat(node.getMarksAsArray().filter(m => m.type == type))
: array.concat(node.getMarksByTypeAsArray(type))
}, [])
@@ -1159,7 +1172,7 @@ class Node {
const child = this.assertDescendant(key)
let last
- if (child.kind == 'block') {
+ if (child.object == 'block') {
last = child.getLastText()
} else {
const block = this.getClosestBlock(key)
@@ -1286,7 +1299,7 @@ class Node {
let node = null
this.nodes.find((child) => {
- if (child.kind == 'text') {
+ if (child.object == 'text') {
return false
} else {
node = child.getParent(key)
@@ -1340,7 +1353,7 @@ class Node {
const child = this.assertDescendant(key)
let first
- if (child.kind == 'block') {
+ if (child.object == 'block') {
first = child.getFirstText()
} else {
const block = this.getClosestBlock(key)
@@ -1423,7 +1436,7 @@ class Node {
let end = null
this.nodes.forEach((child, i) => {
- if (child.kind == 'text') {
+ if (child.object == 'text') {
if (start == null && child.key == startKey) start = i
if (end == null && child.key == endKey) end = i + 1
} else {
@@ -1507,7 +1520,7 @@ class Node {
let array = []
this.nodes.forEach((node) => {
- if (node.kind == 'text') {
+ if (node.object == 'text') {
array.push(node)
} else {
array = array.concat(node.getTextsAsArray())
@@ -1613,7 +1626,7 @@ class Node {
node = node.regenerateKey()
}
- if (node.kind != 'text') {
+ if (node.object != 'text') {
node = node.mapDescendants((desc) => {
return keys.contains(desc.key)
? desc.regenerateKey()
@@ -1676,8 +1689,8 @@ class Node {
isLeafBlock() {
return (
- this.kind == 'block' &&
- this.nodes.every(n => n.kind != 'block')
+ this.object == 'block' &&
+ this.nodes.every(n => n.object != 'block')
)
}
@@ -1689,8 +1702,8 @@ class Node {
isLeafInline() {
return (
- this.kind == 'inline' &&
- this.nodes.every(n => n.kind != 'inline')
+ this.object == 'inline' &&
+ this.nodes.every(n => n.object != 'inline')
)
}
@@ -1709,12 +1722,12 @@ class Node {
let one = node.nodes.get(withIndex)
const two = node.nodes.get(index)
- if (one.kind != two.kind) {
- throw new Error(`Tried to merge two nodes of different kinds: "${one.kind}" and "${two.kind}".`)
+ if (one.object != two.object) {
+ throw new Error(`Tried to merge two nodes of different objects: "${one.object}" and "${two.object}".`)
}
// If the nodes are text nodes, concatenate their characters together.
- if (one.kind == 'text') {
+ if (one.object == 'text') {
const characters = one.characters.concat(two.characters)
one = one.set('characters', characters)
}
@@ -1763,7 +1776,7 @@ class Node {
nodes.forEach((node, i) => {
let ret = node
- if (ret.kind != 'text') ret = ret.mapDescendants(iterator)
+ if (ret.object != 'text') ret = ret.mapDescendants(iterator)
ret = iterator(ret, i, this.nodes)
if (ret == node) return
@@ -1835,7 +1848,7 @@ class Node {
// If the child is a text node, the `position` refers to the text offset at
// which to split it.
- if (child.kind == 'text') {
+ if (child.object == 'text') {
const befores = child.characters.take(position)
const afters = child.characters.skip(position)
one = child.set('characters', befores)
diff --git a/packages/slate/src/models/operation.js b/packages/slate/src/models/operation.js
index faec20ee6..8bb220a0c 100644
--- a/packages/slate/src/models/operation.js
+++ b/packages/slate/src/models/operation.js
@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, Record } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -194,15 +195,20 @@ class Operation extends Record(DEFAULTS) {
}
/**
- * Get the node's kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'operation'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Return a JSON representation of the operation.
*
@@ -211,8 +217,8 @@ class Operation extends Record(DEFAULTS) {
*/
toJSON(options = {}) {
- const { kind, type } = this
- const object = { kind, type }
+ const { object, type } = this
+ const json = { object, type }
const ATTRIBUTES = OPERATION_ATTRIBUTES[type]
for (const key of ATTRIBUTES) {
@@ -264,10 +270,10 @@ class Operation extends Record(DEFAULTS) {
value = v
}
- object[key] = value
+ json[key] = value
}
- return object
+ return json
}
/**
diff --git a/packages/slate/src/models/range.js b/packages/slate/src/models/range.js
index 2460c3016..7d983b9cf 100644
--- a/packages/slate/src/models/range.js
+++ b/packages/slate/src/models/range.js
@@ -151,15 +151,20 @@ class Range extends Record(DEFAULTS) {
}
/**
- * Get the kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'range'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Check whether the range is blurred.
*
@@ -315,7 +320,7 @@ class Range extends Record(DEFAULTS) {
*/
hasAnchorIn(node) {
- return node.kind == 'text'
+ return node.object == 'text'
? node.key == this.anchorKey
: this.anchorKey != null && node.hasDescendant(this.anchorKey)
}
@@ -371,7 +376,7 @@ class Range extends Record(DEFAULTS) {
*/
hasFocusIn(node) {
- return node.kind == 'text'
+ return node.object == 'text'
? node.key == this.focusKey
: this.focusKey != null && node.hasDescendant(this.focusKey)
}
@@ -698,7 +703,7 @@ class Range extends Record(DEFAULTS) {
}
// If the anchor node isn't a text node, match it to one.
- if (anchorNode.kind != 'text') {
+ if (anchorNode.object != 'text') {
logger.warn('The range anchor was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:', anchorNode)
const anchorText = anchorNode.getTextAtOffset(anchorOffset)
const offset = anchorNode.getOffset(anchorText.key)
@@ -707,7 +712,7 @@ class Range extends Record(DEFAULTS) {
}
// If the focus node isn't a text node, match it to one.
- if (focusNode.kind != 'text') {
+ if (focusNode.object != 'text') {
logger.warn('The range focus was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:', focusNode)
const focusText = focusNode.getTextAtOffset(focusOffset)
const offset = focusNode.getOffset(focusText.key)
@@ -742,7 +747,7 @@ class Range extends Record(DEFAULTS) {
toJSON() {
const object = {
- kind: this.kind,
+ object: this.object,
anchorKey: this.anchorKey,
anchorOffset: this.anchorOffset,
focusKey: this.focusKey,
@@ -861,7 +866,7 @@ ALIAS_METHODS.forEach(([ alias, method ]) => {
*/
function getFirst(node) {
- return node.kind == 'text' ? node : node.getFirstText()
+ return node.object == 'text' ? node : node.getFirstText()
}
/**
@@ -872,7 +877,7 @@ function getFirst(node) {
*/
function getLast(node) {
- return node.kind == 'text' ? node : node.getLastText()
+ return node.object == 'text' ? node : node.getLastText()
}
/**
diff --git a/packages/slate/src/models/schema.js b/packages/slate/src/models/schema.js
index 1fd6a02a8..58e351c49 100644
--- a/packages/slate/src/models/schema.js
+++ b/packages/slate/src/models/schema.js
@@ -1,6 +1,7 @@
import Debug from 'debug'
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import mergeWith from 'lodash/mergeWith'
import { Record } from 'immutable'
@@ -15,19 +16,19 @@ import memoize from '../utils/memoize'
* @type {Object}
*/
-const CHILD_KIND_INVALID = 'child_kind_invalid'
+const CHILD_OBJECT_INVALID = 'child_object_invalid'
const CHILD_REQUIRED = 'child_required'
const CHILD_TYPE_INVALID = 'child_type_invalid'
const CHILD_UNKNOWN = 'child_unknown'
-const FIRST_CHILD_KIND_INVALID = 'first_child_kind_invalid'
+const FIRST_CHILD_OBJECT_INVALID = 'first_child_object_invalid'
const FIRST_CHILD_TYPE_INVALID = 'first_child_type_invalid'
-const LAST_CHILD_KIND_INVALID = 'last_child_kind_invalid'
+const LAST_CHILD_OBJECT_INVALID = 'last_child_object_invalid'
const LAST_CHILD_TYPE_INVALID = 'last_child_type_invalid'
const NODE_DATA_INVALID = 'node_data_invalid'
const NODE_IS_VOID_INVALID = 'node_is_void_invalid'
const NODE_MARK_INVALID = 'node_mark_invalid'
const NODE_TEXT_INVALID = 'node_text_invalid'
-const PARENT_KIND_INVALID = 'parent_kind_invalid'
+const PARENT_OBJECT_INVALID = 'parent_object_invalid'
const PARENT_TYPE_INVALID = 'parent_type_invalid'
/**
@@ -128,15 +129,20 @@ class Schema extends Record(DEFAULTS) {
}
/**
- * Get the kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'schema'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Get the rule for an `object`.
*
@@ -145,7 +151,7 @@ class Schema extends Record(DEFAULTS) {
*/
getRule(object) {
- switch (object.kind) {
+ switch (object.object) {
case 'document': return this.document
case 'block': return this.blocks[object.type]
case 'inline': return this.inlines[object.type]
@@ -206,32 +212,32 @@ class Schema extends Record(DEFAULTS) {
normalize(change, reason, context) {
switch (reason) {
- case CHILD_KIND_INVALID:
+ case CHILD_OBJECT_INVALID:
case CHILD_TYPE_INVALID:
case CHILD_UNKNOWN:
- case FIRST_CHILD_KIND_INVALID:
+ case FIRST_CHILD_OBJECT_INVALID:
case FIRST_CHILD_TYPE_INVALID:
- case LAST_CHILD_KIND_INVALID:
+ case LAST_CHILD_OBJECT_INVALID:
case LAST_CHILD_TYPE_INVALID: {
const { child, node } = context
- return child.kind == 'text' && node.kind == 'block' && node.nodes.size == 1
+ return child.object == 'text' && node.object == 'block' && node.nodes.size == 1
? change.removeNodeByKey(node.key)
: change.removeNodeByKey(child.key)
}
case CHILD_REQUIRED:
case NODE_TEXT_INVALID:
- case PARENT_KIND_INVALID:
+ case PARENT_OBJECT_INVALID:
case PARENT_TYPE_INVALID: {
const { node } = context
- return node.kind == 'document'
+ return node.object == 'document'
? node.nodes.forEach(child => change.removeNodeByKey(child.key))
: change.removeNodeByKey(node.key)
}
case NODE_DATA_INVALID: {
const { node, key } = context
- return node.data.get(key) === undefined && node.kind != 'document'
+ return node.data.get(key) === undefined && node.object != 'document'
? change.removeNodeByKey(node.key)
: change.setNodeByKey(node.key, { data: node.data.delete(key) })
}
@@ -260,7 +266,7 @@ class Schema extends Record(DEFAULTS) {
const ret = this.stack.find('validateNode', node)
if (ret) return ret
- if (node.kind == 'text') return
+ if (node.object == 'text') return
const rule = this.getRule(node) || {}
const parents = this.getParentRules()
@@ -302,11 +308,11 @@ class Schema extends Record(DEFAULTS) {
}
if (rule.first != null) {
- const { kinds, types } = rule.first
+ const { objects, types } = rule.first
const child = node.nodes.first()
- if (child && kinds && !kinds.includes(child.kind)) {
- return this.fail(FIRST_CHILD_KIND_INVALID, { ...ctx, child })
+ if (child && objects && !objects.includes(child.object)) {
+ return this.fail(FIRST_CHILD_OBJECT_INVALID, { ...ctx, child })
}
if (child && types && !types.includes(child.type)) {
@@ -315,11 +321,11 @@ class Schema extends Record(DEFAULTS) {
}
if (rule.last != null) {
- const { kinds, types } = rule.last
+ const { objects, types } = rule.last
const child = node.nodes.last()
- if (child && kinds && !kinds.includes(child.kind)) {
- return this.fail(LAST_CHILD_KIND_INVALID, { ...ctx, child })
+ if (child && objects && !objects.includes(child.object)) {
+ return this.fail(LAST_CHILD_OBJECT_INVALID, { ...ctx, child })
}
if (child && types && !types.includes(child.type)) {
@@ -363,11 +369,11 @@ class Schema extends Record(DEFAULTS) {
}
while (nextChild()) {
- if (parents != null && child.kind != 'text' && child.type in parents) {
+ if (parents != null && child.object != 'text' && child.type in parents) {
const r = parents[child.type]
- if (r.parent.kinds != null && !r.parent.kinds.includes(node.kind)) {
- return this.fail(PARENT_KIND_INVALID, { node: child, parent: node, rule: r })
+ if (r.parent.objects != null && !r.parent.objects.includes(node.object)) {
+ return this.fail(PARENT_OBJECT_INVALID, { node: child, parent: node, rule: r })
}
if (r.parent.types != null && !r.parent.types.includes(node.type)) {
@@ -380,12 +386,12 @@ class Schema extends Record(DEFAULTS) {
return this.fail(CHILD_UNKNOWN, { ...ctx, child, index })
}
- if (def.kinds != null && !def.kinds.includes(child.kind)) {
+ if (def.objects != null && !def.objects.includes(child.object)) {
if (offset >= min && nextDef()) {
rewind()
continue
}
- return this.fail(CHILD_KIND_INVALID, { ...ctx, child, index })
+ return this.fail(CHILD_OBJECT_INVALID, { ...ctx, child, index })
}
if (def.types != null && !def.types.includes(child.type)) {
@@ -418,7 +424,7 @@ class Schema extends Record(DEFAULTS) {
toJSON() {
const object = {
- kind: this.kind,
+ object: this.object,
document: this.document,
blocks: this.blocks,
inlines: this.inlines,
@@ -501,13 +507,13 @@ function resolveDocumentRule(obj) {
/**
* Resolve a node rule with `type` from `obj`.
*
- * @param {String} kind
+ * @param {String} object
* @param {String} type
* @param {Object} obj
* @return {Object}
*/
-function resolveNodeRule(kind, type, obj) {
+function resolveNodeRule(object, type, obj) {
return {
data: {},
isVoid: null,
@@ -521,7 +527,7 @@ function resolveNodeRule(kind, type, obj) {
}
/**
- * A Lodash customizer for merging schema definitions. Special cases `kinds`
+ * A Lodash customizer for merging schema definitions. Special cases `objects`
* and `types` arrays to be unioned, and ignores new `null` values.
*
* @param {Mixed} target
@@ -530,7 +536,7 @@ function resolveNodeRule(kind, type, obj) {
*/
function customizer(target, source, key) {
- if (key == 'kinds' || key == 'types') {
+ if (key == 'objects' || key == 'types') {
return target == null ? source : target.concat(source)
} else {
return source == null ? target : source
diff --git a/packages/slate/src/models/stack.js b/packages/slate/src/models/stack.js
index dd4a6de0b..286b53108 100644
--- a/packages/slate/src/models/stack.js
+++ b/packages/slate/src/models/stack.js
@@ -1,4 +1,5 @@
+import logger from 'slate-dev-logger'
import { Record } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -46,15 +47,20 @@ class Stack extends Record(DEFAULTS) {
}
/**
- * Get the kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'stack'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Get all plugins with `property`.
*
diff --git a/packages/slate/src/models/text.js b/packages/slate/src/models/text.js
index 178a6b078..324cca4fa 100644
--- a/packages/slate/src/models/text.js
+++ b/packages/slate/src/models/text.js
@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { List, OrderedSet, Record, Set, is } from 'immutable'
import Character from './character'
@@ -130,15 +131,20 @@ class Text extends Record(DEFAULTS) {
}
/**
- * Get the node's kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'text'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Is the node empty?
*
@@ -430,7 +436,7 @@ class Text extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
- kind: this.kind,
+ object: this.object,
leaves: this.getLeaves().toArray().map(r => r.toJSON()),
}
diff --git a/packages/slate/src/models/value.js b/packages/slate/src/models/value.js
index d87358f44..eef489fdc 100644
--- a/packages/slate/src/models/value.js
+++ b/packages/slate/src/models/value.js
@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
+import logger from 'slate-dev-logger'
import { Record, Set, List, Map } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -151,15 +152,20 @@ class Value extends Record(DEFAULTS) {
}
/**
- * Get the kind.
+ * Object.
*
* @return {String}
*/
- get kind() {
+ get object() {
return 'value'
}
+ get kind() {
+ logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
+ return this.object
+ }
+
/**
* Are there undoable events?
*
@@ -628,7 +634,7 @@ class Value extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
- kind: this.kind,
+ object: this.object,
document: this.document.toJSON(options),
}
diff --git a/packages/slate/src/operations/apply.js b/packages/slate/src/operations/apply.js
index 90bbcacff..067d6d31a 100644
--- a/packages/slate/src/operations/apply.js
+++ b/packages/slate/src/operations/apply.js
@@ -111,7 +111,7 @@ const APPLIERS = {
// If the nodes are text nodes and the selection is inside the second node
// update it to refer to the first node instead.
- if (one.kind == 'text') {
+ if (one.object == 'text') {
const { anchorKey, anchorOffset, focusKey, focusOffset } = selection
let normalize = false
@@ -227,8 +227,8 @@ const APPLIERS = {
if (selection.isSet) {
const hasStartNode = node.hasNode(startKey)
const hasEndNode = node.hasNode(endKey)
- const first = node.kind == 'text' ? node : node.getFirstText() || node
- const last = node.kind == 'text' ? node : node.getLastText() || node
+ const first = node.object == 'text' ? node : node.getFirstText() || node
+ const last = node.object == 'text' ? node : node.getLastText() || node
const prev = document.getPreviousText(first.key)
const next = document.getNextText(last.key)
diff --git a/packages/slate/test/changes/by-key/replace-node-by-key/block.js b/packages/slate/test/changes/by-key/replace-node-by-key/block.js
index ae9a59688..56c9a12a1 100644
--- a/packages/slate/test/changes/by-key/replace-node-by-key/block.js
+++ b/packages/slate/test/changes/by-key/replace-node-by-key/block.js
@@ -3,7 +3,7 @@
import h from '../../../helpers/h'
export default function (change) {
- change.replaceNodeByKey('a', { kind: 'block', type: 'quote' })
+ change.replaceNodeByKey('a', { object: 'block', type: 'quote' })
}
export const input = (
diff --git a/packages/slate/test/changes/by-key/replace-node-by-key/inline.js b/packages/slate/test/changes/by-key/replace-node-by-key/inline.js
index c46ad81e0..141c1b9b2 100644
--- a/packages/slate/test/changes/by-key/replace-node-by-key/inline.js
+++ b/packages/slate/test/changes/by-key/replace-node-by-key/inline.js
@@ -3,7 +3,7 @@
import h from '../../../helpers/h'
export default function (change) {
- change.replaceNodeByKey('a', { kind: 'inline', type: 'emoji', isVoid: true })
+ change.replaceNodeByKey('a', { object: 'inline', type: 'emoji', isVoid: true })
}
export const input = (
diff --git a/packages/slate/test/changes/by-key/replace-node-by-key/text.js b/packages/slate/test/changes/by-key/replace-node-by-key/text.js
index eacc294f5..58bb89384 100644
--- a/packages/slate/test/changes/by-key/replace-node-by-key/text.js
+++ b/packages/slate/test/changes/by-key/replace-node-by-key/text.js
@@ -3,7 +3,7 @@
import h from '../../../helpers/h'
export default function (change) {
- change.replaceNodeByKey('a', { kind: 'text', leaves: [{ text: 'three' }] })
+ change.replaceNodeByKey('a', { object: 'text', leaves: [{ text: 'three' }] })
}
export const input = (
diff --git a/packages/slate/test/schema/core/block-create-text.js b/packages/slate/test/schema/core/block-create-text.js
index 89fcd4b97..58c2d5516 100644
--- a/packages/slate/test/schema/core/block-create-text.js
+++ b/packages/slate/test/schema/core/block-create-text.js
@@ -13,22 +13,22 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/schema/core/document-no-inline-children.js b/packages/slate/test/schema/core/document-no-inline-children.js
index d68f4d019..963d4c4f0 100644
--- a/packages/slate/test/schema/core/document-no-inline-children.js
+++ b/packages/slate/test/schema/core/document-no-inline-children.js
@@ -18,22 +18,22 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'two',
marks: [],
}
diff --git a/packages/slate/test/schema/core/document-no-text-children.js b/packages/slate/test/schema/core/document-no-text-children.js
index e6dc485ca..10c7bc881 100644
--- a/packages/slate/test/schema/core/document-no-text-children.js
+++ b/packages/slate/test/schema/core/document-no-text-children.js
@@ -16,22 +16,22 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'two',
marks: [],
}
diff --git a/packages/slate/test/schema/core/inline-no-block-children.js b/packages/slate/test/schema/core/inline-no-block-children.js
index 3239d387e..34739953c 100644
--- a/packages/slate/test/schema/core/inline-no-block-children.js
+++ b/packages/slate/test/schema/core/inline-no-block-children.js
@@ -20,38 +20,38 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'two',
marks: [],
}
@@ -60,10 +60,10 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/schema/core/inline-text-around.js b/packages/slate/test/schema/core/inline-text-around.js
index 24b6efefd..2d11c0df3 100644
--- a/packages/slate/test/schema/core/inline-text-around.js
+++ b/packages/slate/test/schema/core/inline-text-around.js
@@ -22,54 +22,54 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
@@ -78,26 +78,26 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'two',
marks: [],
}
@@ -106,10 +106,10 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
@@ -118,10 +118,10 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/schema/core/remove-empty-inline.js b/packages/slate/test/schema/core/remove-empty-inline.js
index 525ea3221..a6e541ac1 100644
--- a/packages/slate/test/schema/core/remove-empty-inline.js
+++ b/packages/slate/test/schema/core/remove-empty-inline.js
@@ -15,22 +15,22 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/schema/custom/child-kind-invalid-custom-optional-first.js b/packages/slate/test/schema/custom/child-kind-invalid-custom-optional-first.js
index 27d0bb5d5..0cd9809f4 100644
--- a/packages/slate/test/schema/custom/child-kind-invalid-custom-optional-first.js
+++ b/packages/slate/test/schema/custom/child-kind-invalid-custom-optional-first.js
@@ -7,11 +7,11 @@ export const schema = {
paragraph: {},
quote: {
nodes: [
- { kinds: ['block'], types: ['image'], min: 0, max: 1 },
- { kinds: ['block'], types: ['paragraph'], min: 1 }
+ { objects: ['block'], types: ['image'], min: 0, max: 1 },
+ { objects: ['block'], types: ['paragraph'], min: 1 }
],
normalize: (change, reason, { node, child }) => {
- if (reason == 'child_kind_invalid') {
+ if (reason == 'child_object_invalid') {
change.wrapBlockByKey(child.key, 'paragraph')
}
}
diff --git a/packages/slate/test/schema/custom/child-kind-invalid-custom.js b/packages/slate/test/schema/custom/child-kind-invalid-custom.js
index 15449f938..72d50065a 100644
--- a/packages/slate/test/schema/custom/child-kind-invalid-custom.js
+++ b/packages/slate/test/schema/custom/child-kind-invalid-custom.js
@@ -7,10 +7,10 @@ export const schema = {
paragraph: {},
quote: {
nodes: [
- { kinds: ['block'] },
+ { objects: ['block'] },
],
normalize: (change, reason, { child }) => {
- if (reason == 'child_kind_invalid') {
+ if (reason == 'child_object_invalid') {
change.wrapBlockByKey(child.key, 'paragraph')
}
}
diff --git a/packages/slate/test/schema/custom/child-kind-invalid-default.js b/packages/slate/test/schema/custom/child-kind-invalid-default.js
index 0d8fd65cc..f6f7186ef 100644
--- a/packages/slate/test/schema/custom/child-kind-invalid-default.js
+++ b/packages/slate/test/schema/custom/child-kind-invalid-default.js
@@ -7,7 +7,7 @@ export const schema = {
paragraph: {},
quote: {
nodes: [
- { kinds: ['text'] },
+ { objects: ['text'] },
]
}
}
diff --git a/packages/slate/test/schema/custom/child-required-custom.js b/packages/slate/test/schema/custom/child-required-custom.js
index 41377860d..bf43086cc 100644
--- a/packages/slate/test/schema/custom/child-required-custom.js
+++ b/packages/slate/test/schema/custom/child-required-custom.js
@@ -11,7 +11,7 @@ export const schema = {
],
normalize: (change, reason, { node, index }) => {
if (reason == 'child_required') {
- change.insertNodeByKey(node.key, index, { kind: 'block', type: 'paragraph' })
+ change.insertNodeByKey(node.key, index, { object: 'block', type: 'paragraph' })
}
}
}
diff --git a/packages/slate/test/schema/custom/first-child-kind-invalid-custom.js b/packages/slate/test/schema/custom/first-child-kind-invalid-custom.js
index 8c836353e..67a54a4bd 100644
--- a/packages/slate/test/schema/custom/first-child-kind-invalid-custom.js
+++ b/packages/slate/test/schema/custom/first-child-kind-invalid-custom.js
@@ -6,9 +6,9 @@ export const schema = {
blocks: {
paragraph: {},
quote: {
- first: { kinds: ['block'] },
+ first: { objects: ['block'] },
normalize: (change, reason, { child }) => {
- if (reason == 'first_child_kind_invalid') {
+ if (reason == 'first_child_object_invalid') {
change.wrapBlockByKey(child.key, 'paragraph')
}
}
diff --git a/packages/slate/test/schema/custom/first-child-kind-invalid-default.js b/packages/slate/test/schema/custom/first-child-kind-invalid-default.js
index 8e165d884..2a337a212 100644
--- a/packages/slate/test/schema/custom/first-child-kind-invalid-default.js
+++ b/packages/slate/test/schema/custom/first-child-kind-invalid-default.js
@@ -6,7 +6,7 @@ export const schema = {
blocks: {
paragraph: {},
quote: {
- first: { kinds: ['text'] },
+ first: { objects: ['text'] },
}
}
}
diff --git a/packages/slate/test/schema/custom/last-child-kind-invalid-custom.js b/packages/slate/test/schema/custom/last-child-kind-invalid-custom.js
index 35fa79300..582e52b6e 100644
--- a/packages/slate/test/schema/custom/last-child-kind-invalid-custom.js
+++ b/packages/slate/test/schema/custom/last-child-kind-invalid-custom.js
@@ -6,9 +6,9 @@ export const schema = {
blocks: {
paragraph: {},
quote: {
- last: { kinds: ['block'] },
+ last: { objects: ['block'] },
normalize: (change, reason, { child }) => {
- if (reason == 'last_child_kind_invalid') {
+ if (reason == 'last_child_object_invalid') {
change.wrapBlockByKey(child.key, 'paragraph')
}
}
diff --git a/packages/slate/test/schema/custom/last-child-kind-invalid-default.js b/packages/slate/test/schema/custom/last-child-kind-invalid-default.js
index a8632ef0e..eba5fef2d 100644
--- a/packages/slate/test/schema/custom/last-child-kind-invalid-default.js
+++ b/packages/slate/test/schema/custom/last-child-kind-invalid-default.js
@@ -6,7 +6,7 @@ export const schema = {
blocks: {
paragraph: {},
quote: {
- last: { kinds: ['text'] },
+ last: { objects: ['text'] },
}
}
}
diff --git a/packages/slate/test/schema/custom/parent-kind-invalid-custom.js b/packages/slate/test/schema/custom/parent-kind-invalid-custom.js
index 63a425a0b..09f11bac2 100644
--- a/packages/slate/test/schema/custom/parent-kind-invalid-custom.js
+++ b/packages/slate/test/schema/custom/parent-kind-invalid-custom.js
@@ -5,9 +5,9 @@ import h from '../../helpers/h'
export const schema = {
inlines: {
link: {
- parent: { kinds: ['block'] },
+ parent: { objects: ['block'] },
normalize: (change, reason, { node }) => {
- if (reason == 'parent_kind_invalid') {
+ if (reason == 'parent_object_invalid') {
change.unwrapNodeByKey(node.key)
}
}
diff --git a/packages/slate/test/schema/custom/parent-kind-invalid-default.js b/packages/slate/test/schema/custom/parent-kind-invalid-default.js
index ce60c4f27..9c982893d 100644
--- a/packages/slate/test/schema/custom/parent-kind-invalid-default.js
+++ b/packages/slate/test/schema/custom/parent-kind-invalid-default.js
@@ -5,7 +5,7 @@ import h from '../../helpers/h'
export const schema = {
inlines: {
link: {
- parent: { kinds: ['block'] },
+ parent: { objects: ['block'] },
}
}
}
diff --git a/packages/slate/test/serializers/raw/deserialize/block-nested.js b/packages/slate/test/serializers/raw/deserialize/block-nested.js
index 6290da1bd..1e89cf580 100644
--- a/packages/slate/test/serializers/raw/deserialize/block-nested.js
+++ b/packages/slate/test/serializers/raw/deserialize/block-nested.js
@@ -3,29 +3,29 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'quote',
data: {},
isVoid: false,
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'one',
- kind: 'leaf',
+ object: 'leaf',
marks: []
}
]
diff --git a/packages/slate/test/serializers/raw/deserialize/block-with-data.js b/packages/slate/test/serializers/raw/deserialize/block-with-data.js
index 709f1ce34..07470e49c 100644
--- a/packages/slate/test/serializers/raw/deserialize/block-with-data.js
+++ b/packages/slate/test/serializers/raw/deserialize/block-with-data.js
@@ -3,13 +3,13 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {
@@ -17,10 +17,10 @@ export const input = {
},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: []
}
diff --git a/packages/slate/test/serializers/raw/deserialize/block-with-is-void.js b/packages/slate/test/serializers/raw/deserialize/block-with-is-void.js
index 09738ac12..a7d9c83b8 100644
--- a/packages/slate/test/serializers/raw/deserialize/block-with-is-void.js
+++ b/packages/slate/test/serializers/raw/deserialize/block-with-is-void.js
@@ -3,22 +3,22 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'image',
isVoid: true,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: ' ',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/deserialize/block.js b/packages/slate/test/serializers/raw/deserialize/block.js
index 621898fd3..36901bf01 100644
--- a/packages/slate/test/serializers/raw/deserialize/block.js
+++ b/packages/slate/test/serializers/raw/deserialize/block.js
@@ -3,22 +3,22 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/deserialize/inline-nested.js b/packages/slate/test/serializers/raw/deserialize/inline-nested.js
index e55d260b4..cb0e59ea2 100644
--- a/packages/slate/test/serializers/raw/deserialize/inline-nested.js
+++ b/packages/slate/test/serializers/raw/deserialize/inline-nested.js
@@ -3,54 +3,54 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'hashtag',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
@@ -59,10 +59,10 @@ export const input = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
@@ -71,10 +71,10 @@ export const input = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/deserialize/inline-with-data.js b/packages/slate/test/serializers/raw/deserialize/inline-with-data.js
index d754d9cef..12db01e3b 100644
--- a/packages/slate/test/serializers/raw/deserialize/inline-with-data.js
+++ b/packages/slate/test/serializers/raw/deserialize/inline-with-data.js
@@ -3,29 +3,29 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
isVoid: false,
data: {
@@ -33,10 +33,10 @@ export const input = {
},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
@@ -45,10 +45,10 @@ export const input = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/deserialize/inline-with-is-void.js b/packages/slate/test/serializers/raw/deserialize/inline-with-is-void.js
index 608f16fc6..4b6536221 100644
--- a/packages/slate/test/serializers/raw/deserialize/inline-with-is-void.js
+++ b/packages/slate/test/serializers/raw/deserialize/inline-with-is-void.js
@@ -3,38 +3,38 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'emoji',
isVoid: true,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: ' ',
marks: [],
}
@@ -43,10 +43,10 @@ export const input = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/deserialize/inline.js b/packages/slate/test/serializers/raw/deserialize/inline.js
index b93be7bb3..067570391 100644
--- a/packages/slate/test/serializers/raw/deserialize/inline.js
+++ b/packages/slate/test/serializers/raw/deserialize/inline.js
@@ -3,38 +3,38 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
@@ -43,10 +43,10 @@ export const input = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/deserialize/range-with-mark.js b/packages/slate/test/serializers/raw/deserialize/range-with-mark.js
index 7aec5f345..5a7562980 100644
--- a/packages/slate/test/serializers/raw/deserialize/range-with-mark.js
+++ b/packages/slate/test/serializers/raw/deserialize/range-with-mark.js
@@ -3,38 +3,38 @@
import h from '../../../helpers/h'
export const input = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaves',
+ object: 'leaves',
text: 'o',
marks: [],
},
{
- kind: 'leaves',
+ object: 'leaves',
text: 'n',
marks: [
{
- kind: 'mark',
+ object: 'mark',
type: 'bold',
data: {},
}
]
},
{
- kind: 'leaves',
+ object: 'leaves',
text: 'e',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/serialize/block-nested.js b/packages/slate/test/serializers/raw/serialize/block-nested.js
index 378055ad2..5cf9ab30c 100644
--- a/packages/slate/test/serializers/raw/serialize/block-nested.js
+++ b/packages/slate/test/serializers/raw/serialize/block-nested.js
@@ -15,29 +15,29 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'quote',
data: {},
isVoid: false,
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'one',
- kind: 'leaf',
+ object: 'leaf',
marks: []
}
]
diff --git a/packages/slate/test/serializers/raw/serialize/block-with-data.js b/packages/slate/test/serializers/raw/serialize/block-with-data.js
index 9f4aad8f0..64d527096 100644
--- a/packages/slate/test/serializers/raw/serialize/block-with-data.js
+++ b/packages/slate/test/serializers/raw/serialize/block-with-data.js
@@ -13,13 +13,13 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {
@@ -27,10 +27,10 @@ export const output = {
},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: []
}
diff --git a/packages/slate/test/serializers/raw/serialize/block-with-is-void.js b/packages/slate/test/serializers/raw/serialize/block-with-is-void.js
index fb5a082dc..26429cb74 100644
--- a/packages/slate/test/serializers/raw/serialize/block-with-is-void.js
+++ b/packages/slate/test/serializers/raw/serialize/block-with-is-void.js
@@ -11,22 +11,22 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'image',
isVoid: true,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: ' ',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/serialize/block.js b/packages/slate/test/serializers/raw/serialize/block.js
index cc375998a..1ffd5d5cf 100644
--- a/packages/slate/test/serializers/raw/serialize/block.js
+++ b/packages/slate/test/serializers/raw/serialize/block.js
@@ -13,22 +13,22 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/serialize/inline-nested.js b/packages/slate/test/serializers/raw/serialize/inline-nested.js
index c735bf50e..6780f9ec6 100644
--- a/packages/slate/test/serializers/raw/serialize/inline-nested.js
+++ b/packages/slate/test/serializers/raw/serialize/inline-nested.js
@@ -17,54 +17,54 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'hashtag',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
@@ -73,10 +73,10 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
@@ -85,10 +85,10 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/serialize/inline-with-data.js b/packages/slate/test/serializers/raw/serialize/inline-with-data.js
index 552f57c2d..fd19e377f 100644
--- a/packages/slate/test/serializers/raw/serialize/inline-with-data.js
+++ b/packages/slate/test/serializers/raw/serialize/inline-with-data.js
@@ -15,29 +15,29 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
isVoid: false,
data: {
@@ -45,10 +45,10 @@ export const output = {
},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
@@ -57,10 +57,10 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/serialize/inline-with-is-void.js b/packages/slate/test/serializers/raw/serialize/inline-with-is-void.js
index c6fb1f036..e2eff13bc 100644
--- a/packages/slate/test/serializers/raw/serialize/inline-with-is-void.js
+++ b/packages/slate/test/serializers/raw/serialize/inline-with-is-void.js
@@ -13,38 +13,38 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'emoji',
isVoid: true,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: ' ',
marks: [],
}
@@ -53,10 +53,10 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/serialize/inline.js b/packages/slate/test/serializers/raw/serialize/inline.js
index a6a27821c..90434af3b 100644
--- a/packages/slate/test/serializers/raw/serialize/inline.js
+++ b/packages/slate/test/serializers/raw/serialize/inline.js
@@ -15,38 +15,38 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
]
},
{
- kind: 'inline',
+ object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'one',
marks: [],
}
@@ -55,10 +55,10 @@ export const output = {
]
},
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: '',
marks: [],
}
diff --git a/packages/slate/test/serializers/raw/serialize/preserve-data.js b/packages/slate/test/serializers/raw/serialize/preserve-data.js
index 4c12940ef..f8890864c 100644
--- a/packages/slate/test/serializers/raw/serialize/preserve-data.js
+++ b/packages/slate/test/serializers/raw/serialize/preserve-data.js
@@ -13,24 +13,24 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
data: {},
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'one',
- kind: 'leaf',
+ object: 'leaf',
marks: []
}
]
diff --git a/packages/slate/test/serializers/raw/serialize/preserve-keys.js b/packages/slate/test/serializers/raw/serialize/preserve-keys.js
index bb98fd263..3fefad9d1 100644
--- a/packages/slate/test/serializers/raw/serialize/preserve-keys.js
+++ b/packages/slate/test/serializers/raw/serialize/preserve-keys.js
@@ -13,26 +13,26 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
key: '4',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
key: '1',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
key: '0',
leaves: [
{
text: 'one',
- kind: 'leaf',
+ object: 'leaf',
marks: []
}
]
diff --git a/packages/slate/test/serializers/raw/serialize/preserve-selection-and-keys.js b/packages/slate/test/serializers/raw/serialize/preserve-selection-and-keys.js
index 9e794a784..b05c7defb 100644
--- a/packages/slate/test/serializers/raw/serialize/preserve-selection-and-keys.js
+++ b/packages/slate/test/serializers/raw/serialize/preserve-selection-and-keys.js
@@ -13,26 +13,26 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
key: '4',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
key: '1',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
key: '0',
leaves: [
{
text: 'one',
- kind: 'leaf',
+ object: 'leaf',
marks: []
}
]
@@ -42,7 +42,7 @@ export const output = {
]
},
selection: {
- kind: 'range',
+ object: 'range',
anchorKey: '0',
anchorOffset: 0,
focusKey: '0',
diff --git a/packages/slate/test/serializers/raw/serialize/preserve-selection.js b/packages/slate/test/serializers/raw/serialize/preserve-selection.js
index d9c340d75..a20bd54f2 100644
--- a/packages/slate/test/serializers/raw/serialize/preserve-selection.js
+++ b/packages/slate/test/serializers/raw/serialize/preserve-selection.js
@@ -13,23 +13,23 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
text: 'one',
- kind: 'leaf',
+ object: 'leaf',
marks: []
}
]
@@ -39,7 +39,7 @@ export const output = {
]
},
selection: {
- kind: 'range',
+ object: 'range',
anchorPath: [0, 0],
anchorOffset: 0,
focusPath: [0, 0],
diff --git a/packages/slate/test/serializers/raw/serialize/range-with-mark.js b/packages/slate/test/serializers/raw/serialize/range-with-mark.js
index e2a1db400..f7b18a186 100644
--- a/packages/slate/test/serializers/raw/serialize/range-with-mark.js
+++ b/packages/slate/test/serializers/raw/serialize/range-with-mark.js
@@ -13,38 +13,38 @@ export const input = (
)
export const output = {
- kind: 'value',
+ object: 'value',
document: {
- kind: 'document',
+ object: 'document',
data: {},
nodes: [
{
- kind: 'block',
+ object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
- kind: 'text',
+ object: 'text',
leaves: [
{
- kind: 'leaf',
+ object: 'leaf',
text: 'o',
marks: [],
},
{
- kind: 'leaf',
+ object: 'leaf',
text: 'n',
marks: [
{
- kind: 'mark',
+ object: 'mark',
type: 'bold',
data: {},
}
]
},
{
- kind: 'leaf',
+ object: 'leaf',
text: 'e',
marks: [],
}