honest-editor-js
Full-featured, open-source Markdown editor used at Honest.Cash. Based on StackEdit, the PageDown-Markdown library used by Stack Overflow and the other Stack Exchange sites.
DEMO: https://editor.honest.cash
Installation
# install from npmnpm install honest-editor-js
How to use?
Create a container in your HTML.
;; const honestEditor = "honest-editor"; honestEditor; honestEditor; const markdown = honestEditor;const store = honestEditor;
Image Upload Feature:
Users, through the Image modal (Ctrl+Shift+G) can upload images to your backend and insert the URL returned as a response inside their markdown.
To do this you need to specify an options object while instantiating the HonestEditor class:
;; // See below for options explanationconst options = upload: image: url: '' requireAuth: false tokenKey: '' token: '' ; const honestEditor = "honest-editor" options;
The default options object is as follows:
upload: image: url: '' // URL of your upload endpoint. For example: https://honest.cash/api/upload/image requireAuth: false // If set to false, tokenKey and token are not required. Defaults to false. tokenKey: '' // this is the pointer to your authentication header. For example: Bearer token: '' // this is your token for authentication
The response returned from your backend should be in the following format:
files: url: 'https://honest.cash/img/honest-logo-2.png'
The first object in files array will be taken into account and the URL will be inserted into the markdown.
Features:
- Real-time HTML preview with Scroll Sync feature to bind editor and preview scrollbars
- Markdown Extra/GitHub Flavored Markdown support and Prism.js syntax highlighting
- LaTeX mathematical expressions using KaTeX
- Diagrams and flowcharts using Mermaid
- WYSIWYG control buttons
- Smart layout
- Offline editing
License
Apache License Version 2.0
NOTE: This package is a fork of StackEdit.
Changes:
- wrapped stackedit into an importable module
- added subscribe and setContent methods
- removed elements for cloud saves
- added editor options
- added image upload to an API