mirror of
https://github.com/codex-team/editor.js
synced 2024-05-25 01:52:26 +02:00
Merge 9ed922beb0
into bd1de56ef3
This commit is contained in:
commit
fadff782a9
|
@ -632,16 +632,18 @@ export default class UI extends Module<UINodes> {
|
|||
/**
|
||||
* Sometimes we emulate click on some UI elements, for example by Enter on Block Settings button
|
||||
* We don't need to handle such events, because they handled in other place.
|
||||
*
|
||||
* PS: Commented this out because it makes this method behave differently in tests. Cypress-generated clicks are having isTrusted == false.
|
||||
*/
|
||||
if (!event.isTrusted) {
|
||||
return;
|
||||
}
|
||||
// if (!event.isTrusted) {
|
||||
// return;
|
||||
// }
|
||||
/**
|
||||
* Close Inline Toolbar when nothing selected
|
||||
* Do not fire check on clicks at the Inline Toolbar buttons
|
||||
*/
|
||||
const target = event.target as HTMLElement;
|
||||
const clickedInsideOfEditor = this.nodes.holder.contains(target) || Selection.isAtEditor;
|
||||
const clickedInsideOfEditor = this.nodes.holder.contains(target);
|
||||
|
||||
if (!clickedInsideOfEditor) {
|
||||
/**
|
||||
|
|
|
@ -92,5 +92,58 @@ describe('Ui module', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Clicking outside', function () {
|
||||
it('should clear current block even if selection was inside the editor before clicking', function () {
|
||||
cy.createEditor({
|
||||
data: {
|
||||
blocks: [
|
||||
{
|
||||
id: 'block1',
|
||||
type: 'paragraph',
|
||||
data: {
|
||||
text: '',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}).as('editorInstance');
|
||||
|
||||
cy.get('[data-cy=editorjs]')
|
||||
.then(editor => {
|
||||
const editorsParent = editor[0].parentNode;
|
||||
const input = editorsParent.ownerDocument.createElement('div');
|
||||
|
||||
input.contentEditable = 'true';
|
||||
input.style.width = '20px';
|
||||
input.style.height = '20px';
|
||||
input.setAttribute('data-cy', 'test-input');
|
||||
|
||||
editorsParent.appendChild(input);
|
||||
});
|
||||
|
||||
/**
|
||||
* Put cursor inside the editor
|
||||
*/
|
||||
cy.get('[data-cy=editorjs]')
|
||||
.find('.ce-paragraph')
|
||||
.first()
|
||||
.click();
|
||||
|
||||
/**
|
||||
* Click outside of the editor and type '/'
|
||||
*/
|
||||
cy.get('[data-cy=test-input]')
|
||||
.click()
|
||||
.type('/');
|
||||
|
||||
/**
|
||||
* Toolbox shouldn't be open
|
||||
*/
|
||||
cy.get('[data-cy=editorjs]')
|
||||
.get('div.ce-toolbox .ce-popover')
|
||||
.should('not.be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue