File tree Expand file tree Collapse file tree 6 files changed +73
-22
lines changed Expand file tree Collapse file tree 6 files changed +73
-22
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " react-highlight-code" ,
3- "private" : true ,
4- "version" : " 0.0.0 " ,
3+ "private" : false ,
4+ "version" : " 0.0.1 " ,
55 "scripts" : {
66 "dev" : " vite" ,
77 "build" : " vite build" ,
88 "preview" : " vite preview"
99 },
10+ "license" : " MIT" ,
11+ "main" : " ./dist/react-highlight-code.umd.js" ,
12+ "module" : " ./dist/react-highlight-code.es.js" ,
13+ "files" : [
14+ " dist"
15+ ],
16+ "exports" : {
17+ "." : {
18+ "import" : " ./dist/react-highlight-code.es.js" ,
19+ "require" : " ./dist/react-highlight-code.umd.js"
20+ },
21+ "./dist/style.css" : " ./dist/style.css"
22+ },
23+ "repository" : {
24+ "type" : " git" ,
25+ "url" : " https://github.com/F-one-1/react-highlight-code.git"
26+ },
27+ "homepage" : " https://github.com/F-one-1/react-highlight-code" ,
1028 "dependencies" : {
1129 "highlight.js" : " ^11.5.1" ,
1230 "react" : " ^18.0.0" ,
1735 "@types/react-dom" : " ^18.0.0" ,
1836 "@vitejs/plugin-react" : " ^1.3.0" ,
1937 "classnames" : " ^2.3.1" ,
38+ "react-highlight-code" : " ^0.0.1" ,
2039 "sass" : " ^1.53.0" ,
2140 "sass-loader" : " ^13.0.0" ,
2241 "vite" : " ^2.9.9"
23- }
42+ },
43+ "peerDependencies" : {
44+ "react" : " ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" ,
45+ "react-dom" : " ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
46+ },
47+ "keywords" : [
48+ " highlight" ,
49+ " react" ,
50+ " component" ,
51+ " highlight.js"
52+ ]
2453}
Original file line number Diff line number Diff line change 11import logo from './logo.svg'
22import './App.css'
3- import { HighCode } from '../dist/react-highlight-code.es.js'
4- import '../dist/style.css'
3+ // import { HighCode } from 'react-highlight-code'
4+ // import 'react-highlight-code/dist/style.css'
5+ import HighCode from './component/HighCode'
56function App ( ) {
6- const height = '200px'
7- const value = `import { HighCode } from 'vue-highlight-code';
8- import 'vue-highlight-code/dist/style.css';
9- export default {
10- components: {
11- HighCode
12- },
13- data(){
14-
15- }
16- }`
7+ // const height = '200px'
8+ const value = `import { HighCode } from 'react-highlight-code';
9+ import 'react-highlight-code/dist/style.css';
10+ const value = 'only one prop to show highlightCode using highlight.js'
11+ return (
12+ <div className="wrapper">
13+ <HighCode className="code" langName="jsx" codeValue={value}></HighCode>
14+ <HighCode
15+ className="code"
16+ langName="javascript"
17+ codeValue={value}
18+ theme="light"
19+ ></HighCode>
20+ </div>
21+ )
22+ `
1723 return (
1824 < div className = "wrapper" >
19- < HighCode className = "code" height = { height } codeValue = { value } > </ HighCode >
25+ < HighCode className = "code" langName = "jsx" codeValue = { value } > </ HighCode >
26+ < HighCode
27+ className = "code"
28+ langName = "javascript"
29+ codeValue = { value }
30+ theme = "light"
31+ > </ HighCode >
2032 </ div >
2133 )
2234}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export default function HighCode(props) {
1616 width = '520px' ,
1717 height = '' ,
1818 maxWidth = '' ,
19- maxHeight = '' ,
19+ maxHeight = '200px ' ,
2020 scrollStyleBool = true ,
2121 codeValue = '' ,
2222 fontSize = 16 ,
@@ -41,7 +41,7 @@ export default function HighCode(props) {
4141 [ `language-${ lang } ` ] : true ,
4242 } )
4343 const codeHighlight = useRef ( null )
44-
44+ console . log ( langName , props . langName , 'langName' )
4545 useEffect ( ( ) => {
4646 // eslint-disable-next-line no-unused-expressions
4747 if ( codeHighlight && codeHighlight . current ) {
@@ -75,7 +75,7 @@ export default function HighCode(props) {
7575 } }
7676 >
7777 < div className = "code_header" >
78- { nameShow && < TypeShow TL = { props . langName } > </ TypeShow > }
78+ { nameShow && < TypeShow TL = { langName || props . langName } > </ TypeShow > }
7979 { copy && < CopyCode codeValue = { props . codeValue } > </ CopyCode > }
8080 </ div >
8181 < div
Original file line number Diff line number Diff line change 11import './style/TypeShow.scss'
22export default function TypeShow ( props ) {
3- const { langName = 'Bash' } = props
3+ const { TL = 'js' } = props
4+ console . log ( props , 'props' )
45 return (
56 < div className = "TL" >
6- < div className = "TL_word" > { langName } </ div >
7+ < div className = "TL_word" > { TL } </ div >
78 </ div >
89 )
910}
Original file line number Diff line number Diff line change @@ -741,6 +741,15 @@ react-dom@^18.0.0:
741741 loose-envify "^1.1.0"
742742 scheduler "^0.23.0"
743743
744+ react-highlight-code@^0.0.1 :
745+ version "0.0.1"
746+ resolved "https://registry.npmjs.org/react-highlight-code/-/react-highlight-code-0.0.1.tgz#939b8d42d29ad4f4726a096620d29232539ba14a"
747+ integrity sha512-TJnrnqpnHk/utIUmUoLfo7GVsTuPVvr3Vel87bk8TkTrbGkSw1sIbqGVlbPzIOpdxYqQrU87YC+NgUmUJJfh6g==
748+ dependencies :
749+ highlight.js "^11.5.1"
750+ react "^18.0.0"
751+ react-dom "^18.0.0"
752+
744753react-refresh@^0.13.0 :
745754 version "0.13.0"
746755 resolved "https://registry.npmjs.org/react-refresh/-/react-refresh-0.13.0.tgz#cbd01a4482a177a5da8d44c9755ebb1f26d5a1c1"
You can’t perform that action at this time.
0 commit comments