1 | import { Plugin } from '@ckeditor/ckeditor5-core';
|
2 | import FileRepository, {
|
3 | FileLoader,
|
4 | UploadAdapter as IUploadAdapter,
|
5 | } from '@ckeditor/ckeditor5-upload/src/filerepository';
|
6 | import { Locale } from '@ckeditor/ckeditor5-utils';
|
7 | /**
|
8 | * A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
|
9 | *
|
10 | * See the {@glink features/images/image-upload/ckfinder "CKFinder file manager integration" guide} to learn how to configure
|
11 | * and use this feature as well as find out more about the full integration with the file manager
|
12 | * provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
|
13 | *
|
14 | * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} to learn about
|
15 | * other ways to upload images into CKEditor 5.
|
16 | */
|
17 | export default class CKFinderUploadAdapter extends Plugin {
|
18 | static readonly requires: [typeof FileRepository];
|
19 | static readonly pluginName: 'CKFinderUploadAdapter';
|
20 | init(): void;
|
21 | }
|
22 | /**
|
23 | * Upload adapter for CKFinder.
|
24 | */
|
25 | export class UploadAdapter implements IUploadAdapter {
|
26 | /**
|
27 | * FileLoader instance to use during the upload.
|
28 | */
|
29 | readonly loader: FileLoader;
|
30 | /**
|
31 | * Upload URL.
|
32 | */
|
33 | readonly url: string;
|
34 | /**
|
35 | * Locale translation method.
|
36 | */
|
37 | readonly t: Locale['t'];
|
38 | protected xhr?: XMLHttpRequest;
|
39 | /**
|
40 | * Creates a new adapter instance.
|
41 | */
|
42 | constructor(loader: FileLoader, url: string, t: Locale['t']);
|
43 | /**
|
44 | * Starts the upload process.
|
45 | */
|
46 | upload(): Promise<{
|
47 | default: string;
|
48 | }>;
|
49 | /**
|
50 | * Aborts the upload process.
|
51 | */
|
52 | abort(): void;
|
53 | /**
|
54 | * Initializes the XMLHttpRequest object.
|
55 | */
|
56 | private _initRequest(): void;
|
57 | /**
|
58 | * Initializes XMLHttpRequest listeners.
|
59 | */
|
60 | private _initListeners(
|
61 | resolve: (value: { default: string }) => void,
|
62 | reject: (reason?: unknown) => void,
|
63 | file: File,
|
64 | ): void;
|
65 | /**
|
66 | * Prepares the data and sends the request.
|
67 | */
|
68 | private _sendRequest(file: File): void;
|
69 | }
|
70 |
|
71 | declare module '@ckeditor/ckeditor5-core/src/plugincollection' {
|
72 | interface Plugins {
|
73 | CKFinderUploadAdapter: CKFinderUploadAdapter;
|
74 | }
|
75 | }
|