1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-08 06:00:40 +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 return memo
} }
const commonProps = {kind: 'block', nodes: [node]} const { defaultBlockType } = this
const block = this.defaultBlockType.typeof === 'string' const defaults = typeof defaultBlockType == 'string'
? {type: this.defaultBlockType, ...commonProps} ? { type: defaultBlockType }
: {...commonProps, ...this.defaultBlockType} : defaultBlockType
const block = {
kind: 'block',
nodes: [node],
...defaults
}
memo.push(block) memo.push(block)
return memo return memo

View File

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

View File

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