File tree Expand file tree Collapse file tree 7 files changed +30
-46
lines changed Expand file tree Collapse file tree 7 files changed +30
-46
lines changed Original file line number Diff line number Diff line change 54
54
"@rollup/plugin-replace" : " ^5.0.2" ,
55
55
"@types/codemirror" : " ^5.60.2" ,
56
56
"@types/node" : " ^18.15.3" ,
57
- "@vitejs/plugin-vue" : " ^4.1.0 " ,
57
+ "@vitejs/plugin-vue" : " ^4.2.3 " ,
58
58
"@volar/monaco" : " 1.7.8" ,
59
59
"@volar/typescript" : " 1.7.8" ,
60
60
"@vue/language-service" : " 1.8.1" ,
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
import CodeMirror , { type Props } from ' ../codemirror/CodeMirror.vue'
3
3
import { computed } from ' vue'
4
- import type { PreviewMode } from ' ./types'
4
+ import type { EditorEmits , EditorProps } from ' ./types'
5
5
6
6
defineOptions ({
7
7
editorType: ' codemirror' ,
8
8
})
9
9
10
- const props = defineProps <{
11
- value: string
12
- filename: string
13
- readonly? : boolean
14
- mode? : PreviewMode
15
- }>()
16
-
17
- const emits = defineEmits <{
18
- (e : ' change' , code : string ): void
19
- }>()
10
+ const props = defineProps <EditorProps >()
11
+ const emit = defineEmits <EditorEmits >()
20
12
21
13
const onChange = (code : string ) => {
22
- emits (' change' , code )
14
+ emit (' change' , code )
23
15
}
24
16
25
17
const modes: Record <string , Props [' mode' ]> = {
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
- withDefaults (
3
- defineProps <{
4
- modelValue? : boolean
5
- }>(),
6
- {
7
- modelValue: false ,
8
- }
9
- )
10
-
11
- defineEmits <{
12
- (e : ' update:modelValue' , value : boolean ): void
13
- }>()
2
+ const visible = defineModel <boolean >()
14
3
</script >
4
+
15
5
<template >
16
- <div class =" wrapper" @click =" $emit('update:modelValue', !modelValue) " >
6
+ <div class =" wrapper" @click =" visible = !visible " >
17
7
<span >Show Error</span >
18
8
<div class =" toggle" :class =" [{ active: modelValue }]" >
19
9
<div class =" indicator" />
20
10
</div >
21
11
</div >
22
12
</template >
13
+
23
14
<style scoped>
24
15
.wrapper {
25
16
position : absolute ;
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
import Monaco from ' ../monaco/Monaco.vue'
3
- import type { PreviewMode } from ' ./types'
3
+ import type { EditorEmits , EditorProps } from ' ./types'
4
4
5
- defineProps <{
6
- value: string
7
- filename: string
8
- readonly? : boolean
9
- mode? : PreviewMode
10
- }>()
11
-
12
- const emit = defineEmits <{
13
- (e : ' change' , code : string ): void
14
- }>()
5
+ defineProps <EditorProps >()
6
+ const emit = defineEmits <EditorEmits >()
15
7
16
8
defineOptions ({
17
9
editorType: ' monaco' ,
Original file line number Diff line number Diff line change 1
- import { Component } from 'vue'
1
+ import { type FunctionalComponent } from 'vue'
2
2
3
3
export type PreviewMode = 'js' | 'css' | 'ssr'
4
4
5
- interface EditorProps {
5
+ export interface EditorProps {
6
6
value : string
7
7
filename : string
8
8
readonly ?: boolean
9
9
mode ?: PreviewMode
10
10
}
11
11
12
- interface EditorEmits {
12
+ export interface EditorEmits {
13
13
( e : 'change' , code : string ) : void
14
14
}
15
15
16
- export type EditorComponentType = Component < EditorProps , EditorEmits > & {
16
+ export type EditorComponentType = FunctionalComponent <
17
+ EditorProps ,
18
+ { change : ( code : string ) => void }
19
+ > & {
17
20
editorType : 'monaco' | 'codemirror'
18
21
}
19
22
Original file line number Diff line number Diff line change @@ -3,7 +3,13 @@ import vue from '@vitejs/plugin-vue'
3
3
import replace from '@rollup/plugin-replace'
4
4
5
5
export default defineConfig ( {
6
- plugins : [ vue ( ) ] ,
6
+ plugins : [
7
+ vue ( {
8
+ script : {
9
+ defineModel : true ,
10
+ } ,
11
+ } ) ,
12
+ ] ,
7
13
resolve : {
8
14
alias : {
9
15
path : 'path-browserify' ,
You can’t perform that action at this time.
0 commit comments