mirror of
https://github.com/codex-team/editor.js
synced 2024-05-17 05:46:46 +02:00
b7b00fd060
* block onchange stash * improve block filtration * update tool root * chore(block): remove willSelect und willUnselect * onchange events batching * get rid of CustomEvent extension, create custom event map instead * improve types of EventsDispatcher * fix tests * custom sinon + chai matchers * improve tests, add mutex for fake cursor * add test for fake-cursor mutex * test for batch filtering * fix caret setting by enter press at the end of the block * test for detectToolRootChange * remove resolved todos * changelog added * fix tests * Update CHANGELOG.md * rename FakeCursorAboutToBeSet -> FakeCursorAboutToBeToggled * update didMutated statements * move inputs cache clearing to a separate method * rm Record inheritance from Event maps * add type alisases * rename isElementContainsFakeCursor -> isFakeCursorInsideContainer * improve code style
79 lines
2 KiB
TypeScript
79 lines
2 KiB
TypeScript
describe('Keydown', function () {
|
|
describe('enter', function () {
|
|
it('should split block and remove selected fragment if some text fragment selected', function () {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [
|
|
{
|
|
type: 'paragraph',
|
|
data: {
|
|
text: 'The block with some text',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
|
|
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.click()
|
|
.selectText('with so')
|
|
.wait(0)
|
|
.type('{enter}');
|
|
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('div.ce-block')
|
|
.then((blocks) => {
|
|
/**
|
|
* Check that there is two blocks after split
|
|
*/
|
|
expect(blocks.length).to.equal(2);
|
|
|
|
/**
|
|
* Check that selected text fragment has been removed
|
|
*/
|
|
expect(blocks[0].textContent).to.equal('The block ');
|
|
expect(blocks[1].textContent).to.equal('me text');
|
|
});
|
|
});
|
|
|
|
it('should set caret to the new block if it was created after Enter key press at very end of the block', function () {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [
|
|
{
|
|
type: 'paragraph',
|
|
data: {
|
|
text: 'The block with some text',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.click()
|
|
.type('{enter}');
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('div.ce-block')
|
|
.last()
|
|
.as('lastBlock');
|
|
|
|
cy.window()
|
|
.then((window) => {
|
|
const selection = window.getSelection();
|
|
const range = selection.getRangeAt(0);
|
|
|
|
cy.get('@lastBlock').should(($block) => {
|
|
expect($block[0].contains(range.startContainer)).to.be.true;
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|