From 8276daa5ca48ef98afe6d316da77eba65be1c1bc Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Wed, 1 May 2024 20:59:33 +0300 Subject: [PATCH] fix changelog (#2704) --- src/components/modules/blockEvents.ts | 7 +++++++ test/cypress/tests/modules/BlockEvents/Slash.cy.ts | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/modules/blockEvents.ts b/src/components/modules/blockEvents.ts index 78f23336..f1e98336 100644 --- a/src/components/modules/blockEvents.ts +++ b/src/components/modules/blockEvents.ts @@ -249,6 +249,13 @@ export default class BlockEvents extends Module { return; } + /** + * The Toolbox will be opened with immediate focus on the Search input, + * and '/' will be added in the search input by default — we need to prevent it and add '/' manually + */ + event.preventDefault(); + this.Editor.Caret.insertContentAtCaretPosition('/'); + this.activateToolbox(); } diff --git a/test/cypress/tests/modules/BlockEvents/Slash.cy.ts b/test/cypress/tests/modules/BlockEvents/Slash.cy.ts index aca84cd1..0d9db5fc 100644 --- a/test/cypress/tests/modules/BlockEvents/Slash.cy.ts +++ b/test/cypress/tests/modules/BlockEvents/Slash.cy.ts @@ -1,6 +1,6 @@ describe('Slash keydown', function () { describe('pressed in empty block', function () { - it('should open Toolbox', () => { + it('should add "/" in a block and open Toolbox', () => { cy.createEditor({ data: { blocks: [ @@ -19,6 +19,14 @@ describe('Slash keydown', function () { .click() .type('/'); + /** + * Block content should contain slash + */ + cy.get('[data-cy=editorjs]') + .find('.ce-paragraph') + .invoke('text') + .should('eq', '/'); + cy.get('[data-cy="toolbox"] .ce-popover__container') .should('be.visible'); });