DLynch has uploaded a new change for review.
https://gerrit.wikimedia.org/r/301629
Change subject: MWLinkAnnotationInspector: change where auto switch to external
occurs
......................................................................
MWLinkAnnotationInspector: change where auto switch to external occurs
OnInternalLinkChange happened post-validation, and received an already title-
normalized version of the href. Thus `file://` would become `:File://`. As
such, hook up to the raw internal link input change event, and judge what the
user actually entered.
Bug: T138956
Change-Id: I0f9f3de3b7bf6e5430e55fa69626522b0c74296a
---
M modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js
1 file changed, 27 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/29/301629/1
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js
b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js
index 3acee5e..93d699f 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js
@@ -76,6 +76,7 @@
this.externalAnnotationInput.connect( this, { change:
'onExternalLinkChange' } );
this.internalAnnotationInput.input.getResults().connect( this, {
choose: 'onFormSubmit' } );
// Form submit only auto triggers on enter when there is one input
+ this.internalAnnotationInput.getTextInputWidget().connect( this, {
change: 'onInternalLinkInputChange' } );
this.internalAnnotationInput.getTextInputWidget().connect( this, {
enter: 'onFormSubmit' } );
this.externalAnnotationInput.getTextInputWidget().connect( this, {
enter: 'onFormSubmit' } );
@@ -111,26 +112,6 @@
* @param {ve.dm.MWInternalLinkAnnotation} annotation Annotation
*/
ve.ui.MWLinkAnnotationInspector.prototype.onInternalLinkChange = function (
annotation ) {
- var href = annotation ? annotation.getAttribute( 'title' ) : '';
-
- // If this looks like an external link, switch to the correct card.
- // Note: We don't care here if it's a *valid* link, so we just
- // check whether it looks like a URI -- i.e. whether it starts with
- // something that appears to be a schema per RFC1630. Later the external
- // link inspector will use getExternalLinkUrlProtocolsRegExp for
validity
- // checking.
- // Note 2: RFC1630 might be too broad in practice. You don't really see
- // schemas that use the full set of allowed characters, and we might get
- // more false positives by checking for them.
- // Note 3: We allow protocol-relative URIs here.
- if (
- !this.allowProtocolInInternal &&
- /^(?:[a-z][a-z0-9\$\-_@\.&!\*"'\(\),]*:)?\/\//i.test( href )
- ) {
- this.linkTypeIndex.setCard( 'external' );
- // Changing card focuses and selects the input, so collapse the
cursor back to the end.
-
this.externalAnnotationInput.getTextInputWidget().moveCursorToEnd();
- }
this.updateActions();
};
@@ -186,6 +167,32 @@
};
/**
+ * Handle change events on the internal link widget's input
+ *
+ * @param {string} value Current value of input widget
+ */
+ve.ui.MWLinkAnnotationInspector.prototype.onInternalLinkInputChange = function
( value ) {
+ // If this looks like an external link, switch to the correct card.
+ // Note: We don't care here if it's a *valid* link, so we just
+ // check whether it looks like a URI -- i.e. whether it starts with
+ // something that appears to be a schema per RFC1630. Later the external
+ // link inspector will use getExternalLinkUrlProtocolsRegExp for
validity
+ // checking.
+ // Note 2: RFC1630 might be too broad in practice. You don't really see
+ // schemas that use the full set of allowed characters, and we might get
+ // more false positives by checking for them.
+ // Note 3: We allow protocol-relative URIs here.
+ if (
+ !this.allowProtocolInInternal &&
+ /^(?:[a-z][a-z0-9\$\-_@\.&!\*"'\(\),]*:)?\/\//i.test(
value.trim() )
+ ) {
+ this.linkTypeIndex.setCard( 'external' );
+ // Changing card focuses and selects the input, so collapse the
cursor back to the end.
+
this.externalAnnotationInput.getTextInputWidget().moveCursorToEnd();
+ }
+};
+
+/**
* @inheritdoc
*/
ve.ui.MWLinkAnnotationInspector.prototype.createAnnotationInput = function () {
--
To view, visit https://gerrit.wikimedia.org/r/301629
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f9f3de3b7bf6e5430e55fa69626522b0c74296a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits