From c579641c823872574db7244df730486d359c4b2b Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Fri, 22 Sep 2023 11:53:58 +0100 Subject: [PATCH] [visual] Configure italic markup to be placed inside the pasted styled element (#14918) GitOrigin-RevId: b7038381583a6828a9ab24f6d9608c10cf3e370a --- .../extensions/visual/paste-html.ts | 1 + ...demirror-editor-visual-paste-html.spec.tsx | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts b/services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts index 3de879304f..ff2c1e8ff7 100644 --- a/services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts +++ b/services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts @@ -560,6 +560,7 @@ const selectors = [ element.style.fontStyle === 'italic' && hasContent(element), start: () => '\\textit{', end: () => '}', + inside: true, }), createSelector({ selector: 'em', diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx index bf9c32afe3..0a3896b400 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx @@ -278,6 +278,27 @@ describe(' paste HTML in Visual mode', function () { ) }) + it('handles a pasted table with cell styles', function () { + window.metaAttributesCache.set('ol-splitTestVariants', { + 'paste-html': 'enabled', + 'table-generator': 'enabled', + }) + + mountEditor() + + const data = + '
foobarbaz
' + + const clipboardData = new DataTransfer() + clipboardData.setData('text/html', data) + cy.get('@content').trigger('paste', { clipboardData }) + + cy.get('@content').should('have.text', 'foobarbaz') + cy.findByText(/Sorry/).should('not.exist') + cy.get('td b').should('have.length', 2) + cy.get('td i').should('have.length', 2) + }) + it('handles a pasted table with a caption', function () { mountEditor()