@@ -19,6 +19,8 @@ enum CodeColorType {
1919} )
2020export class AppCode {
2121
22+ @Prop ( { connect : 'ion-alert-controller' } ) alertController : HTMLIonAlertControllerElement ;
23+
2224 @Element ( ) el : HTMLElement ;
2325
2426 @Prop ( )
@@ -68,10 +70,7 @@ export class AppCode {
6870 private initCurrentHiglight ( ) : Promise < void > {
6971 return new Promise < void > ( async ( resolve ) => {
7072 this . highlightLines = this . selectedElement && this . selectedElement . getAttribute ( 'highlight-lines' ) ? this . selectedElement . getAttribute ( 'highlight-lines' ) : null ;
71-
72- if ( this . selectedElement && this . selectedElement . style . getPropertyValue ( '--deckgo-highlight-code-line-background' ) ) {
73- this . highlightColor = this . selectedElement . style . getPropertyValue ( '--deckgo-highlight-code-line-background' ) ;
74- }
73+ this . highlightColor = this . selectedElement && this . selectedElement . style . getPropertyValue ( '--deckgo-highlight-code-line-background' ) ? this . selectedElement . style . getPropertyValue ( '--deckgo-highlight-code-line-background' ) : '#3880ff' ;
7574
7675 resolve ( ) ;
7776 } ) ;
@@ -251,58 +250,67 @@ export class AppCode {
251250 } ) ;
252251 }
253252
253+ private async presentHighlightInfo ( ) {
254+ const alert = await this . alertController . create ( {
255+ message : 'If you wish to highlight some specific lines of your code, list their line numbers separately using comma.<br/><br/>For example: 0,2 7,7 13,15<br/><br/>Which would highlight lines 0 to 2, line 7 and lines 13 to 15.' ,
256+ buttons : [ 'Ok' ]
257+ } ) ;
258+
259+ return await alert . present ( ) ;
260+ }
261+
254262 render ( ) {
255- return < ion-list >
256- < ion-item-divider > < ion-label > Language </ ion-label > </ ion-item-divider >
257-
258- < ion-item class = "select" >
259- < ion-label > Language </ ion-label >
260- < ion-select value = { this . currentLanguage } onIonChange = { ( e : CustomEvent ) => this . toggleCodeLanguage ( e ) } class = " ion-padding-start ion-padding-end" >
261- { this . renderSelectOptions ( ) }
262- </ ion-select >
263- </ ion-item >
264-
265- < ion-item-divider class = "ion-padding-top" > < ion-label > Colors </ ion-label > </ ion-item-divider >
266-
267- < ion-item class = "select" >
268- < ion-label > Color applied to </ ion-label >
269-
270- < ion-select value = { this . codeColorType } onIonChange = { ( e : CustomEvent ) => this . toggleColorType ( e ) } class = "ion-padding-start ion-padding-end" >
271- < ion-select-option value = { CodeColorType . COMMENTS } > Comments </ ion-select-option >
272- < ion-select-option value = { CodeColorType . FUNCTION } > Functions </ ion-select-option >
273- < ion-select-option value = { CodeColorType . KEYWORD } > Keywords </ ion-select-option >
274- < ion-select-option value = { CodeColorType . OPERATOR } > Operators </ ion-select-option >
275- < ion-select-option value = { CodeColorType . PUNCTUATION } > Punctuation </ ion-select-option >
276- < ion-select-option value = { CodeColorType . PROPERTY } > Properties </ ion-select-option >
277- < ion-select-option value = { CodeColorType . REGEX } > Regex </ ion-select-option >
278- < ion-select-option value = { CodeColorType . SELECTOR } > Selector </ ion-select-option >
279- < /ion-select >
280- </ ion-item >
281-
282- < ion-item >
283- < ion-label > Color </ ion-label >
284- < input type = "color" value = { this . codeColor } onChange = { ( e ) => this . selectColor ( e , this . setCodeColor ) } > </ input >
285- </ ion-item >
286-
287- < ion-item-divider class = "ion-padding-top" >
288- < ion-label > Highlight lines </ ion-label >
289- < /ion-item-divider >
290-
291- < ion-item >
292- < ion-input value = { this . highlightLines } placeholder = "Enter lines here" debounce = { 500 }
293- onIonInput = { ( e : CustomEvent < KeyboardEvent > ) => this . handleInput ( e ) }
294- onIonChange = { ( ) => this . highlightSelectedLines ( ) } > </ ion-input >
295- </ ion-item >
296-
297- < ion-item >
298- < small > To highlight lines, use a coma separated list of lines. For example: 0,2 7,7 13,15 </ small >
299- </ ion-item >
300-
301- < ion-item >
302- < ion-label > Color</ ion-label >
303- < input type = "color" value = { this . highlightColor } onChange = { ( e ) => this . selectColor ( e , this . setHighlightColor ) } > </ input >
304- </ ion-item >
305- </ ion-list >
263+ return [ < div class = " ion-padding" > < h2 > Code attributes </ h2 > </ div > ,
264+ < ion-list >
265+ < ion-item-divider > < ion-label > Language </ ion-label > </ ion-item-divider >
266+
267+ < ion-item class = "select" >
268+ < ion-label > Language </ ion-label >
269+ < ion-select value = { this . currentLanguage } onIonChange = { ( e : CustomEvent ) => this . toggleCodeLanguage ( e ) } class = "ion-padding-start ion-padding-end" >
270+ { this . renderSelectOptions ( ) }
271+ </ ion-select >
272+ </ ion-item >
273+
274+ < ion-item-divider class = "ion-padding-top" > < ion-label > Colors </ ion-label > </ ion-item-divider >
275+
276+ < ion-item class = "select" >
277+ < ion-label > Color applied to </ ion-label >
278+
279+ < ion-select value = { this . codeColorType } onIonChange = { ( e : CustomEvent ) => this . toggleColorType ( e ) } class = " ion-padding-start ion-padding-end" >
280+ < ion-select-option value = { CodeColorType . COMMENTS } > Comments </ ion-select-option >
281+ < ion-select-option value = { CodeColorType . FUNCTION } > Functions </ ion-select-option >
282+ < ion-select-option value = { CodeColorType . KEYWORD } > Keywords </ ion-select-option >
283+ < ion-select-option value = { CodeColorType . OPERATOR } > Operators </ ion-select-option >
284+ < ion-select-option value = { CodeColorType . PUNCTUATION } > Punctuation </ ion-select-option >
285+ < ion-select-option value = { CodeColorType . PROPERTY } > Properties </ ion-select-option >
286+ < ion-select-option value = { CodeColorType . REGEX } > Regex </ ion-select-option >
287+ < ion-select-option value = { CodeColorType . SELECTOR } > Selector < /ion-select-option >
288+ </ ion-select >
289+ </ ion-item >
290+
291+ < ion-item >
292+ < ion-label > Color </ ion-label >
293+ < input type = "color" value = { this . codeColor } onChange = { ( e ) => this . selectColor ( e , this . setCodeColor ) } > </ input >
294+ </ ion-item >
295+
296+ < ion-item-divider class = " ion-padding-top" >
297+ < ion-label > Highlight lines < /ion-label >
298+ < button slot = "end" class = "info" onClick = { ( ) => this . presentHighlightInfo ( ) } >
299+ < ion-icon name = "help" > </ ion-icon >
300+ </ button >
301+ </ ion-item-divider >
302+
303+ < ion-item >
304+ < ion-input value = { this . highlightLines } placeholder = "List your lines here" debounce = { 500 }
305+ onIonInput = { ( e : CustomEvent < KeyboardEvent > ) => this . handleInput ( e ) }
306+ onIonChange = { ( ) => this . highlightSelectedLines ( ) } > </ ion-input >
307+ </ ion-item >
308+
309+ < ion-item >
310+ < ion-label > Color</ ion-label >
311+ < input type = "color" value = { this . highlightColor } onChange = { ( e ) => this . selectColor ( e , this . setHighlightColor ) } > </ input >
312+ </ ion-item >
313+ </ ion-list > ]
306314 }
307315
308316 private renderSelectOptions ( ) {
0 commit comments