@jhits/plugin-images 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/src/api/fallback/route.ts +0 -69
- package/src/api/index.ts +0 -10
- package/src/api/list/index.ts +0 -96
- package/src/api/resolve/route.ts +0 -241
- package/src/api/router.ts +0 -85
- package/src/api/upload/index.ts +0 -88
- package/src/api/uploads/[filename]/route.ts +0 -93
- package/src/api-server.ts +0 -11
- package/src/assets/noimagefound.jpg +0 -0
- package/src/components/BackgroundImage.d.ts +0 -11
- package/src/components/BackgroundImage.d.ts.map +0 -1
- package/src/components/BackgroundImage.js +0 -35
- package/src/components/BackgroundImage.tsx +0 -92
- package/src/components/GlobalImageEditor/config.d.ts +0 -9
- package/src/components/GlobalImageEditor/config.d.ts.map +0 -1
- package/src/components/GlobalImageEditor/config.js +0 -18
- package/src/components/GlobalImageEditor/config.ts +0 -21
- package/src/components/GlobalImageEditor/eventHandlers.d.ts +0 -20
- package/src/components/GlobalImageEditor/eventHandlers.d.ts.map +0 -1
- package/src/components/GlobalImageEditor/eventHandlers.js +0 -206
- package/src/components/GlobalImageEditor/eventHandlers.ts +0 -267
- package/src/components/GlobalImageEditor/imageDetection.d.ts +0 -16
- package/src/components/GlobalImageEditor/imageDetection.d.ts.map +0 -1
- package/src/components/GlobalImageEditor/imageDetection.js +0 -130
- package/src/components/GlobalImageEditor/imageDetection.ts +0 -160
- package/src/components/GlobalImageEditor/imageSetup.d.ts +0 -9
- package/src/components/GlobalImageEditor/imageSetup.d.ts.map +0 -1
- package/src/components/GlobalImageEditor/imageSetup.js +0 -261
- package/src/components/GlobalImageEditor/imageSetup.ts +0 -306
- package/src/components/GlobalImageEditor/saveLogic.d.ts +0 -26
- package/src/components/GlobalImageEditor/saveLogic.d.ts.map +0 -1
- package/src/components/GlobalImageEditor/saveLogic.js +0 -99
- package/src/components/GlobalImageEditor/saveLogic.ts +0 -133
- package/src/components/GlobalImageEditor/stylingDetection.d.ts +0 -9
- package/src/components/GlobalImageEditor/stylingDetection.d.ts.map +0 -1
- package/src/components/GlobalImageEditor/stylingDetection.js +0 -110
- package/src/components/GlobalImageEditor/stylingDetection.ts +0 -122
- package/src/components/GlobalImageEditor/transformParsing.d.ts +0 -16
- package/src/components/GlobalImageEditor/transformParsing.d.ts.map +0 -1
- package/src/components/GlobalImageEditor/transformParsing.js +0 -68
- package/src/components/GlobalImageEditor/transformParsing.ts +0 -83
- package/src/components/GlobalImageEditor/types.d.ts +0 -36
- package/src/components/GlobalImageEditor/types.d.ts.map +0 -1
- package/src/components/GlobalImageEditor/types.js +0 -4
- package/src/components/GlobalImageEditor/types.ts +0 -39
- package/src/components/GlobalImageEditor.d.ts +0 -8
- package/src/components/GlobalImageEditor.d.ts.map +0 -1
- package/src/components/GlobalImageEditor.js +0 -227
- package/src/components/GlobalImageEditor.tsx +0 -327
- package/src/components/Image.d.ts +0 -22
- package/src/components/Image.d.ts.map +0 -1
- package/src/components/Image.js +0 -229
- package/src/components/Image.tsx +0 -343
- package/src/components/ImageBrowserModal.d.ts +0 -13
- package/src/components/ImageBrowserModal.d.ts.map +0 -1
- package/src/components/ImageBrowserModal.js +0 -504
- package/src/components/ImageBrowserModal.tsx +0 -837
- package/src/components/ImageEditor.d.ts +0 -27
- package/src/components/ImageEditor.d.ts.map +0 -1
- package/src/components/ImageEditor.js +0 -173
- package/src/components/ImageEditor.tsx +0 -323
- package/src/components/ImageEffectsPanel.tsx +0 -116
- package/src/components/ImagePicker.d.ts +0 -3
- package/src/components/ImagePicker.d.ts.map +0 -1
- package/src/components/ImagePicker.js +0 -143
- package/src/components/ImagePicker.tsx +0 -265
- package/src/components/ImagesPluginInit.d.ts +0 -24
- package/src/components/ImagesPluginInit.d.ts.map +0 -1
- package/src/components/ImagesPluginInit.js +0 -28
- package/src/components/ImagesPluginInit.tsx +0 -31
- package/src/components/index.ts +0 -10
- package/src/config.ts +0 -179
- package/src/hooks/useImagePicker.d.ts +0 -20
- package/src/hooks/useImagePicker.d.ts.map +0 -1
- package/src/hooks/useImagePicker.js +0 -322
- package/src/hooks/useImagePicker.ts +0 -344
- package/src/index.d.ts +0 -23
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -28
- package/src/index.server.ts +0 -12
- package/src/index.tsx +0 -56
- package/src/init.d.ts +0 -33
- package/src/init.d.ts.map +0 -1
- package/src/init.js +0 -43
- package/src/init.tsx +0 -58
- package/src/types/index.d.ts +0 -80
- package/src/types/index.d.ts.map +0 -1
- package/src/types/index.js +0 -4
- package/src/types/index.ts +0 -84
- package/src/utils/fallback.d.ts +0 -27
- package/src/utils/fallback.d.ts.map +0 -1
- package/src/utils/fallback.js +0 -63
- package/src/utils/fallback.ts +0 -73
- package/src/utils/transforms.d.ts +0 -26
- package/src/utils/transforms.d.ts.map +0 -1
- package/src/utils/transforms.js +0 -38
- package/src/utils/transforms.ts +0 -54
- package/src/views/ImageManager.d.ts +0 -10
- package/src/views/ImageManager.d.ts.map +0 -1
- package/src/views/ImageManager.js +0 -9
- package/src/views/ImageManager.tsx +0 -30
package/src/types/index.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Plugin Types
|
|
3
|
-
*/
|
|
4
|
-
export interface ImageMetadata {
|
|
5
|
-
/** Unique image ID */
|
|
6
|
-
id: string;
|
|
7
|
-
/** Original filename */
|
|
8
|
-
filename: string;
|
|
9
|
-
/** File path/URL */
|
|
10
|
-
url: string;
|
|
11
|
-
/** File size in bytes */
|
|
12
|
-
size: number;
|
|
13
|
-
/** MIME type */
|
|
14
|
-
mimeType: string;
|
|
15
|
-
/** Image dimensions */
|
|
16
|
-
width?: number;
|
|
17
|
-
height?: number;
|
|
18
|
-
/** Alt text */
|
|
19
|
-
alt?: string;
|
|
20
|
-
/** Upload timestamp */
|
|
21
|
-
uploadedAt: string;
|
|
22
|
-
/** Uploaded by user ID */
|
|
23
|
-
uploadedBy?: string;
|
|
24
|
-
/** Tags for searching */
|
|
25
|
-
tags?: string[];
|
|
26
|
-
}
|
|
27
|
-
export interface ImageUploadResponse {
|
|
28
|
-
success: boolean;
|
|
29
|
-
image?: ImageMetadata;
|
|
30
|
-
error?: string;
|
|
31
|
-
}
|
|
32
|
-
export interface ImageListResponse {
|
|
33
|
-
images: ImageMetadata[];
|
|
34
|
-
total: number;
|
|
35
|
-
page: number;
|
|
36
|
-
limit: number;
|
|
37
|
-
}
|
|
38
|
-
export interface ImagePickerProps {
|
|
39
|
-
/** Current selected image URL */
|
|
40
|
-
value?: string;
|
|
41
|
-
/** Callback when image is selected */
|
|
42
|
-
onChange: (image: ImageMetadata | null) => void;
|
|
43
|
-
/** Whether dark mode is enabled */
|
|
44
|
-
darkMode?: boolean;
|
|
45
|
-
/** Show brightness and blur controls */
|
|
46
|
-
showEffects?: boolean;
|
|
47
|
-
/** Current brightness value (0-200, 100 = normal) */
|
|
48
|
-
brightness?: number;
|
|
49
|
-
/** Current blur value (0-20) */
|
|
50
|
-
blur?: number;
|
|
51
|
-
/** Current scale value (0.1-3.0, 1.0 = normal) */
|
|
52
|
-
scale?: number;
|
|
53
|
-
/** Current X position offset (-100 to 100, 0 = center) */
|
|
54
|
-
positionX?: number;
|
|
55
|
-
/** Current Y position offset (-100 to 100, 0 = center) */
|
|
56
|
-
positionY?: number;
|
|
57
|
-
/** Aspect ratio for preview/editor (e.g., "4/5", "3/4", "16/9", "1/1") */
|
|
58
|
-
aspectRatio?: string;
|
|
59
|
-
/** Border radius class (e.g., "rounded-xl", "rounded-3xl") */
|
|
60
|
-
borderRadius?: string;
|
|
61
|
-
/** Object fit style (e.g., "cover", "contain") */
|
|
62
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
63
|
-
/** Object position (e.g., "center", "top", "bottom") */
|
|
64
|
-
objectPosition?: string;
|
|
65
|
-
/** Callback when brightness changes */
|
|
66
|
-
onBrightnessChange?: (brightness: number) => void;
|
|
67
|
-
/** Callback when blur changes */
|
|
68
|
-
onBlurChange?: (blur: number) => void;
|
|
69
|
-
/** Callback when scale changes */
|
|
70
|
-
onScaleChange?: (scale: number) => void;
|
|
71
|
-
/** Callback when X position changes */
|
|
72
|
-
onPositionXChange?: (positionX: number) => void;
|
|
73
|
-
/** Callback when Y position changes */
|
|
74
|
-
onPositionYChange?: (positionY: number) => void;
|
|
75
|
-
/** Callback when editor "Done" button is clicked - triggers immediate save */
|
|
76
|
-
onEditorSave?: (scale: number, positionX: number, positionY: number, brightness?: number, blur?: number) => void;
|
|
77
|
-
/** Automatically open the editor when component mounts (useful for modal scenarios) */
|
|
78
|
-
autoOpenEditor?: boolean;
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=index.d.ts.map
|
package/src/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC1B,sBAAsB;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC7B,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;IACjE,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,iCAAiC;IACjC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,kCAAkC;IAClC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,8EAA8E;IAC9E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjH,uFAAuF;IACvF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
package/src/types/index.js
DELETED
package/src/types/index.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Plugin Types
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export interface ImageMetadata {
|
|
6
|
-
/** Unique image ID */
|
|
7
|
-
id: string;
|
|
8
|
-
/** Original filename */
|
|
9
|
-
filename: string;
|
|
10
|
-
/** File path/URL */
|
|
11
|
-
url: string;
|
|
12
|
-
/** File size in bytes */
|
|
13
|
-
size: number;
|
|
14
|
-
/** MIME type */
|
|
15
|
-
mimeType: string;
|
|
16
|
-
/** Image dimensions */
|
|
17
|
-
width?: number;
|
|
18
|
-
height?: number;
|
|
19
|
-
/** Alt text */
|
|
20
|
-
alt?: string;
|
|
21
|
-
/** Upload timestamp */
|
|
22
|
-
uploadedAt: string;
|
|
23
|
-
/** Uploaded by user ID */
|
|
24
|
-
uploadedBy?: string;
|
|
25
|
-
/** Tags for searching */
|
|
26
|
-
tags?: string[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ImageUploadResponse {
|
|
30
|
-
success: boolean;
|
|
31
|
-
image?: ImageMetadata;
|
|
32
|
-
error?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface ImageListResponse {
|
|
36
|
-
images: ImageMetadata[];
|
|
37
|
-
total: number;
|
|
38
|
-
page: number;
|
|
39
|
-
limit: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface ImagePickerProps {
|
|
43
|
-
/** Current selected image URL */
|
|
44
|
-
value?: string;
|
|
45
|
-
/** Callback when image is selected */
|
|
46
|
-
onChange: (image: ImageMetadata | null) => void;
|
|
47
|
-
/** Whether dark mode is enabled */
|
|
48
|
-
darkMode?: boolean;
|
|
49
|
-
/** Show brightness and blur controls */
|
|
50
|
-
showEffects?: boolean;
|
|
51
|
-
/** Current brightness value (0-200, 100 = normal) */
|
|
52
|
-
brightness?: number;
|
|
53
|
-
/** Current blur value (0-20) */
|
|
54
|
-
blur?: number;
|
|
55
|
-
/** Current scale value (0.1-3.0, 1.0 = normal) */
|
|
56
|
-
scale?: number;
|
|
57
|
-
/** Current X position offset (-100 to 100, 0 = center) */
|
|
58
|
-
positionX?: number;
|
|
59
|
-
/** Current Y position offset (-100 to 100, 0 = center) */
|
|
60
|
-
positionY?: number;
|
|
61
|
-
/** Aspect ratio for preview/editor (e.g., "4/5", "3/4", "16/9", "1/1") */
|
|
62
|
-
aspectRatio?: string;
|
|
63
|
-
/** Border radius class (e.g., "rounded-xl", "rounded-3xl") */
|
|
64
|
-
borderRadius?: string;
|
|
65
|
-
/** Object fit style (e.g., "cover", "contain") */
|
|
66
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
67
|
-
/** Object position (e.g., "center", "top", "bottom") */
|
|
68
|
-
objectPosition?: string;
|
|
69
|
-
/** Callback when brightness changes */
|
|
70
|
-
onBrightnessChange?: (brightness: number) => void;
|
|
71
|
-
/** Callback when blur changes */
|
|
72
|
-
onBlurChange?: (blur: number) => void;
|
|
73
|
-
/** Callback when scale changes */
|
|
74
|
-
onScaleChange?: (scale: number) => void;
|
|
75
|
-
/** Callback when X position changes */
|
|
76
|
-
onPositionXChange?: (positionX: number) => void;
|
|
77
|
-
/** Callback when Y position changes */
|
|
78
|
-
onPositionYChange?: (positionY: number) => void;
|
|
79
|
-
/** Callback when editor "Done" button is clicked - triggers immediate save */
|
|
80
|
-
onEditorSave?: (scale: number, positionX: number, positionY: number, brightness?: number, blur?: number) => void;
|
|
81
|
-
/** Automatically open the editor when component mounts (useful for modal scenarios) */
|
|
82
|
-
autoOpenEditor?: boolean;
|
|
83
|
-
}
|
|
84
|
-
|
package/src/utils/fallback.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fallback image utility
|
|
3
|
-
* Provides a default fallback image URL when images fail to load or are invalid
|
|
4
|
-
* Also handles URL construction for image filenames
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Returns the URL for the fallback "image not found" image
|
|
8
|
-
* Served from the plugin's API route
|
|
9
|
-
*/
|
|
10
|
-
export declare function getFallbackImageUrl(): string;
|
|
11
|
-
/**
|
|
12
|
-
* Constructs the full image URL from a filename or URL
|
|
13
|
-
* - If it's already a full URL (http://, https://, or starts with /), returns as-is
|
|
14
|
-
* - If it's a filename, constructs `/api/uploads/${filename}`
|
|
15
|
-
*/
|
|
16
|
-
export declare function constructImageUrl(src: string | null | undefined): string | null;
|
|
17
|
-
/**
|
|
18
|
-
* Validates if a URL is valid and can be used with Next.js Image component
|
|
19
|
-
*/
|
|
20
|
-
export declare function isValidImageUrl(url: string | null | undefined): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Gets a safe image URL with automatic URL construction and fallback
|
|
23
|
-
* - Constructs the full URL if src is a filename
|
|
24
|
-
* - Falls back to the plugin's fallback image if invalid or missing
|
|
25
|
-
*/
|
|
26
|
-
export declare function getSafeImageUrl(src: string | null | undefined): string;
|
|
27
|
-
//# sourceMappingURL=fallback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["fallback.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAY/E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAkBvE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAUtE"}
|
package/src/utils/fallback.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fallback image utility
|
|
3
|
-
* Provides a default fallback image URL when images fail to load or are invalid
|
|
4
|
-
* Also handles URL construction for image filenames
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Returns the URL for the fallback "image not found" image
|
|
8
|
-
* Served from the plugin's API route
|
|
9
|
-
*/
|
|
10
|
-
export function getFallbackImageUrl() {
|
|
11
|
-
return '/api/plugin-images/fallback';
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Constructs the full image URL from a filename or URL
|
|
15
|
-
* - If it's already a full URL (http://, https://, or starts with /), returns as-is
|
|
16
|
-
* - If it's a filename, constructs `/api/uploads/${filename}`
|
|
17
|
-
*/
|
|
18
|
-
export function constructImageUrl(src) {
|
|
19
|
-
if (!src || typeof src !== 'string') {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
// If it's already a full URL (absolute or relative), return as-is
|
|
23
|
-
if (src.startsWith('http://') || src.startsWith('https://') || src.startsWith('/')) {
|
|
24
|
-
return src;
|
|
25
|
-
}
|
|
26
|
-
// Otherwise, it's a filename - construct the API URL
|
|
27
|
-
return `/api/uploads/${src}`;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Validates if a URL is valid and can be used with Next.js Image component
|
|
31
|
-
*/
|
|
32
|
-
export function isValidImageUrl(url) {
|
|
33
|
-
if (!url || typeof url !== 'string') {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
// Check if it's a valid URL format
|
|
37
|
-
try {
|
|
38
|
-
// For relative URLs (starting with /), they're valid
|
|
39
|
-
if (url.startsWith('/')) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
// For absolute URLs, validate the URL format
|
|
43
|
-
new URL(url);
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
catch (_a) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Gets a safe image URL with automatic URL construction and fallback
|
|
52
|
-
* - Constructs the full URL if src is a filename
|
|
53
|
-
* - Falls back to the plugin's fallback image if invalid or missing
|
|
54
|
-
*/
|
|
55
|
-
export function getSafeImageUrl(src) {
|
|
56
|
-
// First, construct the URL if it's a filename
|
|
57
|
-
const constructedUrl = constructImageUrl(src);
|
|
58
|
-
// Then validate and return, or fallback
|
|
59
|
-
if (isValidImageUrl(constructedUrl)) {
|
|
60
|
-
return constructedUrl;
|
|
61
|
-
}
|
|
62
|
-
return getFallbackImageUrl();
|
|
63
|
-
}
|
package/src/utils/fallback.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fallback image utility
|
|
3
|
-
* Provides a default fallback image URL when images fail to load or are invalid
|
|
4
|
-
* Also handles URL construction for image filenames
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Returns the URL for the fallback "image not found" image
|
|
9
|
-
* Served from the plugin's API route
|
|
10
|
-
*/
|
|
11
|
-
export function getFallbackImageUrl(): string {
|
|
12
|
-
return '/api/plugin-images/fallback';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Constructs the full image URL from a filename or URL
|
|
17
|
-
* - If it's already a full URL (http://, https://, or starts with /), returns as-is
|
|
18
|
-
* - If it's a filename, constructs `/api/uploads/${filename}`
|
|
19
|
-
*/
|
|
20
|
-
export function constructImageUrl(src: string | null | undefined): string | null {
|
|
21
|
-
if (!src || typeof src !== 'string') {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// If it's already a full URL (absolute or relative), return as-is
|
|
26
|
-
if (src.startsWith('http://') || src.startsWith('https://') || src.startsWith('/')) {
|
|
27
|
-
return src;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Otherwise, it's a filename - construct the API URL
|
|
31
|
-
return `/api/uploads/${src}`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Validates if a URL is valid and can be used with Next.js Image component
|
|
36
|
-
*/
|
|
37
|
-
export function isValidImageUrl(url: string | null | undefined): boolean {
|
|
38
|
-
if (!url || typeof url !== 'string') {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check if it's a valid URL format
|
|
43
|
-
try {
|
|
44
|
-
// For relative URLs (starting with /), they're valid
|
|
45
|
-
if (url.startsWith('/')) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// For absolute URLs, validate the URL format
|
|
50
|
-
new URL(url);
|
|
51
|
-
return true;
|
|
52
|
-
} catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Gets a safe image URL with automatic URL construction and fallback
|
|
59
|
-
* - Constructs the full URL if src is a filename
|
|
60
|
-
* - Falls back to the plugin's fallback image if invalid or missing
|
|
61
|
-
*/
|
|
62
|
-
export function getSafeImageUrl(src: string | null | undefined): string {
|
|
63
|
-
// First, construct the URL if it's a filename
|
|
64
|
-
const constructedUrl = constructImageUrl(src);
|
|
65
|
-
|
|
66
|
-
// Then validate and return, or fallback
|
|
67
|
-
if (isValidImageUrl(constructedUrl)) {
|
|
68
|
-
return constructedUrl!;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return getFallbackImageUrl();
|
|
72
|
-
}
|
|
73
|
-
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Transform Utilities
|
|
3
|
-
*/
|
|
4
|
-
export interface ImageTransformOptions {
|
|
5
|
-
scale: number;
|
|
6
|
-
positionX: number;
|
|
7
|
-
positionY: number;
|
|
8
|
-
baseScale?: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Calculates the CSS transform string
|
|
12
|
-
* Order: Center -> Scale -> Translate (Offset)
|
|
13
|
-
*
|
|
14
|
-
* Position values are stored as percentages of the CONTAINER, not the image.
|
|
15
|
-
* This makes them consistent across different container sizes.
|
|
16
|
-
*
|
|
17
|
-
* IMPORTANT: The image uses width: auto; height: auto with minWidth: 100%; minHeight: 100%
|
|
18
|
-
* This allows the image to maintain its natural aspect ratio while ensuring it covers the container.
|
|
19
|
-
* baseScale handles the "fitting" to ensure the image is large enough to fill the container.
|
|
20
|
-
*
|
|
21
|
-
* Applying SCALE before POSITION makes the position relative to the visual size you see,
|
|
22
|
-
* not the original raw file size. This ensures consistent positioning across different scales.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getImageTransform(options: ImageTransformOptions, needsCentering?: boolean, caller?: string): string;
|
|
25
|
-
export declare function getImageFilter(brightness?: number, blur?: number): string | undefined;
|
|
26
|
-
//# sourceMappingURL=transforms.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["transforms.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE,qBAAqB,EAC9B,cAAc,GAAE,OAAe,EAC/B,MAAM,CAAC,EAAE,MAAM,GAChB,MAAM,CAmBR;AAED,wBAAgB,cAAc,CAAC,UAAU,GAAE,MAAY,EAAE,IAAI,GAAE,MAAU,GAAG,MAAM,GAAG,SAAS,CAG7F"}
|
package/src/utils/transforms.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Transform Utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Calculates the CSS transform string
|
|
6
|
-
* Order: Center -> Scale -> Translate (Offset)
|
|
7
|
-
*
|
|
8
|
-
* Position values are stored as percentages of the CONTAINER, not the image.
|
|
9
|
-
* This makes them consistent across different container sizes.
|
|
10
|
-
*
|
|
11
|
-
* IMPORTANT: The image uses width: auto; height: auto with minWidth: 100%; minHeight: 100%
|
|
12
|
-
* This allows the image to maintain its natural aspect ratio while ensuring it covers the container.
|
|
13
|
-
* baseScale handles the "fitting" to ensure the image is large enough to fill the container.
|
|
14
|
-
*
|
|
15
|
-
* Applying SCALE before POSITION makes the position relative to the visual size you see,
|
|
16
|
-
* not the original raw file size. This ensures consistent positioning across different scales.
|
|
17
|
-
*/
|
|
18
|
-
export function getImageTransform(options, needsCentering = false, caller) {
|
|
19
|
-
const { scale, positionX, positionY, baseScale = 1 } = options;
|
|
20
|
-
const totalScale = baseScale * scale;
|
|
21
|
-
// 1. Center the image (if using top:50% left:50%)
|
|
22
|
-
const center = needsCentering ? 'translate(-50%, -50%)' : '';
|
|
23
|
-
// 2. Apply the scaling (base x zoom) FIRST
|
|
24
|
-
// This ensures the position offset is relative to the scaled visual size
|
|
25
|
-
const zoom = `scale(${totalScale})`;
|
|
26
|
-
// 3. Apply the offset (positionX/Y) AFTER scaling
|
|
27
|
-
// Position values are stored as percentage of CONTAINER
|
|
28
|
-
// Since scale is applied first, the translate is relative to the scaled visual size
|
|
29
|
-
const offset = `translate(${positionX}%, ${positionY}%)`;
|
|
30
|
-
// Combining them: Center first, then scale, then move
|
|
31
|
-
// Order matters: scale before translate ensures position is relative to visual size
|
|
32
|
-
return `${center} ${zoom} ${offset}`.trim();
|
|
33
|
-
}
|
|
34
|
-
export function getImageFilter(brightness = 100, blur = 0) {
|
|
35
|
-
if (brightness === 100 && blur === 0)
|
|
36
|
-
return undefined;
|
|
37
|
-
return `brightness(${brightness}%) blur(${blur}px)`;
|
|
38
|
-
}
|
package/src/utils/transforms.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Transform Utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export interface ImageTransformOptions {
|
|
6
|
-
scale: number;
|
|
7
|
-
positionX: number;
|
|
8
|
-
positionY: number;
|
|
9
|
-
baseScale?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Calculates the CSS transform string
|
|
14
|
-
* Order: Center -> Scale -> Translate (Offset)
|
|
15
|
-
*
|
|
16
|
-
* Position values are stored as percentages of the CONTAINER, not the image.
|
|
17
|
-
* This makes them consistent across different container sizes.
|
|
18
|
-
*
|
|
19
|
-
* IMPORTANT: The image uses width: auto; height: auto with minWidth: 100%; minHeight: 100%
|
|
20
|
-
* This allows the image to maintain its natural aspect ratio while ensuring it covers the container.
|
|
21
|
-
* baseScale handles the "fitting" to ensure the image is large enough to fill the container.
|
|
22
|
-
*
|
|
23
|
-
* Applying SCALE before POSITION makes the position relative to the visual size you see,
|
|
24
|
-
* not the original raw file size. This ensures consistent positioning across different scales.
|
|
25
|
-
*/
|
|
26
|
-
export function getImageTransform(
|
|
27
|
-
options: ImageTransformOptions,
|
|
28
|
-
needsCentering: boolean = false,
|
|
29
|
-
caller?: string
|
|
30
|
-
): string {
|
|
31
|
-
const { scale, positionX, positionY, baseScale = 1 } = options;
|
|
32
|
-
const totalScale = baseScale * scale;
|
|
33
|
-
|
|
34
|
-
// 1. Center the image (if using top:50% left:50%)
|
|
35
|
-
const center = needsCentering ? 'translate(-50%, -50%)' : '';
|
|
36
|
-
|
|
37
|
-
// 2. Apply the scaling (base x zoom) FIRST
|
|
38
|
-
// This ensures the position offset is relative to the scaled visual size
|
|
39
|
-
const zoom = `scale(${totalScale})`;
|
|
40
|
-
|
|
41
|
-
// 3. Apply the offset (positionX/Y) AFTER scaling
|
|
42
|
-
// Position values are stored as percentage of CONTAINER
|
|
43
|
-
// Since scale is applied first, the translate is relative to the scaled visual size
|
|
44
|
-
const offset = `translate(${positionX}%, ${positionY}%)`;
|
|
45
|
-
|
|
46
|
-
// Combining them: Center first, then scale, then move
|
|
47
|
-
// Order matters: scale before translate ensures position is relative to visual size
|
|
48
|
-
return `${center} ${zoom} ${offset}`.trim();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function getImageFilter(brightness: number = 100, blur: number = 0): string | undefined {
|
|
52
|
-
if (brightness === 100 && blur === 0) return undefined;
|
|
53
|
-
return `brightness(${brightness}%) blur(${blur}px)`;
|
|
54
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Manager View
|
|
3
|
-
* Main view for managing uploaded images
|
|
4
|
-
*/
|
|
5
|
-
export interface ImageManagerViewProps {
|
|
6
|
-
siteId: string;
|
|
7
|
-
locale: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function ImageManagerView({ siteId, locale }: ImageManagerViewProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
//# sourceMappingURL=ImageManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ImageManager.d.ts","sourceRoot":"","sources":["ImageManager.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,qBAAqB,2CAczE"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Manager View
|
|
3
|
-
* Main view for managing uploaded images
|
|
4
|
-
*/
|
|
5
|
-
'use client';
|
|
6
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
export function ImageManagerView({ siteId, locale }) {
|
|
8
|
-
return (_jsx("div", { className: "min-h-screen bg-dashboard-bg p-8", children: _jsxs("div", { className: "max-w-7xl mx-auto", children: [_jsx("h1", { className: "text-4xl font-black uppercase tracking-tighter text-dashboard-text mb-8", children: "Image Manager" }), _jsx("p", { className: "text-sm text-neutral-600 dark:text-neutral-400 mb-8", children: "This plugin provides image upload and management functionality. Use the ImagePicker component in other plugins to select images." })] }) }));
|
|
9
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Manager View
|
|
3
|
-
* Main view for managing uploaded images
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
|
|
10
|
-
export interface ImageManagerViewProps {
|
|
11
|
-
siteId: string;
|
|
12
|
-
locale: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function ImageManagerView({ siteId, locale }: ImageManagerViewProps) {
|
|
16
|
-
return (
|
|
17
|
-
<div className="min-h-screen bg-dashboard-bg p-8">
|
|
18
|
-
<div className="max-w-7xl mx-auto">
|
|
19
|
-
<h1 className="text-4xl font-black uppercase tracking-tighter text-dashboard-text mb-8">
|
|
20
|
-
Image Manager
|
|
21
|
-
</h1>
|
|
22
|
-
<p className="text-sm text-neutral-600 dark:text-neutral-400 mb-8">
|
|
23
|
-
This plugin provides image upload and management functionality.
|
|
24
|
-
Use the ImagePicker component in other plugins to select images.
|
|
25
|
-
</p>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|