GithubHelp home page GithubHelp logo

pulpmedia / angular-medium-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thijsw/angular-medium-editor

0.0 5.0 0.0 277 KB

AngularJS directive for Medium.com editor clone

JavaScript 64.86% CSS 23.83% HTML 11.32%

angular-medium-editor's Introduction

angular-medium-editor

This is an AngularJS directive for the medium.com inline editor clone made by Davi Ferreira.

Getting Started

Download the production version or the development version.

In your web page:

<script src="angular.js"></script>
<script src="dist/angular-medium-editor.min.js"></script>

Demo

If you want to view the included demo, you have to run bower first in order to retrieve the dependencies.

$ bower install --save angular-medium-editor

Documentation

Header example limited to one line and no toolbar

<h1 ng-model="title" medium-editor options='{"placeholder": "Enter a title", "disableToolbar": true, "forcePlainText": true, "disableReturn": true}'></h1>

Paragraph with support for multiple lines and customized toolbar buttons

<p ng-model="description" medium-editor options='{"placeholder": "Enter a description", "buttons": ["bold", "italic", "underline", "anchor", "header1", "header2", "quote", "orderedlist", "unorderedlist"]}'></p>

Example for extending the toolbar with customized element 'highlighter' (using rangy and the CSS Class Applier Module to support highlighting of text). For more detailed info on extensions, please refer to MediumEditor.

<p ng-model="text" medium-editor options='{"buttons": ["bold", "italic", "highlight"]}' bind-options="mediumBindOptions"></p>
function Highlighter() {
  this.button = document.createElement('button');
  this.button.className = 'medium-editor-action';
  this.button.innerText = 'H';
  this.button.onclick = this.onClick.bind(this);
  this.classApplier = rangy.createCssClassApplier('highlight', {
    elementTagName: 'mark',
    normalize: true
  });
}
Highlighter.prototype.onClick = function() {
  this.classApplier.toggleSelection();
};
Highlighter.prototype.getButton = function() {
  return this.button;
};
Highlighter.prototype.checkState = function(node) {
  if (node.tagName == 'MARK') {
    this.button.classList.add('medium-editor-button-active');
  }
};

scope.mediumBindOptions = {
  extensions: {
    'highlight': new Highlighter()
  }
};

(More coming soon)

Examples

(Coming soon)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.