Skip to content

Commit 529aeb4

Browse files
akoremangethinwebster
authored andcommitted
chore: replace Ace text highlight rules with in-repo function
1 parent d0550ce commit 529aeb4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/code-view/internal.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,32 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { useCurrentMode } from "@cloudscape-design/component-toolkit/internal";
44
import Box from "@cloudscape-design/components/box";
5-
import { TextHighlightRules } from "ace-code/src/mode/text_highlight_rules";
65
import clsx from "clsx";
76
import { useRef } from "react";
87
import { Children } from "react";
98
import { InternalBaseComponentProps, getBaseProps } from "../internal/base-component/use-base-component";
10-
import { createHighlight } from "./highlight";
119
import { CodeViewProps } from "./interfaces";
1210
import styles from "./styles.css.js";
1311

1412
const ACE_CLASSES = { light: "ace-cloud_editor", dark: "ace-cloud_editor_dark" };
1513

1614
type InternalCodeViewProps = CodeViewProps & InternalBaseComponentProps;
1715

18-
const textHighlight = createHighlight(new TextHighlightRules());
16+
// Breaks down the input code for non-highlighted code-view into React
17+
// Elements similar to how a highlight function would do.
18+
const textHighlight = (code: string) => {
19+
const lines = code.split("\n");
20+
return (
21+
<span>
22+
{lines.map((line, lineIndex) => (
23+
<span key={lineIndex}>
24+
{line}
25+
{"\n"}
26+
</span>
27+
))}
28+
</span>
29+
);
30+
};
1931

2032
export function InternalCodeView({
2133
content,

0 commit comments

Comments
 (0)