fix mdoc preview highlight content when it is added at the bottom of a markup page
@@ -24,17 +24,15 @@ class PageContentPreviewDiff {
const bn = btw.nextNode()
const an = atw.nextNode()
- if (bn === null || an === null) {
- return null
+ if (bn === null && an !== null) {
+ return an
}
- const classes = (typeof an.className === 'string') ? an.className.split(' ').filter((cn) => cn.length) : []
- if (! classes.length) {
- continue
+ if (bn === null || an === null) {
+ return null
}
- const isClassToIgnore = classNamesToSkip.some(cn => classes.indexOf(cn) !== -1)
- if (isClassToIgnore) {
+ if (ignoreNode(an)) {
continue
}
@@ -45,4 +43,14 @@ class PageContentPreviewDiff {
}
}
+function ignoreNode(node) {
+ const classes = (typeof node.className === 'string') ? node.className.split(' ').filter((cn) => cn.length) : []
+ if (! classes.length) {
+ return true
+ }
+
+ return classNamesToSkip.some(cn => classes.indexOf(cn) !== -1)
+
+}
+
export default PageContentPreviewDiff
