yabwe /medium-editor
Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.
★ 16,098⑂ 1,802👁 346⑃ 641● 943▤ 149
+0
Daily
16,098
stars
1,802
forks
346
watchers
641
prs
943
issues
149
releases
README
!medium-editor needs help!
If you would be interested in helping to maintain one of the most successful WYSIWYG text editors on github, let us know! (See issue 1503)
MediumEditor
This is a clone of medium.com inline editor toolbar.
MediumEditor has been written using vanilla JavaScript, no additional frameworks required.
Browser Support
!Supported Browsers
Basic usage
Demo
__demo__: http://yabwe.github.io/medium-editor/
Installation
Via npm:
Run in your console: npm install medium-editor
Via bower:
bower install medium-editor
Via an external CDN
Using jsDelivr.
For the latest version:
html
For a custom one:
html
Using CDNJS.
Manual installation:
Download the latest release and attach medium editor's stylesheets to your page:
Find the files to below mentioned linking in the dist folder. (./medium-editor/dist/...)
html
Usage
The next step is to reference the editor's script
html
You can now instantiate a new MediumEditor object:
html
var editor = new MediumEditor('.editable');
The above code will transform all the elements with the .editable class into HTML5 editable contents and add the medium editor toolbar to them.
You can also pass a list of HTML elements:
javascript
var elements = document.querySelectorAll('.editable'),
editor = new MediumEditor(elements);
MediumEditor also supports textarea. If you provide a textarea element, the script will create a new div with contentEditable=true, hide the textarea and link the textarea value to the div HTML content.
Integrating with various frameworks
People have contributed wrappers around MediumEditor for integrating with different frameworks and tech stacks. Take a look at the list of existing Wrappers and Integrations that have already been written for MediumEditor!
MediumEditor Options
View the MediumEditor Options documentation on all the various options for MediumEditor.
Options to customize medium-editor are passed as the second argument to the MediumEditor constructor. Example:
js
var editor = new MediumEditor('.editor', {
// options go here
});
Core options
__activeButtonClass__: CSS class added to active buttons in the toolbar. Default: 'medium-editor-button-active'
__buttonLabels__: type of labels on the buttons. Values: false | 'fontawesome'. Default: false
NOTE:
Using 'fontawesome' as the buttonLabels requires version 4.1.0 of the fontawesome css to be on the page to ensure all icons will be displayed correctly
__delay__: time in milliseconds to show the toolbar or anchor tag preview. Default: 0
__disableReturn__: enables/disables the use of the return-key. You can also set specific element behavior by using setting a data-disable-return attribute. Default: false
__disableDoubleReturn__: allows/disallows two (or more) empty new lines. You can also set specific element behavior by using setting a data-disable-double-return attribute. Default: false
__disableExtraSpaces__: when sTop issues
#543Unwanted <span style="font-size: 18px;"><br></span> added46 comments · 2015-04-08#1503We're LOW on support! Help us get up again!!!30 comments · 2019-04-13#666Create list inside of list31 comments · 2015-06-02#70Add option for return key adding line break, and double enter adding new paragraph23 comments · 2013-10-30#523medium-editor support for font color?21 comments · 2015-03-30#34default to <p> tag20 comments · 2013-09-26#434Internal Model Representation of the Editor Content17 comments · 2015-02-18#901Issue in edit links 16 comments · 2015-12-04
Discussions
Latest release
5.23.3 5.23.3 2017-12-20:mrs_claus: Christmas release! :santa: This is a patch release with: - a bug related to Firefox - a bug if you use data-disable-preview List of changes: Fix medium-editor-insert plugin css fixes on beagle theme 1361 Update jsDelivr links 1366 & 1367 Fix Firefox console warning causing issues 1370 Do not check only for null targets or it will fail when it's undefined. 1373 Fix crash when 'extensions' in 'isElementDescendantOfExtension' is undefined 1362 Fix Jasmine Unit Test errors 1385 Fix null error on pastedPlain.split 1397 Fix broken browser tests 1396