Convert Figma logo to code with AI

lepture logoeditor

A markdown editor. http://lab.lepture.com/editor/

2,800
262
2,800
54

Top Related Projects

12,021

📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies

45,838

Quill is a modern WYSIWYG editor built for compatibility and extensibility

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.

10,179

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.

15,726

The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular

19,552

A rich text editor for everyday writing

Quick Overview

Lepture/editor is a lightweight, customizable Markdown editor for web applications. It provides a simple interface for writing and editing Markdown content, with real-time preview capabilities and support for various extensions.

Pros

  • Lightweight and easy to integrate into existing web projects
  • Customizable with various options and extensions
  • Supports real-time preview of Markdown content
  • Active development and community support

Cons

  • Limited advanced features compared to some full-featured Markdown editors
  • May require additional styling for optimal appearance in different environments
  • Documentation could be more comprehensive for advanced use cases

Code Examples

  1. Basic initialization:
var editor = new Editor();
editor.render();

This code creates a new Editor instance and renders it to the default container.

  1. Customizing editor options:
var editor = new Editor({
  textarea: document.getElementById('my-textarea'),
  toolbar: ['bold', 'italic', 'link', 'image'],
  preview: false
});
editor.render();

This example initializes the editor with a specific textarea, custom toolbar buttons, and disables the preview.

  1. Adding a custom button to the toolbar:
Editor.toolbar.add('myButton', {
  name: 'myButton',
  action: function(editor) {
    editor.codemirror.replaceSelection('Custom text');
  },
  className: 'fa fa-star',
  title: 'Insert Custom Text'
});

var editor = new Editor({
  toolbar: ['bold', 'italic', 'myButton']
});
editor.render();

This code adds a custom button to the toolbar that inserts specific text when clicked.

Getting Started

To get started with lepture/editor, follow these steps:

  1. Include the necessary files in your HTML:
<link rel="stylesheet" href="https://unpkg.com/lepture-editor@latest/dist/editor.css" />
<script src="https://unpkg.com/lepture-editor@latest/dist/editor.js"></script>
  1. Create a container for the editor in your HTML:
<div id="editor-container"></div>
  1. Initialize the editor in your JavaScript:
document.addEventListener('DOMContentLoaded', function() {
  var editor = new Editor({
    element: document.getElementById('editor-container')
  });
  editor.render();
});

This will create a basic Markdown editor in your web page. You can further customize it by exploring the available options and extensions in the documentation.

Competitor Comparisons

12,021

📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies

Pros of Pell

  • Extremely lightweight (1.5KB gzipped) compared to Editor's larger size
  • No dependencies, making it easier to integrate
  • Simpler API and configuration options

Cons of Pell

  • Fewer built-in features and customization options than Editor
  • Less extensive documentation and examples
  • Smaller community and fewer updates

Code Comparison

Editor:

var editor = new Editor();
editor.render();
editor.codemirror.on('change', function() {
  console.log(editor.codemirror.getValue());
});

Pell:

const editor = pell.init({
  element: document.getElementById('editor'),
  onChange: html => console.log(html)
});

Summary

Pell is a lightweight, dependency-free rich text editor that prioritizes simplicity and ease of use. It's ideal for projects requiring a basic editor with minimal overhead. However, it lacks some advanced features and customization options found in Editor.

Editor, on the other hand, offers more extensive functionality and customization, but comes with a larger file size and potential dependencies. It's better suited for projects that require a more feature-rich editing experience and have the capacity to handle a larger library.

The choice between the two depends on the specific needs of your project, balancing simplicity and file size against feature set and customization options.

45,838

Quill is a modern WYSIWYG editor built for compatibility and extensibility

Pros of Quill

  • More feature-rich and customizable with a modular architecture
  • Better cross-browser compatibility and mobile support
  • Larger community and more frequent updates

Cons of Quill

  • Larger file size and potentially heavier performance impact
  • Steeper learning curve due to more complex API
  • May be overkill for simple text editing needs

Code Comparison

Editor:

var editor = new Editor();
editor.render();
editor.codemirror.on('change', function(cm) {
  console.log(cm.getValue());
});

Quill:

var quill = new Quill('#editor', {
  modules: { toolbar: true },
  theme: 'snow'
});
quill.on('text-change', function(delta, oldDelta, source) {
  console.log(quill.getText());
});

Summary

Editor is a lightweight, simple Markdown editor that's easy to set up and use. It's ideal for basic text editing needs and projects where a small footprint is crucial.

Quill, on the other hand, is a more powerful and versatile rich text editor with extensive customization options. It offers better cross-platform support and a wider range of features, making it suitable for complex editing requirements.

The choice between the two depends on the specific needs of your project, balancing simplicity and lightweight performance against feature richness and customization.

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.

Pros of medium-editor

  • More feature-rich with a wider range of built-in extensions and plugins
  • Offers a WYSIWYG interface similar to Medium's editor, which may be more intuitive for some users
  • Actively maintained with frequent updates and a larger community

Cons of medium-editor

  • Larger file size and potentially heavier on resources due to more features
  • May have a steeper learning curve for customization compared to editor
  • Less suitable for minimalist or lightweight implementations

Code comparison

editor:

var editor = new Editor();
editor.render();

medium-editor:

var editor = new MediumEditor('.editable', {
    toolbar: {
        buttons: ['bold', 'italic', 'underline', 'anchor', 'h2', 'h3', 'quote']
    }
});

Summary

medium-editor provides a more comprehensive editing experience with numerous built-in features, making it suitable for projects requiring a rich text editor similar to Medium's interface. However, this comes at the cost of a larger file size and potentially more complex setup.

editor, on the other hand, offers a simpler, more lightweight solution that may be preferable for projects needing basic editing functionality with minimal overhead. It's easier to set up but lacks some of the advanced features found in medium-editor.

The choice between the two depends on the specific requirements of your project, balancing feature richness against simplicity and performance.

10,179

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.

Pros of CKEditor 5

  • More feature-rich with a wide range of plugins and customization options
  • Better support for collaborative editing and real-time collaboration
  • Stronger accessibility compliance and internationalization support

Cons of CKEditor 5

  • Larger file size and potentially slower load times
  • Steeper learning curve for developers due to its complexity
  • More resource-intensive, which may impact performance on low-end devices

Code Comparison

Editor:

var editor = new Editor();
editor.render();
editor.codemirror.setValue('# Hello\n\nEdit here...');

CKEditor 5:

ClassicEditor
    .create(document.querySelector('#editor'))
    .then(editor => {
        console.log('Editor was initialized', editor);
    })
    .catch(error => {
        console.error(error);
    });

Key Differences

  • Editor is a lightweight Markdown editor, while CKEditor 5 is a full-featured WYSIWYG editor
  • Editor uses CodeMirror for syntax highlighting, CKEditor 5 has its own rendering engine
  • CKEditor 5 offers a more modern and modular architecture
  • Editor is simpler to set up and use for basic editing needs
  • CKEditor 5 provides more advanced features like track changes and comments
15,726

The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular

Pros of TinyMCE

  • More feature-rich with a wide range of plugins and customization options
  • Better cross-browser compatibility and support for older browsers
  • Larger community and more frequent updates

Cons of TinyMCE

  • Larger file size and potentially slower load times
  • Steeper learning curve due to its extensive API and configuration options
  • May be overkill for simple text editing needs

Code Comparison

TinyMCE initialization:

tinymce.init({
  selector: '#myTextarea',
  plugins: 'link image table',
  toolbar: 'undo redo | formatselect | bold italic | alignleft aligncenter alignright | link image'
});

Editor initialization:

var editor = new Editor();
editor.render();

TinyMCE offers more configuration options out of the box, while Editor provides a simpler setup. TinyMCE's initialization includes plugin and toolbar customization, whereas Editor's basic setup is more straightforward.

TinyMCE is a comprehensive WYSIWYG editor with extensive features, making it suitable for complex content management systems. Editor, on the other hand, is a lightweight Markdown editor focused on simplicity and ease of use.

TinyMCE has a larger footprint but offers more advanced formatting options and better browser compatibility. Editor is more suitable for projects requiring a minimal, fast-loading Markdown editor with basic formatting capabilities.

19,552

A rich text editor for everyday writing

Pros of Trix

  • More feature-rich, with built-in toolbar and formatting options
  • Better browser compatibility and mobile support
  • Actively maintained with regular updates and bug fixes

Cons of Trix

  • Larger file size and potentially heavier on resources
  • Less customizable compared to Editor's minimalist approach
  • Steeper learning curve for developers due to more complex API

Code Comparison

Editor:

var editor = new Editor();
editor.render();
editor.codemirror.on('change', function() {
  console.log(editor.codemirror.getValue());
});

Trix:

var element = document.querySelector("trix-editor")
element.addEventListener("trix-change", function(event) {
  console.log(element.value)
})

Summary

Editor is a lightweight, minimalist Markdown editor that offers simplicity and ease of customization. It's ideal for projects requiring a basic editing experience with a small footprint.

Trix, on the other hand, is a more comprehensive rich text editor with a polished user interface and extensive features out of the box. It's better suited for applications needing a full-featured WYSIWYG editor with broad browser support.

The choice between the two depends on the specific requirements of your project, balancing between simplicity and feature set, as well as considering factors like file size and customization needs.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Editor

A markdown editor you really want.

Sponsors

Editor is sponsored by Typlog.

Overview

Editor is not a WYSIWYG editor, it is a plain text markdown editor. Thanks for the great project codemirror, without which editor can never be created.

Basic Usage

The easiest way to use Editor is to simply load the script and stylesheet:

<link rel="stylesheet" href="http://lab.lepture.com/editor/editor.css" />
<script type="text/javascript" src="http://lab.lepture.com/editor/editor.js"></script>
<script type="text/javascript" src="http://lab.lepture.com/editor/marked.js"></script>

You can also use jsdelivr CDN:

<link rel="stylesheet" href="//cdn.jsdelivr.net/editor/0.1.0/editor.css">
<script src="//cdn.jsdelivr.net/editor/0.1.0/editor.js"></script>
<script src="//cdn.jsdelivr.net/editor/0.1.0/marked.js"></script>

Having done this, an editor instance can be created:

var editor = new Editor();
editor.render();

The editor will take the position of the first <textarea> element.

Get the content

To get back the edited content you use:

editor.codemirror.getValue();

Component

If you are using component, you can install it with:

$ component install lepture/editor

Seajs

If you are using seajs, you can install it with:

$ spm install lepture/editor

Development

You can build the dist files with grunt. After this repo is cloned, dig into the repo, and install everything you need:

$ npm install
$ npm install grunt-cli -g

Now you can create the dist files:

$ grunt transport

You can get everything you need in the build directory.

Configuration

The Editor Class accepts an option as the parameter. The supported options are:

  • element (DOM)

    The element of the textarea. The default value is the first <textarea>.

  • tools (array or false)

    If set false, the editor will have no toolbar.

  • status (array or false)

    If set false, the editor will have no statusbar.

  • actions (object)

  • shortcuts (object)

Example:

new Editor({
  element: document.getElementById('editor'),
  toolbar: []
})

Contributing

Contribution is welcome. As a way to keep all code clean, we use Grunt to build our distributed files. Make sure you have read our Contributing Guide.

License

MIT. Copyright (c) 2013 - 2014 by Hsiaoming Yang