Skip to content

Commit 30dcd98

Browse files
refactor(note-block): simplify comments
Co-authored-by: Emir Karabeg <emir-karabeg@users.noreply.github.com>
1 parent 03dd298 commit 30dcd98

File tree

1 file changed

+1
-12
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/note-block

1 file changed

+1
-12
lines changed

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,29 +300,18 @@ function getEmbedInfo(url: string): EmbedInfo | null {
300300
}
301301

302302
/**
303-
* Converts single newlines to markdown hard breaks (two trailing spaces + newline).
304-
* This ensures that pressing Enter in the editor creates a visible line break in the preview.
305-
* Preserves double newlines (paragraph breaks) and code block formatting.
303+
* Convert single newlines to markdown hard breaks, preserving code blocks
306304
*/
307305
function convertNewlinesToBreaks(text: string): string {
308-
// Split by code blocks to preserve their formatting
309306
const parts = text.split(/(```[\s\S]*?```|`[^`\n]+`)/g)
310307

311308
return parts
312309
.map((part, index) => {
313-
// Odd indices are code blocks - don't modify them
314310
if (index % 2 === 1) return part
315311

316-
// For regular text, convert single newlines to hard breaks
317-
// First, temporarily replace double newlines with a placeholder
318312
const placeholder = '\u0000DOUBLE_NEWLINE\u0000'
319313
let processed = part.replace(/\n\n/g, placeholder)
320-
321-
// Add two spaces before single newlines (markdown hard break syntax)
322-
// But only if there aren't already two spaces before the newline
323314
processed = processed.replace(/([^\s\n])(\n)(?!\n)/g, '$1 $2')
324-
325-
// Restore double newlines
326315
processed = processed.replace(new RegExp(placeholder, 'g'), '\n\n')
327316

328317
return processed

0 commit comments

Comments
 (0)