@@ -6,8 +6,10 @@ import type { App, PropType } from 'vue-demi'
6
6
import { conclude , resolveConfig } from 'vue-global-config'
7
7
import { PascalCasedName as name } from '../package.json'
8
8
9
- const propsGlobal : Record < keyof any , any > = { }
10
- const attrsGlobal : Record < keyof any , any > = { }
9
+ export type EditorMode = `${Mode } `
10
+
11
+ const propsGlobal : Record < string , any > = { }
12
+ const attrsGlobal : Record < string , any > = { }
11
13
const modeDefault = 'tree'
12
14
const modelValueProp = isVue3 ? 'modelValue' : 'value'
13
15
const updateModelValue = isVue3 ? 'update:modelValue' : 'input'
@@ -25,38 +27,61 @@ const boolAttrs = [
25
27
export default defineComponent ( {
26
28
name,
27
29
install ( app : App , options = { } ) : void {
28
- const { props, attrs } = resolveConfig ( options , { props : this . props as any } )
30
+ const { props, attrs } = resolveConfig ( options , { props : this . $ props as any } )
29
31
Object . assign ( propsGlobal , props )
30
32
Object . assign ( attrsGlobal , attrs )
31
33
app . component ( name , this )
32
34
} ,
33
35
props : {
34
- [ modelValueProp ] : { } ,
36
+ [ modelValueProp ] : Object ,
35
37
mode : {
36
- type : String as PropType < Mode > ,
38
+ type : String as PropType < EditorMode > ,
37
39
} ,
38
40
debounce : {
39
- type : Number as PropType < number > ,
41
+ type : Number ,
40
42
} ,
41
43
stringified : {
42
- type : Boolean as PropType < boolean > ,
44
+ type : Boolean ,
45
+ default : undefined ,
46
+ } ,
47
+ mainMenuBar : {
48
+ type : Boolean ,
49
+ default : undefined ,
50
+ } ,
51
+ navigationBar : {
52
+ type : Boolean ,
53
+ default : undefined ,
54
+ } ,
55
+ statusBar : {
56
+ type : Boolean ,
57
+ default : undefined ,
58
+ } ,
59
+ askToFormat : {
60
+ type : Boolean ,
61
+ default : undefined ,
62
+ } ,
63
+ readOnly : {
64
+ type : Boolean ,
65
+ default : undefined ,
66
+ } ,
67
+ escapeControlCharacters : {
68
+ type : Boolean ,
69
+ default : undefined ,
70
+ } ,
71
+ escapeUnicodeCharacters : {
72
+ type : Boolean ,
73
+ default : undefined ,
74
+ } ,
75
+ flattenColumns : {
76
+ type : Boolean ,
43
77
default : undefined ,
44
78
} ,
45
- ...Object . fromEntries (
46
- boolAttrs . map ( boolAttr => [
47
- boolAttr ,
48
- {
49
- type : Boolean as PropType < boolean > ,
50
- default : undefined ,
51
- } ,
52
- ] ) ,
53
- ) ,
54
79
} ,
55
80
emits : {
56
81
[ updateModelValue ] ( _payload : any ) {
57
82
return true
58
83
} ,
59
- 'update:mode' : function ( _payload : Mode ) {
84
+ 'update:mode' : function ( _payload : EditorMode ) {
60
85
return true
61
86
} ,
62
87
} ,
@@ -68,13 +93,13 @@ export default defineComponent({
68
93
const modeComputed = ref ( )
69
94
watchEffect ( ( ) => {
70
95
modeComputed . value = conclude ( [ props . mode , propsGlobal . mode ] , {
71
- type : String as PropType < Mode > ,
96
+ type : String as PropType < EditorMode > ,
72
97
} )
73
98
jsonEditor . value ?. updateProps ( {
74
99
mode : modeComputed . value || modeDefault ,
75
100
} )
76
101
} )
77
- const onChangeMode = ( mode : Mode ) => {
102
+ const onChangeMode = ( mode : EditorMode ) => {
78
103
emit ( 'update:mode' , mode )
79
104
}
80
105
// Synchronize the local `mode` with the global one
0 commit comments