Skip to content

Commit c7d96dc

Browse files
authored
Replace react-syntax-highlighter with prism-react-renđerer (#5771)
Signed-off-by: kypham <hongkyhvnh@gmail.com>
1 parent bbc6ea5 commit c7d96dc

File tree

3 files changed

+37
-90
lines changed

3 files changed

+37
-90
lines changed

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"grpc-web": "^1.5.0",
7979
"history": "^4.10.1",
8080
"path-browserify": "^1.0.1",
81+
"prism-react-renderer": "^2.4.1",
8182
"query-string": "^6.14.1",
8283
"react": "^17.0.2",
8384
"react-cookie": "^8.0.1",
@@ -87,7 +88,6 @@
8788
"react-markdown": "^6.0.3",
8889
"react-redux": "^7.2.9",
8990
"react-router-dom": "^6.30.0",
90-
"react-syntax-highlighter": "^15.6.1",
9191
"redux-thunk": "^2.4.1",
9292
"yup": "^0.32.11"
9393
},

web/src/components/settings-page/piped/components/piped-table-row.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import {
1919
import { MoreVert as MoreVertIcon } from "@material-ui/icons";
2020
import clsx from "clsx";
2121
import dayjs from "dayjs";
22-
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
23-
import { coy } from "react-syntax-highlighter/dist/esm/styles/prism";
22+
import { Highlight, themes } from "prism-react-renderer";
2423
import * as React from "react";
2524
import { FC, memo, useCallback, useState } from "react";
2625
import { CopyIconButton } from "~/components/copy-icon-button";
@@ -75,6 +74,10 @@ const useStyles = makeStyles((theme) => ({
7574
backgroundColor: "grey",
7675
},
7776
},
77+
codeBlock: {
78+
padding: theme.spacing(2),
79+
overflow: "auto",
80+
},
7881
}));
7982

8083
interface Props {
@@ -307,9 +310,19 @@ export const PipedTableRow: FC<Props> = memo(function PipedTableRow({
307310
Piped configuration
308311
</DialogTitle>
309312
<DialogContent>
310-
<SyntaxHighlighter language="yaml" style={coy}>
311-
{piped.config}
312-
</SyntaxHighlighter>
313+
<Highlight theme={themes.github} code={piped.config} language="yaml">
314+
{({ style, tokens, getLineProps, getTokenProps }) => (
315+
<pre style={style} className={classes.codeBlock}>
316+
{tokens.map((line, i) => (
317+
<div key={i} {...getLineProps({ line })}>
318+
{line.map((token, key) => (
319+
<span key={key} {...getTokenProps({ token })} />
320+
))}
321+
</div>
322+
))}
323+
</pre>
324+
)}
325+
</Highlight>
313326
</DialogContent>
314327
</Dialog>
315328
</>

web/yarn.lock

Lines changed: 18 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,11 @@
15781578
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.3.0.tgz#2e8332cc7363f887d32ec5496b207d26ba8052bb"
15791579
integrity sha512-hkc1DATxFLQo4VxPDpMH1gCkPpBbpOoJ/4nhuXw4n63/0R6bCpQECj4+K226UJ4JO/eJQz+1mC2I7JsWanAdQw==
15801580

1581+
"@types/prismjs@^1.26.0":
1582+
version "1.26.5"
1583+
resolved "https://registry.yarnpkg.com/@types/prismjs/-/prismjs-1.26.5.tgz#72499abbb4c4ec9982446509d2f14fb8483869d6"
1584+
integrity sha512-AUZTa7hQ2KY5L7AmtSiqxlhWxb4ina0yd8hNbl4TWuqnv/pFP0nDMb3YrfSBf4hJVGLh2YEIBfKaBW/9UEl6IQ==
1585+
15811586
"@types/prop-types@*":
15821587
version "15.7.3"
15831588
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
@@ -2614,6 +2619,11 @@ clsx@^1.2.1:
26142619
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12"
26152620
integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==
26162621

2622+
clsx@^2.0.0:
2623+
version "2.1.1"
2624+
resolved "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz"
2625+
integrity sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==
2626+
26172627
co@^4.6.0:
26182628
version "4.6.0"
26192629
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
@@ -3594,13 +3604,6 @@ fastq@^1.6.0:
35943604
dependencies:
35953605
reusify "^1.0.4"
35963606

3597-
fault@^1.0.0:
3598-
version "1.0.4"
3599-
resolved "https://registry.yarnpkg.com/fault/-/fault-1.0.4.tgz#eafcfc0a6d214fc94601e170df29954a4f842f13"
3600-
integrity sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==
3601-
dependencies:
3602-
format "^0.2.0"
3603-
36043607
faye-websocket@^0.11.3:
36053608
version "0.11.4"
36063609
resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da"
@@ -3715,11 +3718,6 @@ form-data@^4.0.0:
37153718
combined-stream "^1.0.8"
37163719
mime-types "^2.1.12"
37173720

3718-
format@^0.2.0:
3719-
version "0.2.2"
3720-
resolved "https://registry.yarnpkg.com/format/-/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b"
3721-
integrity sha1-1hcBB+nv3E7TDJ3DkBbflCtctYs=
3722-
37233721
formik@^2.2.9:
37243722
version "2.2.9"
37253723
resolved "https://registry.yarnpkg.com/formik/-/formik-2.2.9.tgz#8594ba9c5e2e5cf1f42c5704128e119fc46232d0"
@@ -3970,22 +3968,6 @@ hasown@^2.0.0:
39703968
dependencies:
39713969
function-bind "^1.1.2"
39723970

3973-
hast-util-parse-selector@^2.0.0:
3974-
version "2.2.4"
3975-
resolved "https://registry.yarnpkg.com/hast-util-parse-selector/-/hast-util-parse-selector-2.2.4.tgz#60c99d0b519e12ab4ed32e58f150ec3f61ed1974"
3976-
integrity sha512-gW3sxfynIvZApL4L07wryYF4+C9VvH3AUi7LAnVXV4MneGEgwOByXvFo18BgmTWnm7oHAe874jKbIB1YhHSIzA==
3977-
3978-
hastscript@^6.0.0:
3979-
version "6.0.0"
3980-
resolved "https://registry.yarnpkg.com/hastscript/-/hastscript-6.0.0.tgz#e8768d7eac56c3fdeac8a92830d58e811e5bf640"
3981-
integrity sha512-nDM6bvd7lIqDUiYEiu5Sl/+6ReP0BMk/2f4U/Rooccxkj0P5nm+acM5PrGJ/t5I8qPGiqZSE6hVAwZEdZIvP4w==
3982-
dependencies:
3983-
"@types/hast" "^2.0.0"
3984-
comma-separated-tokens "^1.0.0"
3985-
hast-util-parse-selector "^2.0.0"
3986-
property-information "^5.0.0"
3987-
space-separated-tokens "^1.0.0"
3988-
39893971
he@^1.2.0:
39903972
version "1.2.0"
39913973
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
@@ -3996,16 +3978,6 @@ headers-utils@^1.2.0:
39963978
resolved "https://registry.yarnpkg.com/headers-utils/-/headers-utils-1.2.0.tgz#5e10d1bc9d2bccf789547afca5b991a3167241e8"
39973979
integrity sha512-4/BMXcWrJErw7JpM87gF8MNEXcIMLzepYZjNRv/P9ctgupl2Ywa3u1PgHtNhSRq84bHH9Ndlkdy7bSi+bZ9I9A==
39983980

3999-
highlight.js@^10.4.1, highlight.js@~10.7.0:
4000-
version "10.7.3"
4001-
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.7.3.tgz#697272e3991356e40c3cac566a74eef681756531"
4002-
integrity sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==
4003-
4004-
highlightjs-vue@^1.0.0:
4005-
version "1.0.0"
4006-
resolved "https://registry.yarnpkg.com/highlightjs-vue/-/highlightjs-vue-1.0.0.tgz#fdfe97fbea6354e70ee44e3a955875e114db086d"
4007-
integrity sha512-PDEfEF102G23vHmPhLyPboFCD+BkMGu+GuJe2d9/eH4FsCwvgBpnc9n0pGE+ffKdph38s6foEZiEjdgHdzp+IA==
4008-
40093981
history@^4.10.1:
40103982
version "4.10.1"
40113983
resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3"
@@ -5166,14 +5138,6 @@ lower-case@^2.0.2:
51665138
dependencies:
51675139
tslib "^2.0.3"
51685140

5169-
lowlight@^1.17.0:
5170-
version "1.20.0"
5171-
resolved "https://registry.yarnpkg.com/lowlight/-/lowlight-1.20.0.tgz#ddb197d33462ad0d93bf19d17b6c301aa3941888"
5172-
integrity sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==
5173-
dependencies:
5174-
fault "^1.0.0"
5175-
highlight.js "~10.7.0"
5176-
51775141
lru-cache@^5.1.1:
51785142
version "5.1.1"
51795143
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
@@ -5866,15 +5830,13 @@ pretty-format@^29.7.0:
58665830
ansi-styles "^5.0.0"
58675831
react-is "^18.0.0"
58685832

5869-
prismjs@^1.27.0:
5870-
version "1.28.0"
5871-
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.28.0.tgz#0d8f561fa0f7cf6ebca901747828b149147044b6"
5872-
integrity sha512-8aaXdYvl1F7iC7Xm1spqSaY/OJBpYW3v+KJ+F17iYxvdc8sfjW194COK5wVhMZX45tGteiBQgdvD/nhxcRwylw==
5873-
5874-
prismjs@~1.27.0:
5875-
version "1.27.0"
5876-
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.27.0.tgz#bb6ee3138a0b438a3653dd4d6ce0cc6510a45057"
5877-
integrity sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==
5833+
prism-react-renderer@^2.4.1:
5834+
version "2.4.1"
5835+
resolved "https://registry.yarnpkg.com/prism-react-renderer/-/prism-react-renderer-2.4.1.tgz#ac63b7f78e56c8f2b5e76e823a976d5ede77e35f"
5836+
integrity sha512-ey8Ls/+Di31eqzUxC46h8MksNuGx/n0AAC8uKpwFau4RPDYLuE3EXTp8N8G2vX2N7UC/+IXeNUnlWBGGcAG+Ig==
5837+
dependencies:
5838+
"@types/prismjs" "^1.26.0"
5839+
clsx "^2.0.0"
58785840

58795841
process-nextick-args@~2.0.0:
58805842
version "2.0.1"
@@ -5922,13 +5884,6 @@ property-expr@^2.0.4:
59225884
resolved "https://registry.yarnpkg.com/property-expr/-/property-expr-2.0.4.tgz#37b925478e58965031bb612ec5b3260f8241e910"
59235885
integrity sha512-sFPkHQjVKheDNnPvotjQmm3KD3uk1fWKUN7CrpdbwmUx3CrG3QiM8QpTSimvig5vTXmTvjz7+TDvXOI9+4rkcg==
59245886

5925-
property-information@^5.0.0:
5926-
version "5.5.0"
5927-
resolved "https://registry.yarnpkg.com/property-information/-/property-information-5.5.0.tgz#4dc075d493061a82e2b7d096f406e076ed859943"
5928-
integrity sha512-RgEbCx2HLa1chNgvChcx+rrCWD0ctBmGSE0M7lVm1yyv4UbvbrWoXp/BkVLZefzjrRBGW8/Js6uh/BnlHXFyjA==
5929-
dependencies:
5930-
xtend "^4.0.0"
5931-
59325887
property-information@^5.3.0:
59335888
version "5.6.0"
59345889
resolved "https://registry.yarnpkg.com/property-information/-/property-information-5.6.0.tgz#61675545fb23002f245c6540ec46077d4da3ed69"
@@ -6117,18 +6072,6 @@ react-shallow-renderer@^16.13.1:
61176072
object-assign "^4.1.1"
61186073
react-is "^16.12.0 || ^17.0.0"
61196074

6120-
react-syntax-highlighter@^15.6.1:
6121-
version "15.6.1"
6122-
resolved "https://registry.yarnpkg.com/react-syntax-highlighter/-/react-syntax-highlighter-15.6.1.tgz#fa567cb0a9f96be7bbccf2c13a3c4b5657d9543e"
6123-
integrity sha512-OqJ2/vL7lEeV5zTJyG7kmARppUjiB9h9udl4qHQjjgEos66z00Ia0OckwYfRxCSFrW8RJIBnsBwQsHZbVPspqg==
6124-
dependencies:
6125-
"@babel/runtime" "^7.3.1"
6126-
highlight.js "^10.4.1"
6127-
highlightjs-vue "^1.0.0"
6128-
lowlight "^1.17.0"
6129-
prismjs "^1.27.0"
6130-
refractor "^3.6.0"
6131-
61326075
react-test-renderer@^17.0.2:
61336076
version "17.0.2"
61346077
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-17.0.2.tgz#4cd4ae5ef1ad5670fc0ef776e8cc7e1231d9866c"
@@ -6239,15 +6182,6 @@ redux@^4.2.1:
62396182
dependencies:
62406183
"@babel/runtime" "^7.9.2"
62416184

6242-
refractor@^3.6.0:
6243-
version "3.6.0"
6244-
resolved "https://registry.yarnpkg.com/refractor/-/refractor-3.6.0.tgz#ac318f5a0715ead790fcfb0c71f4dd83d977935a"
6245-
integrity sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA==
6246-
dependencies:
6247-
hastscript "^6.0.0"
6248-
parse-entities "^2.0.0"
6249-
prismjs "~1.27.0"
6250-
62516185
regenerator-runtime@^0.13.4:
62526186
version "0.13.7"
62536187
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
@@ -6678,7 +6612,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1:
66786612
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
66796613
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
66806614

6681-
space-separated-tokens@^1.0.0, space-separated-tokens@^1.1.0:
6615+
space-separated-tokens@^1.1.0:
66826616
version "1.1.5"
66836617
resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz#85f32c3d10d9682007e917414ddc5c26d1aa6899"
66846618
integrity sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==

0 commit comments

Comments
 (0)