diff --git a/src/components/DocumentView/Annotation/Annotation.tsx b/src/components/DocumentView/Annotation/Annotation.tsx index df81e7cd5..75999fefe 100644 --- a/src/components/DocumentView/Annotation/Annotation.tsx +++ b/src/components/DocumentView/Annotation/Annotation.tsx @@ -12,7 +12,7 @@ export async function Annotation(props: InlineProps) { const fragment = getNodeFragmentByType(inline, 'annotation-body'); const content = children ?? ( - + ); if (!fragment) { diff --git a/src/components/DocumentView/Caption.tsx b/src/components/DocumentView/Caption.tsx index 13eb6beef..61b0ffcbd 100644 --- a/src/components/DocumentView/Caption.tsx +++ b/src/components/DocumentView/Caption.tsx @@ -70,7 +70,12 @@ export function Caption( 'dark:text-light/6', )} > - + ); diff --git a/src/components/DocumentView/CodeBlock/CodeBlock.tsx b/src/components/DocumentView/CodeBlock/CodeBlock.tsx index c11b63d1f..bef85c1a6 100644 --- a/src/components/DocumentView/CodeBlock/CodeBlock.tsx +++ b/src/components/DocumentView/CodeBlock/CodeBlock.tsx @@ -265,7 +265,12 @@ function CodeHighlightToken(props: { if (token.type === 'inline') { return ( - + ) { 'group-open:rotate-90', )} /> - + ) {
- +
); diff --git a/src/components/DocumentView/Inline.tsx b/src/components/DocumentView/Inline.tsx index abb1812d2..19046b0dc 100644 --- a/src/components/DocumentView/Inline.tsx +++ b/src/components/DocumentView/Inline.tsx @@ -26,6 +26,11 @@ export interface InlineProps extends DocumentContextPr */ document: JSONDocument; + /** + * Inline ancestors of the current inline. + */ + ancestorInlines: DocumentInline[]; + /** * If defined, replace the content of the inline. */ diff --git a/src/components/DocumentView/InlineImage.tsx b/src/components/DocumentView/InlineImage.tsx index 919028da6..c3c35fbc4 100644 --- a/src/components/DocumentView/InlineImage.tsx +++ b/src/components/DocumentView/InlineImage.tsx @@ -9,7 +9,7 @@ import { InlineProps } from './Inline'; import { Image } from '../utils'; export async function InlineImage(props: InlineProps) { - const { inline, context } = props; + const { inline, context, ancestorInlines } = props; const { size = 'original' } = inline.data; const [src, darkSrc] = await Promise.all([ @@ -21,6 +21,8 @@ export async function InlineImage(props: InlineProps) { return null; } + const isInLink = ancestorInlines.some((ancestor) => ancestor.type === 'link'); + return ( /* Ensure images dont expand to the size of the container where this Image may be nested in. Now it's always nested in a size-restricted container */ @@ -43,7 +45,7 @@ export async function InlineImage(props: InlineProps) { preload style={[size === 'line' ? ['max-h-[1lh]', 'h-[1lh]', 'w-auto'] : null]} inline - zoom + zoom={!isInLink} /> ); diff --git a/src/components/DocumentView/InlineLink.tsx b/src/components/DocumentView/InlineLink.tsx index 68e4fe69e..801f45951 100644 --- a/src/components/DocumentView/InlineLink.tsx +++ b/src/components/DocumentView/InlineLink.tsx @@ -5,14 +5,19 @@ import { Inlines } from './Inlines'; import { Link } from '../primitives'; export async function InlineLink(props: InlineProps) { - const { inline, document, context } = props; + const { inline, document, context, ancestorInlines } = props; const resolved = await context.resolveContentRef(inline.data.ref); if (!resolved) { return ( - + ); } @@ -22,7 +27,12 @@ export async function InlineLink(props: InlineProps) { href={resolved.href} className="underline underline-offset-2 text-primary hover:text-primary-700 transition-colors " > - + ); } diff --git a/src/components/DocumentView/Inlines.tsx b/src/components/DocumentView/Inlines.tsx index 441470b36..dc604054d 100644 --- a/src/components/DocumentView/Inlines.tsx +++ b/src/components/DocumentView/Inlines.tsx @@ -11,10 +11,18 @@ export function Inlines( */ document: JSONDocument; + /** + * Ancestors of the current inline. + */ + ancestorInlines: DocumentInline[]; + + /** + * Nodes to render + */ nodes: T[]; }, ) { - const { nodes, document, ...contextProps } = props; + const { nodes, document, ancestorInlines, ...contextProps } = props; return ( <> @@ -24,7 +32,13 @@ export function Inlines( } return ( - + ); })} diff --git a/src/components/DocumentView/Paragraph.tsx b/src/components/DocumentView/Paragraph.tsx index 2147ec01e..e6b7a82eb 100644 --- a/src/components/DocumentView/Paragraph.tsx +++ b/src/components/DocumentView/Paragraph.tsx @@ -10,7 +10,7 @@ export function Paragraph(props: BlockProps) { return (

- +

); }