Git Product home page Git Product logo

simpleeditor's Introduction

IE <=9 - supported IE >9 - tested Firefox - tested Chrome - tested Safari - tested

SimpleEditor

JS class for creating very simple text/html editor combinated with <iframe> element.

Actual version

Editor creation

JavaScript

  var i_am_instance= class_SimpleEditor.init({
      editor_element: iframe_NODE_element,
      default_value: default_content
  });

HTML

  <iframe id="editor" src='about:blank'></iframe>
  <button onclick="i_am_instance.format('bold');">Bold</button>

Methods

  • format(format_name):
    • primary for using as onclick listener
    • format_name= DOMString command name (i.e. 'Commands List' below);
  • getContent: return <iframe> HTML content
  • getTextContent: return <iframe> text content

Commands List

  • "bold", "italic", "underline": Toggle bold/italic format new or selected text
  • "removeFormat": remove format
  • "insertOrderedList", "insertUnorderedList", "insertParagraph": add <ol>, <ul>, or <p>
  • "createEmail", "createLink", "insertImage": Toggle email, URL link or create image
    • in case of email and URL link: the link is created from selected text (if detected), or you can add link via prompt
    • "insertImage": for now no detection implemented (in aditional, you must combine this with some uploader)
  • "justifyLeft", "justifyRight", "justifyCenter", "justifyFull": alingment change
  • Another possibilites in Document.execCommand()

Register validator

  • Email example:
      i_am_instance.setValidationFunction("createEmail", function emailValidation(email_candidate) {
        /*_@_*/ let e= email_candidate.split("@"); if(e.length!==2) return false;
        /*_@_._*/ e= [e[0], ...e[1].split(".")]; if(e.length!==3) return false;
        const _e= !/(#|\?|!|\\|\/|\||\.\.)/i.test(e[0]);
        return _e && e.reduce((r,o)=>r&&o.length>1&&!/\s/.test(o), _e);
      });

simpleeditor's People

Contributors

dependabot[bot] avatar jaandrle avatar

Watchers

 avatar  avatar

simpleeditor's Issues

Autoinitialization

Rework for auto initialize editor and its buttons. Handle special classes or data.*

Requests from others public repositories on GitHub

The purpose of this issue task is to simplify requests (already implemented in another GitHub repository). Just use jaandrle/SimpleEditor#1 in commit's comments / issues. Keep in mind that non-public repository is not accesible outside your repository team.

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.