/
findandreplaceformview.ts
854 lines (705 loc) · 22.3 KB
/
findandreplaceformview.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module find-and-replace/ui/findandreplaceformview
*/
import {
View,
ButtonView,
LabeledFieldView,
FocusCycler,
createLabeledInputText,
submitHandler,
ViewCollection,
type Template,
type InputView,
type FocusableView,
SwitchButtonView,
CollapsibleView
} from 'ckeditor5/src/ui.js';
import {
FocusTracker,
KeystrokeHandler,
Rect,
isVisible,
type Locale
} from 'ckeditor5/src/utils.js';
// See: #8833.
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
import '../../theme/findandreplaceform.css';
import { icons } from 'ckeditor5/src/core.js';
/**
* The find and replace form view class.
*
* See {@link module:find-and-replace/ui/findandreplaceformview~FindAndReplaceFormView}.
*/
export default class FindAndReplaceFormView extends View {
/**
* A collection of child views.
*/
public children: ViewCollection;
/**
* Stores the number of matched search results.
*
* @readonly
* @observable
*/
declare public matchCount: number;
/**
* The offset of currently highlighted search result in {@link #matchCount matched results}.
*
* @observable
*/
declare public readonly highlightOffset: number;
/**
* `true` when the search params (find text, options) has been changed by the user since
* the last time find was executed. `false` otherwise.
*
* @readonly
* @observable
*/
declare public isDirty: boolean;
/**
* A live object with the aggregated `isEnabled` states of editor commands related to find and
* replace. For instance, it may look as follows:
*
* ```json
* {
* findNext: true,
* findPrevious: true,
* replace: false,
* replaceAll: false
* }
* ```
*
* @internal
* @observable
*/
declare public readonly _areCommandsEnabled: Record<string, boolean>;
/**
* The content of the counter label displaying the index of the current highlighted match
* on top of the find input, for instance "3 of 50".
*
* @internal
* @readonly
* @observable
*/
declare public _resultsCounterText: string;
/**
* The flag reflecting the state of the "Match case" switch button in the search options
* dropdown.
*
* @internal
* @readonly
* @observable
*/
declare public _matchCase: boolean;
/**
* The flag reflecting the state of the "Whole words only" switch button in the search options
* dropdown.
*
* @internal
* @readonly
* @observable
*/
declare public _wholeWordsOnly: boolean;
/**
* This flag is set `true` when some matches were found and the user didn't change the search
* params (text to find, options) yet. This is only possible immediately after hitting the "Find" button.
* `false` when there were no matches (see {@link #matchCount}) or the user changed the params (see {@link #isDirty}).
*
* It is used to control the enabled state of the replace UI (input and buttons); replacing text is only possible
* if this flag is `true`.
*
* @internal
* @observable
*/
declare public readonly _searchResultsFound: boolean;
/**
* The find in text input view that stores the searched string.
*
* @internal
*/
public readonly _findInputView: LabeledFieldView<InputView>;
/**
* The replace input view.
*/
private readonly _replaceInputView: LabeledFieldView;
/**
* The find button view that initializes the search process.
*/
private readonly _findButtonView: ButtonView;
/**
* The find previous button view.
*/
private readonly _findPrevButtonView: ButtonView;
/**
* The find next button view.
*/
private readonly _findNextButtonView: ButtonView;
/**
* A collapsible view aggregating the advanced search options.
*/
private readonly _advancedOptionsCollapsibleView: CollapsibleView;
/**
* A switch button view controlling the "Match case" option.
*/
private readonly _matchCaseSwitchView: SwitchButtonView;
/**
* A switch button view controlling the "Whole words only" option.
*/
private readonly _wholeWordsOnlySwitchView: SwitchButtonView;
/**
* The replace button view.
*/
private readonly _replaceButtonView: ButtonView;
/**
* The replace all button view.
*/
private readonly _replaceAllButtonView: ButtonView;
/**
* The `div` aggregating the inputs.
*/
private readonly _inputsDivView: View;
/**
* The `div` aggregating the action buttons.
*/
private readonly _actionButtonsDivView: View;
/**
* Tracks information about the DOM focus in the form.
*/
private readonly _focusTracker: FocusTracker;
/**
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
*/
private readonly _keystrokes: KeystrokeHandler;
/**
* A collection of views that can be focused in the form.
*/
private readonly _focusables: ViewCollection<FocusableView>;
/**
* Helps cycling over {@link #_focusables} in the form.
*/
public readonly focusCycler: FocusCycler;
public declare locale: Locale;
/**
* Creates a view of find and replace form.
*
* @param locale The localization services instance.
*/
constructor( locale: Locale ) {
super( locale );
const t = locale.t;
this.children = this.createCollection();
this.set( 'matchCount', 0 );
this.set( 'highlightOffset', 0 );
this.set( 'isDirty', false );
this.set( '_areCommandsEnabled', {} );
this.set( '_resultsCounterText', '' );
this.set( '_matchCase', false );
this.set( '_wholeWordsOnly', false );
this.bind( '_searchResultsFound' ).to(
this, 'matchCount',
this, 'isDirty',
( matchCount, isDirty ) => {
return matchCount > 0 && !isDirty;
}
);
this._findInputView = this._createInputField( t( 'Find in text…' ) );
this._findPrevButtonView = this._createButton( {
label: t( 'Previous result' ),
class: 'ck-button-prev',
icon: icons.previousArrow,
keystroke: 'Shift+F3',
tooltip: true
} );
this._findNextButtonView = this._createButton( {
label: t( 'Next result' ),
class: 'ck-button-next',
icon: icons.previousArrow,
keystroke: 'F3',
tooltip: true
} );
this._replaceInputView = this._createInputField( t( 'Replace with…' ), 'ck-labeled-field-replace' );
this._inputsDivView = this._createInputsDiv();
this._matchCaseSwitchView = this._createMatchCaseSwitch();
this._wholeWordsOnlySwitchView = this._createWholeWordsOnlySwitch();
this._advancedOptionsCollapsibleView = this._createAdvancedOptionsCollapsible();
this._replaceAllButtonView = this._createButton( {
label: t( 'Replace all' ),
class: 'ck-button-replaceall',
withText: true
} );
this._replaceButtonView = this._createButton( {
label: t( 'Replace' ),
class: 'ck-button-replace',
withText: true
} );
this._findButtonView = this._createButton( {
label: t( 'Find' ),
class: 'ck-button-find ck-button-action',
withText: true
} );
this._actionButtonsDivView = this._createActionButtonsDiv();
this._focusTracker = new FocusTracker();
this._keystrokes = new KeystrokeHandler();
this._focusables = new ViewCollection();
this.focusCycler = new FocusCycler( {
focusables: this._focusables,
focusTracker: this._focusTracker,
keystrokeHandler: this._keystrokes,
actions: {
// Navigate form fields backwards using the <kbd>Shift</kbd> + <kbd>Tab</kbd> keystroke.
focusPrevious: 'shift + tab',
// Navigate form fields forwards using the <kbd>Tab</kbd> key.
focusNext: 'tab'
}
} );
this.children.addMany( [
this._inputsDivView,
this._advancedOptionsCollapsibleView,
this._actionButtonsDivView
] );
this.setTemplate( {
tag: 'form',
attributes: {
class: [
'ck',
'ck-find-and-replace-form'
],
tabindex: '-1'
},
children: this.children
} );
}
/**
* @inheritDoc
*/
public override render(): void {
super.render();
submitHandler( { view: this } );
this._initFocusCycling();
this._initKeystrokeHandling();
}
/**
* @inheritDoc
*/
public override destroy(): void {
super.destroy();
this._focusTracker.destroy();
this._keystrokes.destroy();
}
/**
* @inheritDoc
*/
public focus( direction?: 1 | -1 ): void {
if ( direction === -1 ) {
this.focusCycler.focusLast();
} else {
this.focusCycler.focusFirst();
}
}
/**
* Resets the form before re-appearing.
*
* It clears error messages, hides the match counter and disables the replace feature
* until the next hit of the "Find" button.
*
* **Note**: It does not reset inputs and options, though. This way the form works better in editors with
* disappearing toolbar (e.g. BalloonEditor): hiding the toolbar by accident (together with the find and replace UI)
* does not require filling the entire form again.
*/
public reset(): void {
this._findInputView.errorText = null;
this.isDirty = true;
}
/**
* Returns the value of the find input.
*/
private get _textToFind(): string {
return ( this._findInputView.fieldView.element as HTMLInputElement ).value;
}
/**
* Returns the value of the replace input.
*/
private get _textToReplace() {
return ( this._replaceInputView.fieldView.element as HTMLInputElement ).value;
}
/**
* Configures and returns the `<div>` aggregating all form inputs.
*/
private _createInputsDiv(): View {
const locale = this.locale;
const t = locale.t;
const inputsDivView = new View( locale );
// Typing in the find field invalidates all previous results (the form is "dirty").
this._findInputView.fieldView.on( 'input', () => {
this.isDirty = true;
} );
// Pressing prev/next buttons fires related event on the form.
this._findPrevButtonView.delegate( 'execute' ).to( this, 'findPrevious' );
this._findNextButtonView.delegate( 'execute' ).to( this, 'findNext' );
// Prev/next buttons will be disabled when related editor command gets disabled.
this._findPrevButtonView.bind( 'isEnabled' ).to( this, '_areCommandsEnabled', ( { findPrevious } ) => findPrevious );
this._findNextButtonView.bind( 'isEnabled' ).to( this, '_areCommandsEnabled', ( { findNext } ) => findNext );
this._injectFindResultsCounter();
this._replaceInputView.bind( 'isEnabled' ).to(
this, '_areCommandsEnabled',
this, '_searchResultsFound',
( { replace }, resultsFound ) => replace && resultsFound );
this._replaceInputView.bind( 'infoText' ).to(
this._replaceInputView, 'isEnabled',
this._replaceInputView, 'isFocused',
( isEnabled, isFocused ) => {
if ( isEnabled || !isFocused ) {
return '';
}
return t( 'Tip: Find some text first in order to replace it.' );
} );
inputsDivView.setTemplate( {
tag: 'div',
attributes: {
class: [ 'ck', 'ck-find-and-replace-form__inputs' ]
},
children: [
this._findInputView,
this._findPrevButtonView,
this._findNextButtonView,
this._replaceInputView
]
} );
return inputsDivView;
}
/**
* The action performed when the {@link #_findButtonView} is pressed.
*/
private _onFindButtonExecute() {
// When hitting "Find" in an empty input, an error should be displayed.
// Also, if the form was "dirty", it should remain so.
if ( !this._textToFind ) {
const t = this.t!;
this._findInputView.errorText = t( 'Text to find must not be empty.' );
return;
}
// Hitting "Find" automatically clears the dirty state.
this.isDirty = false;
this.fire<FindNextEvent>( 'findNext', {
searchText: this._textToFind,
matchCase: this._matchCase,
wholeWords: this._wholeWordsOnly
} );
}
/**
* Configures an injects the find results counter displaying a "N of M" label of the {@link #_findInputView}.
*/
private _injectFindResultsCounter() {
const locale = this.locale;
const t = locale.t;
const bind = this.bindTemplate;
const resultsCounterView = new View( this.locale );
this.bind( '_resultsCounterText' ).to( this, 'highlightOffset', this, 'matchCount',
( highlightOffset, matchCount ) => t( '%0 of %1', [ highlightOffset, matchCount ] )
);
resultsCounterView.setTemplate( {
tag: 'span',
attributes: {
class: [
'ck',
'ck-results-counter',
// The counter only makes sense when the field text corresponds to search results in the editing.
bind.if( 'isDirty', 'ck-hidden' )
]
},
children: [
{
text: bind.to( '_resultsCounterText' )
}
]
} );
// The whole idea is that when the text of the counter changes, its width also increases/decreases and
// it consumes more or less space over the input. The input, on the other hand, should adjust it's right
// padding so its *entire* text always remains visible and available to the user.
const updateFindInputPadding = () => {
const inputElement = this._findInputView.fieldView.element;
// Don't adjust the padding if the input (also: counter) were not rendered or not inserted into DOM yet.
if ( !inputElement || !isVisible( inputElement ) ) {
return;
}
const counterWidth = new Rect( resultsCounterView.element! ).width;
const paddingPropertyName = locale.uiLanguageDirection === 'ltr' ? 'paddingRight' : 'paddingLeft';
if ( !counterWidth ) {
inputElement.style[ paddingPropertyName ] = '';
} else {
inputElement.style[ paddingPropertyName ] = `calc( 2 * var(--ck-spacing-standard) + ${ counterWidth }px )`;
}
};
// Adjust the input padding when the text of the counter changes, for instance "1 of 200" is narrower than "123 of 200".
// Using "low" priority to let the text be set by the template binding first.
this.on( 'change:_resultsCounterText', updateFindInputPadding, { priority: 'low' } );
// Adjust the input padding when the counter shows or hides. When hidden, there should be no padding. When it shows, the
// padding should be set according to the text of the counter.
// Using "low" priority to let the text be set by the template binding first.
this.on( 'change:isDirty', updateFindInputPadding, { priority: 'low' } );
// Put the counter element next to the <input> in the find field.
( this._findInputView.template!.children![ 0 ] as Template ).children!.push( resultsCounterView );
}
/**
* Creates the collapsible view aggregating the advanced search options.
*/
private _createAdvancedOptionsCollapsible(): CollapsibleView {
const t = this.locale.t;
const collapsible = new CollapsibleView( this.locale, [
this._matchCaseSwitchView,
this._wholeWordsOnlySwitchView
] );
collapsible.set( {
label: t( 'Advanced options' ),
isCollapsed: true
} );
return collapsible;
}
/**
* Configures and returns the `<div>` element aggregating all form action buttons.
*/
private _createActionButtonsDiv(): View {
const actionsDivView = new View( this.locale );
this._replaceButtonView.bind( 'isEnabled' ).to(
this, '_areCommandsEnabled',
this, '_searchResultsFound',
( { replace }, resultsFound ) => replace && resultsFound );
this._replaceAllButtonView.bind( 'isEnabled' ).to(
this, '_areCommandsEnabled',
this, '_searchResultsFound',
( { replaceAll }, resultsFound ) => replaceAll && resultsFound );
this._replaceButtonView.on( 'execute', () => {
this.fire( 'replace', {
searchText: this._textToFind,
replaceText: this._textToReplace
} );
} );
this._replaceAllButtonView.on( 'execute', () => {
this.fire( 'replaceAll', {
searchText: this._textToFind,
replaceText: this._textToReplace
} );
this.focus();
} );
this._findButtonView.on( 'execute', this._onFindButtonExecute.bind( this ) );
actionsDivView.setTemplate( {
tag: 'div',
attributes: {
class: [ 'ck', 'ck-find-and-replace-form__actions' ]
},
children: [
this._replaceAllButtonView,
this._replaceButtonView,
this._findButtonView
]
} );
return actionsDivView;
}
/**
* Creates, configures and returns and instance of a dropdown allowing users to narrow
* the search criteria down. The dropdown has a list with switch buttons for each option.
*/
private _createMatchCaseSwitch(): SwitchButtonView {
const t = this.locale.t;
const matchCaseSwitchButton = new SwitchButtonView( this.locale );
matchCaseSwitchButton.set( {
label: t( 'Match case' ),
withText: true
} );
// Let the switch be controlled by form's observable property.
matchCaseSwitchButton.bind( 'isOn' ).to( this, '_matchCase' );
// // Update the state of the form when a switch is toggled.
matchCaseSwitchButton.on( 'execute', () => {
this._matchCase = !this._matchCase;
// Toggling a switch makes the form dirty because this changes search criteria
// just like typing text of the find input.
this.isDirty = true;
} );
return matchCaseSwitchButton;
}
/**
* Creates, configures and returns and instance of a dropdown allowing users to narrow
* the search criteria down. The dropdown has a list with switch buttons for each option.
*/
private _createWholeWordsOnlySwitch(): SwitchButtonView {
const t = this.locale.t;
const wholeWordsOnlySwitchButton = new SwitchButtonView( this.locale );
wholeWordsOnlySwitchButton.set( {
label: t( 'Whole words only' ),
withText: true
} );
// Let the switch be controlled by form's observable property.
wholeWordsOnlySwitchButton.bind( 'isOn' ).to( this, '_wholeWordsOnly' );
// // Update the state of the form when a switch is toggled.
wholeWordsOnlySwitchButton.on( 'execute', () => {
this._wholeWordsOnly = !this._wholeWordsOnly;
// Toggling a switch makes the form dirty because this changes search criteria
// just like typing text of the find input.
this.isDirty = true;
} );
return wholeWordsOnlySwitchButton;
}
/**
* Initializes the {@link #_focusables} and {@link #_focusTracker} to allow navigation
* using <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keystrokes in the right order.
*/
private _initFocusCycling() {
const childViews = [
this._findInputView,
this._findPrevButtonView,
this._findNextButtonView,
this._replaceInputView,
this._advancedOptionsCollapsibleView.buttonView,
this._matchCaseSwitchView,
this._wholeWordsOnlySwitchView,
this._replaceAllButtonView,
this._replaceButtonView,
this._findButtonView
];
childViews.forEach( v => {
// Register the view as focusable.
this._focusables.add( v );
// Register the view in the focus tracker.
this._focusTracker.add( v.element! );
} );
}
/**
* Initializes the keystroke handling in the form.
*/
private _initKeystrokeHandling() {
const stopPropagation = ( data: Event ) => data.stopPropagation();
const stopPropagationAndPreventDefault = ( data: Event ) => {
data.stopPropagation();
data.preventDefault();
};
// Start listening for the keystrokes coming from #element.
this._keystrokes.listenTo( this.element! );
// Find the next result upon F3.
this._keystrokes.set( 'f3', event => {
stopPropagationAndPreventDefault( event );
this._findNextButtonView.fire( 'execute' );
} );
// Find the previous result upon F3.
this._keystrokes.set( 'shift+f3', event => {
stopPropagationAndPreventDefault( event );
this._findPrevButtonView.fire( 'execute' );
} );
// Find or replace upon pressing Enter in the find and replace fields.
this._keystrokes.set( 'enter', event => {
const target = event.target;
if ( target === this._findInputView.fieldView.element ) {
if ( this._areCommandsEnabled.findNext ) {
this._findNextButtonView.fire( 'execute' );
} else {
this._findButtonView.fire( 'execute' );
}
stopPropagationAndPreventDefault( event );
} else if ( target === this._replaceInputView.fieldView.element && !this.isDirty ) {
this._replaceButtonView.fire( 'execute' );
stopPropagationAndPreventDefault( event );
}
} );
// Find previous upon pressing Shift+Enter in the find field.
this._keystrokes.set( 'shift+enter', event => {
const target = event.target;
if ( target !== this._findInputView.fieldView.element ) {
return;
}
if ( this._areCommandsEnabled.findPrevious ) {
this._findPrevButtonView.fire( 'execute' );
} else {
this._findButtonView.fire( 'execute' );
}
stopPropagationAndPreventDefault( event );
} );
// Since the form is in the dropdown panel which is a child of the toolbar, the toolbar's
// keystroke handler would take over the key management in the URL input.
// We need to prevent this ASAP. Otherwise, the basic caret movement using the arrow keys will be impossible.
this._keystrokes.set( 'arrowright', stopPropagation );
this._keystrokes.set( 'arrowleft', stopPropagation );
this._keystrokes.set( 'arrowup', stopPropagation );
this._keystrokes.set( 'arrowdown', stopPropagation );
}
/**
* Creates a button view.
*
* @param options The properties of the `ButtonView`.
* @returns The button view instance.
*/
private _createButton( options: object ): ButtonView {
const button = new ButtonView( this.locale );
button.set( options );
return button;
}
/**
* Creates a labeled input view.
*
* @param label The input label.
* @returns The labeled input view instance.
*/
private _createInputField( label: string, className?: string ): LabeledFieldView<InputView> {
const labeledInput = new LabeledFieldView( this.locale, createLabeledInputText );
labeledInput.label = label;
labeledInput.class = className;
return labeledInput;
}
}
/**
* Fired when the find next button is triggered.
*
* @eventName ~FindAndReplaceFormView#findNext
* @param data The event data.
*/
export type FindNextEvent = {
name: 'findNext';
args: [ data?: FindNextEventData ];
};
export type FindNextEventData = FindEventBaseData & {
matchCase: boolean;
wholeWords: boolean;
};
/**
* Fired when the find previous button is triggered.
*
* @eventName ~FindAndReplaceFormView#findPrevious
* @param data The event data.
*/
export type FindPreviousEvent = {
name: 'findPrevious';
args: [ data?: FindEventBaseData ];
};
/**
* Base type for all find/replace events.
*/
export type FindEventBaseData = {
searchText: string;
};
/**
* Fired when the replace button is triggered.
*
* @eventName ~FindAndReplaceFormView#replace
* @param data The event data.
*/
export type ReplaceEvent = {
name: 'replace';
args: [ data: ReplaceEventData ];
};
export type ReplaceEventData = FindEventBaseData & {
replaceText: string;
};
/**
* Fired when the replaceAll button is triggered.
*
* @eventName ~FindAndReplaceFormView#replaceAll
* @param data The event data.
*/
export type ReplaceAllEvent = {
name: 'replaceAll';
args: [ data: ReplaceEventData ];
};