Giter VIP home page Giter VIP logo

medium-editor-custom-html's Introduction

medium-editor-custom-html

Insert custom HTML using a new button in the Medium Editor toolbar

Preview

Check out the demo page hosted on GitHub pages.

Documentation

new CustomHtml(options)

Creates a new instance of CustomHtml extension.

Params:

  • Object options An object containing the extension configuration. The following fields should be provided:
  • buttonText: the text of the button (default: </>)
  • htmlToInsert: the HTML code that should be inserted

onClick()

The click event handler that calls insertHtmlAtCaret method.

getButton()

This function is called by the Medium Editor and returns the button that is added in the toolbar

Return:

  • HTMLButtonElement The button that is attached in the Medium Editor toolbar

Example

Load in the page the following scripts in this order:

  • Medium Editor JS
  • Custom HTML Medium Editor Extension
  • Your custom script (that creates the editor and contains the custom handlers)
window.onload = function () {
    var myEditor = new MediumEditor(".container", {
        buttons: [
            "bold"
          , "italic"
          , "underline"
          , "anchor"
          , "header1"
          , "header2"
          , "quote"
          , "customHtml"
        ]
      , extensions: {
            "customHtml": new CustomHtml({
                buttonText: "<hr>"
              , htmlToInsert: "<hr class='someclass'>"
            })
        }
    });
};

Development

Run the following commands to download and install the extension:

$ git clone [email protected]:jillix/medium-editor-custom-html.git medium-editor-custom-html
$ cd medium-editor-custom-html
$ npm install

How to contribute

  1. File an issue in the repository, using the bug tracker, describing the contribution you'd like to make. This will help us to get you started on the right foot.
  2. Fork the project in your account and create a new branch: your-great-feature.
  3. Commit your changes in that branch.
  4. Open a pull request, and reference the initial issue in the pull request message.

License

See the LICENSE file.

medium-editor-custom-html's People

Contributors

arielsvn avatar ionicabizau avatar tingham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

medium-editor-custom-html's Issues

Add the option to retain the selected text

What would make this extension ever more useful is an option to append the defined html to the selected text - by surrounding the selection with the html tags instead of completely removing it.

This could be an extra setting for the extension, "keepSelection: true"

Add custom html to an element

Hey I was wondering if there was a way to add an element after closing the current paragraph, or if I could define another container where I'd like the html element to be appended.
I'm trying to achieve a layout where there are options next to each paragraph in the editor, which have some data related to the content of the paragraph.

Selected text is replaced

Maybe I'm doing something wrong, but whenever I use this to append an html tag, it completely removes the words selected.

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.