Skip to content

Conversation

@tezpark
Copy link
Collaborator

@tezpark tezpark commented Oct 20, 2025

Summary

이미지와 텍스트/링크가 마크다운에서 빈 라인 없이 함께 작성될 때 발생하는 렌더링 문제를 수정

Problem

문제 1: 이미지 높이 오류

![](image.jpg)
[링크](url)

위와 같이 빈 라인 없이 작성하면 cmark-gfm이 하나의 paragraph로 파싱하고, ImageView 초기화가 실패하여 InlineText로 폴백됨.
이 경우 이미지가 화면 전체 높이로 잘못 렌더링됨.

문제 2: 과도한 간격

문제 1을 해결해도 이미지와 텍스트 사이에 테마의 마진 설정으로 인해 과도한 간격이 생김.

Solution

1. 혼합 콘텐츠 감지

  • hasMixedImageContent: 이미지와 다른 inline 요소가 함께 있는지 감지
  • 혼합 콘텐츠인 경우 별도 렌더링 경로 사용

2. CompactImageView 구현

SendbirdNetworkImage를 직접 사용하여 ResizeToFit 우회하고 GeometryReader의 추가 공간 생성 문제를 해결

3. 테마 독립적인 간격 조정

  • 폰트 크기에 비례한 negative margin 적용 (fontSize * 0.6)
  • TextStyleAttributesReader를 활용하여 현재 테마의 폰트 크기 동적 반영

Result

Before

  • 이미지 높이가 화면 전체를 차지
  • 이미지와 텍스트 사이 과도한 간격

After

  • 이미지가 올바른 크기로 렌더링
  • 이미지와 텍스트가 적절한 간격으로 배치 (리스트 항목 간격과 유사)

Technical Details

주요 변경사항

ParagraphView.swift

  • hasMixedImageContent 속성 추가
  • mixedContentView 구현 (VStack + negative margin)
  • CompactImageView 구조체 추가

호환성

  • iOS 14+
  • iOS 15+
  • iOS 16+
  • TextStyleAttributesReader가 버전별로 적절한 AttributeContainer 사용

기존 동작 유지

  • 단독 이미지 블록: 기존 ImageView 사용 (변경 없음)
  • 빈 라인으로 분리된 이미지: 기존 동작 유지
  • 여러 이미지 (iOS 16+): ImageFlow 사용 (변경 없음)
As-is To-be

Ticket

Changelog

- Added support for mixed content (images + text) in paragraphs.
- Introduced a new image view (CompactImageView) for images within mixed content.

@tezpark tezpark requested a review from damon-v2 October 20, 2025 04:22
@tezpark tezpark self-assigned this Oct 20, 2025
@tezpark tezpark merged commit 36161c5 into main Oct 24, 2025
2 checks passed
@tezpark tezpark deleted the feature/tez/markdown-mixed-inline-syntax branch October 24, 2025 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants