jenkins-bot has submitted this change and it was merged.

Change subject: VE: Lookup the correct command for the node
......................................................................


VE: Lookup the correct command for the node

Bug: T128198
Change-Id: I564b0b3e8cf6906d108ee876cff03196065bd164
---
M modules/ve-cite/ve.ce.MWReferenceNode.js
M modules/ve-cite/ve.ui.MWReference.init.js
2 files changed, 20 insertions(+), 9 deletions(-)

Approvals:
  DLynch: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve-cite/ve.ce.MWReferenceNode.js 
b/modules/ve-cite/ve.ce.MWReferenceNode.js
index 8cd455c..86a566b 100644
--- a/modules/ve-cite/ve.ce.MWReferenceNode.js
+++ b/modules/ve-cite/ve.ce.MWReferenceNode.js
@@ -62,8 +62,6 @@
 
 /**
  * Handle setup event.
- *
- * @method
  */
 ve.ce.MWReferenceNode.prototype.onSetup = function () {
        ve.ce.MWReferenceNode.super.prototype.onSetup.call( this );
@@ -72,8 +70,6 @@
 
 /**
  * Handle teardown event.
- *
- * @method
  */
 ve.ce.MWReferenceNode.prototype.onTeardown = function () {
        // As we are listening to the internal list, we need to make sure
@@ -88,7 +84,6 @@
  *
  * This will occur after a document transaction.
  *
- * @method
  * @param {string[]} groupsChanged A list of groups which have changed in this 
transaction
  */
 ve.ce.MWReferenceNode.prototype.onInternalListUpdate = function ( 
groupsChanged ) {
@@ -99,9 +94,25 @@
 };
 
 /**
- * Handle update events.
- *
- * @method
+ * @inheritdoc ve.ce.FocusableNode
+ */
+ve.ce.MWReferenceNode.prototype.executeCommand = function () {
+       var command, contextItem,
+               items = ve.ui.contextItemFactory.getRelatedItems( [ this.model 
] );
+
+       if ( items.length ) {
+               contextItem = ve.ui.contextItemFactory.lookup( items[ 0 ].name 
);
+               if ( contextItem ) {
+                       command = ve.init.target.commandRegistry.lookup( 
contextItem.static.commandName );
+                       if ( command ) {
+                               command.execute( 
this.focusableSurface.getSurface() );
+                       }
+               }
+       }
+};
+
+/**
+ * Update the rendering
  */
 ve.ce.MWReferenceNode.prototype.update = function () {
        var group = this.model.getGroup();
diff --git a/modules/ve-cite/ve.ui.MWReference.init.js 
b/modules/ve-cite/ve.ui.MWReference.init.js
index f92adef..8ac6f25 100644
--- a/modules/ve-cite/ve.ui.MWReference.init.js
+++ b/modules/ve-cite/ve.ui.MWReference.init.js
@@ -76,7 +76,7 @@
                try {
                        // Must use mw.message to avoid JSON being parsed as 
Wikitext
                        tools = JSON.parse( mw.message( 
'visualeditor-cite-tool-definition.json' ).plain() );
-               } catch ( e ) { }
+               } catch ( e ) {}
 
                if ( Array.isArray( tools ) ) {
                        for ( i = 0, len = Math.min( limit, tools.length ); i < 
len; i++ ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/273583
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I564b0b3e8cf6906d108ee876cff03196065bd164
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Cite
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: DLynch <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to