Skip to content

Commit

Permalink
fix: excel tables copied into editor become images (#5793)
Browse files Browse the repository at this point in the history
#### What type of PR is this?

/kind bug
/area ui
/area editor

#### What this PR does / why we need it:

在进行图片上传的前置处理中,将剪切板属性中的 `text/plain` 类型与 `text/html` 类型进行过滤,用于解决将 Excel 表格粘贴至默认编辑器时,会导致其变为了图片而不是表格。

#### How to test it?

从 Excel 中复制一个表格,在默认编辑器中使用粘贴,查看其是否成功粘贴为表格而不是图片。

#### Which issue(s) this PR fixes:

Fixes #5761 

#### Does this PR introduce a user-facing change?
```release-note
解决 Excel 表格粘贴至默认编辑器后会变为图片的问题。
```
  • Loading branch information
LIlGG authored Apr 26, 2024
1 parent 0e17d53 commit 8abae05
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ui/src/components/editor/extensions/upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const Upload = Extension.create({
return false;
}

const types = event.clipboardData.types;
if (!(types.length === 1 && types[0].toLowerCase() === "files")) {
return false;
}

const files = Array.from(event.clipboardData.files);

if (files.length) {
Expand Down

0 comments on commit 8abae05

Please sign in to comment.