Medium.js

Taking control of content editable


This is Medium.js

Easy

Medium.js keeps HTML code within contenteditable semantic, simple, and clean. Medium.js also supports placeholders, automatic HR (or BR, or P) creation, events, hotkeys, simple & complex element injection, and more!

Compliant

Medium.js is html5 compliant and has been tested in Firefox, Chrome, Safari, Opera, & IE 9+. Browser support is constantly improving!

HTML5 Powered with Connectivity / Realtime, CSS3 / Styling, Device Access, Graphics, 3D & Effects, Multimedia, Performance & Integration, and Semantics

Inspired

This script is inspired by Medium's beautiful content editor, something we have aspired to emulate since it's inception.

Authors

This code is brought to you by jakiestfu author of Snap.js and Behave.js
and Robert Plummer author of wikiLingo and jQuery.sheet. Please share!


Features


Usage


            

Simply include the Medium.js library and CSS, and you are ready to rock. No dependencies


Semantic


            

The code within Medium.js editors are very semantic and organized, giving you peace of mind with using contenteditable.


Options


            

All options (excluding modifiers, tags, and cssClasses) may be overridden with data-medium-* attributes on the element.


Behavior

There are two behaviors available, wild and domesticated.


Methods

Methods provide functionality that can be used with buttons, toolbars, WYSIWYG editors, and the environment it is being used with.


FAQ

What is the purpose of Medium.js?

Medium.js overrides many default keyboard events and substitutes a more cross-browser compliant way to interact with contenteditable elements. This means that you can use contenteditable without fearing your user is going to enter poor or invalid HTML. It keeps things tight, organized, and semantic.

Why are there different behaviours available?

Medium.js was written to be used in many environments, of which, toolbars and WYSIWYG (what you see is what you get editors) editors are used commonly. Plus, when domesticated, you can teach contenteditable all kinds of new tricks ;).

Does this give me the cool highlighting toolbar like Medium's editor

No, it does not. If you're looking for a script that adds support for Medium's toolbar, take a look at wikiLingo, or ZenPen.io

There are weird style issues when inserting empty tags. What gives?

Empty tags do not have what is called layout, a sort of property of an element. You need to set a min-height on the paragraph element you specify.

Medium.js works in modern browsers

This is because of you. But if you find a bug, please fork Medium.js and contribute so we can continue wide support!

Who uses Medium.js


Demos

Inline


                

Partial


                

Rich


                

Rich with Insert Html


                
                

Rich with Insert Html Object (domesticated only)


                
                

Rich with Invoke Element (domesticated only)


                
                
Select me, then click the "Invoke Element" above.

Support

Need commercial support for Medium.js? Currently provided by Visual Interop Development llc., drop us a line, we can't wait to see what we can do together.

Licensing

MIT Licensing

Copyright (c) 2013 Jacob Kelley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Fork me on GitHub