Skip to content

Commit ffee037

Browse files
Fix multiline timeline summaries (#3944)
1 parent 80d864d commit ffee037

6 files changed

Lines changed: 40 additions & 1 deletion

File tree

‎src/lib/components/event/event-card.svelte‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
content={decodedValue}
259259
fill={false}
260260
compact
261+
singleLine
261262
minHeight={0}
262263
overrideTheme="primary"
263264
title={translate('workflows.summary')}

‎src/lib/components/event/event-summary-row.svelte‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@
370370
fill={false}
371371
fitContent
372372
compact
373+
singleLine
373374
minHeight={0}
374375
overrideTheme="primary"
375376
title={translate('workflows.summary')}

‎src/lib/components/lines-and-dots/timeline-graph/timeline-graph-row.svelte‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
fill={false}
198198
fitContent
199199
compact
200+
singleLine
200201
minHeight={0}
201202
overrideTheme="primary"
202203
title={translate('workflows.summary')}

‎src/lib/holocene/markdown-editor/preview.svelte‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
88
import { useDarkMode } from '$lib/utilities/dark-mode';
99
10+
import { normalizePreviewContent } from './preview';
11+
1012
interface Props {
1113
content: string;
1214
class?: ClassNameValue;
@@ -30,6 +32,8 @@
3032
* or two rather than a document.
3133
*/
3234
compact?: boolean;
35+
/** Normalize line breaks so Markdown renders on a single line. */
36+
singleLine?: boolean;
3337
/**
3438
* Accessible name for the frame. Name what the content is, so a frame in
3539
* a list of them is distinguishable.
@@ -47,6 +51,7 @@
4751
minHeight = 100,
4852
previewTheme,
4953
compact = false,
54+
singleLine = false,
5055
title = 'output',
5156
}: Props = $props();
5257
@@ -162,7 +167,10 @@
162167
return content;
163168
};
164169
165-
const templatedContent = $derived(replaceTemplate(content));
170+
const normalizedContent = $derived(
171+
normalizePreviewContent(content, singleLine),
172+
);
173+
const templatedContent = $derived(replaceTemplate(normalizedContent));
166174
const resolvedPreviewTheme = $derived(
167175
previewTheme ?? ($useDarkMode ? 'dark' : 'light'),
168176
);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
import { normalizePreviewContent } from './preview';
4+
5+
describe('normalizePreviewContent', () => {
6+
it('preserves line breaks by default', () => {
7+
const content = 'First line \nSecond line';
8+
9+
expect(normalizePreviewContent(content, false)).toBe(content);
10+
});
11+
12+
it('removes line breaks in single-line mode', () => {
13+
expect(normalizePreviewContent('First line \nSecond line', true)).toBe(
14+
'First line Second line',
15+
);
16+
});
17+
18+
it('preserves inline Markdown in single-line mode', () => {
19+
const content = '[Link](https://temporal.io) and **bold text**';
20+
21+
expect(normalizePreviewContent(content, true)).toBe(content);
22+
});
23+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const normalizePreviewContent = (
2+
content: string,
3+
singleLine: boolean,
4+
): string =>
5+
singleLine ? content.replace(/[ \t]*(?:\r\n?|\n)+[ \t]*/g, ' ') : content;

0 commit comments

Comments
 (0)