Skip to content

Commit 79f8660

Browse files
gohaberegneSpecc
authored andcommitted
Version 2.13 (#719)
* 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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
1 parent ce69182 commit 79f8660

28 files changed

+303
-118
lines changed

README.md

+46-53
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<p align="center"><img src="https://capella.pics/79ce946a-d636-41cd-aa96-d3bc5ecfde03.jpg"></p>
1+
<a href="https://editorjs.io/"><p align="center"><img src="https://capella.pics/79ce946a-d636-41cd-aa96-d3bc5ecfde03.jpg"></p></a>
22

33
[![](https://flat.badgen.net/npm/v/@editorjs/editorjs?icon=npm)](https://www.npmjs.com/package/@editorjs/editorjs)
44
[![](https://flat.badgen.net/bundlephobia/min/@editorjs/editorjs?color=cyan)](https://www.npmjs.com/package/@editorjs/editorjs)
55
[![](https://flat.badgen.net/bundlephobia/minzip/@editorjs/editorjs?color=green)](https://www.npmjs.com/package/@editorjs/editorjs)
6+
[![Backers on Open Collective](https://opencollective.com/editorjs/backers/badge.svg)](#backers)
7+
[![Sponsors on Open Collective](https://opencollective.com/editorjs/sponsors/badge.svg)](#sponsors)
68
[![](https://flat.badgen.net/npm/license/@editorjs/editorjs)](https://www.npmjs.com/package/@editorjs/editorjs)
79
[![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)
810

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

21-
### 2.7-2.9 changelog
22-
23-
- `Fix` - Clear focus when click is outside the Editor instance
24-
- `Fix` — Fix CMD+A Selection on multiple Editor instances
25-
- `New` — Toolbox now have beautiful helpers with Tool names and shortcuts
26-
- `Improvements` — Prevent navigating back on Firefox when Block is removing by backspace
27-
- `New` — Blocks selected with Rectangle Selection can be also removed, copied or cut
28-
- `New` — Migrate from `postcss-cssnext` to `postcss-preset-env` and disable `postcss-custom-properties` which conflicts with `postcss-preset-env`
29-
- `New` *RectangeSelection* — Ability to select Block or several Blocks with mouse
30-
31-
### 2.2—2.7 changelog
32-
33-
- `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.
34-
- `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.
35-
- `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.
36-
- `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.
37-
- `New` *Block Tool*[Table](http://github.com/editor-js/table) constructor 💪
38-
- `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
39-
- `New` [Public TS-types](https://github.com/codex-team/editor.js/tree/master/types) are presented.
40-
- `Changes` *Tools API* — options `irreplaceable` and `contentless` was removed.
41-
- `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.
42-
- `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.
43-
- `Improvements` — All Projects code now on TypeScript
44-
- `Improvements` — NPM package size decreased from 1300kb to 422kb
45-
- `Improvements` — Bundle size decreased from 438kb to 252kb
46-
- `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.
47-
- `Improvements` — Block Settings won't be shown near empty Blocks of `initialType` by default. You should click on them instead.
48-
- `Improvements``onChange`-callback now will be fired even with children attributes changing.
49-
- `Improvements` — HTMLJanitor package was updated due to found vulnerability
50-
- `Improvements` — Logging improved: now all Editor's logs will be preceded by beautiful label with current Editor version.
51-
- `Improvements` — Internal `isEmpty` checking was improved for Blocks with many children nodes (200 and more)
52-
- `Improvements` — Paste improvements: tags that can be substituted by Tool now will matched even on deep-level of pasted DOM three.
53-
- `Improvements` — There is no more «unavailable» sound on copying Block by `CMD+C` on macOS
54-
- `Improvements` — Dozens of bugfixes and small improvements
23+
## ⭐️ If you like a project
5524

56-
See a whole [Changelog](/docs/CHANGELOG.md)
25+
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)
5726

5827
## Documentation
5928

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

62-
- [Installation](docs/installation.md)
63-
- [How to use](docs/usage.md)
64-
- [How to create a Block Tool Plugin](docs/tools.md)
65-
- [How to create an Inline Tool Plugin](docs/tools-inline.md)
66-
- [API for Tools](docs/api.md)
31+
- [Base concepts](https://editorjs.io/base-concepts)
32+
- [Getting started](https://editorjs.io/getting-started)
33+
- [Configuration](https://editorjs.io/configuration)
34+
- [How to create a Block Tool Plugin](https://editorjs.io/creating-a-block-tool)
35+
- [How to create an Inline Tool Plugin](https://editorjs.io/creating-an-inline-tool)
36+
- [API for Tools](https://editorjs.io/tools-api)
6737

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

7040
---
7141

42+
## Changelog
43+
44+
See a whole [Changelog](/docs/CHANGELOG.md)
45+
7246
# So how to use Editor.js
7347

7448
## Basics
7549

7650
Editor.js is a Block-Styled editor. Blocks are structural units, of which the Entry is composed.
7751
For example, `Paragraph`, `Heading`, `Image`, `Video`, `List` are Blocks. Each Block is represented by Plugin.
78-
We have [many](http://github.com/editor-js/) ready-to-use Plugins and a [simple API](docs/tools.md) for creating new ones.
52+
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.
7953

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

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

154128
```shell
155-
npm i @editorjs/editorjs --save-dev
129+
npm i @editorjs/editorjs
156130
```
157131

158132
Include module in your application
@@ -245,10 +219,10 @@ var editor = new EditorJS({
245219

246220
## Saving Data
247221

248-
Call `editor.saver.save()` and handle returned Promise with saved data.
222+
Call `editor.save()` and handle returned Promise with saved data.
249223

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

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

239+
# Support project improvements
240+
241+
Love Editor.js? Please consider supporting our collective:
242+
243+
👉 [https://opencollective.com/editorjs](https://opencollective.com/editorjs)
244+
245+
👉 [Patreon](https://www.patreon.com/editorjs)
246+
247+
## Contributors
248+
249+
This project exists thanks to all the people who contribute. <img src="https://opencollective.com/editorjs/contributors.svg?width=890&button=false" />
250+
251+
## Backers
252+
253+
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/editorjs#backer)]
254+
255+
<a href="https://opencollective.com/editorjs#backers" target="_blank"><img src="https://opencollective.com/editorjs/backers.svg?width=890"></a>
256+
257+
## Sponsors
258+
259+
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)]
260+
261+
<a href="https://opencollective.com/editorjs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/editorjs/sponsor/0/avatar.svg"></a>
262+
265263
# About team
266264

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

273271
[codex.so](https://codex.so)
274-
275-
# Support project improvements
276-
277-
Love Editor.js? Please consider supporting our collective:
278-
👉 [https://opencollective.com/editorjs](https://opencollective.com/editorjs)

dist/editor.js

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CHANGELOG.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
# Changelog
22

3+
### 2.13
4+
5+
- `Improvements` *BlockSelection* — Block Selection allows to select single editable element via CMD+A
6+
- `New` *API* — Added [API methods](api.md) to open and close inline toolbar [#665](https://github.com/codex-team/editor.js/issues/665)
7+
- `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)
8+
- `Deprecated` *Config* - `holderId` property now is deprecated and will removed in next major release. Use `holder` instead.
9+
- `Fix` *Types* — Fixed error with `codex-notifier` package [#713](https://github.com/codex-team/editor.js/issues/713)
10+
- `Improvements` — Close inline toolbar after creating a new link.
11+
- `New` *Config* — Option `minHeight` for customizing Editor's bottom zone height added.
12+
313
### 2.12.4
414

5-
- `Improvements` CodeX.Shortcuts version updated to the v1.1 [#684](https://github.com/codex-team/editor.js/issues/684)
15+
- `Improvements` CodeX.Shortcuts version updated to the v1.1 [#684](https://github.com/codex-team/editor.js/issues/684)
616
- `Fix` — Do not start multi-block selection on Toolbox and Inline Toolbar [#646](https://github.com/codex-team/editor.js/issues/646)
717
- `Fix` — Minor fixes of caret behaviour [#663](https://github.com/codex-team/editor.js/issues/663)
818
- `Fix` — Fix inline-link icon position in Firefox [#674](https://github.com/codex-team/editor.js/issues/674)

docs/api.md

+8
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ Methods that working with Toolbar
6969

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

72+
### InlineToolbarAPI
73+
74+
Methods that works with inline toolbar
75+
76+
`open()` - opens inline toolbar, (opens for the current selection)
77+
78+
`close()` - closes inline toolbar
79+
7280
### ListenerAPI
7381

7482
Methods that allows to work with DOM listener. Useful when you forgot to remove listener. Module collects all listeners and destroys automatically

docs/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Choose the most usable method of getting Editor for you.
2121
Install the package via NPM or Yarn
2222

2323
```shell
24-
npm i @editorjs/editorjs --save-dev
24+
npm i @editorjs/editorjs
2525
```
2626

2727
Include module at your application

docs/usage.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Action | Shortcut | Restrictions
4040
Also we support shortcuts on the all type of Tools. Specify a shortcut with the Tools configuration. For example:
4141

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

6464

6565
```js
66-
var editor = EditorJS({
66+
var editor = new EditorJS({
6767
//...
6868
autofocus: true
6969
//...
7070
});
7171

7272
```
73+
74+
## Holder
75+
The `holder` property supports an id or a reference to dom element.
76+
77+
```js
78+
var editor = new EditorJS({
79+
holder: document.querySelector('.editor'),
80+
})
81+
82+
var editor2 = new EditorJS({
83+
holder: 'codex-editor' // like document.getElementById('codex-editor')
84+
})
85+
```

example/example-dev.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
/**
8888
* Wrapper of Editor
8989
*/
90-
holderId: 'editorjs',
90+
holder: 'editorjs',
9191

9292
/**
9393
* Tools list
@@ -259,7 +259,7 @@
259259
{
260260
type : 'paragraph',
261261
data : {
262-
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. 😏'
262+
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. 😏'
263263
}
264264
},
265265
{

example/example.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
/**
7979
* Wrapper of Editor
8080
*/
81-
holderId: 'editorjs',
81+
holder: 'editorjs',
8282

8383
/**
8484
* Tools list
@@ -248,7 +248,7 @@
248248
{
249249
type : 'paragraph',
250250
data : {
251-
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. 😏'
251+
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. 😏'
252252
}
253253
},
254254
{

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@editorjs/editorjs",
3-
"version": "2.12.4",
3+
"version": "2.13.0",
44
"description": "Editor.js — Native JS, based on API and Open Source",
55
"main": "dist/editor.js",
66
"types": "./types/index.d.ts",
@@ -40,7 +40,6 @@
4040
"babel-loader": "^8.0.5",
4141
"babel-plugin-add-module-exports": "^1.0.0",
4242
"babel-plugin-class-display-name": "^2.1.0",
43-
"codex-notifier": "^1.1.1",
4443
"css-loader": "^2.1.1",
4544
"cssnano": "^4.1.10",
4645
"eslint": "^5.15.1",
@@ -69,5 +68,8 @@
6968
"collective": {
7069
"type": "opencollective",
7170
"url": "https://opencollective.com/editorjs"
71+
},
72+
"dependencies": {
73+
"codex-notifier": "^1.1.2"
7274
}
7375
}

src/components/block.ts

+35-9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ export default class Block {
5959
* @returns {HTMLElement[]}
6060
*/
6161
get inputs(): HTMLElement[] {
62+
/**
63+
* Return from cache if existed
64+
*/
65+
if (this.cachedInputs.length !== 0) {
66+
return this.cachedInputs;
67+
}
68+
6269
const content = this.holder;
6370
const allowedInputTypes = ['text', 'password', 'email', 'number', 'search', 'tel', 'url'];
6471

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

95+
/**
96+
* Cache inputs
97+
*/
98+
this.cachedInputs = inputs;
99+
88100
return inputs;
89101
}
90102

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

279+
/**
280+
* Toggle drop target state
281+
* @param {boolean} state
282+
*/
283+
public set dropTarget(state) {
284+
this.holder.classList.toggle(Block.CSS.dropTarget, state);
285+
}
286+
267287
/**
268288
* Block Tool`s name
269289
*/
@@ -294,6 +314,12 @@ export default class Block {
294314
*/
295315
public tunes: BlockTune[];
296316

317+
/**
318+
* Cached inputs
319+
* @type {HTMLElement[]}
320+
*/
321+
private cachedInputs: HTMLElement[] = [];
322+
297323
/**
298324
* Editor`s API
299325
*/
@@ -445,14 +471,6 @@ export default class Block {
445471
return tunesElement;
446472
}
447473

448-
/**
449-
* Toggle drop target state
450-
* @param {boolean} state
451-
*/
452-
public set dropTarget(state) {
453-
this.holder.classList.toggle(Block.CSS.dropTarget, state);
454-
}
455-
456474
/**
457475
* Update current input index with selection anchor node
458476
*/
@@ -480,7 +498,15 @@ export default class Block {
480498
/**
481499
* Is fired when DOM mutation has been happened
482500
*/
483-
private didMutated = () => {
501+
private didMutated = (): void => {
502+
/**
503+
* Drop cache
504+
*/
505+
this.cachedInputs = [];
506+
507+
/**
508+
* Update current input
509+
*/
484510
this.updateCurrentInput();
485511
}
486512

0 commit comments

Comments
 (0)