@jhits/plugin-images 0.0.7 → 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.
Files changed (102) hide show
  1. package/package.json +8 -9
  2. package/src/api/fallback/route.ts +0 -69
  3. package/src/api/index.ts +0 -10
  4. package/src/api/list/index.ts +0 -96
  5. package/src/api/resolve/route.ts +0 -241
  6. package/src/api/router.ts +0 -85
  7. package/src/api/upload/index.ts +0 -88
  8. package/src/api/uploads/[filename]/route.ts +0 -93
  9. package/src/api-server.ts +0 -11
  10. package/src/assets/noimagefound.jpg +0 -0
  11. package/src/components/BackgroundImage.d.ts +0 -11
  12. package/src/components/BackgroundImage.d.ts.map +0 -1
  13. package/src/components/BackgroundImage.js +0 -35
  14. package/src/components/BackgroundImage.tsx +0 -92
  15. package/src/components/GlobalImageEditor/config.d.ts +0 -9
  16. package/src/components/GlobalImageEditor/config.d.ts.map +0 -1
  17. package/src/components/GlobalImageEditor/config.js +0 -18
  18. package/src/components/GlobalImageEditor/config.ts +0 -21
  19. package/src/components/GlobalImageEditor/eventHandlers.d.ts +0 -20
  20. package/src/components/GlobalImageEditor/eventHandlers.d.ts.map +0 -1
  21. package/src/components/GlobalImageEditor/eventHandlers.js +0 -206
  22. package/src/components/GlobalImageEditor/eventHandlers.ts +0 -267
  23. package/src/components/GlobalImageEditor/imageDetection.d.ts +0 -16
  24. package/src/components/GlobalImageEditor/imageDetection.d.ts.map +0 -1
  25. package/src/components/GlobalImageEditor/imageDetection.js +0 -130
  26. package/src/components/GlobalImageEditor/imageDetection.ts +0 -160
  27. package/src/components/GlobalImageEditor/imageSetup.d.ts +0 -9
  28. package/src/components/GlobalImageEditor/imageSetup.d.ts.map +0 -1
  29. package/src/components/GlobalImageEditor/imageSetup.js +0 -261
  30. package/src/components/GlobalImageEditor/imageSetup.ts +0 -306
  31. package/src/components/GlobalImageEditor/saveLogic.d.ts +0 -26
  32. package/src/components/GlobalImageEditor/saveLogic.d.ts.map +0 -1
  33. package/src/components/GlobalImageEditor/saveLogic.js +0 -99
  34. package/src/components/GlobalImageEditor/saveLogic.ts +0 -133
  35. package/src/components/GlobalImageEditor/stylingDetection.d.ts +0 -9
  36. package/src/components/GlobalImageEditor/stylingDetection.d.ts.map +0 -1
  37. package/src/components/GlobalImageEditor/stylingDetection.js +0 -110
  38. package/src/components/GlobalImageEditor/stylingDetection.ts +0 -122
  39. package/src/components/GlobalImageEditor/transformParsing.d.ts +0 -16
  40. package/src/components/GlobalImageEditor/transformParsing.d.ts.map +0 -1
  41. package/src/components/GlobalImageEditor/transformParsing.js +0 -68
  42. package/src/components/GlobalImageEditor/transformParsing.ts +0 -83
  43. package/src/components/GlobalImageEditor/types.d.ts +0 -36
  44. package/src/components/GlobalImageEditor/types.d.ts.map +0 -1
  45. package/src/components/GlobalImageEditor/types.js +0 -4
  46. package/src/components/GlobalImageEditor/types.ts +0 -39
  47. package/src/components/GlobalImageEditor.d.ts +0 -8
  48. package/src/components/GlobalImageEditor.d.ts.map +0 -1
  49. package/src/components/GlobalImageEditor.js +0 -227
  50. package/src/components/GlobalImageEditor.tsx +0 -327
  51. package/src/components/Image.d.ts +0 -22
  52. package/src/components/Image.d.ts.map +0 -1
  53. package/src/components/Image.js +0 -229
  54. package/src/components/Image.tsx +0 -343
  55. package/src/components/ImageBrowserModal.d.ts +0 -13
  56. package/src/components/ImageBrowserModal.d.ts.map +0 -1
  57. package/src/components/ImageBrowserModal.js +0 -504
  58. package/src/components/ImageBrowserModal.tsx +0 -837
  59. package/src/components/ImageEditor.d.ts +0 -27
  60. package/src/components/ImageEditor.d.ts.map +0 -1
  61. package/src/components/ImageEditor.js +0 -173
  62. package/src/components/ImageEditor.tsx +0 -323
  63. package/src/components/ImageEffectsPanel.tsx +0 -116
  64. package/src/components/ImagePicker.d.ts +0 -3
  65. package/src/components/ImagePicker.d.ts.map +0 -1
  66. package/src/components/ImagePicker.js +0 -143
  67. package/src/components/ImagePicker.tsx +0 -265
  68. package/src/components/ImagesPluginInit.d.ts +0 -24
  69. package/src/components/ImagesPluginInit.d.ts.map +0 -1
  70. package/src/components/ImagesPluginInit.js +0 -28
  71. package/src/components/ImagesPluginInit.tsx +0 -31
  72. package/src/components/index.ts +0 -10
  73. package/src/config.ts +0 -179
  74. package/src/hooks/useImagePicker.d.ts +0 -20
  75. package/src/hooks/useImagePicker.d.ts.map +0 -1
  76. package/src/hooks/useImagePicker.js +0 -322
  77. package/src/hooks/useImagePicker.ts +0 -344
  78. package/src/index.d.ts +0 -23
  79. package/src/index.d.ts.map +0 -1
  80. package/src/index.js +0 -28
  81. package/src/index.server.ts +0 -12
  82. package/src/index.tsx +0 -56
  83. package/src/init.d.ts +0 -33
  84. package/src/init.d.ts.map +0 -1
  85. package/src/init.js +0 -43
  86. package/src/init.tsx +0 -58
  87. package/src/types/index.d.ts +0 -80
  88. package/src/types/index.d.ts.map +0 -1
  89. package/src/types/index.js +0 -4
  90. package/src/types/index.ts +0 -84
  91. package/src/utils/fallback.d.ts +0 -27
  92. package/src/utils/fallback.d.ts.map +0 -1
  93. package/src/utils/fallback.js +0 -63
  94. package/src/utils/fallback.ts +0 -73
  95. package/src/utils/transforms.d.ts +0 -26
  96. package/src/utils/transforms.d.ts.map +0 -1
  97. package/src/utils/transforms.js +0 -38
  98. package/src/utils/transforms.ts +0 -54
  99. package/src/views/ImageManager.d.ts +0 -10
  100. package/src/views/ImageManager.d.ts.map +0 -1
  101. package/src/views/ImageManager.js +0 -9
  102. package/src/views/ImageManager.tsx +0 -30
@@ -1,344 +0,0 @@
1
- /**
2
- * Hook for Image Picker Logic
3
- */
4
-
5
- import { useState, useEffect, useRef } from 'react';
6
- import type { ImageMetadata } from '../types';
7
-
8
- export interface UseImagePickerOptions {
9
- value?: string;
10
- images: ImageMetadata[];
11
- }
12
-
13
- export function useImagePicker({ value, images }: UseImagePickerOptions) {
14
- const [selectedImage, setSelectedImage] = useState<ImageMetadata | null>(null);
15
- const [uploading, setUploading] = useState(false);
16
- const fileInputRef = useRef<HTMLInputElement>(null);
17
- const lastResolvedValueRef = useRef<string | undefined>(undefined);
18
- const isResolvingRef = useRef(false);
19
- const lastImagesRef = useRef<string>('');
20
-
21
- // Find selected image from value (can be ID or URL)
22
- useEffect(() => {
23
- // Create a stable reference for images array to detect actual changes
24
- const imagesKey = JSON.stringify(images.map(img => ({ id: img.id, url: img.url })));
25
-
26
- // Prevent infinite loops by checking if we're already resolving or if value and images haven't changed
27
- if (isResolvingRef.current || (lastResolvedValueRef.current === value && lastImagesRef.current === imagesKey)) {
28
- return;
29
- }
30
-
31
- lastImagesRef.current = imagesKey;
32
-
33
- if (!value) {
34
- if (selectedImage !== null) {
35
- setSelectedImage(null);
36
- }
37
- lastResolvedValueRef.current = value;
38
- return;
39
- }
40
-
41
- isResolvingRef.current = true;
42
- const resolveImage = async () => {
43
- // Normalize the value - extract filename if it's a URL
44
- const isFullUrl = value.startsWith('http://') || value.startsWith('https://');
45
- const isRelativeUrl = value.startsWith('/');
46
- const isUrl = isFullUrl || isRelativeUrl;
47
-
48
- // Extract filename from URL if it's a URL
49
- let filenameFromUrl: string | null = null;
50
- let imageIdToResolve = value;
51
-
52
- if (isUrl) {
53
- const urlParts = value.split('/');
54
- filenameFromUrl = urlParts[urlParts.length - 1]?.split('?')[0] || null;
55
- // If it's a full URL, try to resolve using the filename instead
56
- if (isFullUrl && filenameFromUrl) {
57
- imageIdToResolve = filenameFromUrl;
58
- }
59
- }
60
-
61
- // First, try to find by ID (preferred method)
62
- let found = images.find(img => img.id === value || img.id === imageIdToResolve);
63
-
64
- // If not found by ID, try to find by URL
65
- if (!found) {
66
- found = images.find(img => img.url === value);
67
- }
68
-
69
- // If still not found, try to match by filename extracted from URL
70
- if (!found && filenameFromUrl) {
71
- found = images.find(img => img.id === filenameFromUrl || img.filename === filenameFromUrl);
72
- }
73
-
74
- if (found) {
75
- // Only update if the image is actually different
76
- setSelectedImage(prev => {
77
- if (prev?.id === found.id && prev?.url === found.url) {
78
- return prev;
79
- }
80
- return found;
81
- });
82
- } else {
83
- // If value is already a full URL, use it directly
84
- if (isFullUrl) {
85
- const newImage = {
86
- id: value,
87
- filename: filenameFromUrl || value,
88
- url: value, // Use the full URL as-is
89
- size: 0,
90
- mimeType: 'image/jpeg',
91
- uploadedAt: new Date().toISOString(),
92
- };
93
- setSelectedImage(prev => {
94
- if (prev?.id === newImage.id && prev?.url === newImage.url) {
95
- return prev;
96
- }
97
- return newImage;
98
- });
99
- lastResolvedValueRef.current = value;
100
- isResolvingRef.current = false;
101
- return;
102
- }
103
-
104
- // If value is a relative URL, use it directly
105
- if (isRelativeUrl) {
106
- const newImage = {
107
- id: value,
108
- filename: filenameFromUrl || value,
109
- url: value, // Use the relative URL as-is
110
- size: 0,
111
- mimeType: 'image/jpeg',
112
- uploadedAt: new Date().toISOString(),
113
- };
114
- setSelectedImage(prev => {
115
- if (prev?.id === newImage.id && prev?.url === newImage.url) {
116
- return prev;
117
- }
118
- return newImage;
119
- });
120
- lastResolvedValueRef.current = value;
121
- isResolvingRef.current = false;
122
- return;
123
- }
124
-
125
- // Check if value looks like a filename (has extension or starts with digits)
126
- const isLikelyPath = /\.(jpg|jpeg|png|webp|gif|svg)$/i.test(value) || /^\d+-/.test(value);
127
-
128
- if (isLikelyPath) {
129
- // It's likely a filename, create image object directly
130
- const newImage = {
131
- id: value,
132
- filename: value,
133
- url: `/api/uploads/${value}`,
134
- size: 0,
135
- mimeType: 'image/jpeg',
136
- uploadedAt: new Date().toISOString(),
137
- };
138
- setSelectedImage(prev => {
139
- if (prev?.id === newImage.id && prev?.url === newImage.url) {
140
- return prev;
141
- }
142
- return newImage;
143
- });
144
- lastResolvedValueRef.current = value;
145
- isResolvingRef.current = false;
146
- } else {
147
- // It might be a semantic ID, try to resolve via API
148
- // Use the extracted ID (filename) if value was a URL, otherwise use value
149
- try {
150
- const response = await fetch(`/api/plugin-images/resolve?id=${encodeURIComponent(imageIdToResolve)}`);
151
- if (response.ok) {
152
- const data = await response.json();
153
- // Normalize the URL - ensure it's a proper URL
154
- let imageUrl: string;
155
- if (data.url) {
156
- // If API returns a URL, use it (but check if it's already a full URL)
157
- if (data.url.startsWith('http://') || data.url.startsWith('https://')) {
158
- imageUrl = data.url;
159
- } else if (data.url.startsWith('/')) {
160
- imageUrl = data.url;
161
- } else {
162
- // Relative path without leading slash
163
- imageUrl = `/api/uploads/${data.url}`;
164
- }
165
- } else if (data.filename) {
166
- // Use filename to construct URL
167
- imageUrl = `/api/uploads/${data.filename}`;
168
- } else {
169
- // Fallback: if original value was a URL, use it; otherwise construct
170
- imageUrl = isFullUrl ? value : (isRelativeUrl ? value : `/api/uploads/${value}`);
171
- }
172
-
173
- const newImage = {
174
- id: value,
175
- filename: data.filename || filenameFromUrl || value,
176
- url: imageUrl,
177
- size: 0,
178
- mimeType: 'image/jpeg',
179
- uploadedAt: new Date().toISOString(),
180
- };
181
- setSelectedImage(prev => {
182
- if (prev?.id === newImage.id && prev?.url === newImage.url) {
183
- return prev;
184
- }
185
- return newImage;
186
- });
187
- lastResolvedValueRef.current = value;
188
- isResolvingRef.current = false;
189
- } else {
190
- // API resolution failed - check if it's a semantic ID or actual filename
191
- const isLikelyFilename = /\.(jpg|jpeg|png|webp|gif|svg)$/i.test(imageIdToResolve) || /^\d+-/.test(imageIdToResolve);
192
-
193
- if (!isLikelyFilename) {
194
- // It's a semantic ID that couldn't be resolved - clear selection
195
- // This prevents showing broken URLs like /api/uploads/blog-featured-...
196
- setSelectedImage(null);
197
- lastResolvedValueRef.current = value;
198
- isResolvingRef.current = false;
199
- return;
200
- }
201
-
202
- // It's a filename, create fallback object
203
- const isFullUrl = value.startsWith('http://') || value.startsWith('https://');
204
- const isRelativeUrl = value.startsWith('/');
205
-
206
- let imageUrl: string;
207
- if (isFullUrl) {
208
- // Already a full URL, use as-is
209
- imageUrl = value;
210
- } else if (isRelativeUrl) {
211
- // Already a relative URL starting with /, use as-is
212
- imageUrl = value;
213
- } else {
214
- // It's a filename, construct the URL
215
- imageUrl = `/api/uploads/${value}`;
216
- }
217
-
218
- const urlParts = value.split('/');
219
- const filename = urlParts[urlParts.length - 1]?.split('?')[0] || value;
220
-
221
- const newImage = {
222
- id: value,
223
- filename: filename,
224
- url: imageUrl,
225
- size: 0,
226
- mimeType: 'image/jpeg',
227
- uploadedAt: new Date().toISOString(),
228
- };
229
- setSelectedImage(prev => {
230
- if (prev?.id === newImage.id && prev?.url === newImage.url) {
231
- return prev;
232
- }
233
- return newImage;
234
- });
235
- lastResolvedValueRef.current = value;
236
- isResolvingRef.current = false;
237
- }
238
- } catch (error) {
239
- // API call failed - check if it's a semantic ID or actual filename
240
- const isLikelyFilename = /\.(jpg|jpeg|png|webp|gif|svg)$/i.test(imageIdToResolve) || /^\d+-/.test(imageIdToResolve);
241
-
242
- if (!isLikelyFilename) {
243
- // It's a semantic ID that couldn't be resolved - clear selection
244
- // This prevents showing broken URLs like /api/uploads/blog-featured-...
245
- setSelectedImage(null);
246
- lastResolvedValueRef.current = value;
247
- isResolvingRef.current = false;
248
- return;
249
- }
250
-
251
- // It's a filename, create fallback object
252
- const isFullUrl = value.startsWith('http://') || value.startsWith('https://');
253
- const isRelativeUrl = value.startsWith('/');
254
-
255
- let imageUrl: string;
256
- if (isFullUrl) {
257
- // Already a full URL, use as-is
258
- imageUrl = value;
259
- } else if (isRelativeUrl) {
260
- // Already a relative URL starting with /, use as-is
261
- imageUrl = value;
262
- } else {
263
- // It's a filename, construct the URL
264
- imageUrl = `/api/uploads/${value}`;
265
- }
266
-
267
- const urlParts = value.split('/');
268
- const filename = urlParts[urlParts.length - 1]?.split('?')[0] || value;
269
-
270
- const newImage = {
271
- id: value,
272
- filename: filename,
273
- url: imageUrl,
274
- size: 0,
275
- mimeType: 'image/jpeg',
276
- uploadedAt: new Date().toISOString(),
277
- };
278
- setSelectedImage(prev => {
279
- if (prev?.id === newImage.id && prev?.url === newImage.url) {
280
- return prev;
281
- }
282
- return newImage;
283
- });
284
- lastResolvedValueRef.current = value;
285
- isResolvingRef.current = false;
286
- }
287
- }
288
- }
289
- };
290
-
291
- resolveImage().catch(() => {
292
- // Error already handled in catch block
293
- isResolvingRef.current = false;
294
- });
295
- }, [value, images]);
296
-
297
- // Handle file upload
298
- const handleFileSelect = async (e?: React.ChangeEvent<HTMLInputElement> | { target: { files: File[] | null } }) => {
299
- const file = e?.target?.files?.[0];
300
- if (!file) return null;
301
-
302
- setUploading(true);
303
- try {
304
- const formData = new FormData();
305
- formData.append('file', file);
306
-
307
- const response = await fetch('/api/plugin-images/upload', {
308
- method: 'POST',
309
- body: formData,
310
- });
311
-
312
- const data = await response.json();
313
-
314
- if (data.success && data.image) {
315
- // Select the newly uploaded image
316
- setSelectedImage(data.image);
317
- if (fileInputRef.current) {
318
- fileInputRef.current.value = '';
319
- }
320
- return data.image;
321
- } else {
322
- alert(data.error || 'Failed to upload image');
323
- return null;
324
- }
325
- } catch (error) {
326
- console.error('Upload error:', error);
327
- alert('Failed to upload image');
328
- return null;
329
- } finally {
330
- setUploading(false);
331
- if (fileInputRef.current) {
332
- fileInputRef.current.value = '';
333
- }
334
- }
335
- };
336
-
337
- return {
338
- selectedImage,
339
- setSelectedImage,
340
- uploading,
341
- fileInputRef,
342
- handleFileSelect,
343
- };
344
- }
package/src/index.d.ts DELETED
@@ -1,23 +0,0 @@
1
- /**
2
- * Plugin Images - Main Entry Point
3
- * Image management plugin for uploading, searching, and managing images
4
- */
5
- export interface PluginProps {
6
- subPath: string[];
7
- siteId: string;
8
- locale: string;
9
- }
10
- export default function ImagesPlugin({ subPath, siteId, locale }: PluginProps): import("react/jsx-runtime").JSX.Element;
11
- export { ImagesPlugin as Index };
12
- export { ImagePicker } from './components/ImagePicker';
13
- export { GlobalImageEditor } from './components/GlobalImageEditor';
14
- export { ImagesPluginInit } from './components/ImagesPluginInit';
15
- export { Image } from './components/Image';
16
- export { BackgroundImage } from './components/BackgroundImage';
17
- export type { ImagePickerProps, ImageMetadata } from './types';
18
- export type { PluginImageProps } from './components/Image';
19
- export type { BackgroundImageProps } from './components/BackgroundImage';
20
- export { initImagesPlugin } from './init';
21
- export type { ImagesPluginConfig } from './init';
22
- export { getFallbackImageUrl, isValidImageUrl, getSafeImageUrl, constructImageUrl } from './utils/fallback';
23
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,WAAW,2CAU5E;AAGD,OAAO,EAAE,YAAY,IAAI,KAAK,EAAE,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAGjD,OAAO,EACH,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,iBAAiB,EACpB,MAAM,kBAAkB,CAAC"}
package/src/index.js DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * Plugin Images - Main Entry Point
3
- * Image management plugin for uploading, searching, and managing images
4
- */
5
- 'use client';
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- import { ImageManagerView } from './views/ImageManager';
8
- export default function ImagesPlugin({ subPath, siteId, locale }) {
9
- const route = subPath[0] || 'manager';
10
- switch (route) {
11
- case 'manager':
12
- return _jsx(ImageManagerView, { siteId: siteId, locale: locale });
13
- default:
14
- return _jsx(ImageManagerView, { siteId: siteId, locale: locale });
15
- }
16
- }
17
- // Export for use as default
18
- export { ImagesPlugin as Index };
19
- // Export components for use in other plugins
20
- export { ImagePicker } from './components/ImagePicker';
21
- export { GlobalImageEditor } from './components/GlobalImageEditor';
22
- export { ImagesPluginInit } from './components/ImagesPluginInit';
23
- export { Image } from './components/Image';
24
- export { BackgroundImage } from './components/BackgroundImage';
25
- // Export initialization utility
26
- export { initImagesPlugin } from './init';
27
- // Export utility functions
28
- export { getFallbackImageUrl, isValidImageUrl, getSafeImageUrl, constructImageUrl } from './utils/fallback';
@@ -1,12 +0,0 @@
1
- import 'server-only';
2
- /**
3
- * Plugin Images - Server-Only Entry Point
4
- * This file exports only server-side API handlers
5
- * Used by the dynamic plugin router via @jhits/plugin-images/server
6
- *
7
- * Note: This file is server-only (no 'use server' needed - that's only for Server Actions)
8
- */
9
-
10
- export { handleImagesApi as handleApi } from './api/router';
11
- export { handleImagesApi } from './api/router'; // Keep original export for backward compatibility
12
-
package/src/index.tsx DELETED
@@ -1,56 +0,0 @@
1
- /**
2
- * Plugin Images - Main Entry Point
3
- * Image management plugin for uploading, searching, and managing images
4
- */
5
-
6
- 'use client';
7
-
8
- import React from 'react';
9
- import { ImageManagerView } from './views/ImageManager';
10
-
11
- export interface PluginProps {
12
- subPath: string[];
13
- siteId: string;
14
- locale: string;
15
- }
16
-
17
- export default function ImagesPlugin({ subPath, siteId, locale }: PluginProps) {
18
- const route = subPath[0] || 'manager';
19
-
20
- switch (route) {
21
- case 'manager':
22
- return <ImageManagerView siteId={siteId} locale={locale} />;
23
-
24
- default:
25
- return <ImageManagerView siteId={siteId} locale={locale} />;
26
- }
27
- }
28
-
29
- // Export for use as default
30
- export { ImagesPlugin as Index };
31
-
32
- // Export components for use in other plugins
33
- export { ImagePicker } from './components/ImagePicker';
34
- export { GlobalImageEditor } from './components/GlobalImageEditor';
35
- export { ImagesPluginInit } from './components/ImagesPluginInit';
36
- export { Image } from './components/Image';
37
- export { BackgroundImage } from './components/BackgroundImage';
38
- export type { ImagePickerProps, ImageMetadata } from './types';
39
- export type { PluginImageProps } from './components/Image';
40
- export type { BackgroundImageProps } from './components/BackgroundImage';
41
-
42
- // Export initialization utility
43
- export { initImagesPlugin } from './init';
44
- export type { ImagesPluginConfig } from './init';
45
-
46
- // Export utility functions
47
- export {
48
- getFallbackImageUrl,
49
- isValidImageUrl,
50
- getSafeImageUrl,
51
- constructImageUrl
52
- } from './utils/fallback';
53
-
54
- // Note: API handlers are server-only and exported from ./index.ts (server entry point)
55
- // They are NOT exported here to prevent client/server context mixing
56
-
package/src/init.d.ts DELETED
@@ -1,33 +0,0 @@
1
- /**
2
- * Images Plugin Initialization Utility
3
- *
4
- * Simple function to initialize the images plugin with client configuration.
5
- * Call this once in your app (e.g., in root layout) to enable global image editing.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { initImagesPlugin } from '@jhits/plugin-images/init';
10
- * import { imagesConfig } from '@/plugins/images-config';
11
- *
12
- * // Call once when your app loads
13
- * initImagesPlugin(imagesConfig);
14
- * ```
15
- */
16
- export interface ImagesPluginConfig {
17
- /** Enable global image editor (default: true) */
18
- enabled?: boolean;
19
- /** Custom styling for the editor modal */
20
- className?: string;
21
- /** Custom styling for the modal overlay */
22
- overlayClassName?: string;
23
- }
24
- /**
25
- * Initialize the images plugin with client configuration
26
- *
27
- * This function sets up the window global that the plugin reads from automatically.
28
- * Call this once when your app loads, before the plugin component is rendered.
29
- *
30
- * @param config - Images plugin configuration (enabled, styling, etc.)
31
- */
32
- export declare function initImagesPlugin(config?: ImagesPluginConfig): void;
33
- //# sourceMappingURL=init.d.ts.map
package/src/init.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["init.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,WAAW,kBAAkB;IAC/B,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAqBlE"}
package/src/init.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * Images Plugin Initialization Utility
3
- *
4
- * Simple function to initialize the images plugin with client configuration.
5
- * Call this once in your app (e.g., in root layout) to enable global image editing.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { initImagesPlugin } from '@jhits/plugin-images/init';
10
- * import { imagesConfig } from '@/plugins/images-config';
11
- *
12
- * // Call once when your app loads
13
- * initImagesPlugin(imagesConfig);
14
- * ```
15
- */
16
- 'use client';
17
- /**
18
- * Initialize the images plugin with client configuration
19
- *
20
- * This function sets up the window global that the plugin reads from automatically.
21
- * Call this once when your app loads, before the plugin component is rendered.
22
- *
23
- * @param config - Images plugin configuration (enabled, styling, etc.)
24
- */
25
- export function initImagesPlugin(config) {
26
- if (typeof window === 'undefined') {
27
- // Server-side: no-op
28
- return;
29
- }
30
- // Initialize the global plugin props object if it doesn't exist
31
- if (!window.__JHITS_PLUGIN_PROPS__) {
32
- window.__JHITS_PLUGIN_PROPS__ = {};
33
- }
34
- // Set images plugin configuration
35
- window.__JHITS_PLUGIN_PROPS__['plugin-images'] = {
36
- enabled: (config === null || config === void 0 ? void 0 : config.enabled) !== undefined ? config.enabled : true,
37
- className: config === null || config === void 0 ? void 0 : config.className,
38
- overlayClassName: config === null || config === void 0 ? void 0 : config.overlayClassName,
39
- };
40
- console.log('[ImagesPlugin] Initialized with config:', {
41
- enabled: (config === null || config === void 0 ? void 0 : config.enabled) !== undefined ? config.enabled : true,
42
- });
43
- }
package/src/init.tsx DELETED
@@ -1,58 +0,0 @@
1
- /**
2
- * Images Plugin Initialization Utility
3
- *
4
- * Simple function to initialize the images plugin with client configuration.
5
- * Call this once in your app (e.g., in root layout) to enable global image editing.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { initImagesPlugin } from '@jhits/plugin-images/init';
10
- * import { imagesConfig } from '@/plugins/images-config';
11
- *
12
- * // Call once when your app loads
13
- * initImagesPlugin(imagesConfig);
14
- * ```
15
- */
16
-
17
- 'use client';
18
-
19
- export interface ImagesPluginConfig {
20
- /** Enable global image editor (default: true) */
21
- enabled?: boolean;
22
- /** Custom styling for the editor modal */
23
- className?: string;
24
- /** Custom styling for the modal overlay */
25
- overlayClassName?: string;
26
- }
27
-
28
- /**
29
- * Initialize the images plugin with client configuration
30
- *
31
- * This function sets up the window global that the plugin reads from automatically.
32
- * Call this once when your app loads, before the plugin component is rendered.
33
- *
34
- * @param config - Images plugin configuration (enabled, styling, etc.)
35
- */
36
- export function initImagesPlugin(config?: ImagesPluginConfig): void {
37
- if (typeof window === 'undefined') {
38
- // Server-side: no-op
39
- return;
40
- }
41
-
42
- // Initialize the global plugin props object if it doesn't exist
43
- if (!(window as any).__JHITS_PLUGIN_PROPS__) {
44
- (window as any).__JHITS_PLUGIN_PROPS__ = {};
45
- }
46
-
47
- // Set images plugin configuration
48
- (window as any).__JHITS_PLUGIN_PROPS__['plugin-images'] = {
49
- enabled: config?.enabled !== undefined ? config.enabled : true,
50
- className: config?.className,
51
- overlayClassName: config?.overlayClassName,
52
- };
53
-
54
- console.log('[ImagesPlugin] Initialized with config:', {
55
- enabled: config?.enabled !== undefined ? config.enabled : true,
56
- });
57
- }
58
-