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+ } ) ;
34+ CMS . registerEditorComponent ( {
35+ id : "galleria" ,
36+ label : "Galleria" ,
37+ fields : [
38+ {
39+ name : "body" ,
40+ label : "the body text" ,
41+ widget : "text"
42+ } ,
43+ ] ,
44+ pattern : / ^ { % g a l l e r i a \( \) % } \n ( .* ?) \n ^ { % e n d % } $ / ms,
45+ fromBlock : function ( match ) {
46+ return {
47+ body : match [ 1 ] ,
48+ } ;
49+ } ,
50+ toBlock : function ( obj ) {
51+ const body = obj . body || '' ;
52+ return `
53+ {% galleria() %}
54+ ${ body }
55+ {% end %}
56+ ` ;
57+ } ,
58+ toPreview : function ( obj ) {
59+ const body = obj . body || '' ;
60+ return `
61+ {% galleria() %}
62+ ${ body }
63+ {% end %}
64+ ` ;
65+ } ,
66+ } ) ;
167CMS . registerEditorComponent ( {
268 id : "gist" ,
369 label : "Gist" ,
4- fields : [ {
5- name : "username" ,
6- label : "Github Username (mandatory)" ,
7- widget : "string"
8- } ,
9- {
10- name : "gid" ,
11- label : "Gist ID (mandatory)" ,
12- widget : "string"
13- } ,
14- {
15- name : "file" ,
16- label : "by default, the shortcode will pull every file from the URL unless a specific filename is requested (optional)" ,
17- widget : "string"
18- } ,
19- {
20- name : "class" ,
21- label : "a class to add to the <div> surrounding the iframe (optional)" ,
22- widget : "string"
23- } ,
70+ fields : [
71+ {
72+ name : "username" ,
73+ label : "Github Username (mandatory)" ,
74+ widget : "string"
75+ } ,
76+ {
77+ name : "gid" ,
78+ label : "Gist ID (mandatory)" ,
79+ widget : "string"
80+ } ,
81+ {
82+ name : "file" ,
83+ label : "by default, the shortcode will pull every file from the URL unless a specific filename is requested (optional)" ,
84+ widget : "string"
85+ } ,
86+ {
87+ name : "class" ,
88+ label : "a class to add to the <div> surrounding the iframe (optional)" ,
89+ widget : "string"
90+ } ,
2491 ] ,
2592 pattern : / { { g i s t \( u r l = " h t t p s : \/ \/ g i s t \. g i t h u b \. c o m \/ ( [ - a - z A - Z 0 - 9 ] + ) \/ ( [ a - z A - Z 0 - 9 ] + ) " ( , f i l e = " ( [ - _ . a - z A - Z 0 - 9 ] + ) " ) ? ( , c l a s s = " ( [ a - z A - Z ] [ - _ . : a - z A - Z 0 - 9 ] * ) " ) ? \) } } / ,
2693 fromBlock : function ( match ) {
@@ -47,18 +114,134 @@ CMS.registerEditorComponent({
47114 } ,
48115} ) ;
49116CMS . registerEditorComponent ( {
50- id : "streamable" ,
51- label : "Streamable" ,
52- fields : [ {
53- name : "id" ,
54- label : "the video id (mandatory)" ,
55- widget : "string"
117+ id : "katex" ,
118+ label : "Katex" ,
119+ fields : [
120+ {
121+ name : "body" ,
122+ label : "the body text" ,
123+ widget : "text"
124+ } ,
125+ {
126+ name : "block" ,
127+ label : "if true, add `mode=display` into type of the script tag." ,
128+ widget : "boolean"
129+ } ,
130+ ] ,
131+ 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,
132+ fromBlock : function ( match ) {
133+ return {
134+ block : match [ 1 ] ,
135+ body : match [ 2 ] ,
136+ } ;
137+ } ,
138+ toBlock : function ( obj ) {
139+ const block = ! ! obj . block ;
140+ const body = obj . body || '' ;
141+ return `
142+ {% katex(block=${ block } ) %}
143+ ${ body }
144+ {% end %}
145+ ` ;
146+ } ,
147+ toPreview : function ( obj ) {
148+ const block = ! ! obj . block ;
149+ const body = obj . body || '' ;
150+ return `
151+ {% katex(block=${ block } ) %}
152+ ${ body }
153+ {% end %}
154+ ` ;
155+ } ,
156+ } ) ;
157+ CMS . registerEditorComponent ( {
158+ id : "mapbox" ,
159+ label : "Mapbox" ,
160+ fields : [
161+ {
162+ name : "body" ,
163+ label : "the body text" ,
164+ widget : "text"
165+ } ,
166+ {
167+ name : "zoom" ,
168+ label : "zoom level. see https://docs.mapbox.com/help/glossary/zoom-level/" ,
169+ widget : "number"
170+ } ,
171+ ] ,
172+ pattern : / ^ { % m a p b o x \( z o o m = ( [ 0 - 9 ] + ) \) % } \n ( .* ?) \n ^ { % e n d % } $ / ms,
173+ fromBlock : function ( match ) {
174+ return {
175+ zoom : match [ 1 ] ,
176+ body : match [ 2 ] ,
177+ } ;
178+ } ,
179+ toBlock : function ( obj ) {
180+ const zoom = obj . zoom ?? 10 ;
181+ const body = obj . body || '' ;
182+ return `
183+ {% mapbox(zoom=${ zoom } ) %}
184+ ${ body }
185+ {% end %}
186+ ` ;
187+ } ,
188+ toPreview : function ( obj ) {
189+ const zoom = obj . zoom ?? 10 ;
190+ const body = obj . body || '' ;
191+ return `
192+ {% mapbox(zoom=${ zoom } ) %}
193+ ${ body }
194+ {% end %}
195+ ` ;
196+ } ,
197+ } ) ;
198+ CMS . registerEditorComponent ( {
199+ id : "mermaid" ,
200+ label : "Mermaid" ,
201+ fields : [
202+ {
203+ name : "body" ,
204+ label : "the body text" ,
205+ widget : "text"
206+ } ,
207+ ] ,
208+ pattern : / ^ { % m e r m a i d \( \) % } \n ( .* ?) \n ^ { % e n d % } $ / ms,
209+ fromBlock : function ( match ) {
210+ return {
211+ body : match [ 1 ] ,
212+ } ;
213+ } ,
214+ toBlock : function ( obj ) {
215+ const body = obj . body || '' ;
216+ return `
217+ {% mermaid() %}
218+ ${ body }
219+ {% end %}
220+ ` ;
56221 } ,
57- {
58- name : "class" ,
59- label : "a class to add to the <div> surrounding the iframe (optional)" ,
60- widget : "string"
222+ toPreview : function ( obj ) {
223+ const body = obj . body || '' ;
224+ return `
225+ {% mermaid() %}
226+ ${ body }
227+ {% end %}
228+ ` ;
61229 } ,
230+ } ) ;
231+ CMS . registerEditorComponent ( {
232+ id : "streamable" ,
233+ label : "Streamable" ,
234+ fields : [
235+ {
236+ name : "id" ,
237+ label : "the video id (mandatory)" ,
238+ widget : "string"
239+ } ,
240+ {
241+ name : "class" ,
242+ label : "a class to add to the <div> surrounding the iframe (optional)" ,
243+ widget : "string"
244+ } ,
62245 ] ,
63246 pattern : / { { s t r e a m a b l e \( i d = " ( [ a - z A - Z 0 - 9 ] + ) " ( , c l a s s = " ( [ a - z A - Z ] [ - _ . : a - z A - Z 0 - 9 ] * ) " ) ? \) } } / ,
64247 fromBlock : function ( match ) {
@@ -81,43 +264,37 @@ CMS.registerEditorComponent({
81264CMS . registerEditorComponent ( {
82265 id : "vimeo" ,
83266 label : "Vimeo" ,
84- fields : [ {
85- name : "id" ,
86- label : "the video id (mandatory)" ,
87- widget : "string"
88- } ,
89- {
90- name : "class" ,
91- label : "a class to add to the <div> surrounding the iframe (optional)" ,
92- widget : "string"
93- } ,
267+ fields : [
268+ {
269+ name : "id" ,
270+ label : "the video id (mandatory)" ,
271+ widget : "string"
272+ } ,
94273 ] ,
95- pattern : / { { v i m e o \( i d = " ( [ 0 - 9 ] + ) " ( , c l a s s = " ( [ a - z A - Z ] [ - _ . : a - z A - Z 0 - 9 ] * ) " ) ? \) } } / ,
274+ pattern : / { { v i m e o \( i d = " ( [ 0 - 9 ] + ) " \) } } / ,
96275 fromBlock : function ( match ) {
97276 return {
98277 id : match [ 1 ] ,
99- class : match [ 3 ] ,
100278 } ;
101279 } ,
102280 toBlock : function ( obj ) {
103281 const id = obj . id || '' ;
104- const c = ! ! obj . class ? `, class="${ obj . class } "` : '' ;
105- return `{{ vimeo(id="${ id } "${ c } ) }}` ;
282+ return `{{ vimeo(id="${ obj . id || '' } ") }}` ;
106283 } ,
107284 toPreview : function ( obj ) {
108285 const id = obj . id || '' ;
109- const c = ! ! obj . class ? `, class="${ obj . class } "` : '' ;
110- return `{{ vimeo(id="${ id } "${ c } ) }}` ;
286+ return `{{ vimeo(id="${ obj . id || '' } ") }}` ;
111287 } ,
112288} ) ;
113289CMS . registerEditorComponent ( {
114290 id : "youtube" ,
115291 label : "YouTube" ,
116- fields : [ {
117- name : "id" ,
118- label : "the video id (mandatory)" ,
119- widget : "string"
120- } ,
292+ fields : [
293+ {
294+ name : "id" ,
295+ label : "the video id (mandatory)" ,
296+ widget : "string"
297+ } ,
121298 ] ,
122299 pattern : / { { y o u t u b e \( i d = " ( [ a - z A - Z 0 - 9 ] + ) " \) } } / ,
123300 fromBlock : function ( match ) {
0 commit comments