File tree Expand file tree Collapse file tree 6 files changed +206
-0
lines changed Expand file tree Collapse file tree 6 files changed +206
-0
lines changed Original file line number Diff line number Diff line change
1
+ CMS . registerEditorComponent ( {
2
+ id : "chart" ,
3
+ label : "Chart" ,
4
+ fields : [
5
+ {
6
+ name : "body" ,
7
+ label : "the body text" ,
8
+ widget : "text"
9
+ } ,
10
+ ] ,
11
+ pattern : / ^ { % c h a r t \( \) % } \n ( .* ?) \n ^ { % e n d % } $ / ms,
12
+ fromBlock : function ( match ) {
13
+ return {
14
+ body : match [ 1 ] ,
15
+ } ;
16
+ } ,
17
+ toBlock : function ( obj ) {
18
+ const body = obj . body || '' ;
19
+ return `
20
+ {% chart() %}
21
+ ${ body }
22
+ {% end %}
23
+ ` ;
24
+ } ,
25
+ toPreview : function ( obj ) {
26
+ const body = obj . body || '' ;
27
+ return `
28
+ {% chart() %}
29
+ ${ body }
30
+ {% end %}
31
+ ` ;
32
+ } ,
33
+ } ) ;
Original file line number Diff line number Diff line change
1
+ CMS . registerEditorComponent ( {
2
+ id : "galleria" ,
3
+ label : "Galleria" ,
4
+ fields : [
5
+ {
6
+ name : "body" ,
7
+ label : "the body text" ,
8
+ widget : "text"
9
+ } ,
10
+ ] ,
11
+ pattern : / ^ { % g a l l e r i a \( \) % } \n ( .* ?) \n ^ { % e n d % } $ / ms,
12
+ fromBlock : function ( match ) {
13
+ return {
14
+ body : match [ 1 ] ,
15
+ } ;
16
+ } ,
17
+ toBlock : function ( obj ) {
18
+ const body = obj . body || '' ;
19
+ return `
20
+ {% galleria() %}
21
+ ${ body }
22
+ {% end %}
23
+ ` ;
24
+ } ,
25
+ toPreview : function ( obj ) {
26
+ const body = obj . body || '' ;
27
+ return `
28
+ {% galleria() %}
29
+ ${ body }
30
+ {% end %}
31
+ ` ;
32
+ } ,
33
+ } ) ;
Original file line number Diff line number Diff line change
1
+ CMS . registerEditorComponent ( {
2
+ id : "katex" ,
3
+ label : "Katex" ,
4
+ fields : [
5
+ {
6
+ name : "body" ,
7
+ label : "the body text" ,
8
+ widget : "text"
9
+ } ,
10
+ {
11
+ name : "block" ,
12
+ label : "if true, add `mode=display` into type of the script tag." ,
13
+ widget : "boolean"
14
+ } ,
15
+ ] ,
16
+ pattern : / ^ { % k a t e x \( b l o c k = ( t r u e | f a l s e ) \) % } \n ( .* ?) \n ^ { % e n d % } $ / ms,
17
+ fromBlock : function ( match ) {
18
+ return {
19
+ block : match [ 1 ] ,
20
+ body : match [ 2 ] ,
21
+ } ;
22
+ } ,
23
+ toBlock : function ( obj ) {
24
+ const block = ! ! obj . block ;
25
+ const body = obj . body || '' ;
26
+ return `
27
+ {% katex(block=${ block } ) %}
28
+ ${ body }
29
+ {% end %}
30
+ ` ;
31
+ } ,
32
+ toPreview : function ( obj ) {
33
+ const block = ! ! obj . block ;
34
+ const body = obj . body || '' ;
35
+ return `
36
+ {% katex(block=${ block } ) %}
37
+ ${ body }
38
+ {% end %}
39
+ ` ;
40
+ } ,
41
+ } ) ;
Original file line number Diff line number Diff line change
1
+ CMS . registerEditorComponent ( {
2
+ id : "mapbox" ,
3
+ label : "Mapbox" ,
4
+ fields : [
5
+ {
6
+ name : "body" ,
7
+ label : "the body text" ,
8
+ widget : "text"
9
+ } ,
10
+ {
11
+ name : "zoom" ,
12
+ label : "zoom level. see https://docs.mapbox.com/help/glossary/zoom-level/" ,
13
+ widget : "number"
14
+ } ,
15
+ ] ,
16
+ pattern : / ^ { % m a p b o x \( z o o m = ( [ 0 - 9 ] + ) \) % } \n ( .* ?) \n ^ { % e n d % } $ / ms,
17
+ fromBlock : function ( match ) {
18
+ return {
19
+ zoom : match [ 1 ] ,
20
+ body : match [ 2 ] ,
21
+ } ;
22
+ } ,
23
+ toBlock : function ( obj ) {
24
+ const zoom = obj . zoom ?? 10 ;
25
+ const body = obj . body || '' ;
26
+ return `
27
+ {% mapbox(zoom=${ zoom } ) %}
28
+ ${ body }
29
+ {% end %}
30
+ ` ;
31
+ } ,
32
+ toPreview : function ( obj ) {
33
+ const zoom = obj . zoom ?? 10 ;
34
+ const body = obj . body || '' ;
35
+ return `
36
+ {% mapbox(zoom=${ zoom } ) %}
37
+ ${ body }
38
+ {% end %}
39
+ ` ;
40
+ } ,
41
+ } ) ;
Original file line number Diff line number Diff line change
1
+ CMS . registerEditorComponent ( {
2
+ id : "mermaid" ,
3
+ label : "Mermaid" ,
4
+ fields : [
5
+ {
6
+ name : "body" ,
7
+ label : "the body text" ,
8
+ widget : "text"
9
+ } ,
10
+ ] ,
11
+ pattern : / ^ { % m e r m a i d \( \) % } \n ( .* ?) \n ^ { % e n d % } $ / ms,
12
+ fromBlock : function ( match ) {
13
+ return {
14
+ body : match [ 1 ] ,
15
+ } ;
16
+ } ,
17
+ toBlock : function ( obj ) {
18
+ const body = obj . body || '' ;
19
+ return `
20
+ {% mermaid() %}
21
+ ${ body }
22
+ {% end %}
23
+ ` ;
24
+ } ,
25
+ toPreview : function ( obj ) {
26
+ const body = obj . body || '' ;
27
+ return `
28
+ {% mermaid() %}
29
+ ${ body }
30
+ {% end %}
31
+ ` ;
32
+ } ,
33
+ } ) ;
Original file line number Diff line number Diff line change
1
+ CMS . registerEditorComponent ( {
2
+ id : "vimeo" ,
3
+ label : "Vimeo" ,
4
+ fields : [
5
+ {
6
+ name : "id" ,
7
+ label : "the video id (mandatory)" ,
8
+ widget : "string"
9
+ } ,
10
+ ] ,
11
+ pattern : / { { v i m e o \( i d = " ( [ 0 - 9 ] + ) " \) } } / ,
12
+ fromBlock : function ( match ) {
13
+ return {
14
+ id : match [ 1 ] ,
15
+ } ;
16
+ } ,
17
+ toBlock : function ( obj ) {
18
+ const id = obj . id || '' ;
19
+ return `{{ vimeo(id="${ obj . id || '' } ") }}` ;
20
+ } ,
21
+ toPreview : function ( obj ) {
22
+ const id = obj . id || '' ;
23
+ return `{{ vimeo(id="${ obj . id || '' } ") }}` ;
24
+ } ,
25
+ } ) ;
You can’t perform that action at this time.
0 commit comments