Fix i18n for tunes and tools (#1711)

* we need to call isTune param to get result

* remove Tune from exported name

* Update CHANGELOG.md

* Bump version

* Update Tools.spec.ts

* Update Tools.spec.ts

* prevent tooltip jumping

* Update CHANGELOG.md

* Delete table

* Create table

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
This commit is contained in:
Taly 2021-06-28 13:06:35 +03:00 committed by GitHub
parent 9e25400bf8
commit cf494a7a28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 16 deletions

View file

@ -1,5 +1,9 @@
# Changelog
### 2.22.1
- `Fix` — I18n for internal Block Tunes [#1661](https://github.com/codex-team/editor.js/issues/1661)
### 2.22.0
- `New` - `onChange` callback now receive Block API object of affected block

@ -1 +1 @@
Subproject commit 5c1a73a8022c18ac1c15ee8d0134caae029bfbe9
Subproject commit b8944944e3c159db367dea7d79c30d68f31e76b4

View file

@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.22.0",
"version": "2.22.1",
"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",

View file

@ -75,7 +75,9 @@ export default class DeleteTune implements BlockTune {
/**
* Enable tooltip module
*/
this.api.tooltip.onHover(this.nodes.button, this.api.i18n.t('Delete'));
this.api.tooltip.onHover(this.nodes.button, this.api.i18n.t('Delete'), {
hidingDelay: 300,
});
return this.nodes.button;
}

View file

@ -63,7 +63,9 @@ export default class MoveDownTune implements BlockTune {
/**
* Enable tooltip module on button
*/
this.api.tooltip.onHover(moveDownButton, this.api.i18n.t('Move down'));
this.api.tooltip.onHover(moveDownButton, this.api.i18n.t('Move down'), {
hidingDelay: 300,
});
return moveDownButton;
}

View file

@ -62,7 +62,9 @@ export default class MoveUpTune implements BlockTune {
/**
* Enable tooltip module on button
*/
this.api.tooltip.onHover(moveUpButton, this.api.i18n.t('Move up'));
this.api.tooltip.onHover(moveUpButton, this.api.i18n.t('Move up'), {
hidingDelay: 300,
});
return moveUpButton;
}

View file

@ -14,7 +14,7 @@ export default class I18nAPI extends Module {
* @param tool - tool object
*/
private static getNamespace(tool: ToolClass): string {
if (tool.isTune) {
if (tool.isTune()) {
return `blockTunes.${tool.name}`;
}

View file

@ -212,15 +212,15 @@ export default class Tools extends Module {
class: Stub,
isInternal: true,
},
moveUpTune: {
moveUp: {
class: MoveUpTune,
isInternal: true,
},
deleteTune: {
delete: {
class: DeleteTune,
isInternal: true,
},
moveDownTune: {
moveDown: {
class: MoveDownTune,
isInternal: true,
},

View file

@ -208,17 +208,17 @@ describe('Tools module', () => {
it('Block Tools should contain default tunes if no settings is specified', () => {
const tool = module.blockTools.get('blockToolWithoutSettings');
expect(tool.tunes.has('deleteTune')).to.be.true;
expect(tool.tunes.has('moveUpTune')).to.be.true;
expect(tool.tunes.has('moveDownTune')).to.be.true;
expect(tool.tunes.has('delete')).to.be.true;
expect(tool.tunes.has('moveUp')).to.be.true;
expect(tool.tunes.has('moveDown')).to.be.true;
});
it('Block Tools should contain default tunes', () => {
const tool = module.blockTools.get('blockTool');
expect(tool.tunes.has('deleteTune')).to.be.true;
expect(tool.tunes.has('moveUpTune')).to.be.true;
expect(tool.tunes.has('moveDownTune')).to.be.true;
expect(tool.tunes.has('delete')).to.be.true;
expect(tool.tunes.has('moveUp')).to.be.true;
expect(tool.tunes.has('moveDown')).to.be.true;
});
it('Block Tools should contain tunes in correct order', () => {
@ -226,7 +226,7 @@ describe('Tools module', () => {
expect(tool.tunes.has('blockTune')).to.be.true;
expect(tool.tunes.has('blockTune2')).to.be.true;
expect(Array.from(tool.tunes.keys())).to.be.deep.eq(['blockTune2', 'blockTune', 'moveUpTune', 'deleteTune', 'moveDownTune']);
expect(Array.from(tool.tunes.keys())).to.be.deep.eq(['blockTune2', 'blockTune', 'moveUp', 'delete', 'moveDown']);
tool = module.blockTools.get('withSuccessfulPrepare');