Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Block Tunes API #1596

Merged
merged 29 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
24dc069
Add internal wrappers for tools classes
gohabereg Mar 14, 2021
224dd3b
FIx lint
gohabereg Mar 14, 2021
83e17bb
Change tools collections to map
gohabereg Mar 15, 2021
1ffcbed
Apply some more refactoring
gohabereg Mar 15, 2021
3d743f3
Make tool instance private field
gohabereg Mar 15, 2021
e56579c
Add some docs
gohabereg Mar 15, 2021
0069a2a
Fix eslint
gohabereg Mar 15, 2021
d407e32
Basic implementation for Block Tunes
gohabereg Mar 15, 2021
a0160ef
Small fix for demo
gohabereg Mar 15, 2021
dde3bd4
Review changes
gohabereg Mar 16, 2021
28bfacf
Merge branch 'next' of github.com:codex-team/editor.js into reafctori…
gohabereg Mar 16, 2021
ca1aef3
Fix
gohabereg Mar 16, 2021
a459ab5
Merge branch 'reafctoring/tools' of github.com:codex-team/editor.js i…
gohabereg Mar 16, 2021
6ecc3ac
Add common tunes and ToolsCollection class
gohabereg Mar 17, 2021
1f9c5f1
Fixes after review
gohabereg Mar 18, 2021
c81b9a0
Merge branch 'reafctoring/tools' of github.com:codex-team/editor.js i…
gohabereg Mar 18, 2021
b8ba38c
Rename tools collections
gohabereg Mar 18, 2021
aea3158
Readonly fix
gohabereg Mar 18, 2021
82f3bfa
Merge branch 'reafctoring/tools' of github.com:codex-team/editor.js i…
gohabereg Mar 18, 2021
a3bb039
Some fixes after review
gohabereg Mar 27, 2021
41274fb
Merge branch 'next' of github.com:codex-team/editor.js into feature/b…
gohabereg Mar 31, 2021
13b64eb
Apply suggestions from code review
gohabereg Apr 2, 2021
4e9a098
Fixes after review
gohabereg Apr 2, 2021
ebc8b3f
Add docs and changelog
gohabereg Apr 2, 2021
cad9691
Update docs/block-tunes.md
gohabereg Apr 2, 2021
66feab7
Apply suggestions from code review
gohabereg Apr 2, 2021
8ce77a8
Update src/components/block/index.ts
gohabereg Apr 4, 2021
94bfd10
[Dev] Tools utils tests (#1602)
gohabereg Apr 4, 2021
5fe699c
Fix test & bump version
gohabereg Apr 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix test & bump version
  • Loading branch information
gohabereg committed Apr 4, 2021
commit 5fe699c67272aaca7349ea4719f76a5362eda2df
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.19.3",
"version": "2.20.0",
"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",
Expand Down
16 changes: 8 additions & 8 deletions test/cypress/tests/tools/BlockTool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ describe('BlockTool', () => {
});
});

context('.instance()', () => {
context('.create()', () => {
const tool = new BlockTool(options as any);
const data = { text: 'text' };
const blockAPI = {
Expand All @@ -341,37 +341,37 @@ describe('BlockTool', () => {
};

it('should return Tool instance', () => {
expect(tool.instance(data, blockAPI as any, false)).to.be.instanceOf(options.constructable);
expect(tool.create(data, blockAPI as any, false)).to.be.instanceOf(options.constructable);
});

it('should return Tool instance with passed data', () => {
const instance = tool.instance(data, blockAPI as any, false) as any;
const instance = tool.create(data, blockAPI as any, false) as any;

expect(instance.data).to.be.deep.eq(data);
});

it('should return Tool instance with passed BlockAPI object', () => {
const instance = tool.instance(data, blockAPI as any, false) as any;
const instance = tool.create(data, blockAPI as any, false) as any;

expect(instance.block).to.be.deep.eq(blockAPI);
});

it('should return Tool instance with passed readOnly flag', () => {
const instance1 = tool.instance(data, blockAPI as any, false) as any;
const instance2 = tool.instance(data, blockAPI as any, true) as any;
const instance1 = tool.create(data, blockAPI as any, false) as any;
const instance2 = tool.create(data, blockAPI as any, true) as any;

expect(instance1.readonly).to.be.eq(false);
expect(instance2.readonly).to.be.eq(true);
});

it('should return Tool instance with passed API object', () => {
const instance = tool.instance(data, blockAPI as any, false) as any;
const instance = tool.create(data, blockAPI as any, false) as any;

expect(instance.api).to.be.deep.eq(options.api.getMethodsForTool());
});

it('should return Tool instance with passed config', () => {
const instance = tool.instance(data, blockAPI as any, false) as any;
const instance = tool.create(data, blockAPI as any, false) as any;

expect(instance.config).to.be.deep.eq(options.config.config);
});
Expand Down
12 changes: 6 additions & 6 deletions test/cypress/tests/tools/BlockTune.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('BlockTune', () => {
});
});

context('.instance()', () => {
context('.create()', () => {
const tool = new BlockTune(options as any);
const data = { text: 'text' };
const blockAPI = {
Expand All @@ -148,29 +148,29 @@ describe('BlockTune', () => {
};

it('should return Tool instance', () => {
expect(tool.instance(data, blockAPI as any)).to.be.instanceOf(options.constructable);
expect(tool.create(data, blockAPI as any)).to.be.instanceOf(options.constructable);
});

it('should return Tool instance with passed data', () => {
const instance = tool.instance(data, blockAPI as any) as any;
const instance = tool.create(data, blockAPI as any) as any;

expect(instance.data).to.be.deep.eq(data);
});

it('should return Tool instance with passed BlockAPI object', () => {
const instance = tool.instance(data, blockAPI as any) as any;
const instance = tool.create(data, blockAPI as any) as any;

expect(instance.block).to.be.deep.eq(blockAPI);
});

it('should return Tool instance with passed API object', () => {
const instance = tool.instance(data, blockAPI as any) as any;
const instance = tool.create(data, blockAPI as any) as any;

expect(instance.api).to.be.deep.eq(options.api.getMethodsForTool());
});

it('should return Tool instance with passed settings', () => {
const instance = tool.instance(data, blockAPI as any) as any;
const instance = tool.create(data, blockAPI as any) as any;

expect(instance.settings).to.be.deep.eq(options.config.config);
});
Expand Down
8 changes: 4 additions & 4 deletions test/cypress/tests/tools/InlineTool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,21 @@ describe('InlineTool', () => {
});
});

context('.instance()', () => {
context('.create()', () => {
const tool = new InlineTool(options as any);

it('should return Tool instance', () => {
expect(tool.instance()).to.be.instanceOf(options.constructable);
expect(tool.create()).to.be.instanceOf(options.constructable);
});

it('should return Tool instance with passed API object', () => {
const instance = tool.instance() as any;
const instance = tool.create() as any;

expect(instance.api).to.be.deep.eq(options.api.getMethodsForTool());
});

it('should return Tool instance with passed config', () => {
const instance = tool.instance() as any;
const instance = tool.create() as any;

expect(instance.config).to.be.deep.eq(options.config.config);
});
Expand Down