mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-23 22:03:28 +00:00
3c3050447b
Just like the 2017 editor, we show the number of results and which one is currently highlighted. This patch also brings the Tab behaviour closer to the 2017 editor. Hitting Tab from the search input focuses the replace input, followed by the replacement buttons, then the find buttons, then the content editable. Shift+Tab largely does the reverse, except Shift+Tab from the editor doesn't bring you to the search panel. Doing this would require a lot of work for minor benefit, as we'd need to determine which panel to focus to. Add basic unit test Bug: T371436 Change-Id: I968f91320ecb6ab9e9da0994052d33c76f85974b
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
/* eslint-disable-next-line n/no-missing-require */
|
|
const { EditorView, EditorState } = require( 'ext.CodeMirror.v6.lib' );
|
|
const CodeMirrorSearch = require( '../../resources/codemirror.search.js' );
|
|
|
|
describe( 'CodeMirrorSearch', () => {
|
|
it( 'should provide an Extension getter and a Panel getter', () => {
|
|
const cmSearch = new CodeMirrorSearch();
|
|
cmSearch.view = new EditorView();
|
|
expect( cmSearch.extension ).toBeInstanceOf( Array );
|
|
expect( cmSearch.extension[ 0 ][ 0 ].constructor.name ).toStrictEqual( 'FacetProvider' );
|
|
expect( cmSearch.panel ).toHaveProperty( 'dom' );
|
|
} );
|
|
|
|
it( 'should disable replacement fields if the textarea is read-only', () => {
|
|
const cmSearch = new CodeMirrorSearch();
|
|
cmSearch.view = new EditorView();
|
|
// eslint-disable-next-line no-unused-expressions
|
|
cmSearch.panel;
|
|
|
|
cmSearch.view = new EditorView( {
|
|
state: EditorState.create( {
|
|
doc: '',
|
|
extensions: [ EditorState.readOnly.of( true ) ]
|
|
} )
|
|
} );
|
|
// eslint-disable-next-line no-unused-expressions
|
|
cmSearch.panel;
|
|
expect( cmSearch.replaceInput.disabled ).toBe( true );
|
|
} );
|
|
} );
|