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:
committed by
Ian Storm Taylor
parent
e464bd652e
commit
7684fff545
@@ -299,7 +299,7 @@ class Html {
|
|||||||
leaf.marks.push({ type, data })
|
leaf.marks.push({ type, data })
|
||||||
return leaf
|
return leaf
|
||||||
})
|
})
|
||||||
} else {
|
} else if (node.nodes) {
|
||||||
node.nodes = node.nodes.map(applyMark)
|
node.nodes = node.nodes.map(applyMark)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
)
|
@@ -25,6 +25,10 @@ const h = createHyperscript({
|
|||||||
type: 'emoji',
|
type: 'emoji',
|
||||||
isVoid: true,
|
isVoid: true,
|
||||||
},
|
},
|
||||||
|
linebreak: {
|
||||||
|
type: 'linebreak',
|
||||||
|
isVoid: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
marks: {
|
marks: {
|
||||||
b: 'bold',
|
b: 'bold',
|
||||||
|
Reference in New Issue
Block a user