mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 23:12:52 +02:00
Ignore comments in Html deserializer (#856)
This commit is contained in:
committed by
Ian Storm Taylor
parent
c26f2dc71b
commit
53542cb55b
@@ -35,6 +35,8 @@ const TEXT_RULE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (el.type == 'text') {
|
if (el.type == 'text') {
|
||||||
|
if (el.data && el.data.match(/<!--.*?-->/)) return
|
||||||
|
|
||||||
return {
|
return {
|
||||||
kind: 'text',
|
kind: 'text',
|
||||||
text: el.data
|
text: el.data
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
export default {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
deserialize(el, next) {
|
||||||
|
switch (el.tagName) {
|
||||||
|
case 'p': {
|
||||||
|
return {
|
||||||
|
kind: 'block',
|
||||||
|
type: 'paragraph',
|
||||||
|
nodes: next(el.children)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -0,0 +1,2 @@
|
|||||||
|
<!-- This comment should be ignored -->
|
||||||
|
<p>text</p>
|
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
data: {}
|
||||||
|
nodes:
|
||||||
|
- type: paragraph
|
||||||
|
isVoid: false
|
||||||
|
data: {}
|
||||||
|
nodes:
|
||||||
|
- characters:
|
||||||
|
- text: t
|
||||||
|
marks: []
|
||||||
|
- text: e
|
||||||
|
marks: []
|
||||||
|
- text: x
|
||||||
|
marks: []
|
||||||
|
- text: t
|
||||||
|
marks: []
|
Reference in New Issue
Block a user