Skip to content

Commit 0bc245b

Browse files
emir-karabegcursoragentwaleedlatif1
authored
feat(note-block): note block preview newlines (#3127)
* feat(note-block): add single newline support in preview Add remark-breaks plugin to the note block markdown renderer to convert single newlines into line breaks. This fixes the issue where users had to use double newlines (\n\n) to create visible line breaks in the note block preview. Co-authored-by: Emir Karabeg <emir-karabeg@users.noreply.github.com> * Revert "feat(note-block): add single newline support in preview" This reverts commit 049b425. * feat(note-block): add single newline support in preview Add a preprocessor function that converts single newlines to markdown hard breaks (two trailing spaces + newline) before rendering. This ensures that when users press Enter in the note block editor, the line break shows up in the preview. The function preserves: - Double newlines (paragraph breaks) - Code block formatting (fenced and inline) Co-authored-by: Emir Karabeg <emir-karabeg@users.noreply.github.com> * refactor(note-block): simplify comments Co-authored-by: Emir Karabeg <emir-karabeg@users.noreply.github.com> * added remark-breaks to allow single new line --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Emir Karabeg <emir-karabeg@users.noreply.github.com> Co-authored-by: waleed <walif6@gmail.com>
1 parent 0a08ac0 commit 0bc245b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/note-block/note-block.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { memo, useCallback, useMemo } from 'react'
22
import ReactMarkdown from 'react-markdown'
33
import type { NodeProps } from 'reactflow'
4+
import remarkBreaks from 'remark-breaks'
45
import remarkGfm from 'remark-gfm'
56
import { cn } from '@/lib/core/utils/cn'
67
import { BLOCK_DIMENSIONS } from '@/lib/workflows/blocks/block-dimensions'
@@ -305,7 +306,7 @@ function getEmbedInfo(url: string): EmbedInfo | null {
305306
const NoteMarkdown = memo(function NoteMarkdown({ content }: { content: string }) {
306307
return (
307308
<ReactMarkdown
308-
remarkPlugins={[remarkGfm]}
309+
remarkPlugins={[remarkGfm, remarkBreaks]}
309310
components={{
310311
p: ({ children }: any) => (
311312
<p className='mb-1 break-words text-[var(--text-primary)] text-sm leading-[1.25rem] last:mb-0'>

apps/sim/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
"redis": "5.10.0",
149149
"rehype-autolink-headings": "^7.1.0",
150150
"rehype-slug": "^6.0.0",
151+
"remark-breaks": "^4.0.0",
151152
"remark-gfm": "4.0.1",
152153
"resend": "^4.1.2",
153154
"rss-parser": "3.13.0",

bun.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)