fix: error editing post when img component has file attribute (#5434)

#### What type of PR is this?

/kind bug
/area editor
/area ui
/milestone 2.14.x

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

使用默认编辑器时,当图片、视频中具有 `file` 属性时,进入编辑界面时会报错。此 PR 将不再从渲染后的 HTML 中获取 file 属性,并且在渲染 HTML 时,抛弃掉 file 属性用于解决这个问题。

#### How to test it?

测试图片上传、视频上传功能不受影响即可。

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

Fixes #5430 

#### Does this PR introduce a user-facing change?
```release-note
修复进入文章页面会偶现错误提示的问题
```
pull/5448/head
Takagi 2024-03-05 15:20:09 +08:00 committed by GitHub
parent eef53ea81a
commit 98523b2bd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View File

@ -22,9 +22,6 @@ const Image = ExtensionImage.extend<UiImageOptions>({
addAttributes() {
return {
...this.parent?.(),
file: {
default: null,
},
width: {
default: "100%",
parseHTML: (element) => {
@ -51,6 +48,15 @@ const Image = ExtensionImage.extend<UiImageOptions>({
};
},
},
file: {
default: null,
renderHTML() {
return {};
},
parseHTML() {
return null;
},
},
};
},

View File

@ -24,6 +24,12 @@ const Video = ExtensionVideo.extend<UiVideoOptions>({
...this.parent?.(),
file: {
default: null,
renderHTML() {
return {};
},
parseHTML() {
return null;
},
},
};
},