Skip to content

Commit cf494a7

Browse files
talygurynneSpecc
andauthored
Fix i18n for tunes and tools (codex-team#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 <[email protected]>
1 parent 9e25400 commit cf494a7

File tree

9 files changed

+26
-16
lines changed

9 files changed

+26
-16
lines changed

docs/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 2.22.1
4+
5+
- `Fix` — I18n for internal Block Tunes [#1661](https://github.com/codex-team/editor.js/issues/1661)
6+
37
### 2.22.0
48

59
- `New` - `onChange` callback now receive Block API object of affected block

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@editorjs/editorjs",
3-
"version": "2.22.0",
3+
"version": "2.22.1",
44
"description": "Editor.js — Native JS, based on API and Open Source",
55
"main": "dist/editor.js",
66
"types": "./types/index.d.ts",

src/components/block-tunes/block-tune-delete.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ export default class DeleteTune implements BlockTune {
7575
/**
7676
* Enable tooltip module
7777
*/
78-
this.api.tooltip.onHover(this.nodes.button, this.api.i18n.t('Delete'));
78+
this.api.tooltip.onHover(this.nodes.button, this.api.i18n.t('Delete'), {
79+
hidingDelay: 300,
80+
});
7981

8082
return this.nodes.button;
8183
}

src/components/block-tunes/block-tune-move-down.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ export default class MoveDownTune implements BlockTune {
6363
/**
6464
* Enable tooltip module on button
6565
*/
66-
this.api.tooltip.onHover(moveDownButton, this.api.i18n.t('Move down'));
66+
this.api.tooltip.onHover(moveDownButton, this.api.i18n.t('Move down'), {
67+
hidingDelay: 300,
68+
});
6769

6870
return moveDownButton;
6971
}

src/components/block-tunes/block-tune-move-up.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export default class MoveUpTune implements BlockTune {
6262
/**
6363
* Enable tooltip module on button
6464
*/
65-
this.api.tooltip.onHover(moveUpButton, this.api.i18n.t('Move up'));
65+
this.api.tooltip.onHover(moveUpButton, this.api.i18n.t('Move up'), {
66+
hidingDelay: 300,
67+
});
6668

6769
return moveUpButton;
6870
}

src/components/modules/api/i18n.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class I18nAPI extends Module {
1414
* @param tool - tool object
1515
*/
1616
private static getNamespace(tool: ToolClass): string {
17-
if (tool.isTune) {
17+
if (tool.isTune()) {
1818
return `blockTunes.${tool.name}`;
1919
}
2020

src/components/modules/tools.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,15 @@ export default class Tools extends Module {
212212
class: Stub,
213213
isInternal: true,
214214
},
215-
moveUpTune: {
215+
moveUp: {
216216
class: MoveUpTune,
217217
isInternal: true,
218218
},
219-
deleteTune: {
219+
delete: {
220220
class: DeleteTune,
221221
isInternal: true,
222222
},
223-
moveDownTune: {
223+
moveDown: {
224224
class: MoveDownTune,
225225
isInternal: true,
226226
},

test/cypress/tests/modules/Tools.spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -208,25 +208,25 @@ describe('Tools module', () => {
208208
it('Block Tools should contain default tunes if no settings is specified', () => {
209209
const tool = module.blockTools.get('blockToolWithoutSettings');
210210

211-
expect(tool.tunes.has('deleteTune')).to.be.true;
212-
expect(tool.tunes.has('moveUpTune')).to.be.true;
213-
expect(tool.tunes.has('moveDownTune')).to.be.true;
211+
expect(tool.tunes.has('delete')).to.be.true;
212+
expect(tool.tunes.has('moveUp')).to.be.true;
213+
expect(tool.tunes.has('moveDown')).to.be.true;
214214
});
215215

216216
it('Block Tools should contain default tunes', () => {
217217
const tool = module.blockTools.get('blockTool');
218218

219-
expect(tool.tunes.has('deleteTune')).to.be.true;
220-
expect(tool.tunes.has('moveUpTune')).to.be.true;
221-
expect(tool.tunes.has('moveDownTune')).to.be.true;
219+
expect(tool.tunes.has('delete')).to.be.true;
220+
expect(tool.tunes.has('moveUp')).to.be.true;
221+
expect(tool.tunes.has('moveDown')).to.be.true;
222222
});
223223

224224
it('Block Tools should contain tunes in correct order', () => {
225225
let tool = module.blockTools.get('blockTool');
226226

227227
expect(tool.tunes.has('blockTune')).to.be.true;
228228
expect(tool.tunes.has('blockTune2')).to.be.true;
229-
expect(Array.from(tool.tunes.keys())).to.be.deep.eq(['blockTune2', 'blockTune', 'moveUpTune', 'deleteTune', 'moveDownTune']);
229+
expect(Array.from(tool.tunes.keys())).to.be.deep.eq(['blockTune2', 'blockTune', 'moveUp', 'delete', 'moveDown']);
230230

231231
tool = module.blockTools.get('withSuccessfulPrepare');
232232

0 commit comments

Comments
 (0)