Skip to content

Commit

Permalink
[Feature] i18n (codex-team#1106)
Browse files Browse the repository at this point in the history
* i18n first steps

* i18n internal, toolbox, api for tools

* namespaced api

* tn, t

* tn in block tunes

* join toolbox and inlineTools under toolNames

* translations

* make enum toolTypes

* Update block.ts

* Update src/components/core.ts

Co-Authored-By: George Berezhnoy <[email protected]>

* add more types

* rm tn

* export i18n types

* upd bundle

* fix tabulation

* Add type-safe namespaces

* upd

* Improve example

* Update toolbox.ts

* improve examplle

* upd

* fix typo

* Add comments for complex types

Co-authored-by: George Berezhnoy <[email protected]>
Co-authored-by: Georgy Berezhnoy <[email protected]>
  • Loading branch information
3 people authored Apr 20, 2020
1 parent 4c0d806 commit 21cac86
Show file tree
Hide file tree
Showing 35 changed files with 1,014 additions and 76 deletions.
2 changes: 1 addition & 1 deletion dist/editor.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions dist/editor.js.LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
* @author CodeX-Team <https://ifmo.su>
*/

/**
* Base Paragraph Block for the Editor.js.
* Represents simple paragraph
*
* @author CodeX ([email protected])
* @copyright CodeX 2018
* @license The MIT License (MIT)
*/

/*!
* Codex JavaScript Notification module
* https://github.com/codex-team/js-notifier
Expand All @@ -46,15 +55,6 @@
* @version 1.1.1
*/

/**
* Base Paragraph Block for the Editor.js.
* Represents simple paragraph
*
* @author CodeX ([email protected])
* @copyright CodeX 2018
* @license The MIT License (MIT)
*/

/*!
* CodeX.Tooltips
*
Expand Down
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

- `Improvements` - TSLint (deprecated) replaced with ESLint, old config changed to [CodeX ESLint Config](https://github.com/codex-team/eslint-config).
- `Improvements` - Fix many code-style issues, add missed annotations.
- `Improvements` - Adjusted GitHub action for ESLint.
- `Improvements` - Adjusted GitHub Action for ESLint.
- `New` *I18n API* — Ability to provide internalization for Editor.js core and tools. [#751](https://github.com/codex-team/editor.js/issues/751)

### 2.17

Expand Down
41 changes: 24 additions & 17 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Editor.js API

---
Most actual API described by [this interface](../types/api/index.d.ts).

---
📃 See official API documentation [https://editorjs.io/api](https://editorjs.io/api)

---

Blocks have access to the public methods provided by Editor.js API Module. Plugin and Tune Developers
can use Editor\`s API as they want.
Expand Down Expand Up @@ -42,7 +49,7 @@ use 'move' instead)

`stretchBlock(index: number, status: boolean)` - make Block stretched

`insertNewBlock()` - __Deprecated__ insert new Block after working place
`insertNewBlock()` - __Deprecated__ insert new Block after working place

`insert(type?: string, data?: BlockToolData, config?: ToolConfig, index?: number, needToFocus?: boolean)` - insert new Block with passed parameters

Expand Down Expand Up @@ -100,11 +107,11 @@ Each method accept `position` and `offset` parameters. `Offset` should be used t

`Position` can be one of the following values:

| Value | Description
| --------- | -----------
| Value | Description
| --------- | -----------
| `start` | Caret will be set at the Block's beginning
| `end` | Caret will be set at the Block end
| `default` | More or less emulates browser behaviour, in most cases behaves as `start`
| `default` | More or less emulates browser behaviour, in most cases behaves as `start`

Each method returns `boolean` value: true if caret is set successfully or false otherwise (e.g. when there is no Block at index);

Expand Down Expand Up @@ -148,7 +155,7 @@ this.api.notifier.show({
![](https://capella.pics/14fcdbe4-d6eb-41d4-b66e-e0e86ccf1a4b.jpg)


Check out [`codex-notifier` package page](https://github.com/codex-team/js-notifier) on GitHub to find docs, params and examples.
Check out [`codex-notifier` package page](https://github.com/codex-team/js-notifier) on GitHub to find docs, params and examples.

### Destroy API

Expand All @@ -173,28 +180,28 @@ Methods for showing Tooltip helper near your elements. Parameters are the same a
#### Show

Method shows tooltip with custom content on passed element

```js
this.api.tooltip.show(element, content, options);
```
```

| parameter | type | description |
| -- | -- | -- |
| `element` | _HTMLElement_ | Tooltip will be showed near this element |
| `content` | _String_ or _Node_ | Content that will be appended to the Tooltip |
| `options` | _Object_ | Some displaying options, see below |

Available showing options
Available showing options

| name | type | action |
| -- | -- | -- |
| placement | `top`, `bottom`, `left`, `right` | Where to place the tooltip. Default value is `bottom' |
| marginTop | _Number_ | Offset above the tooltip with `top` placement |
| marginBottom | _Number_ | Offset below the tooltip with `bottom` placement |
| marginLeft | _Number_ | Offset at left from the tooltip with `left` placement |
| marginRight | _Number_ | Offset at right from the tooltip with `right` placement |
| delay | _Number_ | Delay before showing, in ms. Default is `70` |
| hidingDelay | _Number_ | Delay before hiding, in ms. Default is `0` |
| placement | `top`, `bottom`, `left`, `right` | Where to place the tooltip. Default value is `bottom' |
| marginTop | _Number_ | Offset above the tooltip with `top` placement |
| marginBottom | _Number_ | Offset below the tooltip with `bottom` placement |
| marginLeft | _Number_ | Offset at left from the tooltip with `left` placement |
| marginRight | _Number_ | Offset at right from the tooltip with `right` placement |
| delay | _Number_ | Delay before showing, in ms. Default is `70` |
| hidingDelay | _Number_ | Delay before hiding, in ms. Default is `0` |

#### Hide

Expand All @@ -206,15 +213,15 @@ this.api.tooltip.hide();

#### onHover

Decorator for showing tooltip near some element by "mouseenter" and hide by "mouseleave".
Decorator for showing tooltip near some element by "mouseenter" and hide by "mouseleave".

```js
this.api.tooltip.onHover(element, content, options);
```

### API Shorthands

Editor`s API provides some shorthands for API methods.
Editor`s API provides some shorthands for API methods.

| Alias | Method |
| ------ | --------------- |
Expand Down
3 changes: 2 additions & 1 deletion example/example-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@
},
onChange: function() {
console.log('something changed');
}
},
});


/**
* Saving example
*/
Expand Down
Loading

0 comments on commit 21cac86

Please sign in to comment.