Skip to content

Commit

Permalink
[field] PT: fix some typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin authored and rexxars committed Oct 6, 2020
1 parent 5ea4be4 commit dd82ed0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Header from './previews/Header'
import Paragraph from './previews/Paragraph'

import styles from './PTDiff.css'
import {ArrayDiff, ObjectDiff} from '../../index'
import {ObjectDiff} from '../../index'

type Props = {
blockDiff: ObjectDiff
Expand Down Expand Up @@ -78,12 +78,13 @@ export const PortableText = (props: Props): JSX.Element => {
}

// Do the final render
let block = blockDiff.toValue
let block = blockDiff.toValue as PortableTextBlock
if (somethingIsRemoved(blockDiff)) {
block = blockDiff.fromValue
block = blockDiff.fromValue as PortableTextBlock
}
const children = block.children || []
return renderBlock({
block: block as PortableTextBlock,
children: block.children.map(child => renderChild(child))
block,
children: children.map(child => renderChild(child))
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ export function isHeader(node: PortableTextBlock) {

export function createChildMap(blockDiff: ObjectDiff, schemaType: ObjectSchemaType) {
// Create a map from span to diff
const block = somethingIsRemoved(blockDiff) ? blockDiff.fromValue : blockDiff.toValue
const block = (somethingIsRemoved(blockDiff)
? blockDiff.fromValue
: blockDiff.toValue) as PortableTextBlock
const childMap: ChildMap = {}
block.children.forEach(child => {
const children = block.children || []
children.forEach(child => {
// Fallback for renderer
if (child) {
child._type = child._type || 'undefined' // string
Expand Down

0 comments on commit dd82ed0

Please sign in to comment.