Go to file
Tanya 6c0555a322
[Feature] Multiple toolbox items for single tool (#2050)
* the popover component, vertical toolbox

* toolbox position improved

* popover width improved

* always show the plus button

* search field added

* search input in popover

* trying to create mobile toolbox

* FIx mobile popover fixed positioning

* Add mobile popover overlay

* Hide mobile popover on scroll

* Tmp

* feat(toolbox): popover adapted for mobile devices (#2004)

* FIx mobile popover fixed positioning

* Add mobile popover overlay

* Hide mobile popover on scroll

* Alter toolbox buttons hover

* Fix closing popover on overlay click

* Tests fix

* Fix onchange test

* restore focus after toolbox closing by ESC

* don't move toolbar by block-hover on mobile

Resolves #1972

* popover mobile styles improved

* Cleanup

* Remove scroll event listener

* Lock scroll on mobile

* don't show shortcuts in mobile popover

* Change data attr name

* Remove unused styles

* Remove unused listeners

* disable hover on mobile popover

* Scroll fix

* Lint

* Revert "Scroll fix"

This reverts commit 82deae543e.

* Return back background color for active state of toolbox buttons

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* Vertical toolbox fixes (#2017)

* Replace visibility property with display for hiding popover

* Disable arrow right and left keys for popover

* Revert "Replace visibility property with display for hiding popover"

This reverts commit af521cf6f2.

* Hide popover via setting max-height to 0 to fix animation in safari

* Remove redundant condition

* Extend element interface to avoid ts errors

* Do not subscribe to block hovered if mobile

* Add unsubscribing from overlay click event

* Rename isMobile to isMobileScreen

* Cleanup

* fix: popover opening direction (#2022)

* Change popover opening direction based on available space below it

* Update check

* Use cacheable decorator

* Update src/components/flipper.ts

Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com>

* Fixes

* Fix test

* Clear search on popover hide

* Fix popover width

* Fix for tests

* Update todos

* Linter fixes

* rm todo about beforeInsert

because I have no idea what does it mean

* i18n for search labels done

* rm methods for hiding/showing of +

* some code style update

* Update CHANGELOG.md

* make the list items a little bit compact

* fix z-index issue caused by block-appearing animation

also, improve popover padding for two reasons:

- make the popover more consistent with the Table tool popover (in future, it can be done with the same api method)
- make popover looks better

* Some progress

Use overriden config

tmp

* Cleanup

* Proceed cleanup

* Update tool-settings.d.ts

* Get rid of isToolboxItemActive

* Get rid of key

* Filter out duplicates in conversion menu

* Rename hash to id

* Change function for generating hash

* Cleanup

* Further cleanup

* [Feature] Multiple toolbox items: using of data overrides instead of config overrides (#2064)

* Use data instead of config

* check if active toolbox entry exists

* comparison improved

* eslint fix

* rename toolbox types, simplify hasTools method

* add empty line

* wrong line

* add multiple toobox note to the doc

* Update toolbox configs merge logic

* Add a test case

* Add toolbox ui tests

* Update tests

* upd doc

* Update header

* Update changelog and package.json

* Update changelog

* Update jsdoc

* Remove unused dependency

* Make BlockTool's toolbox getter always return an array

* Fix for unconfigured toolbox

* Revert "Fix for unconfigured toolbox"

This reverts commit dff1df2304.

* Change return type

* Merge data overrides with actual block data when inserting a block

* Revert "Merge data overrides with actual block data when inserting a block"

This reverts commit eb0a59cc64.

* Merge tool's data with data overrides

* Move merging block data with data overrides to insertNewBlock

* Update changelog

* Rename getDefaultBlockData to composeBlockData

* Create block data on condition

* Update types/api/blocks.d.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* Update src/components/modules/api/blocks.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com>
2022-06-17 18:31:55 +03:00
.github feat(toolbar): toolbar refactored and ui improved (#1815) 2021-11-24 21:14:24 +03:00
docs [Feature] Multiple toolbox items for single tool (#2050) 2022-06-17 18:31:55 +03:00
example chore: update the roadmap at the readme (#2043) 2022-05-01 15:52:29 +03:00
src [Feature] Multiple toolbox items for single tool (#2050) 2022-06-17 18:31:55 +03:00
test [Feature] Multiple toolbox items for single tool (#2050) 2022-06-17 18:31:55 +03:00
types [Feature] Multiple toolbox items for single tool (#2050) 2022-06-17 18:31:55 +03:00
.babelrc [Feature] Block Tunes API (#1596) 2021-04-04 15:10:26 +03:00
.editorconfig Release 2.14 (#799) 2019-06-12 20:38:16 +03:00
.eslintignore Release / 2.18 (#1181) 2020-06-03 11:17:29 +03:00
.eslintrc Fire onChange event for native inputs (#1832) 2022-01-13 16:12:08 +00:00
.gitignore [Feature] Block Tunes API (#1596) 2021-04-04 15:10:26 +03:00
.gitmodules chore(dev): update tools submodules to the last version (#2025) 2022-04-22 18:24:33 +03:00
.npmignore feat(dx): add a dev-server for debugging on mobile devices from a local network (#2009) 2022-04-05 19:49:16 +03:00
.postcssrc.yml Fix hover on the Delete Block button (#659) 2019-03-20 15:46:43 +03:00
.stylelintrc Release 2.0-beta (#387) 2018-08-05 14:51:58 +03:00
CODEOWNERS fix(#2036): scrolling issue with block hovering (#2042) 2022-05-01 15:09:16 +03:00
cypress.json [Feature] Block Tunes API (#1596) 2021-04-04 15:10:26 +03:00
devserver.js feat(dx): add a dev-server for debugging on mobile devices from a local network (#2009) 2022-04-05 19:49:16 +03:00
LICENSE Release 2.16 (#966) 2019-11-30 23:42:39 +03:00
package.json [Feature] Multiple toolbox items for single tool (#2050) 2022-06-17 18:31:55 +03:00
README.md chore: update the roadmap at the readme (#2043) 2022-05-01 15:52:29 +03:00
tsconfig.build.json Add build tsconfig for automatic deployments (#1784) 2021-09-17 15:47:29 +03:00
tsconfig.json refactoring(modules): sanitizer module is util now (#1574) 2021-04-08 21:17:23 +03:00
tslint.json Basic initialisation test for Editor.js (#1410) 2020-11-21 21:01:31 +03:00
webpack.config.js Add build tsconfig for automatic deployments (#1784) 2021-09-17 15:47:29 +03:00
yarn.lock Bump cached-path-relative from 1.0.2 to 1.1.0 (#1948) 2022-04-26 20:43:02 +03:00

Backers on Open Collective Sponsors on Open Collective Join the chat at https://gitter.im/codex-team/editor.js

IE / Edge Edge 12+ Firefox Firefox 18+ Chrome Chrome 49+ Safari Safari 10+ iOS Safari iOS Safari 10+ Opera Opera 36+

Roadmap

  • Collaborative editing

    • Implement Inline Tools JSON format In progress #1801
    • Implement Operations creation and transformations
    • Implement Tools API changes
    • Implement Server and communication
    • Update basic tools to fit the new API
  • Unified Toolbox

    • Block Tunes moved left #1815
    • Toolbox become vertical #2014
    • Ability to display several Toolbox buttons by the single Tool In progress
    • Conversion Toolbar uses Unified Toolbox
    • Block Tunes become vertical
    • Conversion Toolbar added to the Block Tunes
  • Ecosystem improvements

image

If you like a project 💗💗💗

If you like Editor.js you can support project improvements and development of new features with a donation to our collective.

👉 https://opencollective.com/editorjs

Sponsors

Support us by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

Backers

Thank you to all our backers! 🙏 [Become a backer]

Contributors

This project exists thanks to all the people who contribute.

We really welcome new contributors. If you want to make some code with us, please take a look at the Good First Tasks. You can write to us on team@codex.so or via special Telegram chat, or any other way.

Documentation

Please visit https://editorjs.io/ to view all documentation articles.

You can join a Gitter-channel or Telegram-chat and ask a question.

Changelog

See the whole Changelog

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.

How to use the Editor after Installation.

  • Create new Blocks by pressing Enter or clicking 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 a text fragment and apply a style or insert a link from the Inline Toolbar

  • Use the «three-dots» button on the right to open Block Settings. From here, you can move and delete a Block or apply a Tool's settings, if it provided. For example, you can set a Heading level or List style.

Shortcuts

A few shortcuts are preset as available.

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

Each Tool can also have its own shortcuts. These are specified in the configuration of the Tool, for example:

var editor = new 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.

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

Step 1. Load Editor's core

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
Option A. NPM install

Install the package via NPM or Yarn

npm i @editorjs/editorjs

Include module in your application

import EditorJS from '@editorjs/editorjs';
Option B. Use a CDN

You can load EditorJS directly from from jsDelivr CDN.

https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest

For example, place this in your HTML:

<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>

Or download the bundle file and use it from your server.

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

Step 2. Load the Tools that you want to make available

Each Block is represented by a Tool. Tools are simple external scripts with their own logic. For example, there is a Header Tool into which you type your heading text. If you want to be able to use this, install the Header Tool the same way as the Editor (Node.js, CDN, local file).

Example: use Header from CDN

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

Check Editor.js's community to see more ready-to-use Tools.

Step 3. 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
     */
    holder : '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

About CodeX

CodeX is a team of digital specialists around the world interested in building high-quality open source products on a global market. We are open for young people who want to constantly improve their skills and grow professionally with experiments in cutting-edge technologies.

🌐 Join 👋 Twitter Instagram
codex.so codex.so/join @codex_team @codex_team