Yoopta-Editor
Yoopta-Editor copied to clipboard
Setting custom file formats in file attachment plugin leading to wrong state entry
Describe the bug
For file attachment we are letting only .zip and .rar file fomats to be choosen. If user chose other than these, we are showing the alert. But the "file" entry should not be added to the editor state.
To Reproduce Steps to reproduce the behavior:
File.extend({
options: {
accept: '.zip,.rar',
onUpload: async (file: File) => {
if (file.size / 1048576 > 100) {
alert('file should be less than 100MB');
return;
}
const fileName = file.name.toLowerCase();
if (!(fileName.endsWith('.zip') || fileName.endsWith('.rar'))) {
alert('Unsupported file type');
return;
}
const response = await uploadToCloudinary(file, 'auto');
return { url: response.url };
},
},
}),
Expected behavior
The "file" entry should not be added in the editor state unless the chosen file format is supported.
Screenshots
https://github.com/Darginec05/Yopta-Editor/assets/24489435/4dafda88-b099-43e8-9a3f-c6ba4d5cdf30
Desktop (please complete the following information):
OS: Windows 11 22621.1702 Browsers: Chrome 113.0.5672.93 Firefox 118.0.1 (64-bit)
Version : "@yoopta/action-menu-list": "^1.9.16-rc", "@yoopta/blockquote": "^1.9.18-rc", "@yoopta/callout": "^1.9.15-rc", "@yoopta/chat-gpt-assistant": "^1.9.16-rc", "@yoopta/code": "^1.9.15-rc", "@yoopta/editor": "^1.9.26-rc", "@yoopta/embed": "^1.9.18-rc", "@yoopta/exports": "^1.9.17-rc", "@yoopta/file": "^1.0.3-rc", "@yoopta/headings": "^1.9.15-rc", "@yoopta/image": "^1.9.15-rc", "@yoopta/link": "^1.9.15-rc", "@yoopta/link-tool": "^1.9.9-rc", "@yoopta/lists": "^1.9.15-rc", "@yoopta/marks": "^1.9.15-rc", "@yoopta/paragraph": "^1.9.17-rc", "@yoopta/renderer": "^1.9.17-rc", "@yoopta/toolbar": "^1.9.15-rc", "@yoopta/video": "^1.9.17-rc",