mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-12-24 03:23:14 +00:00
9bea2a7905
Adds a custom class for matched brackets to allow better integration with custom bracket styles. The brackets won't be bold in the 2017WTE. Bold font might lead to misalignment there. See ticket. Note: box-shadow seems to be supported for quite some time by all relevant browsers Bug: T270926 Change-Id: Ica1e301f63a106a96db3bfaba4b2f322af64b009
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const Page = require( 'wdio-mediawiki/Page' );
|
|
|
|
// Copied from mediawiki-core edit.page.js
|
|
class EditPage extends Page {
|
|
openForEditing( title ) {
|
|
super.openTitle( title, { action: 'edit', vehidebetadialog: 1, hidewelcomedialog: 1 } );
|
|
}
|
|
|
|
get wikiEditorToolbar() { return $( '#wikiEditor-ui-toolbar' ); }
|
|
get legacyTextInput() { return $( '#wpTextbox1' ); }
|
|
clickText() {
|
|
if ( this.visualEditorSave.isDisplayed() ) {
|
|
this.visualEditorSurface.click();
|
|
} else if ( this.legacyTextInput.isDisplayed() ) {
|
|
this.legacyTextInput.click();
|
|
} else {
|
|
// Click the container, if using WikiEditor etc.
|
|
this.legacyTextInput.parentElement().click();
|
|
}
|
|
}
|
|
|
|
get visualEditorSave() { return $( '.ve-ui-toolbar-saveButton' ); }
|
|
get visualEditorToggle() { return $( '.ve-init-mw-editSwitch' ); }
|
|
get visualEditorSurface() { return $( '.ve-ui-surface-source' ); }
|
|
|
|
cursorToPosition( index ) {
|
|
this.clickText();
|
|
|
|
// Second "Control" deactivates the modifier.
|
|
const keys = [ 'Control', 'Home', 'Control' ];
|
|
for ( let i = 0; i < index; i++ ) {
|
|
keys.push( 'ArrowRight' );
|
|
}
|
|
browser.keys( keys );
|
|
}
|
|
|
|
getHighlightedMatchingBrackets() {
|
|
const elements = $$( '.CodeMirror-line .cm-mw-matchingbracket' );
|
|
const matchingTexts = elements.map( function ( el ) {
|
|
return el.getText();
|
|
} );
|
|
return matchingTexts.join( '' );
|
|
}
|
|
}
|
|
|
|
module.exports = new EditPage();
|