mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: create new AnsiUp instance for every render
This commit is contained in:
1 parent
86d2a36731
commit
e137e1940f
2 files changed
+2
-6
No files matched your search
@@ -3,10 +3,8 @@ import { AnsiUp } from 'ansi_up';
|
|||||||
|
|
||||||
export { formatSeconds, size } from 'hydrooj';
|
export { formatSeconds, size } from 'hydrooj';
|
||||||
|
|
||||||
const AU = new AnsiUp();
|
|
||||||
|
|
||||||
export function ansiToHtml(str: string, whiteToBlack = true) {
|
export function ansiToHtml(str: string, whiteToBlack = true) {
|
||||||
const res = AU.ansi_to_html(str);
|
const res = new AnsiUp().ansi_to_html(str);
|
||||||
return whiteToBlack ? res.replace(/style="color:rgb\(255,255,255\)"/g, 'style="color:black"') : res;
|
return whiteToBlack ? res.replace(/style="color:rgb\(255,255,255\)"/g, 'style="color:black"') : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import { i18n } from 'vj/utils';
|
|||||||
import DataInput from './DataInputComponent';
|
import DataInput from './DataInputComponent';
|
||||||
import Panel from './PanelComponent';
|
import Panel from './PanelComponent';
|
||||||
|
|
||||||
const AU = new AnsiUp();
|
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
input: state.pretest.input,
|
input: state.pretest.input,
|
||||||
output: state.pretest.output,
|
output: state.pretest.output,
|
||||||
@@ -47,7 +45,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadPret
|
|||||||
/>
|
/>
|
||||||
<DataInput
|
<DataInput
|
||||||
title={i18n('Output')}
|
title={i18n('Output')}
|
||||||
value={AU.ansi_to_html(this.props.output)}
|
value={new AnsiUp().ansi_to_html(this.props.output)}
|
||||||
html
|
html
|
||||||
/>
|
/>
|
||||||
</Allotment>
|
</Allotment>
|
||||||
|
|||||||
Reference in new issue
Block a user