File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 40
40
const codeBlock = ref (null );
41
41
42
42
watch (() => props .code , (newVal ) => {
43
- requestAnimationFrame (() => {
44
- requestAnimationFrame (() => {
45
- if (codeBlock .value && newVal .length > 0 ) {
46
- highlightCodeBlocks (codeBlock .value );
47
- }
48
- })
49
- });
43
+ if (codeBlock .value && newVal .length > 0 ) {
44
+ highlightCodeBlocks (codeBlock .value );
45
+ }
50
46
}, {immediate: true });
51
47
52
48
function hoverCode () {
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export default function useShiki() {
55
55
const shiki = ref < ReturnType < typeof getShiki > > ( )
56
56
57
57
async function highlightCodeBlocks ( root : HTMLElement = document . body ) {
58
- return new Promise < void > ( resolve => nextTick ( ( ) => requestAnimationFrame ( async ( ) => {
58
+ return new Promise < void > ( resolve => nextTick ( async ( ) => {
59
59
const blocks = root . querySelectorAll ( 'pre > code' )
60
60
for ( const block of blocks ) {
61
61
const preClassList = block . parentElement ?. classList ;
@@ -93,7 +93,7 @@ export default function useShiki() {
93
93
}
94
94
}
95
95
resolve ( ) ;
96
- } ) ) ) ;
96
+ } ) ;
97
97
}
98
98
99
99
onMounted ( async ( ) => {
You can’t perform that action at this time.
0 commit comments