Skip to content

Commit

Permalink
Release 2.14 (codex-team#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
gohabereg authored Jun 12, 2019
1 parent 9e61e3d commit 23a4b2e
Show file tree
Hide file tree
Showing 33 changed files with 559 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
trim_trailing_whitespace = true
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Shortcut | Action | 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 Down Expand Up @@ -113,7 +113,7 @@ 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](build/editor.js) with Editor's core and some default must-have tools.
Firstly you need to get Editor.js itself. It is a [minified script](dist/editor.js) with Editor's core and some default must-have tools.

Choose the most usable method of getting Editor for you.

Expand Down Expand Up @@ -196,7 +196,7 @@ var editor = new EditorJS({
/**
* Create a holder for the Editor and pass its ID
*/
holderId : 'editorjs',
holder : 'editorjs',
/**
* Available Tools list.
Expand Down
18 changes: 9 additions & 9 deletions dist/editor.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog


### 2.14

- `Fix` *Config* — User config now has higher priority than internal settings [#771](https://github.com/codex-team/editor.js/issues/771)
- `New` — Ability to work with Block Actions and Inline Toolbar from the keyboard by Tab. [#705](https://github.com/codex-team/editor.js/issues/705)
- `Fix` — Fix error thrown by click on the empty editor after `blocks.clear()` method calling [#761](https://github.com/codex-team/editor.js/issues/761)
- `Fix` — Fix placeholder property appearance. Now you can assign it via `placeholder` property of EditorConfig. [#714](https://github.com/codex-team/editor.js/issues/714)
- `Fix` — Add API shorthands to TS types [#788](https://github.com/codex-team/editor.js/issues/788)

### 2.13

- `Improvements` *BlockSelection* — Block Selection allows to select single editable element via CMD+A
Expand Down
22 changes: 21 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,24 @@ var editor = new EditorJS({
var editor2 = new EditorJS({
holder: 'codex-editor' // like document.getElementById('codex-editor')
})
```
```



## Placeholder

By default Editor\`s placeholder is empty.

You can pass your own placeholder via `placeholder` field:


```js
var editor = new EditorJS({
//...
placeholder: 'My awesome placeholder'
//...
});

```

If you are using your custom `Initial Block`, `placeholder` property is passed in `config` to your Tool constructor.
2 changes: 1 addition & 1 deletion example/tools/embed
Submodule embed updated 3 files
+1 −1 dist/bundle.js
+1 −1 package.json
+19 −0 src/index.css
2 changes: 1 addition & 1 deletion example/tools/header
Submodule header updated 3 files
+2 −2 dist/bundle.js
+1 −1 package.json
+16 −0 src/index.css
2 changes: 1 addition & 1 deletion example/tools/image
2 changes: 1 addition & 1 deletion example/tools/link
Submodule link updated 3 files
+1 −321 dist/bundle.js
+1 −1 package.json
+19 −0 src/index.css
2 changes: 1 addition & 1 deletion example/tools/list
Submodule list updated from da8d69 to 019fe7
2 changes: 1 addition & 1 deletion example/tools/quote
Submodule quote updated 3 files
+1 −1 dist/bundle.js
+1 −1 package.json
+17 −0 src/index.css
2 changes: 1 addition & 1 deletion example/tools/simple-image
2 changes: 1 addition & 1 deletion example/tools/warning
Submodule warning updated 3 files
+1 −1 dist/bundle.js
+1 −1 package.json
+17 −0 src/index.css
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.13.0",
"version": "2.14.0",
"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/components/core.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from './dom';
import _ from './utils';
import {EditorConfig, OutputData, SanitizerConfig, ToolSettings} from '../../types';
import {EditorConfig, OutputData, SanitizerConfig} from '../../types';
import {EditorModules} from '../types-internal/editor-modules';

/**
Expand Down Expand Up @@ -163,7 +163,7 @@ export default class Core {
data : {},
};

this.config.placeholder = this.config.placeholder || 'write your story...';
this.config.placeholder = this.config.placeholder || false;
this.config.sanitizer = this.config.sanitizer || {
p: true,
b: true,
Expand Down
79 changes: 79 additions & 0 deletions src/components/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,85 @@ export default class Dom {
}

/**
* Leafs nodes inside the target list from active element
*
* @param {HTMLElement[]} nodeList - target list of nodes
* @param {number} activeIndex — index of active node. By default it must be -1
* @param {string} direction - leaf direction. Can be 'left' or 'right'
* @param {string} activeCSSClass - css class that will be added
*
* @return {Number} index of active node
*/
public static leafNodesAndReturnIndex(
nodeList: HTMLElement[],
activeIndex: number,
direction: string,
activeCSSClass: string,
): number {
/**
* If activeButtonIndex === -1 then we have no chosen Tool in Toolbox
*/
if (activeIndex === -1) {
/**
* Normalize "previous" Tool index depending on direction.
* We need to do this to highlight "first" Tool correctly
*
* Order of Tools: [0] [1] ... [n - 1]
* [0 = n] because of: n % n = 0 % n
*
* Direction 'right': for [0] the [n - 1] is a previous index
* [n - 1] -> [0]
*
* Direction 'left': for [n - 1] the [0] is a previous index
* [n - 1] <- [0]
*
* @type {number}
*/
activeIndex = direction === 'right' ? -1 : 0;
} else {
/**
* If we have chosen Tool then remove highlighting
*/
nodeList[activeIndex].classList.remove(activeCSSClass);
}

/**
* Count index for next Tool
*/
if (direction === 'right') {
/**
* If we go right then choose next (+1) Tool
* @type {number}
*/
activeIndex = (activeIndex + 1) % nodeList.length;
} else {
/**
* If we go left then choose previous (-1) Tool
* Before counting module we need to add length before because of "The JavaScript Modulo Bug"
* @type {number}
*/
activeIndex = (nodeList.length + activeIndex - 1) % nodeList.length;
}

if (Dom.isNativeInput(nodeList[activeIndex])) {
/**
* Focus input
*/
nodeList[activeIndex].focus();
}

/**
* Highlight new chosen Tool
*/
nodeList[activeIndex].classList.add(activeCSSClass);

/**
* Return Active index
*/
return activeIndex;
}

/*
* Helper for get holder from {string} or return HTMLElement
* @param element
*/
Expand Down
1 change: 1 addition & 0 deletions src/components/modules/api/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default class BlocksAPI extends Module {
*/
public clear(): void {
this.Editor.BlockManager.clear(true);
this.Editor.InlineToolbar.close();
}

/**
Expand Down
Loading

0 comments on commit 23a4b2e

Please sign in to comment.