Skip to content

Commit 53d1f39

Browse files
committed
feat: add placeholde for empty line
1 parent 906bebc commit 53d1f39

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/PromptEditor.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import markdown from 'shiki/langs/markdown.mjs'
66
import catppuccinLatte from 'shiki/themes/catppuccin-latte.mjs'
77
import catppuccinMocha from 'shiki/themes/catppuccin-mocha.mjs'
88
import { onBeforeUnmount, ref, watch } from 'vue'
9+
import { transformPlaceholder } from './shikiTransforms'
910
1011
defineOptions({
1112
name: 'PromptEditor',
@@ -50,7 +51,10 @@ watch(model, (str) => {
5051
dark: themesResolved[themesResolved.length > 1 ? 1 : 0].name!,
5152
},
5253
lang: 'markdown',
53-
transformers: [transformerColorizedBrackets()],
54+
transformers: [
55+
transformerColorizedBrackets(),
56+
transformPlaceholder(),
57+
],
5458
})
5559
}, {
5660
immediate: true,

src/shikiTransforms.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { ShikiTransformer } from 'shiki'
2+
3+
export function transformPlaceholder() {
4+
return ({
5+
name: 'placeholder',
6+
preprocess(code) {
7+
return code.split('\n').map((str) => {
8+
return str || '\u00A0'
9+
}).join('\n')
10+
},
11+
}) as ShikiTransformer
12+
}

0 commit comments

Comments
 (0)