Skip to content

Commit 1ba965b

Browse files
committed
add code highlighting, ANSI support, and improve E2E tests
1 parent 4df8087 commit 1ba965b

File tree

16 files changed

+186
-273
lines changed

16 files changed

+186
-273
lines changed

zeppelin-web-angular/e2e/models/published-paragraph-page.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ import { navigateToNotebookWithFallback } from '../utils';
1515
import { BasePage } from './base-page';
1616

1717
export class PublishedParagraphPage extends BasePage {
18-
readonly paragraphResult: Locator;
19-
readonly errorModalContent: Locator;
20-
readonly errorModalOkButton: Locator;
18+
private readonly errorModalContent: Locator;
19+
private readonly errorModalOkButton: Locator;
2120
readonly confirmationModal: Locator;
2221

2322
constructor(page: Page) {
2423
super(page);
25-
this.paragraphResult = page.locator('zeppelin-notebook-paragraph-result');
2624
this.errorModalContent = this.page.locator('.ant-modal-body', { hasText: 'Paragraph Not Found' }).last();
2725
this.errorModalOkButton = page.getByRole('button', { name: 'OK' }).last();
2826
this.confirmationModal = page.locator('div.ant-modal-confirm').last();

zeppelin-web-angular/e2e/tests/notebook/published/published-paragraph.spec.ts

Lines changed: 70 additions & 181 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules

zeppelin-web-angular/projects/zeppelin-react/package-lock.json

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

zeppelin-web-angular/projects/zeppelin-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@ant-design/icons": "5.4.0",
1111
"@antv/g2plot": "2.4.35",
1212
"@zeppelin/sdk": "file:../zeppelin-sdk",
13+
"ansi-to-react": "6.2.6",
1314
"antd": "5.21.0",
1415
"file-saver": "2.0.5",
1516
"react": "18.3.1",

zeppelin-web-angular/projects/zeppelin-react/src/components/common/Empty.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,5 @@
1313
import { Alert } from 'antd';
1414

1515
export const Empty = () => {
16-
return (
17-
<Alert
18-
message="No Data"
19-
description="No paragraph data found"
20-
type="warning"
21-
showIcon
22-
/>
23-
);
24-
};
16+
return <Alert message="No Data" description="No paragraph data found" type="warning" showIcon />;
17+
};

zeppelin-web-angular/projects/zeppelin-react/src/components/common/Loading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ export const Loading = () => {
2121
</Typography.Title>
2222
</div>
2323
);
24-
};
24+
};

zeppelin-web-angular/projects/zeppelin-react/src/components/renderers/HTMLRenderer.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import { useEffect, useRef } from 'react';
14-
// Added styles for tables rendered as HTML from app/pages/workspace/share/result/result.component.ts
14+
import hljs from 'highlight.js';
1515
import './HTMLRenderer.css';
1616

1717
interface HTMLRendererProps {
@@ -29,6 +29,12 @@ export const HTMLRenderer = ({ html }: HTMLRendererProps) => {
2929
// to the DOM to execute them.
3030
container.innerHTML = html;
3131

32+
// Highlight code blocks (matches Angular: result.component.ts renderHTML)
33+
const codeEle = container.querySelector('pre code');
34+
if (codeEle) {
35+
hljs.highlightBlock(codeEle as HTMLElement);
36+
}
37+
3238
const scripts = Array.from(container.querySelectorAll('script'));
3339

3440
scripts.forEach(script => {
@@ -51,4 +57,4 @@ export const HTMLRenderer = ({ html }: HTMLRendererProps) => {
5157
}, [html]);
5258

5359
return <div ref={containerRef} className="inner-html" />;
54-
};
60+
};

zeppelin-web-angular/projects/zeppelin-react/src/components/renderers/ImageRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ export const ImageRenderer = ({ imageData }: ImageRendererProps) => {
2020
return (
2121
<img src={imgSrc} alt="Result" style={{ maxWidth: '100%', height: 'auto' }} />
2222
);
23-
};
23+
};

zeppelin-web-angular/projects/zeppelin-react/src/components/renderers/TextRenderer.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
* limitations under the License.
1111
*/
1212

13-
import { Typography } from 'antd';
13+
import Ansi from 'ansi-to-react';
1414

1515
export interface TextRendererProps {
1616
text: string;
1717
}
1818

19+
// Matches Angular: result.component.ts renderText()
1920
export const TextRenderer = ({ text }: TextRendererProps) => {
2021
return (
21-
<Typography.Text style={{ whiteSpace: 'pre-wrap' }}>
22-
{text}
23-
</Typography.Text>
22+
<pre style={{ whiteSpace: 'pre-wrap', margin: 0 }}>
23+
<Ansi>{text}</Ansi>
24+
</pre>
2425
);
25-
};
26+
};

0 commit comments

Comments
 (0)