From 70c55e4a4255323640944b449922500a8abd4d6a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 26 May 2026 20:38:46 -0400 Subject: [PATCH] feat: Add support for code blocks in comments (#12480) * feat: Add support for code blocks in comments * Add code_block --- app/scenes/Document/components/Comments/CommentEditor.tsx | 4 ++++ server/editor/index.ts | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/scenes/Document/components/Comments/CommentEditor.tsx b/app/scenes/Document/components/Comments/CommentEditor.tsx index 2e18ad2a73..f2ebe9c1de 100644 --- a/app/scenes/Document/components/Comments/CommentEditor.tsx +++ b/app/scenes/Document/components/Comments/CommentEditor.tsx @@ -1,6 +1,8 @@ import { observer } from "mobx-react"; import * as React from "react"; import { basicExtensions, withComments } from "@shared/editor/nodes"; +import CodeBlock from "@shared/editor/nodes/CodeBlock"; +import CodeFence from "@shared/editor/nodes/CodeFence"; import HardBreak from "@shared/editor/nodes/HardBreak"; import type { Props as EditorProps } from "~/components/Editor"; import Editor from "~/components/Editor"; @@ -17,6 +19,8 @@ import useCurrentUser from "~/hooks/useCurrentUser"; const extensions = [ ...withComments(basicExtensions), + CodeBlock, + CodeFence, HardBreak, SmartText, PasteHandler, diff --git a/server/editor/index.ts b/server/editor/index.ts index 193762a029..731e40f4f7 100644 --- a/server/editor/index.ts +++ b/server/editor/index.ts @@ -9,6 +9,8 @@ import { richExtensions, withComments, } from "@shared/editor/nodes"; +import CodeBlock from "@shared/editor/nodes/CodeBlock"; +import CodeFence from "@shared/editor/nodes/CodeFence"; import Mention from "@shared/editor/nodes/Mention"; populateEmojiData(data as EmojiMartData); @@ -56,7 +58,7 @@ export const basicParser = basicExtensionManager.parser({ plugins: basicExtensionManager.rulePlugins, }); -const commentExtensions = [...basicExtensions, Mention]; +const commentExtensions = [...basicExtensions, CodeBlock, CodeFence, Mention]; export const commentExtensionManager = new ExtensionManager(commentExtensions); export const commentSchema = new Schema({