From cf494a7a28d73f1b224b498fee1e78b4e88d1944 Mon Sep 17 00:00:00 2001 From: Taly Date: Mon, 28 Jun 2021 13:06:35 +0300 Subject: [PATCH] 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 --- docs/CHANGELOG.md | 4 ++++ example/tools/table | 2 +- package.json | 2 +- src/components/block-tunes/block-tune-delete.ts | 4 +++- src/components/block-tunes/block-tune-move-down.ts | 4 +++- src/components/block-tunes/block-tune-move-up.ts | 4 +++- src/components/modules/api/i18n.ts | 2 +- src/components/modules/tools.ts | 6 +++--- test/cypress/tests/modules/Tools.spec.ts | 14 +++++++------- 9 files changed, 26 insertions(+), 16 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a943a350..d1a26467 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 diff --git a/example/tools/table b/example/tools/table index 5c1a73a8..b8944944 160000 --- a/example/tools/table +++ b/example/tools/table @@ -1 +1 @@ -Subproject commit 5c1a73a8022c18ac1c15ee8d0134caae029bfbe9 +Subproject commit b8944944e3c159db367dea7d79c30d68f31e76b4 diff --git a/package.json b/package.json index d132360f..dcabe594 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/block-tunes/block-tune-delete.ts b/src/components/block-tunes/block-tune-delete.ts index b6e74333..a9b4c08a 100644 --- a/src/components/block-tunes/block-tune-delete.ts +++ b/src/components/block-tunes/block-tune-delete.ts @@ -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; } diff --git a/src/components/block-tunes/block-tune-move-down.ts b/src/components/block-tunes/block-tune-move-down.ts index f6faa7e1..3f5f4867 100644 --- a/src/components/block-tunes/block-tune-move-down.ts +++ b/src/components/block-tunes/block-tune-move-down.ts @@ -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; } diff --git a/src/components/block-tunes/block-tune-move-up.ts b/src/components/block-tunes/block-tune-move-up.ts index 4b0943b6..940d3da4 100644 --- a/src/components/block-tunes/block-tune-move-up.ts +++ b/src/components/block-tunes/block-tune-move-up.ts @@ -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; } diff --git a/src/components/modules/api/i18n.ts b/src/components/modules/api/i18n.ts index ec406802..9ecb9ceb 100644 --- a/src/components/modules/api/i18n.ts +++ b/src/components/modules/api/i18n.ts @@ -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}`; } diff --git a/src/components/modules/tools.ts b/src/components/modules/tools.ts index 29c497f2..2b4c9bcc 100644 --- a/src/components/modules/tools.ts +++ b/src/components/modules/tools.ts @@ -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, }, diff --git a/test/cypress/tests/modules/Tools.spec.ts b/test/cypress/tests/modules/Tools.spec.ts index d3c43d68..7e15a34f 100644 --- a/test/cypress/tests/modules/Tools.spec.ts +++ b/test/cypress/tests/modules/Tools.spec.ts @@ -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');