@@ -32,13 +32,54 @@ export const INPUT_FIELD_EXAMPLE_DECLARATIONS: Record<InputFieldType, string> =
32
32
invalid : '' ,
33
33
} ;
34
34
35
- export const VIEW_FIELD_EXAMPLE_DECLARATIONS : Record < ViewFieldType , string > = {
36
- image : 'VIEW[{exampleProperty}][image]' ,
37
- link : 'VIEW[{exampleProperty}][link]' ,
38
- math : 'VIEW[{exampleProperty} + 2][math]' ,
39
- text : 'VIEW[some text {exampleProperty}][text]' ,
35
+ export interface ViewFieldExampleDeclaration {
36
+ title : string ;
37
+ declaration : string ;
38
+ display : string ;
39
+ inputField : string ;
40
+ }
40
41
41
- invalid : '' ,
42
+ export const VIEW_FIELD_EXAMPLE_DECLARATIONS : Record < ViewFieldType , ViewFieldExampleDeclaration [ ] > = {
43
+ image : [
44
+ {
45
+ title : 'Image' ,
46
+ declaration : 'VIEW[{globalMemory^MB_VF_image_example}][image]' ,
47
+ display : 'VIEW[{imageExampleProperty}][image]' ,
48
+ inputField : 'INPUT[imageSuggester(optionQuery("")):globalMemory^MB_VF_image_example]' ,
49
+ } ,
50
+ ] ,
51
+ link : [
52
+ {
53
+ title : 'Link' ,
54
+ declaration : 'VIEW[{globalMemory^MB_VF_link_example}][link]' ,
55
+ display : 'VIEW[{linkExampleProperty}][link]' ,
56
+ inputField : 'INPUT[suggester(optionQuery("")):globalMemory^MB_VF_link_example]' ,
57
+ } ,
58
+ ] ,
59
+ math : [
60
+ {
61
+ title : 'Math' ,
62
+ declaration : 'VIEW[{globalMemory^MB_VF_math_example} + 2][math]' ,
63
+ display : 'VIEW[{mathExampleProperty} + 2][math]' ,
64
+ inputField : 'INPUT[number:globalMemory^MB_VF_math_example]' ,
65
+ } ,
66
+ ] ,
67
+ text : [
68
+ {
69
+ title : 'Text' ,
70
+ declaration : 'VIEW[some text {globalMemory^MB_VF_text_example}][text]' ,
71
+ display : 'VIEW[some text {textExampleProperty}][text]' ,
72
+ inputField : 'INPUT[text:globalMemory^MB_VF_text_example]' ,
73
+ } ,
74
+ {
75
+ title : 'Markdown' ,
76
+ declaration : 'VIEW[**some markdown** {globalMemory^MB_VF_text_markdown_example}][text(renderMarkdown)]' ,
77
+ display : 'VIEW[**some markdown** {markdownExampleProperty}][text(renderMarkdown)]' ,
78
+ inputField : 'INPUT[text:globalMemory^MB_VF_text_markdown_example]' ,
79
+ } ,
80
+ ] ,
81
+
82
+ invalid : [ ] ,
42
83
} ;
43
84
44
85
export function createInputFieldFAQExamples ( plugin : IPlugin ) : [ InputFieldType , InputFieldDeclaration ] [ ] {
@@ -66,6 +107,7 @@ export function createInputFieldFAQExamples(plugin: IPlugin): [InputFieldType, I
66
107
} ) ;
67
108
68
109
parsedDeclaration = plugin . api . inputFieldParser . merge ( parsedDeclaration , overrides ) ;
110
+ parsedDeclaration . declarationString = `INPUT[${ declaration } ]` ;
69
111
const validatedDeclaration = plugin . api . inputFieldParser . validate ( parsedDeclaration , '' , undefined ) ;
70
112
71
113
ret . push ( [ type as InputFieldType , validatedDeclaration ] ) ;
@@ -99,19 +141,12 @@ export function createInputFieldInsertExamples(_plugin: IPlugin): [string, strin
99
141
100
142
export function createViewFieldInsertExamples ( _plugin : IPlugin ) : [ string , string ] [ ] {
101
143
const ret : [ string , string ] [ ] = [ ] ;
102
- for ( const [ type , declaration ] of Object . entries ( VIEW_FIELD_EXAMPLE_DECLARATIONS ) ) {
103
- if ( declaration === '' ) {
104
- continue ;
144
+ for ( const declarations of Object . values ( VIEW_FIELD_EXAMPLE_DECLARATIONS ) ) {
145
+ for ( const declaration of declarations ) {
146
+ ret . push ( [ declaration . title , `\` ${ declaration . declaration } ]\`` ] ) ;
105
147
}
106
- const vfType = type as ViewFieldType ;
107
-
108
- const fullDeclaration = `\`${ declaration } \`` ;
109
-
110
- ret . push ( [ vfType , fullDeclaration ] ) ;
111
148
}
112
149
113
- ret . push ( [ 'markdown' , `\`VIEW[**some markdown** {exampleProperty}][text(renderMarkdown)]\`` ] ) ;
114
-
115
150
ret . sort ( ( a , b ) => a [ 0 ] . localeCompare ( b [ 0 ] ) ) ;
116
151
117
152
return ret ;
0 commit comments