mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Improve detection of pasted Excel table in Safari (#20374)
GitOrigin-RevId: 92b9c485b57f753f4fe161e582817f72244436e1
This commit is contained in:
parent
77ad90d59a
commit
ca72351c8e
1 changed files with 16 additions and 1 deletions
|
@ -53,7 +53,11 @@ export const pasteHtml = [
|
|||
// fall back to creating a figure when there's an image on the clipoard,
|
||||
// unless the HTML indicates that it came from an Office application
|
||||
// (which also puts an image on the clipboard)
|
||||
if (clipboardData.files.length > 0 && !hasProgId(documentElement)) {
|
||||
if (
|
||||
clipboardData.files.length > 0 &&
|
||||
!hasProgId(documentElement) &&
|
||||
!isOnlyTable(documentElement)
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -135,6 +139,17 @@ const hasProgId = (documentElement: HTMLElement) => {
|
|||
return meta && meta.content.trim().length > 0
|
||||
}
|
||||
|
||||
// detect a table (probably pasted from desktop Excel)
|
||||
const isOnlyTable = (documentElement: HTMLElement) => {
|
||||
const body = documentElement.querySelector<HTMLBodyElement>('body')
|
||||
|
||||
return (
|
||||
body &&
|
||||
body.childElementCount === 1 &&
|
||||
body.firstElementChild!.nodeName === 'TABLE'
|
||||
)
|
||||
}
|
||||
|
||||
const htmlToLaTeX = (bodyElement: HTMLElement) => {
|
||||
// remove style elements
|
||||
removeUnwantedElements(bodyElement, 'style')
|
||||
|
|
Loading…
Reference in a new issue