Skip to content

Commit

Permalink
Add useAnsiClasses prop to LogViewer component
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-stasse committed Mar 28, 2024
1 parent 06907fe commit ec01202
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/module/src/LogViewer/LogViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ interface LogViewerProps {
}) => void;
/** Forwarded ref */
innerRef?: React.RefObject<any>;
/** Flag to enable or disable the use of classes (instead of inline styles) for ANSI coloring/formatting. */
useAnsiClasses?: boolean;
}

let canvas: HTMLCanvasElement | undefined;
Expand Down Expand Up @@ -89,6 +91,7 @@ const LogViewerBase: React.FunctionComponent<LogViewerProps> = memo(
innerRef,
isTextWrapped = true,
initialIndexWidth,
useAnsiClasses,
...props
}: LogViewerProps) => {
const [searchedInput, setSearchedInput] = useState<string | null>('');
Expand All @@ -108,6 +111,8 @@ const LogViewerBase: React.FunctionComponent<LogViewerProps> = memo(
const ansiUp = new AnsiUp();
// eslint-disable-next-line camelcase
ansiUp.escape_html = false;
// eslint-disable-next-line camelcase
ansiUp.use_classes = useAnsiClasses;

const ref = React.useRef<any>();
const logViewerRef = innerRef || ref;
Expand Down
4 changes: 2 additions & 2 deletions packages/module/src/ansi_up/ansi_up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export default class AnsiUp {
// All construction occurs here
this.setup_palettes();
this.resetStyles();

this._use_classes = false;
}

set use_classes(arg: boolean) {
Expand Down Expand Up @@ -543,8 +545,6 @@ export default class AnsiUp {
}

resetStyles() {
this._use_classes = false;

this.bold = false;
this.faint = false;
this.italic = false;
Expand Down

0 comments on commit ec01202

Please sign in to comment.