mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 13:49:00 +02:00
Avoid adding semantic style from an element which has explicit style (#14781)
GitOrigin-RevId: ae36022a9da36be0703c7e8e04e133975fadb893
This commit is contained in:
@@ -449,8 +449,7 @@ const selectors = [
|
||||
createSelector({
|
||||
selector: 'b',
|
||||
match: element =>
|
||||
element.style.fontWeight !== 'normal' &&
|
||||
!(parseInt(element.style.fontWeight) < 700) &&
|
||||
!element.style.fontWeight &&
|
||||
!isHeading(element.parentElement) &&
|
||||
hasContent(element),
|
||||
start: () => '\\textbf{',
|
||||
@@ -468,17 +467,13 @@ const selectors = [
|
||||
}),
|
||||
createSelector({
|
||||
selector: 'strong',
|
||||
match: element =>
|
||||
element.style.fontWeight !== 'normal' &&
|
||||
!(parseInt(element.style.fontWeight) < 700) &&
|
||||
hasContent(element),
|
||||
match: element => !element.style.fontWeight && hasContent(element),
|
||||
start: () => '\\textbf{',
|
||||
end: () => '}',
|
||||
}),
|
||||
createSelector({
|
||||
selector: 'i',
|
||||
match: element =>
|
||||
element.style.fontStyle !== 'normal' && hasContent(element),
|
||||
match: element => !element.style.fontStyle && hasContent(element),
|
||||
start: () => '\\textit{',
|
||||
end: () => '}',
|
||||
}),
|
||||
@@ -491,14 +486,13 @@ const selectors = [
|
||||
}),
|
||||
createSelector({
|
||||
selector: 'em',
|
||||
match: element =>
|
||||
element.style.fontStyle !== 'normal' && hasContent(element),
|
||||
match: element => !element.style.fontStyle && hasContent(element),
|
||||
start: () => '\\textit{',
|
||||
end: () => '}',
|
||||
}),
|
||||
createSelector({
|
||||
selector: 'sup',
|
||||
match: element => hasContent(element),
|
||||
match: element => !element.style.verticalAlign && hasContent(element),
|
||||
start: () => '\\textsuperscript{',
|
||||
end: () => '}',
|
||||
}),
|
||||
@@ -511,7 +505,7 @@ const selectors = [
|
||||
}),
|
||||
createSelector({
|
||||
selector: 'sub',
|
||||
match: element => hasContent(element),
|
||||
match: element => !element.style.verticalAlign && hasContent(element),
|
||||
start: () => '\\textsubscript{',
|
||||
end: () => '}',
|
||||
}),
|
||||
|
||||
+19
@@ -479,6 +479,25 @@ describe('<CodeMirrorEditor/> paste HTML in Visual mode', function () {
|
||||
cy.get('.ol-cm-command-textit').should('have.length', 0)
|
||||
})
|
||||
|
||||
it('handles pasted elements with duplicate CSS formatting', function () {
|
||||
mountEditor()
|
||||
|
||||
const data = [
|
||||
'<strong style="font-weight:bold">foo</strong>',
|
||||
'<b style="font-weight:bold">foo</b>',
|
||||
'<em style="font-style:italic">foo</em>',
|
||||
'<i style="font-style:italic">foo</i>',
|
||||
'foo',
|
||||
].join(' ')
|
||||
|
||||
const clipboardData = new DataTransfer()
|
||||
clipboardData.setData('text/html', data)
|
||||
cy.get('@content').trigger('paste', { clipboardData })
|
||||
|
||||
cy.get('.ol-cm-command-textbf').should('have.length', 2)
|
||||
cy.get('.ol-cm-command-textit').should('have.length', 2)
|
||||
})
|
||||
|
||||
it('removes a non-breaking space when a text node contains no other content', function () {
|
||||
mountEditor()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user