Trevor Parscal has uploaded a new change for review.
https://gerrit.wikimedia.org/r/60781
Change subject: Link inspector fixes
......................................................................
Link inspector fixes
ve.ce.Node.css
* Added prefixes for use of box-sizing
ve.ui.MWLinkInspector.js
* Whitespace
ve.ui.Inspector.css
* Corrected input width, always 100% wide now by using box-sizing
ve.ui.DialogButtonTool.js, ve.ui.Context.js
* Updated use of getViewsForNode
ve.ui.ViewRegistry.js
* Added inheritance-based prioritization for matching views with annotations
and nodes
Bug: 47413
Change-Id: I286a28002c1691e58bbd7de04ed08cceb8b3bb07
---
M modules/ve/ce/styles/ve.ce.Node.css
M modules/ve/ui/inspectors/ve.ui.MWLinkInspector.js
M modules/ve/ui/styles/ve.ui.Inspector.css
M modules/ve/ui/tools/ve.ui.DialogButtonTool.js
M modules/ve/ui/ve.ui.Context.js
M modules/ve/ui/ve.ui.ViewRegistry.js
6 files changed, 34 insertions(+), 15 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/81/60781/1
diff --git a/modules/ve/ce/styles/ve.ce.Node.css
b/modules/ve/ce/styles/ve.ce.Node.css
index a6936cb..af5bffa 100644
--- a/modules/ve/ce/styles/ve.ce.Node.css
+++ b/modules/ve/ce/styles/ve.ce.Node.css
@@ -90,6 +90,8 @@
position: absolute;
border: solid 1px rgba(0,0,0,0.25);
z-index: 10000;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
box-sizing: border-box;
}
diff --git a/modules/ve/ui/inspectors/ve.ui.MWLinkInspector.js
b/modules/ve/ui/inspectors/ve.ui.MWLinkInspector.js
index ee008bd..f0d258f 100644
--- a/modules/ve/ui/inspectors/ve.ui.MWLinkInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.MWLinkInspector.js
@@ -46,6 +46,7 @@
*/
ve.ui.MWLinkInspector.prototype.getAnnotationFromTarget = function ( target ) {
var title;
+
// Figure out if this is an internal or external link
if ( ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( target
) ) {
// External link
diff --git a/modules/ve/ui/styles/ve.ui.Inspector.css
b/modules/ve/ui/styles/ve.ui.Inspector.css
index 581092b..0be51ee 100644
--- a/modules/ve/ui/styles/ve.ui.Inspector.css
+++ b/modules/ve/ui/styles/ve.ui.Inspector.css
@@ -44,7 +44,10 @@
}
.ve-ui-window-body .ve-ui-textInputWidget input {
- width: 20em;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ width: 100%;
}
.ve-ui-window-body form input.ve-ui-linkInspector-location {
diff --git a/modules/ve/ui/tools/ve.ui.DialogButtonTool.js
b/modules/ve/ui/tools/ve.ui.DialogButtonTool.js
index feadbd3..b5ae06b 100644
--- a/modules/ve/ui/tools/ve.ui.DialogButtonTool.js
+++ b/modules/ve/ui/tools/ve.ui.DialogButtonTool.js
@@ -59,8 +59,7 @@
ve.ui.DialogButtonTool.prototype.onUpdateState = function ( nodes ) {
if ( nodes.length ) {
this.setActive(
- ve.ui.viewRegistry.getViewsForNode( nodes[0] )
- .indexOf( this.constructor.static.dialog ) !==
-1
+ ve.ui.viewRegistry.getViewForNode( nodes[0] ) ===
this.constructor.static.dialog
);
}
};
diff --git a/modules/ve/ui/ve.ui.Context.js b/modules/ve/ui/ve.ui.Context.js
index 79fbdfa..8f0f631 100644
--- a/modules/ve/ui/ve.ui.Context.js
+++ b/modules/ve/ui/ve.ui.Context.js
@@ -189,7 +189,7 @@
* @chainable
*/
ve.ui.Context.prototype.update = function () {
- var i, nodes, views,
+ var i, nodes, views, view,
fragment = this.surface.getModel().getFragment( null, false ),
selection = fragment.getRange(),
inspector = this.inspectors.getCurrent();
@@ -208,7 +208,10 @@
}
}
if ( nodes.length === 1 ) {
- views = views.concat(
ve.ui.viewRegistry.getViewsForNode( nodes[0].node ) );
+ view = ve.ui.viewRegistry.getViewForNode( nodes[0].node
);
+ if ( view ) {
+ views.push( view );
+ }
}
for ( i = 0; i < views.length; i++ ) {
if ( !ve.ui.toolFactory.lookup( views[i] ) ) {
diff --git a/modules/ve/ui/ve.ui.ViewRegistry.js
b/modules/ve/ui/ve.ui.ViewRegistry.js
index 49e76ac..430b65b 100644
--- a/modules/ve/ui/ve.ui.ViewRegistry.js
+++ b/modules/ve/ui/ve.ui.ViewRegistry.js
@@ -39,6 +39,8 @@
/**
* Get a list of views from a set of annotations.
*
+ * The most specific view will be chosen based on inheritance.
+ *
* @method
* @param {ve.dm.AnnotationSet} annotations Annotations to be inspected
* @returns {string[]} Symbolic names of views that can be used to inspect
annotations
@@ -48,42 +50,51 @@
return [];
}
- var i, len, annotation, name, view,
+ var i, len, annotation, name, view, candidateView, candidateViewName,
arr = annotations.get(),
matches = [];
for ( i = 0, len = arr.length; i < len; i++ ) {
annotation = arr[i];
+ candidateView = null;
for ( name in this.registry ) {
view = this.registry[name];
if ( this.isViewRelatedToModel( view, annotation ) ) {
- matches.push( name );
- break;
+ if ( !candidateView || view.prototype
instanceof candidateView ) {
+ candidateView = view;
+ candidateViewName = name;
+ }
}
+ }
+ if ( candidateView ) {
+ matches.push( candidateViewName );
}
}
return matches;
};
/**
- * Get a list of views for a node.
+ * Get a view for a node.
+ *
+ * The most specific view will be chosen based on inheritance.
*
* @method
* @param {ve.dm.Node} node Node to be edited
* @returns {string[]} Symbolic names of views that can be used to edit node
*/
-ve.ui.ViewRegistry.prototype.getViewsForNode = function ( node ) {
- var name, view,
- matches = [];
+ve.ui.ViewRegistry.prototype.getViewForNode = function ( node ) {
+ var name, view, candidateView, candidateViewName;
for ( name in this.registry ) {
view = this.registry[name];
if ( this.isViewRelatedToModel( view, node ) ) {
- matches.push( name );
- break;
+ if ( !candidateView || view.prototype instanceof
candidateView ) {
+ candidateView = view;
+ candidateViewName = name;
+ }
}
}
- return matches;
+ return candidateViewName;
};
/* Initialization */
--
To view, visit https://gerrit.wikimedia.org/r/60781
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I286a28002c1691e58bbd7de04ed08cceb8b3bb07
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits