How to use the medium-editor.prototype function in medium-editor

To help you get started, we’ve selected a few medium-editor 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 m0g / andika / src / medium-editor.js View on Github external
(function() {
  var MediumEditor = require('medium-editor')
    , ipc = require('ipc');

  // Override default anchor preview behavior
  // TODO: Add an edit button after the link
  MediumEditor.prototype.createAnchorPreview = function() {
    var anchorPreview = document.createElement('div');

    anchorPreview.id = 'medium-editor-anchor-preview-' + this.id;
    anchorPreview.className = 'medium-editor-anchor-preview';
    anchorPreview.innerHTML = this.anchorPreviewTemplate();
    this.options.elementsContainer.appendChild(anchorPreview);

    anchorPreview.addEventListener('click', function () {
      ipc.sendChannel('open-anchor',
                      anchorPreview.querySelector('i').textContent);
    });

    return anchorPreview;
  };

  module.exports = MediumEditor;