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:
Lucas.Xu
2026-01-27 12:50:56 +08:00
parent 7f18620b49
commit 48df2f6d61
3 changed files with 6 additions and 0 deletions

View File

@@ -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');

View File

@@ -77,6 +77,7 @@ function VideoRender({
<ReactPlayer {...playerProps} onError={() => {
if(onError) {
const message = getVideoErrorMessage(url || '');
onError(message);
}
}}

View File

@@ -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';
}