All Projects → livingdocsIO → Editable.js

livingdocsIO / Editable.js

Licence: mit
Friendly contenteditable API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Editable.js

vue-input-contenteditable
The same features you expect from `<input type="text">` but in a `contenteditable` Vue component
Stars: ✭ 19 (-87.25%)
Mutual labels:  contenteditable
Sceditor
A lightweight HTML and BBCode WYSIWYG editor
Stars: ✭ 503 (+237.58%)
Mutual labels:  contenteditable
Megadraft
Megadraft is a Rich Text editor built on top of Facebook's Draft.JS featuring a nice default base of components and extensibility
Stars: ✭ 982 (+559.06%)
Mutual labels:  contenteditable
ng-stack
This Angular library contains several projects: forms, api-mock, contenteditable.
Stars: ✭ 132 (-11.41%)
Mutual labels:  contenteditable
Slate Plugins
🔌 Next-gen slate plugins
Stars: ✭ 399 (+167.79%)
Mutual labels:  contenteditable
Suneditor
Pure javascript based WYSIWYG html editor, with no dependencies.
Stars: ✭ 557 (+273.83%)
Mutual labels:  contenteditable
vanilla-caret-js
Set and get Caret position (contenteditable or TextArea) using Vanilla JavaScript
Stars: ✭ 31 (-79.19%)
Mutual labels:  contenteditable
Awesome Wysiwyg
A curated list of awesome WYSIWYG editors.
Stars: ✭ 1,801 (+1108.72%)
Mutual labels:  contenteditable
Ckeditor5
Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
Stars: ✭ 5,406 (+3528.19%)
Mutual labels:  contenteditable
Angular Contenteditable Accessor
This accessor allows you to use Angular forms with contenteditable elements with ease. It has zero dependencies, other than Angular itself as peer and works with Angular 4+ in all modern browsers, including Internet Explorer 11
Stars: ✭ 34 (-77.18%)
Mutual labels:  contenteditable
misbehave
Add IDE-like text entry to HTML contenteditable tags
Stars: ✭ 34 (-77.18%)
Mutual labels:  contenteditable
ng-contenteditable
ng-contenteditable
Stars: ✭ 41 (-72.48%)
Mutual labels:  contenteditable
Ckeditor4
The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.
Stars: ✭ 5,502 (+3592.62%)
Mutual labels:  contenteditable
ed
Text editing with media widgets
Stars: ✭ 56 (-62.42%)
Mutual labels:  contenteditable
React Sane Contenteditable
React component with sane defaults to make any element contentEditable
Stars: ✭ 45 (-69.8%)
Mutual labels:  contenteditable
ng-contenteditable
Angular v4+ contenteditable directive for compatibility with Angular forms
Stars: ✭ 39 (-73.83%)
Mutual labels:  contenteditable
Wysiwyg.js
wysiwyg contenteditable editor (minified+compression: 6kb)
Stars: ✭ 520 (+248.99%)
Mutual labels:  contenteditable
Notion Clone
Stars: ✭ 2,048 (+1274.5%)
Mutual labels:  contenteditable
React Contenteditable
React component for a div with editable contents
Stars: ✭ 1,057 (+609.4%)
Mutual labels:  contenteditable
Awesome Medium Editor
Medium.com WYSIWYG editor clone, with RTL support.
Stars: ✭ 12 (-91.95%)
Mutual labels:  contenteditable

editable.js

Build Status js-standard-style Dependency Status devDependency Status semantic-release

NPM

What is it about?

A JavaScript API that defines a friendly and browser-consistent content editable interface.

Editable is built for block level elements containing only phrasing content. This normally means p, h1-h6, blockquote etc. elements. This allows editable to be lean and mean since it is only concerned with formatting and not with layouting.

We made editable.js to support our vision of online document editing. Have a look at livingdocs.io.

Installation

Via npm:

npm install --save upfront-editable jquery

jQuery is a peerDependency, so you need to install it alongside editable.js. You can either require('upfront-editable') or find a prebuilt file in the npm bundle dist/editable.js. The required module will automatically pick up your jQuery, while the built version expects it as a global variable.

Plnkr Demo

You can check out a simple demo on the website. It features a formatting toolbar and the default insert, split and merge behavior that allow to add and remove content blocks like paragraphs easily.

Events Overview

  • focus
    Fired when an editable element gets focus.
  • blur
    Fired when an editable element loses focus.
  • selection
    Fired when the user selects some text inside an editable element.
  • cursor
    Fired when the cursor position changes.
  • change
    Fired when the user has made a change.
  • spellcheckUpdated
    Fired when the spellcheckService has updated the spellcheck highlights.
  • clipboard
    Fired for copy, cut and paste events.
  • insert
    Fired when the user presses ENTER at the beginning or end of an editable (For example you can insert a new paragraph after the element if this happens).
  • split
    Fired when the user presses ENTER in the middle of an element.
  • merge
    Fired when the user pressed FORWARD DELETE at the end or BACKSPACE at the beginning of an element.
  • switch
    Fired when the user pressed an ARROW KEY at the top or bottom so that you may want to set the cursor into the preceding or following element.
  • newline
    Fired when the user presses SHIFT+ENTER to insert a newline.

How to use

To make an element editable:

var editable = new Editable()
editable.add($elem)

Example for Selection Changes

In a selection event you get the editable element that triggered the event as well as a selection object. Through the selection object you can get information about the selection like coordinates or the text it contains and you can manipulate the selection.

In the following example we are going to show a toolbar on top of the selection whenever the user has selected something inside of an editable element.

editable.selection((editableElement, selection) => {
  if (!selection) return toolbar.hide()

  // get coordinates relative to the document (suited for absolutely positioned elements)
  const coords = selection.getCoordinates()

  // position toolbar
  const top = coords.top - toolbar.outerHeight()
  const left = coords.left + (coords.width / 2) - (toolbar.outerWidth() / 2)
  toolbar.css({top, left}).show()
})

Dive Deeper

We haven't got around to make this documentation comprehensive enough. In the meantime you can find the API methods in src/core.js and the default implementation in src/default-behavior.js.

To find out what you can do with the the editable.js cursor and selection objects see src/cursor.js and src/selection.js.

Development

Setup:

# install node dependencies
npm install

Tasks:

# livereload server with demo app
npm start

# run tests with karma on Headless Chrome
npm run test:karma

# run tests with karma on Headless Chrome and rerun on changes
npm run test:watch

# run tests in Chrome, Firefox and Safari
npm run test:karma:all

# javascript linting (configuration in .eslintrc)
npm run lint

# run tests and build editable.js
npm run build

License

editable.js is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].