mirror of
https://github.com/codex-team/editor.js
synced 2026-03-15 23:25:47 +01:00
Fix #1640
This commit is contained in:
parent
32ac52a62f
commit
97dd938bfa
2 changed files with 15 additions and 3 deletions
|
|
@ -359,18 +359,22 @@ export default class Tools extends Module {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -204,12 +204,20 @@ describe('Tools module', () => {
|
|||
expect(Array.from(module.blockTools.values()).every(tool => tool.isBlock())).to.be.true;
|
||||
});
|
||||
|
||||
it('Block Tools should contain default tunes', () => {
|
||||
let 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…
Add table
Add a link
Reference in a new issue