Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.13 #719

Merged
merged 21 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
84689b5
Do not start multi-block selection on UI elements (#662)
gohabereg Apr 4, 2019
d2cb37f
Add link to issue
gohabereg Apr 5, 2019
7d1ce59
Merge branch 'release/2.12' of https://github.com/codex-team/codex.ed…
Apr 5, 2019
a750894
Fix loss of pointer (#666)
gohabereg Apr 5, 2019
4073724
Update shortcuts module (#685)
khaydarov Apr 6, 2019
a146c2e
Remove margin top for inline-link icon (#690)
talyguryn Apr 6, 2019
f0d9548
Pull fresh tools
talyguryn Apr 6, 2019
d5bc6fa
Remove changelog contents from readme (#700)
kabachook Apr 8, 2019
57b5a09
Merge branch 'master' of https://github.com/codex-team/codex.editor i…
gohabereg Apr 10, 2019
f554945
#665 API to open and close inline-toolbar (#711)
tanmayv Apr 11, 2019
5f71c6f
Allow holderId work with ref on dom element (#710)
dimensi Apr 15, 2019
5f0d242
Activating Open Collective (#736)
monkeywithacupcake Apr 27, 2019
800657e
Do not install editor.js as dev-dependency (#731)
davidsneighbour Apr 27, 2019
2de4318
Move codex-notifier to dependencies for typescript declarations (#728)
gohabereg Apr 27, 2019
27cbaa5
Close inline toolbar after creating new link by pressing ENTER (#722)
tanmayv Apr 27, 2019
ca58f74
Link Logo Image to homepage (#738)
goldensunliu Apr 27, 2019
3befe95
Update README.md (#744)
neSpecc Apr 27, 2019
f518a67
Config minHeight option that allows to customize bottom zone (#745)
neSpecc Apr 28, 2019
1cd6149
issue-739: allow Block's editable element selection (#747)
khaydarov Apr 28, 2019
0ab6a29
Fix typo in example paragraph (#749)
stephan281094 Apr 29, 2019
4816fb4
minor release
neSpecc Apr 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 46 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<p align="center"><img src="https://capella.pics/79ce946a-d636-41cd-aa96-d3bc5ecfde03.jpg"></p>
<a href="https://editorjs.io/"><p align="center"><img src="https://capella.pics/79ce946a-d636-41cd-aa96-d3bc5ecfde03.jpg"></p></a>

[![](https://flat.badgen.net/npm/v/@editorjs/editorjs?icon=npm)](https://www.npmjs.com/package/@editorjs/editorjs)
[![](https://flat.badgen.net/bundlephobia/min/@editorjs/editorjs?color=cyan)](https://www.npmjs.com/package/@editorjs/editorjs)
[![](https://flat.badgen.net/bundlephobia/minzip/@editorjs/editorjs?color=green)](https://www.npmjs.com/package/@editorjs/editorjs)
[![Backers on Open Collective](https://opencollective.com/editorjs/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/editorjs/sponsors/badge.svg)](#sponsors)
[![](https://flat.badgen.net/npm/license/@editorjs/editorjs)](https://www.npmjs.com/package/@editorjs/editorjs)
[![Join the chat at https://gitter.im/codex-team/editor.js](https://badges.gitter.im/codex-team/editor.js.svg)](https://gitter.im/codex-team/editor.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand All @@ -18,66 +20,38 @@ Join [public Telegram-chat](//t.me/codex_editor) or [Gitter-channel](https://git
| --------- | --------- | --------- | --------- | --------- | --------- |
| Edge 12+ | Firefox 18+ | Chrome 49+ | Safari 10+ | Safari 10+ | Opera 36+

### 2.7-2.9 changelog

- `Fix` - Clear focus when click is outside the Editor instance
- `Fix` — Fix CMD+A Selection on multiple Editor instances
- `New` — Toolbox now have beautiful helpers with Tool names and shortcuts
- `Improvements` — Prevent navigating back on Firefox when Block is removing by backspace
- `New` — Blocks selected with Rectangle Selection can be also removed, copied or cut
- `New` — Migrate from `postcss-cssnext` to `postcss-preset-env` and disable `postcss-custom-properties` which conflicts with `postcss-preset-env`
- `New` *RectangeSelection* — Ability to select Block or several Blocks with mouse

### 2.2—2.7 changelog

- `New` *Sanitize API* — [Sanitize Config](https://github.com/codex-team/editor.js/blob/master/docs/tools.md#automatic-sanitize) of `Block Tools` now automatically extends by tags of `Inline Tools` that is enabled by current Tool by `inlineToolbar` option. You don't need more to specify `a, b, mark, code` manually. This feature will be added to fields that supports inline markup.
- `New` *Block Selection* — Ability to select Block by `CMD+A`, and the whole Editor by double `CMD+A`. After that, you can copy (`CMD+C`), remove (`Backspace`) or clear (`Enter`) selected Blocks.
- `New` *[Styles API](https://github.com/codex-team/editor.js/blob/master/types/api/styles.d.ts)* — Added `button` class for stylization of any buttons provided by Tools with one unified style.
- `New` *[Notifier API](https://github.com/codex-team/editor.js/blob/master/docs/api.md#notifierapi)* — methods for showing user notifications: on success, errors, warnings, etc.
- `New` *Block Tool* — [Table](http://github.com/editor-js/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 failed
- `New` [Public TS-types](https://github.com/codex-team/editor.js/tree/master/types) are presented.
- `Changes` *Tools API* — options `irreplaceable` and `contentless` was removed.
- `Changes` *Tools API* — [Paste API](https://github.com/codex-team/editor.js/blob/master/docs/tools.md#paste-handling): tags, patterns and mime-types now should be specified by Tool's `pasteConfig` static property. Custom Paste Event should be handled by `onPaste(event)` that should not be static from now.
- `Changes` *Tools API* — options `displayInToolbox ` and `toolboxIcon` was removed. Use [`toolbox`](https://github.com/codex-team/editor.js/blob/master/docs/tools.md#internal-tool-settings) instead, that should return object with `icon` and `title` field, or `false` if Tool should not be placed at the Toolbox. Also, there are a way to override `toolbox {icon, title}` settings provided by Tool with you own settings at the Initial Config.
- `Improvements` — All Projects code now on TypeScript
- `Improvements` — NPM package size decreased from 1300kb to 422kb
- `Improvements` — Bundle size decreased from 438kb to 252kb
- `Improvements` — `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 of `initialType` by default. You should click on them instead.
- `Improvements` — `onChange`-callback now will be fired even with children attributes changing.
- `Improvements` — HTMLJanitor package was updated due to found vulnerability
- `Improvements` — Logging improved: now all Editor's logs will be preceded by beautiful label with current Editor version.
- `Improvements` — Internal `isEmpty` 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 by `CMD+C` on macOS
- `Improvements` — Dozens of bugfixes and small improvements
## ⭐️ If you like a project

See a whole [Changelog](/docs/CHANGELOG.md)
If you like Editor.js you can support project improvements and development of new features with a small donation on [Open Collective](https://opencollective.com/editorjs) or [Patreon](https://www.patreon.com/editorjs)

## Documentation

While we develop the new Documentation Site with all stuff, you can check some available docs at the [docs/](docs/) dir.
Please, visit [https://editorjs.io/](https://editorjs.io) to view all documentation articles.

- [Installation](docs/installation.md)
- [How to use](docs/usage.md)
- [How to create a Block Tool Plugin](docs/tools.md)
- [How to create an Inline Tool Plugin](docs/tools-inline.md)
- [API for Tools](docs/api.md)
- [Base concepts](https://editorjs.io/base-concepts)
- [Getting started](https://editorjs.io/getting-started)
- [Configuration](https://editorjs.io/configuration)
- [How to create a Block Tool Plugin](https://editorjs.io/creating-a-block-tool)
- [How to create an Inline Tool Plugin](https://editorjs.io/creating-an-inline-tool)
- [API for Tools](https://editorjs.io/tools-api)

Sorry if we missed something. You can join a [Telegram-chat](//t.me/codex_editor) and ask a question.
You can join a [Gitter-channel](https://gitter.im/codex-team/editor.js) or [Telegram-chat](//t.me/codex_editor) and ask a question.

---

## Changelog

See a whole [Changelog](/docs/CHANGELOG.md)

# 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](http://github.com/editor-js/) ready-to-use Plugins and a [simple API](docs/tools.md) for creating new ones.
We have [many](http://github.com/editor-js/) ready-to-use Plugins and a [simple API](https://editorjs.io/tools-api) for creating new ones.

So how to use the Editor after [Installation](docs/installation.md).
So how to use the Editor after [Installation](https://editorjs.io/getting-started).

- Create new Blocks by Enter or with the Plus Button
- Press `TAB` or click on the Plus Button to view the Toolbox
Expand Down Expand Up @@ -152,7 +126,7 @@ Choose the most usable method of getting Editor for you.
Install the package via NPM or Yarn

```shell
npm i @editorjs/editorjs --save-dev
npm i @editorjs/editorjs
```

Include module in your application
Expand Down Expand Up @@ -245,10 +219,10 @@ var editor = new EditorJS({

## Saving Data

Call `editor.saver.save()` and handle returned Promise with saved data.
Call `editor.save()` and handle returned Promise with saved data.

```javascript
editor.saver.save()
editor.save()
.then((savedData) => {
console.log(savedData);
});
Expand All @@ -262,6 +236,30 @@ Take a look at the [example.html](example/example.html) to view more detailed ex

- We use [HTMLJanitor](https://github.com/guardian/html-janitor) module in our Sanitizer module.

# Support project improvements

Love Editor.js? Please consider supporting our collective:

👉 [https://opencollective.com/editorjs](https://opencollective.com/editorjs)

👉 [Patreon](https://www.patreon.com/editorjs)

## Contributors

This project exists thanks to all the people who contribute. <img src="https://opencollective.com/editorjs/contributors.svg?width=890&button=false" />

## Backers

Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/editorjs#backer)]

<a href="https://opencollective.com/editorjs#backers" target="_blank"><img src="https://opencollective.com/editorjs/backers.svg?width=890"></a>

## Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/editorjs#sponsor)]

<a href="https://opencollective.com/editorjs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/editorjs/sponsor/0/avatar.svg"></a>

# About team

We are CodeX and we build products for developers and makers.
Expand All @@ -271,8 +269,3 @@ Follow us on Twitter: [twitter.com/codex_team](https://twitter.com/codex_team)
Feel free to contact: <a href="mailto:[email protected]?subject=Editor.js feedback">[email protected]</a>

[codex.so](https://codex.so)

# Support project improvements

Love Editor.js? Please consider supporting our collective:
👉 [https://opencollective.com/editorjs](https://opencollective.com/editorjs)
18 changes: 9 additions & 9 deletions dist/editor.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# Changelog

### 2.13

- `Improvements` *BlockSelection* — Block Selection allows to select single editable element via CMD+A
- `New` *API* — Added [API methods](api.md) to open and close inline toolbar [#665](https://github.com/codex-team/editor.js/issues/665)
- `New` *Config* - Added new property in EditorConfig `holder`, use this property for append Editor instead `holderId`. `holder` property now support reference on dom element. [#696](https://github.com/codex-team/editor.js/issues/696)
- `Deprecated` *Config* - `holderId` property now is deprecated and will removed in next major release. Use `holder` instead.
- `Fix` *Types* — Fixed error with `codex-notifier` package [#713](https://github.com/codex-team/editor.js/issues/713)
- `Improvements` — Close inline toolbar after creating a new link.
- `New` *Config* — Option `minHeight` for customizing Editor's bottom zone height added.

### 2.12.4

- `Improvements` CodeX.Shortcuts version updated to the v1.1 [#684](https://github.com/codex-team/editor.js/issues/684)
- `Improvements` CodeX.Shortcuts version updated to the v1.1 [#684](https://github.com/codex-team/editor.js/issues/684)
- `Fix` — Do not start multi-block selection on Toolbox and Inline Toolbar [#646](https://github.com/codex-team/editor.js/issues/646)
- `Fix` — Minor fixes of caret behaviour [#663](https://github.com/codex-team/editor.js/issues/663)
- `Fix` — Fix inline-link icon position in Firefox [#674](https://github.com/codex-team/editor.js/issues/674)
Expand Down
8 changes: 8 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ Methods that working with Toolbar

`close()` - closes toolbar, toolbox and blockSettings if they are opened

### InlineToolbarAPI

Methods that works with inline toolbar

`open()` - opens inline toolbar, (opens for the current selection)

`close()` - closes inline toolbar

### ListenerAPI

Methods that allows to work with DOM listener. Useful when you forgot to remove listener. Module collects all listeners and destroys automatically
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Choose the most usable method of getting Editor for you.
Install the package via NPM or Yarn

```shell
npm i @editorjs/editorjs --save-dev
npm i @editorjs/editorjs
```

Include module at your application
Expand Down
17 changes: 15 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Action | Shortcut | Restrictions
Also we support shortcuts on the all type of Tools. Specify a shortcut with the Tools configuration. For example:

```js
var editor = EditorJS({
var editor = new EditorJS({
//...
tools: {
header: {
Expand All @@ -63,10 +63,23 @@ If you want to focus Editor after page has been loaded, you can enable autofocus


```js
var editor = EditorJS({
var editor = new EditorJS({
//...
autofocus: true
//...
});

```

## Holder
The `holder` property supports an id or a reference to dom element.

```js
var editor = new EditorJS({
holder: document.querySelector('.editor'),
})

var editor2 = new EditorJS({
holder: 'codex-editor' // like document.getElementById('codex-editor')
})
```
4 changes: 2 additions & 2 deletions example/example-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
/**
* Wrapper of Editor
*/
holderId: 'editorjs',
holder: 'editorjs',

/**
* Tools list
Expand Down Expand Up @@ -259,7 +259,7 @@
{
type : 'paragraph',
data : {
text : 'We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make it\'s core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. 😏'
text : 'We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make its core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. 😏'
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
/**
* Wrapper of Editor
*/
holderId: 'editorjs',
holder: 'editorjs',

/**
* Tools list
Expand Down Expand Up @@ -248,7 +248,7 @@
{
type : 'paragraph',
data : {
text : 'We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make it\'s core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. 😏'
text : 'We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make its core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. 😏'
}
},
{
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.12.4",
"version": "2.13.0",
"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",
Expand Down Expand Up @@ -40,7 +40,6 @@
"babel-loader": "^8.0.5",
"babel-plugin-add-module-exports": "^1.0.0",
"babel-plugin-class-display-name": "^2.1.0",
"codex-notifier": "^1.1.1",
"css-loader": "^2.1.1",
"cssnano": "^4.1.10",
"eslint": "^5.15.1",
Expand Down Expand Up @@ -69,5 +68,8 @@
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/editorjs"
},
"dependencies": {
"codex-notifier": "^1.1.2"
}
}
44 changes: 35 additions & 9 deletions src/components/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export default class Block {
* @returns {HTMLElement[]}
*/
get inputs(): HTMLElement[] {
/**
* Return from cache if existed
*/
if (this.cachedInputs.length !== 0) {
return this.cachedInputs;
}

const content = this.holder;
const allowedInputTypes = ['text', 'password', 'email', 'number', 'search', 'tel', 'url'];

Expand All @@ -85,6 +92,11 @@ export default class Block {
this.inputIndex = inputs.length - 1;
}

/**
* Cache inputs
*/
this.cachedInputs = inputs;

return inputs;
}

Expand Down Expand Up @@ -264,6 +276,14 @@ export default class Block {
this.holder.classList.toggle(Block.CSS.wrapperStretched, state);
}

/**
* Toggle drop target state
* @param {boolean} state
*/
public set dropTarget(state) {
this.holder.classList.toggle(Block.CSS.dropTarget, state);
}

/**
* Block Tool`s name
*/
Expand Down Expand Up @@ -294,6 +314,12 @@ export default class Block {
*/
public tunes: BlockTune[];

/**
* Cached inputs
* @type {HTMLElement[]}
*/
private cachedInputs: HTMLElement[] = [];

/**
* Editor`s API
*/
Expand Down Expand Up @@ -445,14 +471,6 @@ export default class Block {
return tunesElement;
}

/**
* Toggle drop target state
* @param {boolean} state
*/
public set dropTarget(state) {
this.holder.classList.toggle(Block.CSS.dropTarget, state);
}

/**
* Update current input index with selection anchor node
*/
Expand Down Expand Up @@ -480,7 +498,15 @@ export default class Block {
/**
* Is fired when DOM mutation has been happened
*/
private didMutated = () => {
private didMutated = (): void => {
/**
* Drop cache
*/
this.cachedInputs = [];

/**
* Update current input
*/
this.updateCurrentInput();
}

Expand Down
Loading