bug: markdown images ![alt](url) are not rendered in messages

未关闭 适合新手
#1,432 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript, react
领域
frontend

调研方向

从 packages/markups 中的 InlineElements 开始,检查其他已解析节点类型的渲染方式。对比 packages/gazzodown 中 Rocket.Chat 的 ImageElement,以了解 issue 所述的 URL 清理行为。添加对 parser 的 IMAGE 节点的渲染;当带链接的消息和仅包含图像的消息都能显示图像及其替代文本,并符合预期行为时,即完成。

由索引模型根据 Issue 内容生成。

描述

Description:

A markdown image in a message, ![alt](https://example.com/picture.png), is not shown at all in EmbeddedChat. The text around it is shown, but the image and its alt text disappear, and a message that is only an image renders empty. Rocket.Chat shows the image.

The message parser (@rocket.chat/message-parser) returns an IMAGE node for this syntax:

{"type":"IMAGE","value":{"src":{"type":"PLAIN_TEXT","value":"https://example.com/a.png"},"label":{"type":"PLAIN_TEXT","value":"diagram"}}}

InlineElements in packages/markups has no case for IMAGE, so it returns null. Rocket.Chat's renderer (packages/gazzodown, ImageElement) renders it as an image inside a link, after sanitizing the URL.

Steps to reproduce:
  1. Send look ![diagram](https://example.com/a.png) here.
  2. Send ![](https://example.com/a.png).
Expected behavior:

Both messages show the image, as in Rocket.Chat.

Actual behavior:

The first message shows only "look here", and the second message is empty.

I'd like to send a fix that adds an ImageElement to the markups package, with the same URL sanitizing as Rocket.Chat's.

主要语言
JavaScript
星标
170
派生
397
平均合并
8 天 20 小时
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RocketChat/EmbeddedChat 的其他 Issue

查看 RocketChat/EmbeddedChat 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。