1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-03 04:02:33 +02:00

rename kind to object for clarity (#1501)

* rename `kind` to `object` for clarity

* add deprecation warning for direct access

* add deprecation warning for node creation
This commit is contained in:
Ian Storm Taylor
2018-01-04 15:26:53 -08:00
committed by GitHub
parent a6c56a2c56
commit 5444a300b8
144 changed files with 842 additions and 820 deletions

View File

@@ -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.'

View File

@@ -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 <p>{children}</p>
}
}
@@ -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 <p>{children}</p>
case 'quote': return <blockquote>{children}</blockquote>
case 'code': return <pre><code>{children}</code></pre>
@@ -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 <pre><code>{children}</code></pre>
case 'paragraph': return <p>{children}</p>
case 'quote': return <blockquote>{children}</blockquote>
@@ -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 <strong>{children}</strong>
case 'italic': return <em>{children}</em>
case 'underline': return <u>{children}</u>

View File

@@ -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.'