File tree Expand file tree Collapse file tree 3 files changed +57
-1
lines changed
Expand file tree Collapse file tree 3 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 1+ <script lang="ts" setup>
2+ import IconReset from ' ../icons/Reset.vue'
3+
4+ const state = defineModel ()
5+ const config = `
6+ # YAML Rule is more powerful!
7+ # https://ast-grep.github.io/guide/rule-config.html#rule
8+ rule:
9+ any:
10+ - pattern: console.log($A)
11+ - pattern: console.debug($A)
12+ fix:
13+ logger.log($A)
14+ ` .trim ()
15+
16+ const onReset = () => {
17+ state .value .config = config
18+ state .value .query = ' console.log($MATCH)'
19+ state .value .rewrite = ' logger.log($MATCH)'
20+ }
21+ </script >
22+
23+ <template >
24+ <button class =" reset" title =" Reset your config" @click =" onReset" >
25+ <IconReset />
26+ </button >
27+ </template >
28+
29+ <style scoped>
30+ .reset {
31+ width : 2em ;
32+ height : 2em ;
33+ border-radius : 50% ;
34+ padding : 0px ;
35+ display : flex ;
36+ justify-content : center ;
37+ align-items : center ;
38+ }
39+ </style >
Original file line number Diff line number Diff line change @@ -98,6 +98,15 @@ watch(isDark, () => {
9898 monaco .editor .setTheme (isDark .value ? ' vs-dark' : ' vs' )
9999})
100100
101+ watch (
102+ () => props .modelValue ,
103+ (value ) => {
104+ if (editor .value ?.getValue () === value ) return
105+ editor .value ?.setValue (value || ' ' )
106+ },
107+ { immediate: true },
108+ )
109+
101110const transformHighlight = (match : number []) => {
102111 const [sr, sc, er, ec] = match
103112 return {
@@ -193,4 +202,4 @@ onBeforeUnmount(() => {
193202.monaco-match-span {
194203 background-color : var (--theme-highlight3 );
195204}
196- </style >
205+ </style >
Original file line number Diff line number Diff line change 1+ <template >
2+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" >
3+ <g fill =" none" stroke =" currentColor" stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2" >
4+ <path d =" M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" />
5+ <path d =" M20 4v5h-5" />
6+ </g >
7+ </svg >
8+ </template >
You can’t perform that action at this time.
0 commit comments