How to use the format.a function in format

To help you get started, we’ve selected a few format examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lepture / ed / index.js View on Github external
function linky(e) {
    if (!e.keyCode || e.keyCode === 13) {
      e.preventDefault();
      toolbar._class.remove('ed-link-input-active');
      me.caret.restore();
      var url = input.value;
      var node = me.caret.parent();
      if (url) {
        if (!/https?:\/\//.test(url)) {
          url = 'http://' + url;
        }
        if (node.tagName.toLowerCase() === 'a') {
          node.href = url;
        } else {
          format.a(url);
        }
      } else {
        format.unlink();
      }
    }
  }
  events.bind(input, 'blur', linky);
github lepture / ed / build / build.js View on Github external
function linky(e) {
    if (!e.keyCode || e.keyCode === 13) {
      e.preventDefault();
      toolbar._class.remove('ed-link-input-active');
      me.caret.restore();
      var url = input.value;
      var node = me.caret.parent();
      if (url) {
        if (!/https?:\/\//.test(url)) {
          url = 'http://' + url;
        }
        if (node.tagName.toLowerCase() === 'a') {
          node.href = url;
        } else {
          format.a(url);
        }
      } else {
        format.unlink();
      }
    }
  }
  events.bind(input, 'blur', linky);
github lepture / ed / index.js View on Github external
createButton('a', 'Insert a link', function() {
    if (!toolbar._class.has('ed-link-input-active')) {
      toolbar._class.add('ed-link-input-active');
      var node = me.caret.parent();
      if (node.tagName.toLowerCase() === 'a') {
        input.value = node.href;
      } else {
        input.value = '';
        format.a('/');
      }
      me.caret.save();
      input.focus();
    }
  });
  toolbar.appendChild(input);
github lepture / ed / build / build.js View on Github external
createButton('a', 'Insert a link', function() {
    if (!toolbar._class.has('ed-link-input-active')) {
      toolbar._class.add('ed-link-input-active');
      var node = me.caret.parent();
      if (node.tagName.toLowerCase() === 'a') {
        input.value = node.href;
      } else {
        input.value = '';
        format.a('/');
      }
      me.caret.save();
      input.focus();
    }
  });
  toolbar.appendChild(input);