File tree 4 files changed +43
-25
lines changed
4 files changed +43
-25
lines changed Original file line number Diff line number Diff line change 26
26
.filter ((path ) => path .length > 0 )
27
27
: []
28
28
$ : hasNestedArrays = ! isEmpty (nestedArrayPaths )
29
+ $ : isEmptyDocument = json === undefined && (text === ' ' || text === undefined )
29
30
30
31
$ : documentType = hasNestedArrays
31
32
? ' Object with nested arrays'
32
- : json === undefined && ( text === ' ' || text === undefined )
33
+ : isEmptyDocument
33
34
? ' An empty document'
34
35
: isJSONObject (json )
35
36
? ' An object'
48
49
An object cannot be opened in table mode. You can open a nested array instead, or open the
49
50
document in tree mode.
50
51
{:else }
51
- {documentType } cannot be opened in table mode. You can open the document in tree mode instead.
52
+ {documentType } cannot be opened in table mode.
53
+ {/if }
54
+ {#if isEmptyDocument && ! readOnly }
55
+ You can open the document in tree mode instead, or paste a JSON Array using <b >Ctrl+V</b >.
56
+ {:else }
57
+ You can open the document in tree mode instead.
52
58
{/if }
53
59
</div >
54
60
{#each nestedArrayPaths as nestedArrayPath }
Original file line number Diff line number Diff line change 1027
1027
updateSelection (createValueSelection (documentState .selection .path , false ))
1028
1028
}
1029
1029
1030
+ if (! documentState .selection ) {
1031
+ updateSelection (getInitialSelection (json , documentState ))
1032
+ }
1033
+
1030
1034
handleInsert (type )
1031
1035
}
1032
1036
2145
2149
</label >
2146
2150
{#if json === undefined }
2147
2151
{#if text === ' ' || text === undefined }
2148
- <Welcome {readOnly } />
2152
+ <Welcome
2153
+ {readOnly }
2154
+ onCreateObject ={() => {
2155
+ focus ()
2156
+ handleInsertCharacter (' {' )
2157
+ }}
2158
+ onCreateArray ={() => {
2159
+ focus ()
2160
+ handleInsertCharacter (' [' )
2161
+ }}
2162
+ />
2149
2163
{:else }
2150
2164
<Message
2151
2165
type =" error"
Original file line number Diff line number Diff line change 2
2
3
3
.jse-welcome {
4
4
flex : 1 ;
5
- overflow : auto ; // FIXME: overflow doesn't work (try giving editor 100px height)
5
+ overflow : auto ;
6
6
font-family : var (--jse-font-family );
7
7
font-size : var (--jse-font-size );
8
8
26
26
}
27
27
28
28
.jse-contents {
29
+ display : flex ;
30
+ flex-direction : column ;
31
+ max-width : 300px ;
29
32
margin : 2em $padding 0 ;
30
- color : var ( --jse-panel-color-readonly ) ;
33
+ gap : $padding ;
31
34
32
- ul {
33
- $list-padding : 10px ;
34
-
35
- list-style : ' ●' ;
36
- list-style-position : outside ;
37
- padding-left : 2 * $list-padding ;
35
+ .jse-welcome-title {
36
+ }
38
37
39
- li {
40
- padding-left : $list-padding ;
38
+ .jse-welcome-info {
39
+ color : var (--jse-panel-color-readonly );
40
+ }
41
41
42
- span .jse-bold {
43
- font-family : var (--jse-font-family-mono );
44
- font-weight : bold ;
45
- }
46
- }
42
+ button {
43
+ @include jsoneditor-button-primary ;
47
44
}
48
45
}
49
46
}
Original file line number Diff line number Diff line change 2
2
3
3
<script lang =" ts" >
4
4
export let readOnly: boolean
5
+ export let onCreateArray: () => void
6
+ export let onCreateObject: () => void
5
7
</script >
6
8
7
9
<div class =" jse-welcome" >
8
10
<div class =" jse-space jse-before" />
9
11
<div class =" jse-contents" >
10
- Empty document
12
+ < div class = " jse-welcome-title " > Empty document</ div >
11
13
{#if ! readOnly }
12
- <ul >
13
- <li >Click inside the editor</li >
14
- <li >Paste clipboard data using <span class =" jse-bold" >Ctrl+V</span ></li >
15
- <li >Create a new object by typing <span class =" jse-bold" >{</span ></li >
16
- <li >Create a new array by typing <span class =" jse-bold" >[</span ></li >
17
- </ul >
14
+ <div class =" jse-welcome-info" >
15
+ You can paste clipboard data using <b >Ctrl+V</b >, or use the following options:
16
+ </div >
17
+ <button title ={" Create an empty JSON object (press '{')" } on:click ={() => onCreateObject ()}>Create object</button >
18
+ <button title ={" Create an empty JSON array (press '[')" } on:click ={() => onCreateArray ()}>Create array</button >
18
19
{/if }
19
20
</div >
20
21
<div class =" jse-space jse-after" />
You can’t perform that action at this time.
0 commit comments