@emailmaker/filemanager 0.0.5 → 0.0.6
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/components/FileManagerApp/FileManagerApp.d.ts +1 -1
- package/components/PixieEditor/PixieEditorIframe.d.ts +1 -1
- package/file-manager.d.ts +2 -0
- package/file-manager.esm.js +16 -12
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- package/hooks/usePixieEditor.d.ts +1 -1
- package/package.json +1 -1
- package/types.d.ts +2 -0
|
@@ -2,4 +2,4 @@ import React from 'react';
|
|
|
2
2
|
import { FileManagerProps } from '../../types';
|
|
3
3
|
import '../../styles/index.scss';
|
|
4
4
|
import '../../styles/variables.css';
|
|
5
|
-
export declare const FileManagerApp: React.MemoExoticComponent<({ config, onPathChange, onChangeSelection, searchQuery, sortBySize, apiEndpoints, customIcons, dragDropIcon, dataProviders, publicPath, notification }: FileManagerProps) => import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
export declare const FileManagerApp: React.MemoExoticComponent<({ config, onPathChange, onChangeSelection, onEditorOk, searchQuery, sortBySize, apiEndpoints, customIcons, dragDropIcon, dataProviders, publicPath, notification }: FileManagerProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -4,7 +4,7 @@ interface PixieEditorIframeProps {
|
|
|
4
4
|
visible: boolean;
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
file: AppFile | ThumbnailFile | null;
|
|
7
|
-
onSave: (updatedFile: AppFile) => Promise<void>;
|
|
7
|
+
onSave: (updatedFile: AppFile) => Promise<AppFile | void>;
|
|
8
8
|
}
|
|
9
9
|
export declare const PixieEditorIframe: React.FC<PixieEditorIframeProps>;
|
|
10
10
|
export {};
|
package/file-manager.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface Options {
|
|
|
7
7
|
config?: Config;
|
|
8
8
|
currentPath?: string;
|
|
9
9
|
onPathChange?: (path: string[]) => void;
|
|
10
|
+
onEditorOk?: (file: File) => void;
|
|
10
11
|
searchQuery?: string;
|
|
11
12
|
sortBySize?: string;
|
|
12
13
|
apiEndpoints?: {
|
|
@@ -25,6 +26,7 @@ export interface FileManagerAppProps {
|
|
|
25
26
|
currentPath?: string;
|
|
26
27
|
onPathChange?: (path: string[]) => void;
|
|
27
28
|
onChangeSelection?: (files: File[]) => void;
|
|
29
|
+
onEditorOk?: (file: File) => void;
|
|
28
30
|
searchQuery?: string;
|
|
29
31
|
sortBySize?: string;
|
|
30
32
|
dataProviders?: FileManagerDataProviders;
|
package/file-manager.esm.js
CHANGED
|
@@ -24633,26 +24633,24 @@ const usePixieEditor = ({ files, selectedFiles, fetchFiles, selectedFolder }) =>
|
|
|
24633
24633
|
// Используем dataProvider как основной метод
|
|
24634
24634
|
if ((dataProviders === null || dataProviders === void 0 ? void 0 : dataProviders.uploadFile) && updatedFile.thumbnail) {
|
|
24635
24635
|
try {
|
|
24636
|
-
await dataProviders.uploadFile(Object.assign(Object.assign({}, updatedFile), { type: updatedFile.type || '', data: await fetch(updatedFile.thumbnail).then(res => res.blob()) }));
|
|
24637
|
-
return true;
|
|
24636
|
+
return await dataProviders.uploadFile(Object.assign(Object.assign({}, updatedFile), { type: updatedFile.type || '', data: await fetch(updatedFile.thumbnail).then(res => res.blob()) }));
|
|
24638
24637
|
}
|
|
24639
24638
|
catch (error) {
|
|
24640
24639
|
console.error('Ошибка при сохранении файла через uploadFile:', error);
|
|
24641
|
-
return
|
|
24640
|
+
return null;
|
|
24642
24641
|
}
|
|
24643
24642
|
}
|
|
24644
24643
|
else if (dataProviders === null || dataProviders === void 0 ? void 0 : dataProviders.renameFile) {
|
|
24645
24644
|
try {
|
|
24646
|
-
await dataProviders.renameFile(updatedFile.id, updatedFile.name);
|
|
24647
|
-
return true;
|
|
24645
|
+
return await dataProviders.renameFile(updatedFile.id, updatedFile.name);
|
|
24648
24646
|
}
|
|
24649
24647
|
catch (error) {
|
|
24650
24648
|
console.error('Ошибка при переименовании файла:', error);
|
|
24651
|
-
return
|
|
24649
|
+
return null;
|
|
24652
24650
|
}
|
|
24653
24651
|
}
|
|
24654
24652
|
console.warn('DataProvider для обновления файлов не настроен');
|
|
24655
|
-
return
|
|
24653
|
+
return null;
|
|
24656
24654
|
}, [options]);
|
|
24657
24655
|
// Открытие Pixie редактора
|
|
24658
24656
|
const handleEdit = React.useCallback((fileForEdit) => {
|
|
@@ -24676,14 +24674,15 @@ const usePixieEditor = ({ files, selectedFiles, fetchFiles, selectedFolder }) =>
|
|
|
24676
24674
|
const handlePixieEditorSave = React.useCallback(async (updatedFile) => {
|
|
24677
24675
|
console.log('Файл обновлен:', updatedFile);
|
|
24678
24676
|
try {
|
|
24679
|
-
const
|
|
24680
|
-
if (
|
|
24677
|
+
const savedFile = await saveFileToServer(updatedFile);
|
|
24678
|
+
if (savedFile) {
|
|
24681
24679
|
await fetchFiles({ folderId: selectedFolder || undefined });
|
|
24682
24680
|
notification.success({
|
|
24683
24681
|
message: 'Успех',
|
|
24684
24682
|
description: 'Изображение успешно обновлено',
|
|
24685
24683
|
});
|
|
24686
24684
|
handlePixieEditorClose();
|
|
24685
|
+
return savedFile;
|
|
24687
24686
|
}
|
|
24688
24687
|
}
|
|
24689
24688
|
catch (error) {
|
|
@@ -25380,7 +25379,7 @@ const PixieEditorIframe = ({ visible, onClose, file, onSave }) => {
|
|
|
25380
25379
|
if (!visible)
|
|
25381
25380
|
return;
|
|
25382
25381
|
const handleMessage = async (event) => {
|
|
25383
|
-
var _a;
|
|
25382
|
+
var _a, _b;
|
|
25384
25383
|
if (event.origin !== window.location.origin)
|
|
25385
25384
|
return;
|
|
25386
25385
|
try {
|
|
@@ -25402,9 +25401,13 @@ const PixieEditorIframe = ({ visible, onClose, file, onSave }) => {
|
|
|
25402
25401
|
try {
|
|
25403
25402
|
const base64Data = imageData.split(',')[1];
|
|
25404
25403
|
const updatedFile = Object.assign(Object.assign({}, savedFile), { thumbnail: imageData, size: base64Data.length.toString(), date: new Date().toISOString().split('T')[0] });
|
|
25405
|
-
await onSave(updatedFile);
|
|
25404
|
+
const result = await onSave(updatedFile);
|
|
25405
|
+
if (!result) {
|
|
25406
|
+
throw new Error();
|
|
25407
|
+
}
|
|
25406
25408
|
message.success('Изображение успешно сохранено');
|
|
25407
25409
|
onClose();
|
|
25410
|
+
(_b = options.onEditorOk) === null || _b === void 0 ? void 0 : _b.call(options, result);
|
|
25408
25411
|
}
|
|
25409
25412
|
catch (error) {
|
|
25410
25413
|
console.error('Ошибка сохранения:', error);
|
|
@@ -27001,7 +27004,7 @@ const FileManagerContent = () => {
|
|
|
27001
27004
|
left: `${sidebarResize.resizeGuidePosition}px`,
|
|
27002
27005
|
} })), jsx(ActionsHeader, { selectedFiles: selectedFiles || new Set(), onClearSelection: fileActions.handleClearSelection, onRename: fileActions.handleRename, onDelete: fileActions.handleDeleteSelected, onCopy: fileActions.handleCopy, onMove: fileActions.handleMove, onEdit: fileActions.handleEdit, files: files || [] }), jsx(Divider, { className: "zero-divider" }), jsxs(Layout, { className: "file-manager__content", children: [jsxs(Sider, { width: sidebarResize.sidebarWidth, theme: "light", className: "file-manager-sider", children: [jsx(FolderSidebar, { ref: folderSidebarRef, selectedFolder: selectedFolder || null, generateMenuItems: generateMenuItems, onFolderSelect: (folderId) => handleFolderSelect === null || handleFolderSelect === void 0 ? void 0 : handleFolderSelect(folderId), folders: folders || [], fetchFolders: fetchFolders, handleAddFile: handleAddFileWithRefresh, setIsUrlModalVisible: (visible) => setIsUrlModalVisible === null || setIsUrlModalVisible === void 0 ? void 0 : setIsUrlModalVisible(visible), handleDeleteFolder: handleDeleteFolderWithRefresh, handleCreateFolder: handleCreateFolder, activeLibraryItem: activeLibraryItem, setActiveLibraryItem: (item) => setActiveLibraryItem === null || setActiveLibraryItem === void 0 ? void 0 : setActiveLibraryItem(item) }), jsx("div", { className: `sidebar-resizer ${sidebarResize.isResizing ? 'resizing' : ''}`, onMouseDown: sidebarResize.handleResizeStart, onDoubleClick: sidebarResize.handleDoubleClick, children: jsx("div", { className: "sidebar-resizer-indicator" }) })] }), jsx(Layout, { className: "", children: jsxs(Content, { className: "main-content", ref: aiTabRef, children: [activeLibraryItem === MY_FILES && (jsx(FileContent, { searchTerm: searchTerm, sortField: state.sortField || 'name', setSortField: (field) => setSortField === null || setSortField === void 0 ? void 0 : setSortField(field), pathHistory: pathHistory || [], handleBreadcrumbClick: (index) => handleBreadcrumbClick === null || handleBreadcrumbClick === void 0 ? void 0 : handleBreadcrumbClick(index), handleAddFile: handleAddFileWithRefresh, setIsUrlModalVisible: (visible) => setIsUrlModalVisible === null || setIsUrlModalVisible === void 0 ? void 0 : setIsUrlModalVisible(visible), files: files || [], handleSearch: handleSearch, handleSort: handleSort, sortBy: sortBy, sortOrder: sortOrder, handleSortOptionChange: handleSortOptionChange, pagination: pagination, setPagination: handlePaginationChangeWrap, loading: loading, handleItemClick: (record) => handleItemClick === null || handleItemClick === void 0 ? void 0 : handleItemClick(record), handleDeleteFile: handleDeleteFileWithRefresh, selectedFiles: selectedFiles || new Set(), toggleFileSelection: (fileId) => toggleFileSelection === null || toggleFileSelection === void 0 ? void 0 : toggleFileSelection(fileId), handleDroppedFiles: handleDroppedFilesWithRefresh, fileUpload: fileUpload })), activeLibraryItem === GIF && (jsx(ImageGif, { imageGifList: imageGifList, setImageGifList: setImageGifList, currentReqGif: currentReqGif, setCurrentReqGif: setCurrentReqGif, inputRef: inputGifRef, customRequest: handleAddFileByUrl })), activeLibraryItem === STOCK_IMAGES && (jsx(ImageStock, { imageStockList: imageStockList, setImageStockList: setImageStockList, currentReq: currentReq, setCurrentReq: setCurrentReq, inputRef: inputStockRef, customRequest: handleAddFileByUrl })), activeLibraryItem === AI && !!(config === null || config === void 0 ? void 0 : config.sseQuery) && (jsx(ImageAI, { imageAiList: imageAiList, setImageAiList: setImageAiList, aiImageRequest: aiImageRequest, setAiImageRequest: setAiImageRequest, inputAiRef: inputAiRef, customRequest: (args) => uploadFileWithProvider(args.file), isLoadingAi: isLoadingAi, setIsLoadingAi: setIsLoadingAi, isImageUploaded: isImageUploaded, setIsImageUploaded: setIsImageUploaded, aiTabRef: aiTabRef })), activeLibraryItem === EDITOR && jsx(Fragment, {})] }) })] }), jsx(FileModals, { isModalVisible: isModalVisible, handleModalOk: handleModalOk, handleModalCancel: handleModalCancel, form: form, selectedFolder: selectedFolder || null, folders: folders || [], isUrlModalVisible: isUrlModalVisible, setIsUrlModalVisible: (visible) => setIsUrlModalVisible === null || setIsUrlModalVisible === void 0 ? void 0 : setIsUrlModalVisible(visible), handleAddFileByUrl: handleAddFileByUrlWithRefresh, urlForm: urlForm, isRenameModalVisible: isRenamingFile, handleRenameOk: () => handleRenameOk === null || handleRenameOk === void 0 ? void 0 : handleRenameOk(), handleRenameCancel: () => handleRenameCancel === null || handleRenameCancel === void 0 ? void 0 : handleRenameCancel(), renameForm: renameForm, fileToRename: fileToRename, files: files || [], isMoveModalVisible: isMoveModalVisible, handleMoveOk: handleMoveOk, handleMoveCancel: handleMoveCancel, moveForm: moveForm, selectedFiles: selectedFiles || new Set(), isRenameFolderModalVisible: isRenameFolderModalVisible, handleRenameFolderOk: handleRenameFolderOk, handleRenameFolderCancel: handleRenameFolderCancel, renameFolderForm: renameFolderForm, folderToRename: folderToRename, isCopyModalVisible: isCopyModalVisible, handleCopyOk: filesHook.actions.handleCopyOk || (() => Promise.resolve()), handleCopyCancel: filesHook.actions.handleCopyCancel || (() => { }), copyForm: copyForm }), jsx(PixieEditorIframe, { visible: pixieEditor.isPixieEditorVisible, onClose: pixieEditor.handlePixieEditorClose, file: pixieEditor.editingFile, onSave: pixieEditor.handlePixieEditorSave }), jsx(UploadProgress, { files: fileUpload.uploadFiles, visible: fileUpload.isUploadVisible, minimized: fileUpload.isUploadMinimized, totalFiles: fileUpload.totalFiles, completedFiles: fileUpload.completedFiles, onClose: fileUpload.closeUpload, onMinimize: fileUpload.minimizeUpload, onInsert: fileUpload.insertFile })] }));
|
|
27003
27006
|
};
|
|
27004
|
-
const FileManagerApp = memo(({ config = {}, onPathChange, onChangeSelection, searchQuery = '', sortBySize = 'name', apiEndpoints = {}, customIcons, dragDropIcon, dataProviders, publicPath, notification }) => {
|
|
27007
|
+
const FileManagerApp = memo(({ config = {}, onPathChange, onChangeSelection, onEditorOk, searchQuery = '', sortBySize = 'name', apiEndpoints = {}, customIcons, dragDropIcon, dataProviders, publicPath, notification }) => {
|
|
27005
27008
|
React__default.useEffect(() => {
|
|
27006
27009
|
if (config.theme) {
|
|
27007
27010
|
setTheme(config.theme);
|
|
@@ -27029,6 +27032,7 @@ const FileManagerApp = memo(({ config = {}, onPathChange, onChangeSelection, sea
|
|
|
27029
27032
|
sortBySize,
|
|
27030
27033
|
onPathChange,
|
|
27031
27034
|
onChangeSelection,
|
|
27035
|
+
onEditorOk,
|
|
27032
27036
|
config,
|
|
27033
27037
|
customIcons,
|
|
27034
27038
|
dragDropIcon,
|