@emailmaker/filemanager 0.0.5 → 0.0.7
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/app/themeProvider/ThemeProvider.d.ts +4 -2
- package/components/EmIcons/EmIcons.d.ts +2 -0
- package/components/FileManagerApp/FileManagerApp.d.ts +2 -2
- package/components/PixieEditor/{PixieEditorIframe.d.ts → PixieEditor.d.ts} +3 -3
- package/components/PixieEditor/index.d.ts +1 -1
- package/file-manager.css +629 -710
- package/file-manager.d.ts +23 -1
- package/file-manager.esm.js +85 -27100
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- package/file-manager.js.LICENSE.txt +87 -0
- package/hooks/useNotifications.d.ts +2 -2
- package/hooks/usePixieEditor.d.ts +1 -1
- package/mockServiceWorker.js +1 -1
- package/package.json +1 -1
- package/types.d.ts +16 -28
- package/utils/jsonDataProvider.d.ts +10 -0
- package/utils/themeUtils.d.ts +4 -13
- package/pixie-editor.html +0 -187
|
@@ -19,6 +19,8 @@ See the Apache Version 2.0 License for specific language governing permissions
|
|
|
19
19
|
and limitations under the License.
|
|
20
20
|
***************************************************************************** */
|
|
21
21
|
|
|
22
|
+
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
|
23
|
+
|
|
22
24
|
/**
|
|
23
25
|
* @license
|
|
24
26
|
* Lodash <https://lodash.com/>
|
|
@@ -58,6 +60,16 @@ and limitations under the License.
|
|
|
58
60
|
* LICENSE file in the root directory of this source tree.
|
|
59
61
|
*/
|
|
60
62
|
|
|
63
|
+
/**
|
|
64
|
+
* @license React
|
|
65
|
+
* react-jsx-runtime.production.min.js
|
|
66
|
+
*
|
|
67
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the MIT license found in the
|
|
70
|
+
* LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/
|
|
72
|
+
|
|
61
73
|
/**
|
|
62
74
|
* @license React
|
|
63
75
|
* scheduler.production.js
|
|
@@ -68,6 +80,81 @@ and limitations under the License.
|
|
|
68
80
|
* LICENSE file in the root directory of this source tree.
|
|
69
81
|
*/
|
|
70
82
|
|
|
83
|
+
/**
|
|
84
|
+
* @license React
|
|
85
|
+
* use-sync-external-store-shim.production.min.js
|
|
86
|
+
*
|
|
87
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the MIT license found in the
|
|
90
|
+
* LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @license React
|
|
95
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
96
|
+
*
|
|
97
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the MIT license found in the
|
|
100
|
+
* LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @remix-run/router v1.0.1
|
|
105
|
+
*
|
|
106
|
+
* Copyright (c) Remix Software Inc.
|
|
107
|
+
*
|
|
108
|
+
* This source code is licensed under the MIT license found in the
|
|
109
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
110
|
+
*
|
|
111
|
+
* @license MIT
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* React Router DOM v6.4.1
|
|
116
|
+
*
|
|
117
|
+
* Copyright (c) Remix Software Inc.
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the MIT license found in the
|
|
120
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
121
|
+
*
|
|
122
|
+
* @license MIT
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* React Router v6.4.1
|
|
127
|
+
*
|
|
128
|
+
* Copyright (c) Remix Software Inc.
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the MIT license found in the
|
|
131
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
132
|
+
*
|
|
133
|
+
* @license MIT
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* react-virtual
|
|
138
|
+
*
|
|
139
|
+
* Copyright (c) TanStack
|
|
140
|
+
*
|
|
141
|
+
* This source code is licensed under the MIT license found in the
|
|
142
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
143
|
+
*
|
|
144
|
+
* @license MIT
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* virtual-core
|
|
149
|
+
*
|
|
150
|
+
* Copyright (c) TanStack
|
|
151
|
+
*
|
|
152
|
+
* This source code is licensed under the MIT license found in the
|
|
153
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
154
|
+
*
|
|
155
|
+
* @license MIT
|
|
156
|
+
*/
|
|
157
|
+
|
|
71
158
|
/** */
|
|
72
159
|
|
|
73
160
|
/** */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const useNotifications: () => {
|
|
2
|
-
error: (args: import("antd").NotificationArgsProps) => void;
|
|
3
|
-
open: (args: import("antd").NotificationArgsProps) => void;
|
|
4
2
|
success: (args: import("antd").NotificationArgsProps) => void;
|
|
3
|
+
error: (args: import("antd").NotificationArgsProps) => void;
|
|
5
4
|
info: (args: import("antd").NotificationArgsProps) => void;
|
|
6
5
|
warning: (args: import("antd").NotificationArgsProps) => void;
|
|
6
|
+
open: (args: import("antd").NotificationArgsProps) => void;
|
|
7
7
|
destroy(key?: React.Key): void;
|
|
8
8
|
};
|
|
@@ -9,7 +9,7 @@ export declare const usePixieEditor: ({ files, selectedFiles, fetchFiles, select
|
|
|
9
9
|
isPixieEditorVisible: boolean;
|
|
10
10
|
editingFile: ThumbnailFile | AppFile | null;
|
|
11
11
|
handleEdit: (fileForEdit?: ThumbnailFile | AppFile) => void;
|
|
12
|
-
handlePixieEditorSave: (updatedFile: AppFile) => Promise<
|
|
12
|
+
handlePixieEditorSave: (updatedFile: AppFile) => Promise<AppFile | undefined>;
|
|
13
13
|
handlePixieEditorClose: () => void;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
package/mockServiceWorker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const PACKAGE_VERSION="2.10.
|
|
1
|
+
const PACKAGE_VERSION="2.10.5",INTEGRITY_CHECKSUM="f5825c521429caf22a4dd13b66e243af",IS_MOCKED_RESPONSE=Symbol("isMockedResponse"),activeClientIds=new Set;async function handleRequest(e,t){const n=await resolveMainClient(e),s=e.request.clone(),i=await getResponse(e,n,t);if(n&&activeClientIds.has(n.id)){const e=await serializeRequest(s),a=i.clone();sendToClient(n,{type:"RESPONSE",payload:{isMockedResponse:IS_MOCKED_RESPONSE in i,request:{id:t,...e},response:{type:a.type,status:a.status,statusText:a.statusText,headers:Object.fromEntries(a.headers.entries()),body:a.body}}},a.body?[e.body,a.body]:[])}return i}async function resolveMainClient(e){const t=await self.clients.get(e.clientId);return activeClientIds.has(e.clientId)||"top-level"===t?.frameType?t:(await self.clients.matchAll({type:"window"})).filter(e=>"visible"===e.visibilityState).find(e=>activeClientIds.has(e.id))}async function getResponse(e,t,n){const s=e.request.clone();function i(){const e=new Headers(s.headers),t=e.get("accept");if(t){const n=t.split(",").map(e=>e.trim()).filter(e=>"msw/passthrough"!==e);n.length>0?e.set("accept",n.join(", ")):e.delete("accept")}return fetch(s,{headers:e})}if(!t)return i();if(!activeClientIds.has(t.id))return i();const a=await serializeRequest(e.request),r=await sendToClient(t,{type:"REQUEST",payload:{id:n,...a}},[a.body]);switch(r.type){case"MOCK_RESPONSE":return respondWithMock(r.data);case"PASSTHROUGH":return i()}return i()}function sendToClient(e,t,n=[]){return new Promise((s,i)=>{const a=new MessageChannel;a.port1.onmessage=e=>{if(e.data&&e.data.error)return i(e.data.error);s(e.data)},e.postMessage(t,[a.port2,...n.filter(Boolean)])})}function respondWithMock(e){if(0===e.status)return Response.error();const t=new Response(e.body,e);return Reflect.defineProperty(t,IS_MOCKED_RESPONSE,{value:!0,enumerable:!0}),t}async function serializeRequest(e){return{url:e.url,mode:e.mode,method:e.method,headers:Object.fromEntries(e.headers.entries()),cache:e.cache,credentials:e.credentials,destination:e.destination,integrity:e.integrity,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,body:await e.arrayBuffer(),keepalive:e.keepalive}}addEventListener("install",function(){self.skipWaiting()}),addEventListener("activate",function(e){e.waitUntil(self.clients.claim())}),addEventListener("message",async function(e){const t=Reflect.get(e.source||{},"id");if(!t||!self.clients)return;const n=await self.clients.get(t);if(!n)return;const s=await self.clients.matchAll({type:"window"});switch(e.data){case"KEEPALIVE_REQUEST":sendToClient(n,{type:"KEEPALIVE_RESPONSE"});break;case"INTEGRITY_CHECK_REQUEST":sendToClient(n,{type:"INTEGRITY_CHECK_RESPONSE",payload:{packageVersion:"2.10.5",checksum:INTEGRITY_CHECKSUM}});break;case"MOCK_ACTIVATE":activeClientIds.add(t),sendToClient(n,{type:"MOCKING_ENABLED",payload:{client:{id:n.id,frameType:n.frameType}}});break;case"MOCK_DEACTIVATE":activeClientIds.delete(t);break;case"CLIENT_CLOSED":{activeClientIds.delete(t);const e=s.filter(e=>e.id!==t);0===e.length&&self.registration.unregister();break}}}),addEventListener("fetch",function(e){if("navigate"===e.request.mode)return;if("only-if-cached"===e.request.cache&&"same-origin"!==e.request.mode)return;if(0===activeClientIds.size)return;const t=crypto.randomUUID();e.respondWith(handleRequest(e,t))});
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -117,6 +117,7 @@ export interface FileManagerOptions {
|
|
|
117
117
|
sortBySize?: string;
|
|
118
118
|
onPathChange?: (path: string[]) => void;
|
|
119
119
|
onChangeSelection?: (files: File[]) => void;
|
|
120
|
+
onEditorOk?: (file: File) => void;
|
|
120
121
|
config?: Config;
|
|
121
122
|
publicPath?: string;
|
|
122
123
|
customIcons?: CustomIcons;
|
|
@@ -141,6 +142,7 @@ export interface FileManagerDataProviders {
|
|
|
141
142
|
name: string;
|
|
142
143
|
parentId?: string | null;
|
|
143
144
|
}) => Promise<Folder>;
|
|
145
|
+
renameFolder?: (folderId: string, newName: string) => Promise<Folder>;
|
|
144
146
|
deleteFolder?: (folderId: string) => Promise<boolean>;
|
|
145
147
|
uploadFile: (file: {
|
|
146
148
|
name: string;
|
|
@@ -165,6 +167,15 @@ export interface FileManagerDataProviders {
|
|
|
165
167
|
targetFolderId: string;
|
|
166
168
|
isFolder: boolean;
|
|
167
169
|
}) => Promise<boolean>;
|
|
170
|
+
updateFile?: (fileId: string, updates: {
|
|
171
|
+
name?: string;
|
|
172
|
+
type?: string;
|
|
173
|
+
data?: Blob | string;
|
|
174
|
+
thumbnail?: string;
|
|
175
|
+
dimensions?: string;
|
|
176
|
+
aspectRatio?: string;
|
|
177
|
+
extension?: string;
|
|
178
|
+
}) => Promise<File>;
|
|
168
179
|
}
|
|
169
180
|
export interface FileManagerHookReturn {
|
|
170
181
|
folders: Folder[];
|
|
@@ -225,6 +236,9 @@ interface Limits {
|
|
|
225
236
|
ai_img_limit?: number;
|
|
226
237
|
ai_generator_limit?: number;
|
|
227
238
|
}
|
|
239
|
+
export type CustomTheme = Partial<import('antd/es/theme/interface').AliasToken> & {
|
|
240
|
+
[key: string]: string | number | boolean | undefined;
|
|
241
|
+
};
|
|
228
242
|
export interface Config {
|
|
229
243
|
theme?: 'light' | 'dark';
|
|
230
244
|
disableMockServer?: boolean;
|
|
@@ -241,33 +255,7 @@ export interface Config {
|
|
|
241
255
|
files?: File[];
|
|
242
256
|
folders?: Folder[];
|
|
243
257
|
};
|
|
244
|
-
customTheme?:
|
|
245
|
-
colors?: {
|
|
246
|
-
primary?: string;
|
|
247
|
-
secondary?: string;
|
|
248
|
-
success?: string;
|
|
249
|
-
warning?: string;
|
|
250
|
-
error?: string;
|
|
251
|
-
info?: string;
|
|
252
|
-
textPrimary?: string;
|
|
253
|
-
textSecondary?: string;
|
|
254
|
-
textTertiary?: string;
|
|
255
|
-
bgPrimary?: string;
|
|
256
|
-
bgSecondary?: string;
|
|
257
|
-
bgTertiary?: string;
|
|
258
|
-
borderPrimary?: string;
|
|
259
|
-
borderSecondary?: string;
|
|
260
|
-
};
|
|
261
|
-
borderRadius?: {
|
|
262
|
-
none?: string;
|
|
263
|
-
xs?: string;
|
|
264
|
-
sm?: string;
|
|
265
|
-
md?: string;
|
|
266
|
-
lg?: string;
|
|
267
|
-
xl?: string;
|
|
268
|
-
full?: string;
|
|
269
|
-
};
|
|
270
|
-
};
|
|
258
|
+
customTheme?: CustomTheme;
|
|
271
259
|
UNSPLASH_KEY?: string;
|
|
272
260
|
APP_NAME_UNSPLASH?: string;
|
|
273
261
|
pushToGTM?: boolean;
|
|
@@ -289,7 +277,6 @@ export interface Config {
|
|
|
289
277
|
handleLimitUsageEmitter?: {
|
|
290
278
|
fire: (args: object) => void;
|
|
291
279
|
};
|
|
292
|
-
token?: Partial<import('antd/es/theme/interface').AliasToken>;
|
|
293
280
|
}
|
|
294
281
|
export type LibraryMenuKey = typeof MY_FILES | typeof GIF | typeof STOCK_IMAGES | typeof AI | typeof EDITOR;
|
|
295
282
|
export interface GifItem {
|
|
@@ -411,6 +398,7 @@ export interface FileManagerProps {
|
|
|
411
398
|
currentPath?: string;
|
|
412
399
|
onPathChange?: (path: string[]) => void;
|
|
413
400
|
onChangeSelection?: (files: File[]) => void;
|
|
401
|
+
onEditorOk?: (files: File) => void;
|
|
414
402
|
searchQuery?: string;
|
|
415
403
|
sortBySize?: string;
|
|
416
404
|
dataProviders?: FileManagerDataProviders;
|
|
@@ -25,6 +25,7 @@ export declare class JSONDataProvider implements FileManagerDataProviders {
|
|
|
25
25
|
name: string;
|
|
26
26
|
parentId?: string | null;
|
|
27
27
|
}) => Promise<Folder>;
|
|
28
|
+
renameFolder: (folderId: string, newName: string) => Promise<Folder>;
|
|
28
29
|
deleteFolder: (folderId: string) => Promise<boolean>;
|
|
29
30
|
uploadFile: (file: {
|
|
30
31
|
name: string;
|
|
@@ -42,6 +43,15 @@ export declare class JSONDataProvider implements FileManagerDataProviders {
|
|
|
42
43
|
folderId?: string | null;
|
|
43
44
|
noFolder?: boolean;
|
|
44
45
|
}) => Promise<File>;
|
|
46
|
+
updateFile: (fileId: string, updates: {
|
|
47
|
+
name?: string;
|
|
48
|
+
type?: string;
|
|
49
|
+
data?: Blob | string;
|
|
50
|
+
thumbnail?: string;
|
|
51
|
+
dimensions?: string;
|
|
52
|
+
aspectRatio?: string;
|
|
53
|
+
extension?: string;
|
|
54
|
+
}) => Promise<File>;
|
|
45
55
|
deleteFile: (fileId: string) => Promise<boolean>;
|
|
46
56
|
renameFile: (fileId: string, newName: string) => Promise<File>;
|
|
47
57
|
moveItem: (options: {
|
package/utils/themeUtils.d.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { Config } from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
2
|
+
export declare const switchThemeVariables: (token?: {}) => void;
|
|
3
|
+
/** Применяет кастомную тему к CSS переменным */
|
|
5
4
|
export declare const applyCustomTheme: (config?: Config) => void;
|
|
6
|
-
/**
|
|
7
|
-
* Сбрасывает кастомную тему к значениям по умолчанию
|
|
8
|
-
*/
|
|
9
|
-
export declare const resetCustomTheme: () => void;
|
|
10
|
-
/**
|
|
11
|
-
* Устанавливает тему (светлая/темная)
|
|
12
|
-
*/
|
|
5
|
+
/** Устанавливает тему (светлая/темная) */
|
|
13
6
|
export declare const setTheme: (theme: "light" | "dark") => void;
|
|
14
|
-
/**
|
|
15
|
-
* Получает текущую тему
|
|
16
|
-
*/
|
|
7
|
+
/** Получает текущую тему */
|
|
17
8
|
export declare const getCurrentTheme: () => "light" | "dark";
|
package/pixie-editor.html
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="ru">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Pixie Editor</title>
|
|
7
|
-
<style>
|
|
8
|
-
* {
|
|
9
|
-
margin: 0;
|
|
10
|
-
padding: 0;
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
16
|
-
background: #f5f5f5;
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
#pixie-editor {
|
|
21
|
-
width: 100vw;
|
|
22
|
-
height: 100vh;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.loading {
|
|
26
|
-
position: fixed;
|
|
27
|
-
top: 50%;
|
|
28
|
-
left: 50%;
|
|
29
|
-
transform: translate(-50%, -50%);
|
|
30
|
-
background: white;
|
|
31
|
-
padding: 20px;
|
|
32
|
-
border-radius: 8px;
|
|
33
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
34
|
-
z-index: 1000;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.toolbar {
|
|
38
|
-
position: fixed;
|
|
39
|
-
bottom: 10px;
|
|
40
|
-
right: 10px;
|
|
41
|
-
z-index: 1001;
|
|
42
|
-
display: flex;
|
|
43
|
-
gap: 10px;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.toolbar button {
|
|
47
|
-
padding: 8px 16px;
|
|
48
|
-
border: none;
|
|
49
|
-
border-radius: 4px;
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
font-size: 14px;
|
|
52
|
-
font-weight: 500;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.btn-save {
|
|
56
|
-
background: #1890ff;
|
|
57
|
-
color: white;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.btn-save:hover {
|
|
61
|
-
background: #40a9ff;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.btn-cancel {
|
|
65
|
-
background: #f5f5f5;
|
|
66
|
-
color: #595959;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.btn-cancel:hover {
|
|
70
|
-
background: #e6f7ff;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.btn-save:disabled {
|
|
74
|
-
background: #d9d9d9;
|
|
75
|
-
cursor: not-allowed;
|
|
76
|
-
}
|
|
77
|
-
</style>
|
|
78
|
-
</head>
|
|
79
|
-
<body>
|
|
80
|
-
<div id="loading" class="loading">
|
|
81
|
-
<div>Загрузка редактора...</div>
|
|
82
|
-
</div>
|
|
83
|
-
|
|
84
|
-
<div class="toolbar">
|
|
85
|
-
<button id="saveBtn" class="btn-save" disabled>Сохранить</button>
|
|
86
|
-
<button id="cancelBtn" class="btn-cancel">Отмена</button>
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
<div id="pixie-editor"></div>
|
|
90
|
-
|
|
91
|
-
<script src="loacal_module/pixie/dist/pixie.umd.js"></script>
|
|
92
|
-
<script>
|
|
93
|
-
let pixieInstance = null;
|
|
94
|
-
let currentFile = null;
|
|
95
|
-
|
|
96
|
-
function initPixie(imageData, fileName) {
|
|
97
|
-
try {
|
|
98
|
-
console.log('Инициализация Pixie для файла:', fileName);
|
|
99
|
-
|
|
100
|
-
const config = {
|
|
101
|
-
selector: '#pixie-editor',
|
|
102
|
-
image: imageData,
|
|
103
|
-
baseUrl: "/loacal_module/pixie/assets",
|
|
104
|
-
ui: {
|
|
105
|
-
visible: true,
|
|
106
|
-
mode: 'inline',
|
|
107
|
-
toolbar: {
|
|
108
|
-
items: ['crop', 'resize', 'filter', 'draw', 'text', 'shapes', 'frame']
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
crossOrigin: true
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
if (window.Pixie) {
|
|
115
|
-
pixieInstance = new window.Pixie(config);
|
|
116
|
-
|
|
117
|
-
setTimeout(() => {
|
|
118
|
-
document.getElementById('loading').style.display = 'none';
|
|
119
|
-
document.getElementById('saveBtn').disabled = false;
|
|
120
|
-
console.log('Pixie успешно инициализирован');
|
|
121
|
-
}, 1000);
|
|
122
|
-
} else {
|
|
123
|
-
throw new Error('Pixie не загружен');
|
|
124
|
-
}
|
|
125
|
-
} catch (error) {
|
|
126
|
-
console.error('Ошибка инициализации Pixie:', error);
|
|
127
|
-
document.getElementById('loading').innerHTML = '<div>Ошибка загрузки: ' + error.message + '</div>';
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
document.getElementById('saveBtn').addEventListener('click', async () => {
|
|
131
|
-
if (!pixieInstance || !currentFile) return;
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
document.getElementById('saveBtn').disabled = true;
|
|
135
|
-
document.getElementById('saveBtn').textContent = 'Сохранение...';
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const dataUrl = await pixieInstance.tools.export.getDataUrl("png", 0.9);
|
|
139
|
-
window.parent.postMessage({
|
|
140
|
-
type: 'PIXIE_SAVE',
|
|
141
|
-
data: {
|
|
142
|
-
file: currentFile,
|
|
143
|
-
imageData: dataUrl
|
|
144
|
-
}
|
|
145
|
-
}, '*');
|
|
146
|
-
|
|
147
|
-
} catch (error) {
|
|
148
|
-
console.error('Ошибка сохранения:', error);
|
|
149
|
-
alert('Ошибка при сохранении изображения');
|
|
150
|
-
document.getElementById('saveBtn').disabled = false;
|
|
151
|
-
document.getElementById('saveBtn').textContent = 'Сохранить';
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
document.getElementById('cancelBtn').addEventListener('click', () => {
|
|
156
|
-
window.parent.postMessage({
|
|
157
|
-
type: 'PIXIE_CANCEL'
|
|
158
|
-
}, '*');
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
window.addEventListener('message', (event) => {
|
|
162
|
-
if (event.data.type === 'INIT_PIXIE') {
|
|
163
|
-
currentFile = event.data.file;
|
|
164
|
-
const imageData = event.data.imageData;
|
|
165
|
-
initPixie(imageData, currentFile.name);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
window.addEventListener('load', () => {
|
|
170
|
-
window.parent.postMessage({
|
|
171
|
-
type: 'PIXIE_READY'
|
|
172
|
-
}, '*');
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
window.addEventListener('beforeunload', () => {
|
|
176
|
-
if (pixieInstance) {
|
|
177
|
-
try {
|
|
178
|
-
pixieInstance.close?.();
|
|
179
|
-
pixieInstance.destroy?.();
|
|
180
|
-
} catch (error) {
|
|
181
|
-
console.warn('Ошибка при закрытии Pixie:', error);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
</script>
|
|
186
|
-
</body>
|
|
187
|
-
</html>
|