Pārlūkot izejas kodu

[visual] Configure italic markup to be placed inside the pasted styled element (#14918)

GitOrigin-RevId: b7038381583a6828a9ab24f6d9608c10cf3e370a
Alf Eaton 3 gadi atpakaļ
vecāks
revīzija
9313a1fbd1

+ 1 - 0
services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts

@@ -560,6 +560,7 @@ const selectors = [
       element.style.fontStyle === 'italic' && hasContent(element),
       element.style.fontStyle === 'italic' && hasContent(element),
     start: () => '\\textit{',
     start: () => '\\textit{',
     end: () => '}',
     end: () => '}',
+    inside: true,
   }),
   }),
   createSelector({
   createSelector({
     selector: 'em',
     selector: 'em',

+ 21 - 0
services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx

@@ -278,6 +278,27 @@ describe('<CodeMirrorEditor/> 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 =
+      '<table><tbody><tr><td style="font-weight:bold">foo</td><td style="font-style:italic">bar</td><td style="font-style:italic;font-weight:bold">baz</td></tr></tbody></table>'
+
+    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 () {
   it('handles a pasted table with a caption', function () {
     mountEditor()
     mountEditor()