Skip to content

Commit

Permalink
fix: 粘贴pdf内容卡死
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokyo committed Apr 18, 2021
1 parent 4774675 commit f57674c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/text/paste/paste-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export function getPasteHtml(
pasteHtml = `<p>${text}</p>`
}

// 转译<1,后面跟数字的转译成 &lt;1
pasteHtml = pasteHtml.replace(/<(\d)/gm, (_, num) => '&lt;' + num)

// pdf复制只会有一个meta标签,parseHtml中的过滤meta标签会导致后面内容丢失
pasteHtml = pasteHtml.replace(/<meta.*charset=("|').*("|').*?>/gim, '')

// 剔除多余的标签、属性
pasteHtml = parseHtml(pasteHtml, filterStyle, ignoreImg)

Expand Down

0 comments on commit f57674c

Please sign in to comment.