Project has been renamed
Since version 2.10 CodeX Editor has been renamed to Editor.js. Please, use this package.
Version 2.0-beta is here!
We are glad to introduce the next version of CodeX Editor. Totally new core, structure and plugins — that was an impressive adventure 🤓.
Welcome to testing stage. Please, join a public Telegram-chat where you always find a support.
Browsers support
IE / Edge |
Firefox |
Chrome |
Safari |
iOS Safari |
Opera |
---|---|---|---|---|---|
Edge 12+ | Firefox 18+ | Chrome 49+ | Safari 10+ | Safari 10+ | Opera 36+ |
2.7-2.9 changelog
New
— Toolbox now have beautiful helpers with Tool names and shortcutsImprovements
— Prevent navigating back on Firefox when Block is removing by backspaceNew
— Blocks selected with Rectangle Selection can be also removed, copied or cutNew
— Migrate frompostcss-cssnext
topostcss-preset-env
and disablepostcss-custom-properties
which conflicts withpostcss-preset-env
New
RectangeSelection — Ability to select Block or several Blocks with mouse
2.2—2.7 changelog
New
Sanitize API — Sanitize Config ofBlock Tools
now automatically extends by tags ofInline Tools
that is enabled by current Tool byinlineToolbar
option. You don't need more to specifya, b, mark, code
manually. This feature will be added to fields that supports inline markup.New
Block Selection — Ability to select Block byCMD+A
, and the whole Editor by doubleCMD+A
. After that, you can copy (CMD+C
), remove (Backspace
) or clear (Enter
) selected Blocks.New
Styles API — Addedbutton
class for stylization of any buttons provided by Tools with one unified style.New
Notifier API — methods for showing user notifications: on success, errors, warnings, etc.New
Block Tool — Table constructor 💪New
If one of the Tools is unavailable on Editor initialization, its Blocks will be rendered with Dummy Block, describing that user can not edit content of this Block. Dummy Blocks can be moved, removed and saved as normal Blocks. So saved data won't be lost if one of the Tools is failedNew
Public TS-types are presented.Changes
Tools API — optionsirreplaceable
andcontentless
was removed.Changes
Tools API — Paste API: tags, patterns and mime-types now should be specified by Tool'spasteConfig
static property. Custom Paste Event should be handled byonPaste(event)
that should not be static from now.Changes
Tools API — optionsdisplayInToolbox
andtoolboxIcon
was removed. Usetoolbox
instead, that should return object withicon
andtitle
field, orfalse
if Tool should not be placed at the Toolbox. Also, there are a way to overridetoolbox {icon, title}
settings provided by Tool with you own settings at the Initial Config.Improvements
— All Projects code now on TypeScriptImprovements
— NPM package size decreased from 1300kb to 422kbImprovements
— Bundle size decreased from 438kb to 252kbImprovements
—Inline Toolbar
: when you add a Link to the selected fragment, Editor will highlight this fragment even when Caret is placed into the URL-input.Improvements
— Block Settings won't be shown near empty Blocks ofinitialType
by default. You should click on them instead.Improvements
—onChange
-callback now will be fired even with children attributes changing.Improvements
— HTMLJantior package was updated due to found vulnerabilityImprovements
— Logging improved: now all Editor's logs will be preceded by beautiful label with current Editor version.Improvements
— InternalisEmpty
checking was improved for Blocks with many children nodes (200 and more)Improvements
— Paste improvements: tags that can be substituted by Tool now will matched even on deep-level of pasted DOM three.Improvements
— There is no more «unavailable» sound on copying Block byCMD+C
on macOSImprovements
— Dozens of bugfixes and small improvements
See a whole Changelog
Documentation
While we develop the new Documentation Site with all stuff, you can check some available docs at the docs/ dir.
- Installation
- How to use
- How to create a Block Tool Plugin
- How to create an Inline Tool Plugin
- API for Tools
Sorry if we missed something. You can join a Telegram-chat and ask a question.
So how to use CodeX Editor
Basics
CodeX Editor is a Block-Styled editor. Blocks are structural units, of which the Entry is composed.
For example, Paragraph
, Heading
, Image
, Video
, List
are Blocks. Each Block is represented by Plugin.
We have many ready-to-use Plugins and the simple API for creation new ones.
So how to use the Editor after Installation.
- Create new Blocks by Enter or with the Plus Button
- Press
TAB
or click on the Plus Button to view the Toolbox - Press
TAB
again to leaf Toolbox and select a Block you need. Then press Enter.
- Select text fragment and apply a style or insert a link from the Inline Toolbar
- Use «three-dots» button on the right to open Block Settings. From here, you can move and delete a Block or apply Tool's settings, if it provided. For example, set a Heading level or List style.
Shortcuts
We really appreciate shortcuts. So there are few presets.
Shortcut | Action | Restrictions |
---|---|---|
TAB |
Show/leaf a Toolbox. | On empty block |
SHIFT+TAB |
Leaf back a Toolbox. | While Toolbox is opened |
ENTER |
Create a Block | While Toolbox is opened and some Tool is selected |
CMD+B |
Bold style | On selection |
CMD+I |
Italic style | On selection |
CMD+K |
Insert a link | On selection |
Also we support shortcuts on the all type of Tools. Specify a shortcut with the Tools configuration. For example:
var editor = ;
Installation Guide
There are few steps to run CodeX Editor on your site.
Load Editor's core
Firstly you need to get CodeX Editor itself. It is a minified script with Editor's core and some default must-have tools.
Choose the most usable method of getting Editor for you.
- Node package
- Source from CDN
- Local file from project
Node.js
Install the package via NPM or Yarn
npm i codex.editor --save-dev
Include module in your application
const CodexEditor = ;
Use from CDN
You can load specific version of package from jsDelivr CDN.
https://cdn.jsdelivr.net/npm/codex.editor@2.0.0
Then require this script.
Save sources to project
Copy codex-editor.js file to your project and load it.
Load Tools
Each Block at the CodeX Editor represented by Tools. There are simple external scripts with own logic. Probably you want to use several Block Tools that should be connected.
For example check out our Header Tool that represents heading blocks.
You can install Header Tool by the same way as the Editor (Node.js, CDN, local file).
Check CodeX Editor's community to see more ready-to-use Tools.
Example: use Header from CDN
Create Editor instance
Create an instance of CodeX Editor and pass Configuration Object with holderId
and tools list.
You can create a simple Editor with only default Paragraph Tool by passing a string with element's Id (wrapper for Editor) as a configuration param. Or use the default codex-editor
id for wrapper.
var editor = ; /** Zero-configuration */ // equals var editor = 'codex-editor';
Or pass a whole settings object.
var editor = /** * Create a holder for the Editor and pass its ID */ holderId : 'codex-editor' /** * Available Tools list. * Pass Tool's class or Settings object for each Tool you want to use */ tools: header: class: Header inlineToolbar : true // ... /** * Previously saved data that should be rendered */ data: {};
Saving Data
Call editor.saver.save()
and handle returned Promise with saved data.
editorsaver ;
Example
Take a look at the example.html to view more detailed examples.
Credits and references
- We use HTMLJanitor module in our Sanitizer module.