[Web] Pasted HTML (text + <img> without width/height) collapses images to 80px fallback
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, react-native, typescript
Hướng nghiên cứu
Read src/web/formats/EnrichedImageNodeView.tsx and src/web/EnrichedTextInput.tsx, focusing on how images without explicit dimensions are rendered and how pasted HTML reaches TipTap. Check the existing image node tests and add coverage for mixed text and image paste where the image has no width or height. Done means the image uses its natural dimensions after loading while the pasted text remains intact.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
On Web, when pasting mixed HTML content from an external webpage (text together with one or more <img> elements that rely on CSS sizing and omit explicit width/height HTML attributes), EnrichedImageNodeView renders those images at 80px width (IMAGE_FALLBACK_SIZE = 80).
Why app code cannot cleanly work around this
- Standalone image paste (
Copy Image/ clipboardFile): This can be handled at the app level usingonPasteImages(for binary clipboard files) or intercepting a single-imagepasteevent in capture phase and inserting viaref.setImage(src, width, height)after probing natural dimensions. - Mixed HTML paste (text + images): There is no clean way to handle this without modifying
react-native-enriched-htmlor using brittle DOM hacks (preventDefault()+ async dimension probing that blocks pasting the text + re-injecting viaexecCommand/synthetic events):EnrichedTextInputkeeps the TipTapeditorinstance andtransformPastedHTMLinternal.- The imperative
ref(EnrichedTextInputInstance) has no command to update an existing image node's attributes after paste — onlysetValue(fullHtml), which resets selection/cursor and undo history.
This also hurts cross-platform consistency, since native iOS (ImageAttachment) and Android (EnrichedImageSpan) rely on HTML width and height attributes to compute image bounds.
Relevant code in 1.2.0
src/web/formats/EnrichedImageNodeView.tsx:- When
rawW == null && rawH == null,imgDimsfalls back to{ width: IMAGE_FALLBACK_SIZE }(80).
- When
src/web/EnrichedTextInput.tsx:handleClipboardPasteImageshandles binaryFilepastes (onPasteImages), whereas HTML pastes with<img>go straight throughprepareHtmlForTiptap.
Steps to reproduce
- Copy a selection containing text and an
<img>withoutwidth/heightHTML attributes from a webpage (e.g.<p>Some text</p><img src="https://example.com/photo.jpg">). - Paste into
<EnrichedTextInput />on Web. - Notice the pasted text renders properly, while the image width is clamped to
80px(width="80") regardless of itsnaturalWidth.
Suggested improvement
In EnrichedImageNodeView.tsx, when node.attrs.width == null && node.attrs.height == null, listen to onLoad on the <img> element and call TipTap's updateAttributes({ width: img.naturalWidth, height: img.naturalHeight }) once decoded (or expose a clean prop/hook to transform/update pasted HTML and image nodes).
Environment
react-native-enriched-html:1.2.0- Platform: Web (
@tiptap/react)
- Ngôn ngữ chính
- C
- Star
- 1.4k
- Fork
- 80
- Merge trung bình
- 4 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 21
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của software-mansion/react-native-enriched-html
-
[Web] Leading, trailing, and consecutive spaces in <p> and <codeblock> are stripped by setContent on mount / setValueCó thể đã có người làm @pcbeingused333 đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
software-mansion/react-native-enriched-html#886 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
software-mansion/react-native-enriched-html#885 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
software-mansion/react-native-enriched-html#881 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
software-mansion/react-native-enriched-html#878 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Android] Leading and consecutive spaces are lost when HTML is parsed (iOS keeps them)Có thể đã có người làm @szydlovsky đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
software-mansion/react-native-enriched-html#877 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của software-mansion/react-native-enriched-html
Issue tương tự
-
[Android Auto] MU1017 (MHI2Q_JP_AUG22_P1017) cluster map works with a pinned profile — values insideĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
kamgurgul/mib2q-carplay#74 ·
-
Claude:NotNeeded GPT:NotABug triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
open5gs/open5gs#5195 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
FriendsofECCE/ECCE#1358 ·
-
documentation needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
X11Libre/xserver#4255 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
antoxa2584x/nfsu2-sw#52 ·