1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 13:11:17 +02:00

Fix issue when a nested in mark node a "void" inline node is the cause of error in applyMark method (#1831)

This commit is contained in:
Nikolay Kazakov
2018-05-11 07:05:55 +05:00
committed by Ian Storm Taylor
parent e464bd652e
commit 7684fff545
3 changed files with 58 additions and 1 deletions

View File

@@ -299,7 +299,7 @@ class Html {
leaf.marks.push({ type, data })
return leaf
})
} else {
} else if (node.nodes) {
node.nodes = node.nodes.map(applyMark)
}

View File

@@ -0,0 +1,53 @@
/** @jsx h */
import h from '../helpers/h'
export const config = {
rules: [
{
deserialize(el, next) {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
object: 'mark',
type: 'bold',
nodes: next(el.childNodes),
}
}
case 'br': {
return {
object: 'inline',
type: 'linebreak',
isVoid: true,
}
}
}
},
},
],
}
export const input = `
<p><strong>one<br/>two</strong></p>
`.trim()
export const output = (
<value>
<document>
<paragraph>
<b>
one
<linebreak />
two
</b>
</paragraph>
</document>
</value>
)

View File

@@ -25,6 +25,10 @@ const h = createHyperscript({
type: 'emoji',
isVoid: true,
},
linebreak: {
type: 'linebreak',
isVoid: true,
},
},
marks: {
b: 'bold',