mirror of
https://github.com/codex-team/editor.js
synced 2026-03-17 08:05:47 +01:00
* Move popover types to separate file * tmp * open top * Fix bug with keyboard navigation * Fix bug with scroll * Fix mobile * Add popover header class * Display nested items on mobile * Refactor history * Fix positioning on desktop * Fix tests * Fix child popover indent left * Fix ts errors in popover files * Move files * Rename cn to bem * Clarify comments and rename method * Refactor popover css classes * Rename cls to css * Split popover desktop and mobile classes * Add ability to open popover to the left if not enough space to open to the right * Add nested popover test * Add popover test for mobile screens * Fix tests * Add union type for both popovers * Add global window resize event * Multiple fixes * Move nodes initialization to constructor * Rename handleShowingNestedItems to showNestedItems * Replace WindowResize with EditorMobileLayoutToggled * New doze of fixes * Review fixes * Fixes * Fixes * Make each nested popover decide itself if it should open top * Update changelog * Update changelog * Update changelog
112 lines
2.4 KiB
TypeScript
112 lines
2.4 KiB
TypeScript
describe('Slash keydown', function () {
|
|
describe('pressed in empty block', function () {
|
|
it('should open Toolbox', () => {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [
|
|
{
|
|
type: 'paragraph',
|
|
data: {
|
|
text: '',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.click()
|
|
.type('/');
|
|
|
|
cy.get('[data-cy="toolbox"] .ce-popover__container')
|
|
.should('be.visible');
|
|
});
|
|
|
|
[
|
|
'ctrl',
|
|
'cmd',
|
|
].forEach((key) => {
|
|
it(`should not open Toolbox if Slash pressed with ${key}`, () => {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [
|
|
{
|
|
type: 'paragraph',
|
|
data: {
|
|
text: '',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.click()
|
|
.type(`{${key}}/`);
|
|
|
|
cy.get('[data-cy="toolbox"] .ce-popover__container')
|
|
.should('not.be.visible');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('pressed in non-empty block', function () {
|
|
it('should not open Toolbox and just add the / char', () => {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [
|
|
{
|
|
type: 'paragraph',
|
|
data: {
|
|
text: 'Hello',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.click()
|
|
.type('/');
|
|
|
|
cy.get('[data-cy="toolbox"] .ce-popover__container')
|
|
.should('not.be.visible');
|
|
|
|
/**
|
|
* Block content should contain slash
|
|
*/
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.invoke('text')
|
|
.should('eq', 'Hello/');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('CMD+Slash keydown', function () {
|
|
it('should open Block Tunes', () => {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [
|
|
{
|
|
type: 'paragraph',
|
|
data: {
|
|
text: '',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.click()
|
|
.type('{cmd}/');
|
|
|
|
cy.get('[data-cy="block-tunes"] .ce-popover__container')
|
|
.should('be.visible');
|
|
});
|
|
});
|