Skip to content

Commit

Permalink
[field] PT: fix some issues from Decorator refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin authored and rexxars committed Oct 6, 2020
1 parent 461fd2c commit 8ff8671
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function Decorator({
)
}
if (!isRemoved) {
returned = <span className={`${styles[mark]}`}>{children}</span>
returned = <span className={`${styles[mark]}`}>{returned}</span>
}
return returned
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function PortableText(props: Props): JSX.Element {
}
} else if (seg.action === 'unchanged') {
returnedChildren.push(
renderWithMarks(diff, activeMarks, removedMarks, seg.text, spanSchemaType)
renderWithMarks(diff.origin, activeMarks, removedMarks, seg.text, spanSchemaType)
)
} else if (seg.action === 'removed') {
const textDiffAnnotation = findTextAnnotationFromSegment(diff, seg)
Expand All @@ -112,7 +112,7 @@ export default function PortableText(props: Props): JSX.Element {
as="del"
tooltip={{description: 'Removed text'}}
>
{renderWithMarks(diff, activeMarks, removedMarks, seg.text, spanSchemaType)}
{renderWithMarks(diff.origin, activeMarks, removedMarks, seg.text, spanSchemaType)}
</DiffCard>
)
} else if (seg.action === 'added') {
Expand All @@ -123,7 +123,7 @@ export default function PortableText(props: Props): JSX.Element {
as="ins"
tooltip={{description: 'Added text'}}
>
{renderWithMarks(diff, activeMarks, removedMarks, seg.text, spanSchemaType)}
{renderWithMarks(diff.origin, activeMarks, removedMarks, seg.text, spanSchemaType)}
</DiffCard>
)
}
Expand Down Expand Up @@ -163,7 +163,7 @@ function findTextAnnotationFromSegment(diff: ObjectDiff, segment: StringSegment)
}

function renderWithMarks(
diff: PortableTextDiff,
diff: ObjectDiff,
activeMarks: string[],
removedMarks: string[],
text: string,
Expand All @@ -178,13 +178,13 @@ function renderWithMarks(
allMarks.forEach(mark => {
if (isDecorator(mark, spanSchemaType)) {
returned = (
<Decorator diff={diff.origin} mark={mark} text={text}>
<Decorator diff={diff} mark={mark} text={text}>
{returned}
</Decorator>
)
} else {
returned = (
<Annotation diff={diff.origin} mark={mark}>
<Annotation diff={diff} mark={mark}>
{returned}
</Annotation>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export function isRemoveMark(cDiff: ObjectDiff, cSchemaType?: SchemaType): boole
export function getChildSchemaType(
fields: ObjectField<SchemaType>[],
child: PortableTextChild
): ObjectSchemaType<Record<string, any>> | undefined {
): ObjectSchemaType<Record<string, SchemaType>> | undefined {
const childrenField = fields.find(f => f.name === 'children')
const cSchemaType =
(childrenField &&
Expand Down

0 comments on commit 8ff8671

Please sign in to comment.