@@ -90,12 +90,12 @@ export default class ICSSettingsTab extends PluginSettingTab {
9090
9191 // Add field section management
9292 new Setting ( patternsContainer )
93- . setName ( "Create Field Section " )
94- . setDesc ( "Create a new field section to group related patterns " )
93+ . setName ( "Add new " )
94+ . setDesc ( "Add a new field section" )
9595 . addButton ( ( button : ButtonComponent ) : ButtonComponent => {
96- return button
97- . setTooltip ( "Create Field Section " )
98- . setButtonText ( "+ Field Section " )
96+ const b = button
97+ . setTooltip ( "Add Additional " )
98+ . setButtonText ( "+" )
9999 . onClick ( async ( ) => {
100100 const modal = new FieldSectionModal ( this . app , this . plugin ) ;
101101 modal . onClose = async ( ) => {
@@ -106,24 +106,8 @@ export default class ICSSettingsTab extends PluginSettingTab {
106106 } ;
107107 modal . open ( ) ;
108108 } ) ;
109- } ) ;
110109
111- // Reset to defaults button
112- new Setting ( patternsContainer )
113- . setName ( "Reset to Defaults" )
114- . setDesc ( "Reset all patterns to default video call providers" )
115- . addButton ( ( button : ButtonComponent ) : ButtonComponent => {
116- return button
117- . setButtonText ( "Reset" )
118- . setWarning ( )
119- . onClick ( async ( ) => {
120- const confirmed = confirm ( "Are you sure you want to reset all field extraction patterns to defaults? This will delete all your custom patterns and cannot be undone." ) ;
121- if ( confirmed ) {
122- this . plugin . data . fieldExtraction . patterns = [ ...DEFAULT_FIELD_EXTRACTION_PATTERNS ] ;
123- await this . plugin . saveSettings ( ) ;
124- this . display ( ) ;
125- }
126- } ) ;
110+ return b ;
127111 } ) ;
128112
129113 // Group patterns by field name and display them as manageable sections
@@ -143,8 +127,8 @@ export default class ICSSettingsTab extends PluginSettingTab {
143127 for ( const [ fieldName , fieldPatterns ] of groupedPatterns ) {
144128 // Field section header with management buttons
145129 const fieldHeader = new Setting ( patternsContainer )
146- . setHeading ( )
147130 . setName ( `${ fieldName } (${ fieldPatterns . length } pattern${ fieldPatterns . length === 1 ? '' : 's' } )` )
131+ . setClass ( 'field-section-header' )
148132 . addExtraButton ( ( b ) => {
149133 b . setIcon ( "plus" )
150134 . setTooltip ( "Add Pattern to this Field" )
@@ -270,6 +254,26 @@ export default class ICSSettingsTab extends PluginSettingTab {
270254 }
271255 }
272256
257+ private displayFieldExtractionReset ( containerEl : HTMLElement ) {
258+ // Reset to defaults button - positioned outside patterns to show it affects all patterns
259+ new Setting ( containerEl )
260+ . setName ( "Reset to Defaults" )
261+ . setDesc ( "Reset all field extraction patterns to default video call providers" )
262+ . addButton ( ( button : ButtonComponent ) : ButtonComponent => {
263+ return button
264+ . setButtonText ( "Reset All" )
265+ . setWarning ( )
266+ . onClick ( async ( ) => {
267+ const confirmed = confirm ( "Are you sure you want to reset all field extraction patterns to defaults? This will delete all your custom patterns and cannot be undone." ) ;
268+ if ( confirmed ) {
269+ this . plugin . data . fieldExtraction . patterns = [ ...DEFAULT_FIELD_EXTRACTION_PATTERNS ] ;
270+ await this . plugin . saveSettings ( ) ;
271+ this . display ( ) ;
272+ }
273+ } ) ;
274+ } ) ;
275+ }
276+
273277 private dataViewSyntaxDescription ( ) : DocumentFragment {
274278 const descEl = document . createDocumentFragment ( ) ;
275279 descEl . appendText ( 'Enable this option if you use the DataView plugin to query event start and end times.' ) ;
@@ -463,6 +467,10 @@ export default class ICSSettingsTab extends PluginSettingTab {
463467 containerEl . createDiv ( ) . style . marginBottom = '20px' ;
464468
465469 this . displayFieldExtractionPatterns ( containerEl ) ;
470+
471+ // Add visual separation and reset button
472+ containerEl . createDiv ( ) . style . marginTop = '20px' ;
473+ this . displayFieldExtractionReset ( containerEl ) ;
466474 }
467475 }
468476
@@ -807,7 +815,7 @@ class FieldExtractionPatternModal extends Modal {
807815 pattern : "" ,
808816 matchType : "contains" ,
809817 priority : maxPriority + 1 ,
810- extractedFieldName : defaultFieldName || "Video Call URL "
818+ extractedFieldName : defaultFieldName || "Video Call URLs "
811819 } ;
812820 }
813821 }
@@ -818,6 +826,14 @@ class FieldExtractionPatternModal extends Modal {
818826
819827 const settingDiv = contentEl . createDiv ( { cls : 'video-call-pattern-settings' } ) ;
820828
829+ // Add Esc key handling to close modal
830+ contentEl . addEventListener ( 'keydown' , ( e ) => {
831+ if ( e . key === 'Escape' ) {
832+ e . preventDefault ( ) ;
833+ this . close ( ) ;
834+ }
835+ } ) ;
836+
821837 // Pattern name
822838 let nameText : TextComponent ;
823839 new Setting ( settingDiv )
@@ -874,6 +890,16 @@ class FieldExtractionPatternModal extends Modal {
874890 this . hasChanges = true ;
875891 }
876892 } ) ;
893+ priorityText . inputEl . addEventListener ( 'keydown' , ( e ) => {
894+ if ( e . key === 'Enter' ) {
895+ e . preventDefault ( ) ;
896+ if ( this . validateForm ( ) ) {
897+ this . saved = true ;
898+ this . hasChanges = false ;
899+ this . close ( ) ;
900+ }
901+ }
902+ } ) ;
877903 } ) ;
878904
879905 // Footer buttons
@@ -921,9 +947,6 @@ class FieldExtractionPatternModal extends Modal {
921947 if ( ! this . pattern . name . trim ( ) ) {
922948 return false ;
923949 }
924- if ( ! this . pattern . extractedFieldName . trim ( ) ) {
925- return false ;
926- }
927950 if ( ! this . pattern . pattern . trim ( ) ) {
928951 return false ;
929952 }
@@ -975,6 +998,14 @@ class FieldSectionModal extends Modal {
975998 const { contentEl } = this ;
976999 contentEl . empty ( ) ;
9771000
1001+ // Add Esc key handling to close modal
1002+ contentEl . addEventListener ( 'keydown' , ( e ) => {
1003+ if ( e . key === 'Escape' ) {
1004+ e . preventDefault ( ) ;
1005+ this . close ( ) ;
1006+ }
1007+ } ) ;
1008+
9781009 // Modal title at the top
9791010 const titleEl = contentEl . createEl ( 'h3' , { cls : 'modal-title' } ) ;
9801011 titleEl . textContent = this . isEditing ? 'Edit Field Section' : 'Create Field Section' ;
0 commit comments