Skip to content

メッセージのMarkdown対応#44

Merged
saka-naname merged 5 commits intomainfrom
feat/message-markdown
Mar 13, 2025
Merged

メッセージのMarkdown対応#44
saka-naname merged 5 commits intomainfrom
feat/message-markdown

Conversation

@saka-naname
Copy link
Copy Markdown
Contributor

@saka-naname saka-naname commented Mar 11, 2025

関連 Issue(s)

変更内容

  • unifiedを軸としたMarkdownパーサー及びプラグインの導入
  • Messageコンポーネントの表示内容の追加
    • 本文のMarkdown表示
    • 添付画像の一覧表示
    • リンクカードの埋め込み

スクリーンショット

localhost_3000_channels_a3b24416-48e6-47a6-9b4a-67c384ecb4e0 (1)
各種要素の表示 (拡大推奨)

Screenshot_20250312_023314_Chrome
スマートフォン表示 (1)

Screenshot_20250312_023423_Chrome
スマートフォン表示 (2)

確認手順

  1. seedコード等を利用して、適当なMarkdown文書を含むメッセージを作成する
  2. チャンネルページを開き、メッセージをレンダーする

assets: Pick<Asset, "id" | "type" | "url">[];
className?: string;
}) => {
if (props.assets.length === 0) return <></>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

何も返さない時の値、Reactの推奨は空のフラグメントではなくnullなのでこっちでお願いしたいです🫠
https://ja.react.dev/learn/conditional-rendering#conditionally-returning-nothing-with-null


import styles from "./CodeInline.module.css";

const CodeInline = (props: React.HTMLAttributes<HTMLElement>) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

propsとしてchildren以外も受け取れるのにchildrenしか適用されない状態はちょっとわかりづらそうです。propsの型をComponentPropsとかにしてあげて、スプレッド構文で渡してあげるのはどうでしょう

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あ~確かに、そちらの方が明確で良さそうですね

import { Title, TitleOrder } from "@mantine/core";

const Heading = (
props: React.HTMLAttributes<HTMLHeadingElement> & {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここの型も同様にComponentPropsが使えそう

Comment on lines +29 to +32
style={{
position: "relative",
paddingRight: "1.5rem",
}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

細かいですがstyleは使わずclassNameを使うようお願いします🙏

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここなんですが、一度classNameで指定しようとした所スタイルが思ったように適用されなかったんですよね…

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほどです、そしたら一旦このままで大丈夫です👍

Copy link
Copy Markdown
Contributor Author

@saka-naname saka-naname Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正のタイミングですぐ直せそうなら直して、ダメそうだったらコメント書き残しておきます 🫠

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ディレクトリ名、先頭にアンダースコア入れてる理由あったりしますか?
appディレクトリ配下の場合はルートとして認識させないようにする必要があったので付けてましたが、もし特に理由がなければ消しちゃって大丈夫です👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「Markdown.tsxの中でのみ使用する子孫コンポーネントである」という意図でアンダースコアを付けていましたが、まああまり一般的ではないですしそこまで必要無さそうですかね?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ちょっと関係性をそれで伝えるのは分かりづらいので、もし意図がそれだけだったら不要です!むしろアンダースコアを外せばMarkdown.tsxとmarkdown/がエディタ上で近くなるので見やすそう🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確かに!それは盲点でした…
であればアンダースコア無しに修正しておきます 🙇‍♂️

@saka-naname saka-naname requested a review from newt239 March 12, 2025 15:03
@saka-naname
Copy link
Copy Markdown
Contributor Author

@newt239 修正しました!再レビューお願いします

Copy link
Copy Markdown
Member

@newt239 newt239 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます、良さそうです🙆

@saka-naname saka-naname merged commit 70f255f into main Mar 13, 2025
1 check passed
@saka-naname saka-naname deleted the feat/message-markdown branch March 13, 2025 01:38
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.

メッセージのMarkdown対応

2 participants