Skip to content

Commit

Permalink
Merge branch 'srmagura-custom-prism'
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdriver committed Feb 1, 2022
2 parents 2b6f095 + 7b18e49 commit 4673a85
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"eslint-plugin-react": "^7.28.0",
"jest": "^27.0.6",
"prettier": "^2.5.1",
"prismjs": "^1.26.0",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const CodeEditor = (props) => {
return (
<div className={props.className} style={props.style}>
<Highlight
Prism={Prism}
Prism={props.prism || Prism}
code={code}
theme={props.theme || liveTheme}
language={props.language}
Expand Down Expand Up @@ -79,6 +79,7 @@ CodeEditor.propTypes = {
disabled: PropTypes.bool,
language: PropTypes.string,
onChange: PropTypes.func,
prism: PropTypes.object,
style: PropTypes.object,
theme: PropTypes.object,
};
Expand Down
7 changes: 6 additions & 1 deletion stories/Editor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";

import Prism from "prismjs";
import { Editor } from "../src/index";

export default {
Expand All @@ -14,3 +14,8 @@ Default.args = {
language: "js",
code: "const x = 'Hello World!';",
};

// Can't pass Prism as an arg since it is not JSON-serializable
export const PrismFromNpm = () => (
<Editor language="js" prism={Prism} code="const x = 'Hello World!';" />
);
1 change: 1 addition & 0 deletions typings/react-live.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type EditorProps = Omit<PreProps, 'onChange'> & {
language?: Language;
onChange?: (code: string) => void;
theme?: PrismTheme;
prism?: unknown
}

export const Editor: ComponentClass<EditorProps>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9504,6 +9504,11 @@ prismjs@^1.21.0, prismjs@~1.24.0:
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.24.1.tgz#c4d7895c4d6500289482fa8936d9cdd192684036"
integrity sha512-mNPsedLuk90RVJioIky8ANZEwYm5w9LcvCXrxHlwf4fNVSn8jEipMybMkWUyyF0JhnC+C4VcOVSBuHRKs1L5Ow==

prismjs@^1.26.0:
version "1.26.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.26.0.tgz#16881b594828bb6b45296083a8cbab46b0accd47"
integrity sha512-HUoH9C5Z3jKkl3UunCyiD5jwk0+Hz0fIgQ2nbwU2Oo/ceuTAQAg+pPVnfdt2TJWRVLcxKh9iuoYDUSc8clb5UQ==

process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
Expand Down

0 comments on commit 4673a85

Please sign in to comment.