File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 22// SPDX-License-Identifier: Apache-2.0
33import { useCurrentMode } from "@cloudscape-design/component-toolkit/internal" ;
44import Box from "@cloudscape-design/components/box" ;
5- import { TextHighlightRules } from "ace-code/src/mode/text_highlight_rules" ;
65import clsx from "clsx" ;
76import { useRef } from "react" ;
87import { Children } from "react" ;
98import { InternalBaseComponentProps , getBaseProps } from "../internal/base-component/use-base-component" ;
10- import { createHighlight } from "./highlight" ;
119import { CodeViewProps } from "./interfaces" ;
1210import styles from "./styles.css.js" ;
1311
1412const ACE_CLASSES = { light : "ace-cloud_editor" , dark : "ace-cloud_editor_dark" } ;
1513
1614type 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
2032export function InternalCodeView ( {
2133 content,
You can’t perform that action at this time.
0 commit comments