import Command from './Command'

class EditInlineNodeCommand extends Command {
  constructor(...args) {
    super(...args)
    if (!this.config.nodeType) {
      throw new Error('Every AnnotationCommand must have a nodeType')
    }
  }

  getCommandState(params) {
    let sel = params.selection
    let newState = {
      disabled: true,
      active: false
    }
    let annos = this._getAnnotationsForSelection(params)
    if (annos.length > 0 && annos[0].getSelection().equals(sel)) {
      newState.disabled = false
      newState.nodeId = annos[0].id
    }
    return newState
  }

  execute(params) { // eslint-disable-line

  }

  _getAnnotationsForSelection(params) {
    return params.selectionState.getAnnotationsForType(this.config.nodeType)
  }

}

export default EditInlineNodeCommand

@@ -419,44 +419,194 @@
 ms)%0A
-    if (annos.length %3E 0 && annos%5B0%5D
+%0A    // Among the annotations found we need to pick the first that exactly%0A    // matches the current selection%0A    if (annos.length %3E 0) %7B%0A      annos.forEach(anno =%3E %7B%0A        if (anno
 .get
@@ -634,24 +634,28 @@
 l)) %7B%0A      
+  
+  
 newState.dis
@@ -664,24 +664,28 @@
 led = false%0A
+    
       newSta
@@ -704,15 +704,30 @@
 anno
-s%5B0%5D.id
+.id%0A        %7D%0A      %7D)
 %0A   

Fix to make #1193 (touching inline nodes) work as expected.