File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed
Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 22 <h1 class =" " >Vuejs Code Block UI Component</h1 >
33
44 <CodeBlock
5- theme =" ultramin "
5+ theme =" dracula "
66 :code =" code"
77 language =" python"
88 :numbered =" true"
Original file line number Diff line number Diff line change 2020 alt =" " />
2121 <span >{{ props.fileName }}</span >
2222 </div >
23- <div class =" actions" >
23+ <div
24+ @click =" copyCodeToClipboard(props.code)"
25+ class =" actions" >
2426 <button
2527 type =" button"
2628 class =" copy-button" >
7981 codeBlockInstance
8082 } from ' ./types' ;
8183 import { useCodeBlock } from ' ./use-code-block' ;
82- import { parseCodeIntoLines } from ' ../utils' ;
83-
84+ import { copyCodeToClipboard , parseCodeIntoLines } from ' ../utils' ;
8485 import { addThemeToCodeBlock , themes } from ' ../themes' ;
8586
8687 const props = defineProps (codeBlockProps ());
8788
8889 const codeBlock: Ref <HTMLDivElement | null > = ref (null );
89-
9090 const code = computed (() => parseCodeIntoLines (props .code , props .language ));
9191 const currentTheme = computed (() => themes [props .theme ]);
9292
133133 gap : 0.5rem ;
134134 padding : 0.5rem 1.5rem ;
135135 padding-left : 0.25rem ;
136-
137- /* align-items: center;
138- border-bottom: 1px solid #7dd3fc; */
139136 }
140137
141138 .vuejs-code-block pre .header .file-name p {
154151 padding : 0 ;
155152 cursor : pointer ;
156153 color : #64748b ;
154+ background : rgba (127.5 , 127.5 , 127.5 , 0.15 );
155+ border-radius : 0.5rem ;
157156 transition : color 150ms ease-in-out ;
158157 }
159158
Original file line number Diff line number Diff line change @@ -39,3 +39,7 @@ export function parseCodeIntoLines(
3939 . map ( ( line ) => line . replace ( / \s + $ / , '' ) )
4040 . filter ( ( line ) => line . length > 0 || line === '' ) ;
4141}
42+
43+ export function copyCodeToClipboard ( code : string ) {
44+ window . navigator . clipboard . writeText ( code ) ;
45+ }
You can’t perform that action at this time.
0 commit comments