Skip to content

メッセージ送信機能#45

Merged
newt239 merged 21 commits intomainfrom
feature/send-message
Apr 1, 2025
Merged

メッセージ送信機能#45
newt239 merged 21 commits intomainfrom
feature/send-message

Conversation

@newt239
Copy link
Copy Markdown
Member

@newt239 newt239 commented Mar 12, 2025

close #25

スクリーンショット

スクリーンショット 2025-03-13 21 50 22 スクリーンショット 2025-03-13 21 53 18

@newt239 newt239 self-assigned this Mar 12, 2025
@newt239 newt239 marked this pull request as ready for review March 13, 2025 14:40
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rehype-katex": "^7.0.1",
"rehype-parse": "^9.0.1",
Copy link
Copy Markdown
Member Author

@newt239 newt239 Mar 13, 2025

Choose a reason for hiding this comment

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

タグで囲まれた部分が表示されなくなってしまったため、remark-parseからrehype-parseに変えました

MarkdownではなくHTMLを直接渡している可能性
unified().use(remarkParse) を使っているので、これは Markdown を解析するパイプラインになっています。
もし <h1>Hello</h1> のような HTML 文字列をそのまま渡している場合、remarkParse ではなく rehypeParse を使うべきです。
→ もし HTML を含む文字列を処理するなら、 remarkParse ではなく rehypeParse を試してください。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

この点コメントしたので確認お願いします!
#45 (comment)

User,
} from "@prisma/client";

dayjs.extend(utc);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

layout.tsxでの読み込みはサーバーサイドでしか効かないため、クライアントサイドでレンダリングするときに処理するために必要

@newt239 newt239 requested a review from Meiryo7743 March 13, 2025 14:47
Copy link
Copy Markdown
Contributor

@saka-naname saka-naname left a comment

Choose a reason for hiding this comment

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

コメントしました!

import Message from "#/components/Message";

type ChannelProps = {
session: Session;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sessionはコンポーネントのpropsとして渡すにはふさわしくないと思うので、サーバー側でユーザーIDだけ抜き出してから渡すようにするか、クライアントコンポーネント内でSessionを扱いたければ useSession() フックを使う方が良いかと思います

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

たしかに!そうでした

<ChannelFooter user_id="test" is_joined={false} />
</Stack>
<Channel
session={session}
Copy link
Copy Markdown
Contributor

@saka-naname saka-naname Mar 17, 2025

Choose a reason for hiding this comment

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

同上です

const result = unified()
.use(rehypeParse, {
fragment: true,
})
Copy link
Copy Markdown
Contributor

@saka-naname saka-naname Mar 17, 2025

Choose a reason for hiding this comment

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

これではMarkdownの表示を行うコンポーネントなのにMarkdownの処理を行うプラグインが全て効かなくなってしまうのでは…?(実際、手元で試したところMarkdownをGFMや数式へ変換する処理が全て効かなくなってしまっています)

Markdownに含まれるHTMLタグで囲まれた要素を表示したいのであれば、 remarkParse でパースするのを維持しつつ、 remarkRehype{ allowDangerousHtml: true } を指定して rehypeRawrehypeSanitize を組み合わせるのではどうでしょうか?

余談ですが、TextEditor(TipTap)の出力ってMarkdownではなく <p>Hoge <strong>Fuga</strong></p> のようなHTML形式なんですね…(Markdownで出力されてDBに格納されるものかと思い込んでいた)

Copy link
Copy Markdown
Member Author

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 Author

Choose a reason for hiding this comment

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

この件ですがすぐに解決することが難しそうなので、一旦パース部分をもとの処理に戻しました。
現在のところTiptapから送信されたメッセージが表示できないままになってしまいますが、差分が大きくなるため一旦このPRでは送信処理を実装したというところまでにしたいと思います。
今後の方向性としてはTiptap側が勝手に文字列をpタグやdivタグで囲うのをやめさせるか、それが難しそうであればTiptapを辞めることも含めて検討しようと思います。

})
.processSync(props.content).result;
.processSync(content).result;
console.log(result);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

console.log() が残っていますが消し忘れですか?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

すみません、消します(ESLintも設定しときます......)


const Paragraph = (props: React.ComponentProps<"p">) => {
const { className, ...others } = props;
console.log(props);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

console.log() は消し忘れですか?

@newt239 newt239 requested a review from saka-naname March 30, 2025 11:52
Copy link
Copy Markdown
Contributor

@saka-naname saka-naname left a comment

Choose a reason for hiding this comment

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

LGTMeow

@newt239 newt239 merged commit a76d75f into main Apr 1, 2025
1 check passed
@newt239 newt239 deleted the feature/send-message branch April 1, 2025 01:41
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