[Web] Pasted HTML (text + <img> without width/height) collapses images to 80px fallback
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 58/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react, react-native, typescript
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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)
- 主要语言
- C
- 星标
- 1.4k
- 派生
- 80
- 平均合并
- 4 天 19 小时
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
software-mansion/react-native-enriched-html 的其他 Issue
-
[Web] Leading, trailing, and consecutive spaces in <p> and <codeblock> are stripped by setContent on mount / setValue可能已有人在做 @pcbeingused333 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
software-mansion/react-native-enriched-html#886 ·
维护者通常 2 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 74/100
software-mansion/react-native-enriched-html#885 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
software-mansion/react-native-enriched-html#881 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
software-mansion/react-native-enriched-html#878 ·
维护者通常 2 天内回复
-
[Android] Leading and consecutive spaces are lost when HTML is parsed (iOS keeps them)可能已有人在做 @szydlovsky 于 1 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
software-mansion/react-native-enriched-html#877 · 1 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
查看 software-mansion/react-native-enriched-html 的全部 Issue
相似的 Issue
-
[Android Auto] MU1017 (MHI2Q_JP_AUG22_P1017) cluster map works with a pinned profile — values inside未关闭
难度 1/5 1 小时以内 新手友好度 92/100
kamgurgul/mib2q-carplay#74 ·
-
Claude:NotNeeded GPT:NotABug triage
难度 2/5 1-3 小时 新手友好度 78/100
open5gs/open5gs#5195 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
FriendsofECCE/ECCE#1358 ·
-
documentation needs-triage
难度 2/5 1-3 小时 新手友好度 68/100
X11Libre/xserver#4255 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 84/100
antoxa2584x/nfsu2-sw#52 ·