jenkins-bot has submitted this change and it was merged.
Change subject: Add setContents to textSelection and JS hook for #wpTextbox1 (v
3.1.12)
......................................................................
Add setContents to textSelection and JS hook for #wpTextbox1 (v 3.1.12)
Bug: T108711
Change-Id: I65f25108863339fdcfc55c030a1158c2cd789b91
---
M extension.json
M resources/ext.CodeMirror.js
2 files changed, 27 insertions(+), 2 deletions(-)
Approvals:
Pastakhov: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index 914227d..9720251 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
{
"name": "CodeMirror",
- "version": "3.1.11",
+ "version": "3.1.12",
"author": [
"[https://www.mediawiki.org/wiki/User:Pastakhov Pavel
Astakhov]",
"[https://www.mediawiki.org/wiki/User:Florianschmidtwelzow
Florian Schmidt]"
diff --git a/resources/ext.CodeMirror.js b/resources/ext.CodeMirror.js
index a3e968e..4591f50 100644
--- a/resources/ext.CodeMirror.js
+++ b/resources/ext.CodeMirror.js
@@ -20,6 +20,10 @@
return codeMirror.doc.getValue();
},
+ setContents: function ( newContents ) {
+ codeMirror.doc.setValue( newContents );
+ },
+
/**
* Get the currently selected text in this
textarea. Will focus the textarea
* in some browsers (IE/Opera)
@@ -232,7 +236,28 @@
}
);
}
- };
+ },
+ originHooksTextarea = $.valHooks.textarea;
+
+ // define JQuery hook for searching and replacing text using JS if
CodeMirror is enabled, see Bug: T108711
+ $.valHooks.textarea = {
+ get: function( elem ) {
+ if ( elem.id === 'wpTextbox1' && codeMirror ) {
+ return codeMirror.doc.getValue();
+ } else if ( originHooksTextarea ) {
+ return originHooksTextarea.get( elem );
+ }
+ return elem.value;
+ },
+ set: function( elem, value ) {
+ if ( elem.id === 'wpTextbox1' && codeMirror ) {
+ return codeMirror.doc.setValue( value );
+ } else if ( originHooksTextarea ) {
+ return originHooksTextarea.set( elem, value );
+ }
+ elem.value = value;
+ }
+ };
/**
* Save CodeMirror enabled pref.
--
To view, visit https://gerrit.wikimedia.org/r/231219
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I65f25108863339fdcfc55c030a1158c2cd789b91
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: He7d3r <[email protected]>
Gerrit-Reviewer: Pastakhov <[email protected]>
Gerrit-Reviewer: Schnark <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits