Skip to content

Commit fc9f833

Browse files
author
Paul Korzhyk
committed
Use hljs in Ratel responses to support copy-paste
1 parent 0ddcddf commit fc9f833

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
"react-data-grid": "^4.0.8",
202202
"react-dom": "^16.2.0",
203203
"react-draggable": "^3.0.5",
204+
"react-highlight": "^0.12.0",
204205
"react-redux": "^5.0.6",
205206
"react-router-dom": "^4.2.2",
206207
"react-timeago": "^4.1.9",

client/src/assets/css/Frames.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,14 @@
9595
z-index: 1000;
9696
}
9797

98-
.editor-outer {
98+
pre {
99+
bottom: 0;
99100
flex: 1;
101+
margin: 0;
102+
padding-left: 12px;
103+
position: absolute;
104+
top: 0;
100105
width: 100%;
101-
.CodeMirror {
102-
box-shadow: inset #ccc 0 0 1px 1px;
103-
}
104106
}
105107
}
106108
}

client/src/components/FrameCodeTab.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
import React from "react";
1010
import Clipboard from "react-clipboard.js";
11+
import Highlight from "react-highlight";
1112

12-
import Editor from "containers/Editor";
13+
import "highlight.js/styles/atom-one-light.css";
1314

1415
const STATE_IDLE = 0;
1516
const STATE_ERROR = -1;
@@ -61,7 +62,7 @@ export default class FrameCodeTab extends React.Component {
6162
};
6263

6364
render() {
64-
const { code, mode } = this.props;
65+
const { code } = this.props;
6566
const { copyState } = this.state;
6667
const json =
6768
typeof code === "string"
@@ -86,12 +87,11 @@ export default class FrameCodeTab extends React.Component {
8687
</span>
8788
</Clipboard>
8889

89-
<Editor
90-
key={json.length}
91-
query={json}
92-
mode={mode || "javascript"}
93-
readOnly="nocursor"
94-
/>
90+
{json && json.length > 16000 ? (
91+
<pre>{json}</pre>
92+
) : (
93+
<Highlight>{json}</Highlight>
94+
)}
9595
</div>
9696
);
9797
}

client/src/components/FrameLayout/FrameSession.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function FrameSession(props) {
182182
) : null}
183183

184184
{currentTab === "userQuery" ? (
185-
<FrameCodeTab code={frame.query} mode="graphql" />
185+
<FrameCodeTab code={frame.query} />
186186
) : null}
187187
</div>
188188
);

client/src/components/FrameMessage.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ URL: ${error.url}
6868
currentTab === "jsonResponse",
6969
<FrameCodeTab code={isError ? error : response} />,
7070
)}
71-
{_if(
72-
currentTab === "userQuery",
73-
<FrameCodeTab code={query} mode="graphql" />,
74-
)}
71+
{_if(currentTab === "userQuery", <FrameCodeTab code={query} />)}
7572

7673
{_if(
7774
isError,

0 commit comments

Comments
 (0)