mirror of
https://github.com/codex-team/editor.js
synced 2024-06-19 14:15:19 +02:00
parent
04749ed098
commit
2996affb0a
|
@ -2,6 +2,7 @@
|
|||
|
||||
### 2.20.2
|
||||
|
||||
- `Fix` — Append default Tunes if user tunes are provided for Block Tool [#1640](https://github.com/codex-team/editor.js/issues/1640)
|
||||
- `Fix` - Prevent the leak of codex-tooltip when Editor.js is destroyed [#1475](https://github.com/codex-team/editor.js/issues/1475).
|
||||
|
||||
### 2.20.1
|
||||
|
|
|
@ -354,23 +354,27 @@ export default class Tools extends Module {
|
|||
* @param tool — Block Tool
|
||||
*/
|
||||
private assignBlockTunesToBlockTool(tool: BlockTool): void {
|
||||
if (tool.enabledInlineTools === false) {
|
||||
if (tool.enabledBlockTunes === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(tool.enabledBlockTunes)) {
|
||||
tool.tunes = new ToolsCollection<BlockTune>(
|
||||
const userTunes = new ToolsCollection<BlockTune>(
|
||||
tool.enabledBlockTunes.map(name => [name, this.blockTunes.get(name)])
|
||||
);
|
||||
|
||||
tool.tunes = new ToolsCollection<BlockTune>([...userTunes, ...this.blockTunes.internalTools]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(this.config.tunes)) {
|
||||
tool.tunes = new ToolsCollection<BlockTune>(
|
||||
const userTunes = new ToolsCollection<BlockTune>(
|
||||
this.config.tunes.map(name => [name, this.blockTunes.get(name)])
|
||||
);
|
||||
|
||||
tool.tunes = new ToolsCollection<BlockTune>([...userTunes, ...this.blockTunes.internalTools]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ describe('Tools module', () => {
|
|||
class: class {} as any,
|
||||
inlineToolbar: true,
|
||||
},
|
||||
blockToolWithoutSettings: class {} as any,
|
||||
inlineTool: class {
|
||||
public static isInline = true
|
||||
|
||||
|
@ -204,12 +205,28 @@ describe('Tools module', () => {
|
|||
expect(Array.from(module.blockTools.values()).every(tool => tool.isBlock())).to.be.true;
|
||||
});
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
it('Block Tools should contain tunes in correct order', () => {
|
||||
let tool = module.blockTools.get('blockTool');
|
||||
|
||||
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']);
|
||||
expect(Array.from(tool.tunes.keys())).to.be.deep.eq(['blockTune2', 'blockTune', 'moveUpTune', 'deleteTune', 'moveDownTune']);
|
||||
|
||||
tool = module.blockTools.get('withSuccessfulPrepare');
|
||||
|
||||
|
|
Loading…
Reference in a new issue