File tree Expand file tree Collapse file tree 6 files changed +83
-24
lines changed
Expand file tree Collapse file tree 6 files changed +83
-24
lines changed Original file line number Diff line number Diff line change 11<template >
22 Test:
33 <CodeBlock
4- class =" my-class"
5- id =" my-id"
64 :code =" code"
7- language =" js "
5+ language =" javascript "
86 code-class =" codeClass"
97 :numbered =" true"
108 :lines-highlighted =" [1, 2]"
11- :words-highlighted =" ['log']"
12- as-element = " " / >
9+ :words-highlighted =" ['log']" >
10+ </ CodeBlock >
1311 End of App.vue
12+ <!-- <pre>
13+ {{ langs }}
14+ </pre> -->
1415</template >
1516
1617<script setup lang="ts">
18+ import { ref } from ' vue' ;
1719 import { CodeBlock } from ' ./components/code-block' ;
20+
21+ // import { Prism } from './components/prism-langs';
22+ // const langs = ref(Object.keys(Prism.languages));
23+
1824 const code = `
1925console.log('Hello');
2026const name = 'World';
Original file line number Diff line number Diff line change 77 v-bind =" $attrs"
88 class =" code" >
99 <!-- Line Component -->
10- <template
11- v-for =" (line , i ) in code "
12- :key =" i " >
13- <div class =" line" >
14- <div class =" number-container" >
15- <span
16- class =" number"
17- v-if =" !props.numbered"
18- >{{ i + 1 }}</span
19- >
10+ <slot >
11+ <template
12+ v-for =" (line , i ) in code "
13+ :key =" i " >
14+ <div class =" line" >
15+ <div v-html =" line" ></div >
2016 </div >
21- <div v-html =" line" ></div >
22- </div >
23- </template >
17+ </template >
18+ </slot >
2419 </component >
2520</template >
2621
Original file line number Diff line number Diff line change 1+ import { SupportedLanguageTypes } from 'code-block' ;
12import type {
23 ComponentPublicInstance ,
34 ExtractPropTypes ,
@@ -24,7 +25,7 @@ export const codeBlockProps = () =>
2425 required : true
2526 } ,
2627 language : {
27- type : String as PropType < string > ,
28+ type : String as PropType < SupportedLanguageTypes > ,
2829 required : true
2930 } ,
3031 codeClass : {
Original file line number Diff line number Diff line change 1212// import * as uglify from 'uglify-js';
1313
1414// export const languagesToBundle = <const>[
15- // 'markup ',
15+ // 'vue ',
1616// 'jsx',
1717// 'tsx',
1818// 'swift',
1919// 'kotlin',
20+ // 'java',
2021// 'objectivec',
21- // 'js-extras',
22- // 'reason',
22+ // 'javascript',
2323// 'rust',
2424// 'graphql',
2525// 'yaml',
2626// 'go',
2727// 'cpp',
28+ // 'c',
2829// 'markdown',
2930// 'python',
3031// 'json'
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -15,6 +15,62 @@ declare module 'code-block' {
1515 numbered : boolean ;
1616 }
1717
18+ type SupportedLanguage =
19+ | 'plain'
20+ | 'plaintext'
21+ | 'text'
22+ | 'txt'
23+ | 'extend'
24+ | 'insertBefore'
25+ | 'DFS'
26+ | 'markup'
27+ | 'html'
28+ | 'mathml'
29+ | 'svg'
30+ | 'xml'
31+ | 'ssml'
32+ | 'atom'
33+ | 'rss'
34+ | 'css'
35+ | 'clike'
36+ | 'javascript'
37+ | 'js'
38+ | 'regex'
39+ | 'actionscript'
40+ | 'coffeescript'
41+ | 'coffee'
42+ | 'javadoclike'
43+ | 'yaml'
44+ | 'yml'
45+ | 'markdown'
46+ | 'md'
47+ | 'graphql'
48+ | 'sql'
49+ | 'typescript'
50+ | 'ts'
51+ | 'jsdoc'
52+ | 'flow'
53+ | 'n4js'
54+ | 'n4jsd'
55+ | 'jsx'
56+ | 'tsx'
57+ | 'swift'
58+ | 'kotlin'
59+ | 'kt'
60+ | 'kts'
61+ | 'c'
62+ | 'objectivec'
63+ | 'objc'
64+ | 'reason'
65+ | 'rust'
66+ | 'go'
67+ | 'cpp'
68+ | 'python'
69+ | 'py'
70+ | 'json'
71+ | 'webmanifest'
72+ | 'java' ;
73+
1874 const CodeBlockType : DefineComponent < CodeBlockProps > ;
19- export { CodeBlockType } ;
75+ export { CodeBlockType , SupportedLanguage as SupportedLanguageTypes } ;
2076}
You can’t perform that action at this time.
0 commit comments