Go to file
2018-12-04 20:27:02 +03:00
build Merge branch 'master' of https://github.com/codex-team/codex.editor into add-toolbox-titles 2018-12-04 20:02:02 +03:00
docs Add tools` titles for Toolbox 2018-11-30 19:32:08 +03:00
example Update submodules 2018-12-04 20:27:02 +03:00
src Update submodules 2018-12-04 20:27:02 +03:00
types Override toolbox settings from editor config 2018-12-04 19:59:43 +03:00
.babelrc Move to typescript (#474) 2018-11-23 19:11:50 +03:00
.editorconfig Release 2.0-beta (#387) 2018-08-05 14:51:58 +03:00
.eslintrc Move to typescript (#474) 2018-11-23 19:11:50 +03:00
.gitignore Move to typescript (#474) 2018-11-23 19:11:50 +03:00
.gitmodules Add table plugin to example (#493) 2018-11-20 21:25:09 +03:00
.jshintrc Release 2.0-beta (#387) 2018-08-05 14:51:58 +03:00
.npmignore Add .idea/ dir to npmignore (#489) 2018-11-11 01:31:57 +03:00
.postcssrc Release 2.0-beta (#387) 2018-08-05 14:51:58 +03:00
.stylelintrc Release 2.0-beta (#387) 2018-08-05 14:51:58 +03:00
CODEOWNERS Add CODEOWNERS 2017-08-30 02:16:33 +03:00
LICENSE use Apache-2.0 license (#428) 2018-08-15 19:51:18 +03:00
package.json Merge fixes (#541) 2018-11-30 21:57:30 +03:00
README.md update HTML-Janitor patch (#537) 2018-11-24 22:06:40 +03:00
tsconfig.json Paste handling improvements (#534) 2018-11-29 12:16:06 +03:00
tslint.json Paste handling improvements (#534) 2018-11-29 12:16:06 +03:00
webpack.config.js Move to typescript (#474) 2018-11-23 19:11:50 +03:00
yarn.lock Paste handling improvements (#534) 2018-11-29 12:16:06 +03:00

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.

2.1-beta changelog

  • New Tools API — support pasted content via drag-n-drop or from the Buffer. See documentation and example at the Simple Image Tool.
  • New Tools API — new sanitize getter for Tools for automatic HTML sanitizing of returned data. See documentation and example at the Paragraph Tool
  • New Added onChange-callback, fired after any modifications at the Editor. See documentation.
  • New New Inline Tool example — Marker
  • New New Inline Tool example — Code
  • New New CodeX Editor PHP — example of server-side implementation with HTML purifying and data validation.
  • Improvements - Improvements of Toolbar's position calculation.
  • Improvements — Improved zero-configuration initialization.
  • and many little improvements.

Documentation

While we develop the new Documentation Site with all stuff, you can check some available docs at the docs/ dir.

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 = CodexEditor({
  //...
  tools: {
    header: {
      class: Header,
      shortcut: 'CMD+SHIFT+H'
    },
    list: {
      class: List,
      shortcut: 'CMD+SHIFT+L'
    }
  }
  //...
 });

Installation Guide

There are few steps to run CodeX Editor on your site.

  1. Load Editor's core
  2. Load Tools
  3. Initialize Editor's instance

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 = require('codex.editor');

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.

<script src="..."></script>

Save sources to project

Copy codex-editor.js file to your project and load it.

<script src="codex-editor.js"></script>

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

<script src="https://cdn.jsdelivr.net/npm/codex.editor.header@2.0.4/dist/bundle.js"></script>

Create Editor instance

Create an instance of CodeX Editor and pass Configuration Object with holderId and tools list.

<div id="codex-editor"></div>

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 = new CodexEditor(); /** Zero-configuration */

// equals

var editor = new CodexEditor('codex-editor');

Or pass a whole settings object.

var editor = new CodexEditor({
    /**
     * 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.

editor.saver.save()
  .then((savedData) => {
    console.log(savedData);
  });

Example

Take a look at the example.html to view more detailed examples.

Credits and references