index.js
function () {
    return function (scribe) {
      var jumpLinkCommand = new scribe.api.Command('createLink');
      jumpLinkCommand.nodeName = 'A';

      jumpLinkCommand.execute = function () {
        var selection = new scribe.api.Selection(),
            that = this;
        var fullString = selection.selection.baseNode.textContent
        if($(selection.selection.baseNode.parentNode).hasClass('is-jump-link')){
          // Remove the jump link
          $(selection.selection.baseNode).unwrap()
        }else{
          // Create the jump link
          var startOffset = selection.range.startOffset
          var numOfChar = selection.range.endOffset - startOffset
          var replace = fullString.substr(startOffset, numOfChar)
          if (selection.selection.baseNode.parentNode.nodeName === 'A'){
            var parent = selection.selection.baseNode.parentElement
            parent.classList.add('is-jump-link')
            parent.setAttribute('name', replace)
          }else{
            replace = "<a class='is-jump-link' name=" + replace + ">" + replace + '</a>'
            var newHtml = splice(fullString, startOffset, numOfChar, replace)
            $(selection.selection.baseNode).replaceWith(newHtml)
          }
        }
      };

      // Set this as the jump linking plugin
      scribe.commands.jumpLink = jumpLinkCommand;
    };
  }
function () {
    return function (scribe) {
      var jumpLinkCommand = new scribe.api.Command('createLink');
      jumpLinkCommand.nodeName = 'A';

      jumpLinkCommand.execute = function () {
        var selection = new scribe.api.Selection(),
            that = this;
        var fullString = selection.selection.baseNode.textContent
        if($(selection.selection.baseNode.parentNode).hasClass('is-jump-link')){
          // Remove the jump link
          $(selection.selection.baseNode).unwrap()
        }else{
          // Create the jump link
          var startOffset = selection.range.startOffset
          var numOfChar = selection.range.endOffset - startOffset
          var replace = fullString.substr(startOffset, numOfChar)
          if (selection.selection.baseNode.parentNode.nodeName === 'A'){
            var parent = selection.selection.baseNode.parentElement
            parent.classList.add('is-jump-link')
            parent.setAttribute('name', replace)
          }else{
            replace = "<a class='is-jump-link' name=" + replace + ">" + replace + '</a>'
            var newHtml = splice(fullString, startOffset, numOfChar, replace)
            $(selection.selection.baseNode).replaceWith(newHtml)
          }
        }
      };

      // Set this as the jump linking plugin
      scribe.commands.jumpLink = jumpLinkCommand;
    };
  }
function ( ) { return function ( scribe ) { var jumpLinkCommand = new scribe . api . Command ( 'createLink' ) ; jumpLinkCommand . nodeName = 'A' ; jumpLinkCommand . execute = function ( ) { var selection = new scribe . api . Selection ( ) , that = this ; var fullString = selection . selection . baseNode . textContent if ( $ ( selection . selection . baseNode . parentNode ) . hasClass ( 'is-jump-link' ) ) { // Remove the jump link $ ( selection . selection . baseNode ) . unwrap ( ) } else { // Create the jump link var startOffset = selection . range . startOffset var numOfChar = selection . range . endOffset - startOffset var replace = fullString . substr ( startOffset , numOfChar ) if ( selection . selection . baseNode . parentNode . nodeName === 'A' ) { var parent = selection . selection . baseNode . parentElement parent . classList . add ( 'is-jump-link' ) parent . setAttribute ( 'name' , replace ) } else { replace = "<a class='is-jump-link' name=" + replace + ">" + replace + '</a>' var newHtml = splice ( fullString , startOffset , numOfChar , replace ) $ ( selection . selection . baseNode ) . replaceWith ( newHtml ) } } } ; // Set this as the jump linking plugin scribe . commands . jumpLink = jumpLinkCommand ; } ; }
The main plugin function
The main plugin function