1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-01 11:12:42 +02:00

fix html serializer default block type logic

This commit is contained in:
Ian Storm Taylor
2017-02-13 18:21:27 -08:00
parent add174ef37
commit 44303dc22f
3 changed files with 15 additions and 8 deletions

View File

@@ -109,10 +109,16 @@ class Html {
return memo
}
const commonProps = {kind: 'block', nodes: [node]}
const block = this.defaultBlockType.typeof === 'string'
? {type: this.defaultBlockType, ...commonProps}
: {...commonProps, ...this.defaultBlockType}
const { defaultBlockType } = this
const defaults = typeof defaultBlockType == 'string'
? { type: defaultBlockType }
: defaultBlockType
const block = {
kind: 'block',
nodes: [node],
...defaults
}
memo.push(block)
return memo

View File

@@ -16,9 +16,9 @@ export default {
}
],
defaultBlockType: {
type: 'contentBlock',
type: 'default',
data: {
style: 'default'
key: 'value'
}
}
}

View File

@@ -11,9 +11,10 @@ nodes:
marks: []
- text: e
marks: []
- type: contentBlock
- type: default
isVoid: false
data: {style: default}
data:
key: value
nodes:
- characters:
- text: t