* Do not start multi-block selection on UI elements (#662) * Do not start multi-block selection on UI elements * Do not prevent mousedown event on inline toolbar actions * Remove log * Add comment * Add link to issue closes #646 * Fix loss of pointer (#666) * Fix loss of pointer when click is outside of the editor but selection is inside * Remove log * Update shortcuts module (#685) * Fixed possible grammatical typo (#681) Thanks * Update shortcuts module * update changelog * update * Remove margin top for inline-link icon (#690) * Remove margin top for inline-link icon resolves #674 * Update CHANGELOG.md * Remove unused style * Pull fresh tools * Remove changelog contents from readme (#700) * #665 API to open and close inline-toolbar (#711) * API to open and close inline-toolbar * Fixed documentation * renamed inline -> inline-toolbar * removed dist * reset editor.js * added editor.js bundle * Fixed build error * Null checks on toolbar/inline@open * updated bundle * Improve some comments * Updatd api.md CHANGELOG.md * Change feature to new instead of improvement * Allow holderId work with ref on dom element (#710) * done * update types * attempt to simplify code * remove useless helper * revert holderId logic and add holder property * Apply suggestions from code review Co-Authored-By: dimensi <eddimensi@gmail.com> * update holder type on string | HTMLElement * fix typo * add deprecated notice and fix typos * fix wrong compare * fix comments * swap console.log on _.log * update types for editor config * update examples * update docs * update build * Activating Open Collective (#736) Hi, I'm making updates for Open Collective. Either you or a supporter signed this repo up for Open Collective. This pull request adds backers and sponsors from your Open Collective https://opencollective.com/editorjs❤️ It adds two badges at the top to show the latest number of backers and sponsors. It also adds placeholders so that the avatar/logo of new backers/sponsors can automatically be shown without having to update your README.md. [more info](https://github.com/opencollective/opencollective/wiki/Github-banner). See how it looks on this [repo](https://github.com/apex/apex#backers). You can also add a postinstall script to let people know after npm|yarn install that you are welcoming donations (optional). [More info](https://github.com/OpenCollective/opencollective-cli) You can also add a "Donate" button to your website and automatically show your backers and sponsors there with our widgets. Have a look here: https://opencollective.com/widgets P.S: As with any pull request, feel free to comment or suggest changes. The only thing "required" are the placeholders on the README because we believe it's important to acknowledge the people in your community that are contributing (financially or with code!). Thank you for your great contribution to the open source community. You are awesome! 🙌 And welcome to the open collective community! 😊 Come chat with us in the #opensource channel on https://slack.opencollective.com - great place to ask questions and share best practices with other open source sustainers! * Do not install editor.js as dev-dependency (#731) Resolves #730 * Move codex-notifier to dependencies for typescript declarations (#728) * Close inline toolbar after creating new link by pressing ENTER (#722) * Method to clear current selection and close inline toolbar * clearSelection with optional collapsed range * refactored selection.ts * removed experimental function * Update src/components/selection.ts Co-Authored-By: tanmayv <12tanmayvijay@gmail.com> * update version, add changelog * Link Logo Image to homepage (#738) * Update README.md (#744) * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md Co-Authored-By: neSpecc <specc.dev@gmail.com> * Config minHeight option that allows to customize bottom zone (#745) * issue-739: allow Block's editable element selection (#747) * issue-739: allow Block's input selection * little improvements * update Changelog and cache inputs * small fix * delete map file * fix inputs.count condition * Fix typo in example paragraph (#749) * Fix typo * Update example-dev.html * minor release
9.8 KiB
Version 2.0 is here!
We are glad to introduce the next version of Editor.js. Totally new core, structure and plugins — that was an impressive adventure 🤓.
Join public Telegram-chat or Gitter-channel where you can 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+ |
⭐️ If you like a project
If you like Editor.js you can support project improvements and development of new features with a small donation on Open Collective or Patreon
Documentation
Please, visit https://editorjs.io/ to view all documentation articles.
- Base concepts
- Getting started
- Configuration
- How to create a Block Tool Plugin
- How to create an Inline Tool Plugin
- API for Tools
You can join a Gitter-channel or Telegram-chat and ask a question.
Changelog
See a whole Changelog
So how to use Editor.js
Basics
Editor.js 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 a simple API for creating 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 = EditorJS({
//...
tools: {
header: {
class: Header,
shortcut: 'CMD+SHIFT+H'
},
list: {
class: List,
shortcut: 'CMD+SHIFT+L'
}
}
//...
});
Installation Guide
There are few steps to run Editor.js on your site.
Load Editor's core
Firstly you need to get Editor.js 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 @editorjs/editorjs
Include module in your application
const EditorJS = require('@editorjs/editorjs');
Use from CDN
You can load specific version of package from jsDelivr CDN.
https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest
Then require this script.
<script src="..."></script>
Save sources to project
Copy editor.js file to your project and load it.
<script src="editor.js"></script>
Load Tools
Each Block at the Editor.js 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 Editor.js'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 Editor.js and pass Configuration Object with holderId
and tools list.
<div id="editorjs"></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 editorjs
id for wrapper.
var editor = new EditorJS(); /** Zero-configuration */
// equals
var editor = new EditorJS('editorjs');
Or pass a whole settings object.
var editor = new EditorJS({
/**
* Create a holder for the Editor and pass its ID
*/
holderId : 'editorjs',
/**
* 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.save()
and handle returned Promise with saved data.
editor.save()
.then((savedData) => {
console.log(savedData);
});
Example
Take a look at the example.html to view more detailed examples.
Credits and references
- We use HTMLJanitor module in our Sanitizer module.
Support project improvements
Love Editor.js? Please consider supporting our collective:
👉 https://opencollective.com/editorjs
👉 Patreon
Contributors
This project exists thanks to all the people who contribute.
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
About team
We are CodeX and we build products for developers and makers.
Follow us on Twitter: twitter.com/codex_team
Feel free to contact: team@codex.so