CC editor is a simple small extensible mobile-friendly WYSIWYG text editor for web, with no dependencies
Live demo: https://jaredreich.com/pell
Features
- Pure JavaScript, no dependencies, written in ES6
Included actions:
- Bold
- Italic
- Underline
- Strike-through
- Heading 1
- Heading 2
- Paragraph
- Quote
- Ordered List
- Unordered List
- Code
- Horizontal Rule
- Link
- Image
Other available actions (listed at https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand):
- Justify Center
- Justify Full
- Justify Left
- Justify Right
- Subscript
- Superscript
- Font Name
- Font Size
- Indent
- Outdent
- Clear Formatting
- Undo
- Redo
Or create any custom action!
Browser Support
- IE 9+
- Chrome 5+
- Firefox 4+
- Safari 5+
- Opera 11.6+
Installation
npm:
npm install --save cceditor
Usage
API
// Initialize CCEditor on an HTMLElement // <HTMLElement>, required element: document // <Function>, optional 默认为 // (html) => console.log(html) console // <Array[string | Object]>, string if overwriting, object if customizing/creating // action.name<string> (only required if overwriting) // action.icon<string> (optional if overwriting, required if custom action) // action.title<string> (optional) // action.result<Function> (required) // Specify the actions you specifically want (in order) actions: bold: {} custom: name: 'custom' icon: 'C' title: 'Custom Action' console underline:{} // classes<Array[string]> (optional) // Choose your custom class names classesConfig: editorClass: 'CCEditor' toolsbarClass: 'cc-toolsbar' contentClass: 'cc-content'
List of overwriteable action names
- bold
- italic
- underline
- strikethrough
- heading1
- heading2
- paragraph
- quote
- orderlist
- unorderlist
- code
- line
- link
- image
Example
HTML output:
const editor = element: document { documenttextContent = html } actions: custom: name: 'custom' icon: '<b><u><i>C</i></u></b>' title: 'Custom Action' console
Example
CC Editor Demo Output:
{ var $el = document; var newCCEditor = el: $el { documentinnerHTML = html; } ;}window
Custom Styles
CSS
License
MIT