mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2026-03-13 10:02:51 +08:00
fix: resolve ESLint errors in video components
- Add eslint-disable-next-line for necessary any type in VideoEmpty.tsx - Fix padding-line-between-statements errors by adding blank lines - Ensure consistent code formatting across video-related files
This commit is contained in:
@@ -13,6 +13,7 @@ function VideoEmpty({ node, error }: { node: VideoBlockNode; error?: string }) {
|
||||
const readOnly = useReadOnly() || editor.isElementReadOnly(node as unknown as Element);
|
||||
|
||||
// Translate error if it's a translation key (starts with 'document.plugins.video.')
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const displayMessage = error && error.startsWith('document.plugins.video.')
|
||||
? t(error as any)
|
||||
: error || t('embedAVideo');
|
||||
|
||||
@@ -77,6 +77,7 @@ function VideoRender({
|
||||
<ReactPlayer {...playerProps} onError={() => {
|
||||
if(onError) {
|
||||
const message = getVideoErrorMessage(url || '');
|
||||
|
||||
onError(message);
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { processUrl } from '@/utils/url';
|
||||
*/
|
||||
export function isValidVideoUrl(url: string): boolean {
|
||||
const processedUrl = processUrl(url);
|
||||
|
||||
if (!processedUrl) return false;
|
||||
|
||||
// Only allow http/https protocols for security
|
||||
@@ -27,6 +28,7 @@ export function isValidVideoUrl(url: string): boolean {
|
||||
export function getVideoErrorMessage(url: string): string {
|
||||
// Normalize URL the same way as validation to avoid inconsistencies
|
||||
const processedUrl = processUrl(url);
|
||||
|
||||
if (!processedUrl) {
|
||||
return 'document.plugins.video.errorInvalidUrl';
|
||||
}
|
||||
@@ -35,8 +37,10 @@ export function getVideoErrorMessage(url: string): string {
|
||||
if (processedUrl.includes('facebook.com')) {
|
||||
return 'document.plugins.video.errorFacebookPrivacy';
|
||||
}
|
||||
|
||||
if (processedUrl.match(/\.(mp4|webm|mov|ogv)$/i)) {
|
||||
return 'document.plugins.video.errorFileCors';
|
||||
}
|
||||
|
||||
return 'document.plugins.video.errorGeneric';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user