Skip to content

Commit

Permalink
[block-tools] Robustify annotation conversion (#543)
Browse files Browse the repository at this point in the history
* [block-tools] Ensure that we have an annotation key before putting it in as a mark

* [block-tools] Ensure that marks are truthy before using them in a Slate value
  • Loading branch information
skogsmaskin authored and bjoerge committed Jan 30, 2018
1 parent 38df4be commit d52b31c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -57,7 +57,7 @@ function sanitySpanToRawSlateBlockNode(span, sanityBlock) {
const range = {
kind: 'range',
text: text,
marks: decorators.map(toRawMark)
marks: decorators.filter(Boolean).map(toRawMark)
}

if (!annotations) {
Expand Down
Expand Up @@ -30,7 +30,7 @@ function toSanitySpan(node, sanityBlock, spanIndex) {
Object.keys(annotations).forEach(name => {
const annotation = annotations[name]
const annotationKey = annotation._key
if (annotation) {
if (annotation && annotationKey) {
sanityBlock.markDefs.push(annotation)
annotationKeys.push(annotationKey)
}
Expand Down

0 comments on commit d52b31c

Please sign in to comment.