99 <template v-if =" slots .label " >
1010 <slot name =" label" />
1111 </template >
12- <template v-else >
13- {{ props.label }}
14- </template >
12+ <template v-else >{{ props.label }}</template >
1513 </div >
1614
1715 <div class =" v-code-block--tabs" :style =" tabGroupStyle" >
6967 </div >
7068
7169 <pre :class =" `language-${props.lang}`" :style =" preTagStyles" >
72- <code :class =" `language-${props.lang} ${browserWindow ? 'v-code-block--code-browser' : ''}`" :style =" codeTagStyles" v-html =" renderCode" ></code >
70+ <code
71+ :class =" `language-${props.lang} ${browserWindow ? 'v-code-block--code-browser' : ''}`"
72+ :style =" codeTagStyles"
73+ v-html =" renderCode"
74+ ></code >
7375 </pre >
7476 </div >
7577 </div >
@@ -84,6 +86,7 @@ import {
8486 ref ,
8587 useSlots ,
8688 watch ,
89+ StyleValue ,
8790} from ' vue' ;
8891import Prism from ' prismjs' ;
8992import UAParser from ' ua-parser-js' ;
@@ -101,13 +104,22 @@ const prismThemeSolarizedlight = import.meta.glob('prismjs/themes/prism-solarize
101104const prismThemeTomorrow = import .meta .glob (' prismjs/themes/prism-tomorrow.css' , { eager: true , as: ' raw' });
102105const prismThemeTwilight = import .meta .glob (' prismjs/themes/prism-twilight.css' , { eager: true , as: ' raw' });
103106
107+ // import neonBunnyCarrotTheme from '@/plugin/themes/neon-bunny-carrot.css?inline';
108+ // import neonBunnyTheme from '@/plugin/themes/neon-bunny.css?inline';
109+ // import prismTheme from 'prismjs/themes/prism.css?inline';
110+ // import prismThemeCoy from 'prismjs/themes/prism-coy.css?inline';
111+ // import prismThemeDark from 'prismjs/themes/prism-dark.css?inline';
112+ // import prismThemeFunky from 'prismjs/themes/prism-funky.css?inline';
113+ // import prismThemeOkaidia from 'prismjs/themes/prism-okaidia.css?inline';
114+ // import prismThemeSolarizedlight from 'prismjs/themes/prism-solarizedlight.css?inline';
115+ // import prismThemeTomorrow from 'prismjs/themes/prism-tomorrow.css?inline';
116+ // import prismThemeTwilight from 'prismjs/themes/prism-twilight.css?inline';
104117
105118// -------------------------------------------------- Emits & Slots & Injects //
106119const emit = defineEmits ([' run' , ' update:copy-status' ]);
107120const slots = useSlots ();
108121const codeBlockGlobalOptions = inject <Props >(' codeBlockGlobalOptions' );
109122
110-
111123// -------------------------------------------------- Props //
112124const props = defineProps ({
113125 browserWindow: {
@@ -213,10 +225,9 @@ const props = defineProps({
213225 type: [String , Boolean ],
214226 required: false ,
215227 default: ' neon-bunny' ,
216- }
228+ },
217229});
218230
219-
220231// -------------------------------------------------- Data //
221232const copyTextValue = ref <string >(' ' );
222233const convertedCode = ref (null );
@@ -227,13 +238,12 @@ const runTextValue = ref<string>('');
227238const stylesheetId = ' v-code-block--theme' ;
228239const useTheme = ref <boolean | string >(' ' );
229240
230-
231241// -------------------------------------------------- Computed //
232242const codeBlockClasses = computed <string >(() => {
233243 return isMobile .value ? ' v-code-block--mobile' : ' ' ;
234244});
235245
236- const codeTagStyles = computed <object >(() => {
246+ const codeTagStyles = computed <StyleValue >(() => {
237247 const width = useTheme .value === ' coy' ? ' 100%' : ' ' ;
238248 return { width };
239249});
@@ -247,7 +257,7 @@ const copyButtonClasses = computed<object>(() => {
247257 };
248258});
249259
250- const headerStyles = computed <object >(() => {
260+ const headerStyles = computed <StyleValue >(() => {
251261 return {
252262 bottom: props .floatingTabs ? ' 1px' : ' 0' ,
253263 gap: convertToUnit (props .tabGap ),
@@ -270,7 +280,7 @@ const labelClasses = computed<string>(() => {
270280 return isMobile .value ? ' v-code-block--label-mobile' : ' ' ;
271281});
272282
273- const preTagStyles = computed <object >(() => {
283+ const preTagStyles = computed <StyleValue >(() => {
274284 const radius = props .codeBlockRadius ;
275285 let borderRadius = ` ${radius } 0 ${radius } ${radius } ` ;
276286
@@ -291,7 +301,11 @@ const preTagStyles = computed<object>(() => {
291301const renderCode = computed <unknown >(() => {
292302 convertCode ();
293303
294- const html = Prism .highlight (convertedCode .value , Prism .languages [props .lang ], props .lang );
304+ const html = Prism .highlight (
305+ convertedCode .value ,
306+ Prism .languages [props .lang ],
307+ props .lang ,
308+ );
295309
296310 return html ;
297311});
@@ -304,13 +318,12 @@ const tabClasses = computed<object>(() => {
304318 return classes ;
305319});
306320
307- const tabGroupStyle = computed <object >(() => {
321+ const tabGroupStyle = computed <StyleValue >(() => {
308322 return {
309323 gap: convertToUnit (props .tabGap ),
310324 };
311325});
312326
313-
314327// -------------------------------------------------- Watch //
315328watch (props , () => {
316329 if (props .theme ) {
@@ -327,7 +340,6 @@ watch(props, () => {
327340 }
328341});
329342
330-
331343// -------------------------------------------------- Mounts //
332344onBeforeMount (() => {
333345 copyTextValue .value = props .copyText ;
@@ -340,7 +352,6 @@ onMounted(() => {
340352 mobileCheck ();
341353});
342354
343-
344355// -------------------------------------------------- Methods //
345356function convertCode(): void {
346357 if (props .lang === ' json' ) {
@@ -380,7 +391,8 @@ function copyCode(): void {
380391 copyStatus .value = ' failed' ;
381392 emit (' update:copy-status' , copyStatus .value );
382393 console .error (' Copy to clipboard failed: ' , err );
383- });
394+ },
395+ );
384396
385397 setTimeout (() => {
386398 copyTextValue .value = props .copyText ;
@@ -437,9 +449,6 @@ function loadTheme(): void {
437449 break ;
438450 }
439451
440- const themeKey = Object .keys (selectedTheme )[0 ];
441- selectedTheme = selectedTheme [themeKey ];
442-
443452 themeStyles .setAttribute (' type' , ' text/css' );
444453 themeStyles .id = stylesheetId ;
445454 themeStyles .appendChild (document .createTextNode (selectedTheme ));
@@ -453,7 +462,7 @@ function mobileCheck(): void {
453462 isMobile .value = device .type === ' mobile' ;
454463}
455464
456- window .addEventListener (" orientationchange" , () => {
465+ window .addEventListener (' orientationchange' , () => {
457466 mobileCheck ();
458467});
459468
@@ -462,7 +471,6 @@ function runCode(): void {
462471}
463472 </script >
464473
465-
466474<style lang="scss">
467475@import ' ./styles/utilities' ;
468476
@@ -484,4 +492,3 @@ function runCode(): void {
484492<style lang="scss" scoped>
485493@import ' ./styles/main' ;
486494 </style >
487-
0 commit comments