1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-22 15:02:51 +02:00

Ignore comments in Html deserializer (#856)

This commit is contained in:
Kelly Joseph Price
2017-05-30 13:08:51 -07:00
committed by Ian Storm Taylor
parent c26f2dc71b
commit 53542cb55b
4 changed files with 38 additions and 0 deletions

View File

@@ -35,6 +35,8 @@ const TEXT_RULE = {
}
if (el.type == 'text') {
if (el.data && el.data.match(/<!--.*?-->/)) return
return {
kind: 'text',
text: el.data

View File

@@ -0,0 +1,18 @@
export default {
rules: [
{
deserialize(el, next) {
switch (el.tagName) {
case 'p': {
return {
kind: 'block',
type: 'paragraph',
nodes: next(el.children)
}
}
}
}
}
]
}

View File

@@ -0,0 +1,2 @@
<!-- This comment should be ignored -->
<p>text</p>

View File

@@ -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: []