mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-23 13:56:44 +00:00
CodeMirror: default to using the same height as the textarea
CodeMirrorWikiEditor: add a 'ext.CodeMirror.initialize' hook to allow integrations to manipulate the DOM before CodeMirror is initialized. This is necessary for ProofreadPage, for example (I5c0824bf38cf7). Bug: T357794 Change-Id: I4deeda192bdc233101ba61739a636f8fd143c1de
This commit is contained in:
parent
5bfb8dddad
commit
c9c9ed27d3
2
resources/dist/main.js
vendored
2
resources/dist/main.js
vendored
File diff suppressed because one or more lines are too long
2
resources/dist/main.js.map.json
vendored
2
resources/dist/main.js.map.json
vendored
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,13 @@ export default class CodeMirror {
|
|||
const extensions = [
|
||||
this.contentAttributesExtension,
|
||||
this.phrasesExtension,
|
||||
this.specialCharsExtension
|
||||
this.specialCharsExtension,
|
||||
EditorView.theme( {
|
||||
// Use the same height as the textarea
|
||||
'.cm-content': {
|
||||
height: this.$textarea.outerHeight() + 'px'
|
||||
}
|
||||
} )
|
||||
];
|
||||
const namespaces = mw.config.get( 'wgCodeMirrorLineNumberingNamespaces' );
|
||||
|
||||
|
@ -167,6 +173,8 @@ export default class CodeMirror {
|
|||
* @stable
|
||||
*/
|
||||
initialize( extensions = this.defaultExtensions ) {
|
||||
mw.hook( 'ext.CodeMirror.initialize' ).fire( this.$textarea );
|
||||
|
||||
// Set up the initial EditorState of CodeMirror with contents of the native textarea.
|
||||
this.state = EditorState.create( {
|
||||
doc: this.$textarea.textSelection( 'getContents' ),
|
||||
|
|
Loading…
Reference in a new issue