@ckeditor/ckeditor5-ckfinder 0.0.0-internal-20241017.0
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/CHANGELOG.md +4 -0
- package/LICENSE.md +17 -0
- package/README.md +24 -0
- package/build/ckfinder.js +5 -0
- package/build/translations/af.js +1 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/az.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/bs.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/en-gb.js +1 -0
- package/build/translations/es-co.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/jv.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/ku.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/ne.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sl.js +1 -0
- package/build/translations/sq.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/ckeditor5-metadata.json +26 -0
- package/dist/augmentation.d.ts +26 -0
- package/dist/ckfinder.d.ts +44 -0
- package/dist/ckfindercommand.d.ts +40 -0
- package/dist/ckfinderconfig.d.ts +77 -0
- package/dist/ckfinderediting.d.ts +34 -0
- package/dist/ckfinderui.d.ts +60 -0
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +4 -0
- package/dist/index.css +4 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +321 -0
- package/dist/index.js.map +1 -0
- package/dist/translations/af.d.ts +8 -0
- package/dist/translations/af.js +5 -0
- package/dist/translations/af.umd.js +11 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/az.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/bs.d.ts +8 -0
- package/dist/translations/bs.js +5 -0
- package/dist/translations/bs.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de-ch.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en-gb.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +5 -0
- package/dist/translations/es-co.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fa.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/jv.d.ts +8 -0
- package/dist/translations/jv.js +5 -0
- package/dist/translations/jv.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/ku.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/ne.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sl.d.ts +8 -0
- package/dist/translations/sl.js +5 -0
- package/dist/translations/sl.umd.js +11 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sq.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tk.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/ug.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +5 -0
- package/dist/translations/uz.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -0
- package/lang/contexts.json +7 -0
- package/lang/translations/af.po +38 -0
- package/lang/translations/ar.po +38 -0
- package/lang/translations/az.po +38 -0
- package/lang/translations/bg.po +38 -0
- package/lang/translations/bn.po +38 -0
- package/lang/translations/bs.po +38 -0
- package/lang/translations/ca.po +38 -0
- package/lang/translations/cs.po +38 -0
- package/lang/translations/da.po +38 -0
- package/lang/translations/de-ch.po +38 -0
- package/lang/translations/de.po +38 -0
- package/lang/translations/el.po +38 -0
- package/lang/translations/en-au.po +38 -0
- package/lang/translations/en-gb.po +38 -0
- package/lang/translations/en.po +38 -0
- package/lang/translations/es-co.po +38 -0
- package/lang/translations/es.po +38 -0
- package/lang/translations/et.po +38 -0
- package/lang/translations/fa.po +38 -0
- package/lang/translations/fi.po +38 -0
- package/lang/translations/fr.po +38 -0
- package/lang/translations/gl.po +38 -0
- package/lang/translations/he.po +38 -0
- package/lang/translations/hi.po +38 -0
- package/lang/translations/hr.po +38 -0
- package/lang/translations/hu.po +38 -0
- package/lang/translations/id.po +38 -0
- package/lang/translations/it.po +38 -0
- package/lang/translations/ja.po +38 -0
- package/lang/translations/jv.po +38 -0
- package/lang/translations/ko.po +38 -0
- package/lang/translations/ku.po +38 -0
- package/lang/translations/lt.po +38 -0
- package/lang/translations/lv.po +38 -0
- package/lang/translations/ms.po +38 -0
- package/lang/translations/ne.po +38 -0
- package/lang/translations/nl.po +38 -0
- package/lang/translations/no.po +38 -0
- package/lang/translations/pl.po +38 -0
- package/lang/translations/pt-br.po +38 -0
- package/lang/translations/pt.po +38 -0
- package/lang/translations/ro.po +38 -0
- package/lang/translations/ru.po +38 -0
- package/lang/translations/sk.po +38 -0
- package/lang/translations/sl.po +38 -0
- package/lang/translations/sq.po +38 -0
- package/lang/translations/sr-latn.po +38 -0
- package/lang/translations/sr.po +38 -0
- package/lang/translations/sv.po +38 -0
- package/lang/translations/th.po +38 -0
- package/lang/translations/tk.po +38 -0
- package/lang/translations/tr.po +38 -0
- package/lang/translations/ug.po +38 -0
- package/lang/translations/uk.po +38 -0
- package/lang/translations/ur.po +38 -0
- package/lang/translations/uz.po +38 -0
- package/lang/translations/vi.po +38 -0
- package/lang/translations/zh-cn.po +38 -0
- package/lang/translations/zh.po +38 -0
- package/package.json +41 -0
- package/src/augmentation.d.ts +22 -0
- package/src/augmentation.js +5 -0
- package/src/ckfinder.d.ts +40 -0
- package/src/ckfinder.js +46 -0
- package/src/ckfindercommand.d.ts +36 -0
- package/src/ckfindercommand.js +122 -0
- package/src/ckfinderconfig.d.ts +73 -0
- package/src/ckfinderconfig.js +5 -0
- package/src/ckfinderediting.d.ts +30 -0
- package/src/ckfinderediting.js +56 -0
- package/src/ckfinderui.d.ts +56 -0
- package/src/ckfinderui.js +132 -0
- package/src/index.d.ts +13 -0
- package/src/index.js +11 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/* global window */
|
|
6
|
+
/**
|
|
7
|
+
* @module ckfinder/ckfindercommand
|
|
8
|
+
*/
|
|
9
|
+
import { Command } from 'ckeditor5/src/core.js';
|
|
10
|
+
import { CKEditorError } from 'ckeditor5/src/utils.js';
|
|
11
|
+
/**
|
|
12
|
+
* The CKFinder command. It is used by the {@link module:ckfinder/ckfinderediting~CKFinderEditing CKFinder editing feature}
|
|
13
|
+
* to open the CKFinder file manager to insert an image or a link to a file into the editor content.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* editor.execute( 'ckfinder' );
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* **Note:** This command uses other features to perform tasks:
|
|
20
|
+
* - To insert images the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command
|
|
21
|
+
* from the {@link module:image/image~Image Image feature}.
|
|
22
|
+
* - To insert links to files the {@link module:link/linkcommand~LinkCommand 'link'} command
|
|
23
|
+
* from the {@link module:link/link~Link Link feature}.
|
|
24
|
+
*/
|
|
25
|
+
export default class CKFinderCommand extends Command {
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
constructor(editor) {
|
|
30
|
+
super(editor);
|
|
31
|
+
// The CKFinder command does not affect data by itself.
|
|
32
|
+
this.affectsData = false;
|
|
33
|
+
// Remove default document listener to lower its priority.
|
|
34
|
+
this.stopListening(this.editor.model.document, 'change');
|
|
35
|
+
// Lower this command listener priority to be sure that refresh() will be called after link & image refresh.
|
|
36
|
+
this.listenTo(this.editor.model.document, 'change', () => this.refresh(), { priority: 'low' });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
refresh() {
|
|
42
|
+
const imageCommand = this.editor.commands.get('insertImage');
|
|
43
|
+
const linkCommand = this.editor.commands.get('link');
|
|
44
|
+
// The CKFinder command is enabled when one of image or link command is enabled.
|
|
45
|
+
this.isEnabled = imageCommand.isEnabled || linkCommand.isEnabled;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
*/
|
|
50
|
+
execute() {
|
|
51
|
+
const editor = this.editor;
|
|
52
|
+
const openerMethod = this.editor.config.get('ckfinder.openerMethod') || 'modal';
|
|
53
|
+
if (openerMethod != 'popup' && openerMethod != 'modal') {
|
|
54
|
+
/**
|
|
55
|
+
* The `ckfinder.openerMethod` must be one of: "popup" or "modal".
|
|
56
|
+
*
|
|
57
|
+
* @error ckfinder-unknown-openermethod
|
|
58
|
+
*/
|
|
59
|
+
throw new CKEditorError('ckfinder-unknown-openermethod', editor);
|
|
60
|
+
}
|
|
61
|
+
const options = this.editor.config.get('ckfinder.options') || {};
|
|
62
|
+
options.chooseFiles = true;
|
|
63
|
+
// Cache the user-defined onInit method
|
|
64
|
+
const originalOnInit = options.onInit;
|
|
65
|
+
// Pass the lang code to the CKFinder if not defined by user.
|
|
66
|
+
if (!options.language) {
|
|
67
|
+
options.language = editor.locale.uiLanguage;
|
|
68
|
+
}
|
|
69
|
+
// The onInit method allows to extend CKFinder's behavior. It is used to attach event listeners to file choosing related events.
|
|
70
|
+
options.onInit = finder => {
|
|
71
|
+
// Call original options.onInit if it was defined by user.
|
|
72
|
+
if (originalOnInit) {
|
|
73
|
+
originalOnInit(finder);
|
|
74
|
+
}
|
|
75
|
+
finder.on('files:choose', (evt) => {
|
|
76
|
+
const files = evt.data.files.toArray();
|
|
77
|
+
// Insert links
|
|
78
|
+
const links = files.filter((file) => !file.isImage());
|
|
79
|
+
const images = files.filter((file) => file.isImage());
|
|
80
|
+
for (const linkFile of links) {
|
|
81
|
+
editor.execute('link', linkFile.getUrl());
|
|
82
|
+
}
|
|
83
|
+
const imagesUrls = [];
|
|
84
|
+
for (const image of images) {
|
|
85
|
+
const url = image.getUrl();
|
|
86
|
+
imagesUrls.push(url ? url : finder.request('file:getProxyUrl', { file: image }));
|
|
87
|
+
}
|
|
88
|
+
if (imagesUrls.length) {
|
|
89
|
+
insertImages(editor, imagesUrls);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
finder.on('file:choose:resizedImage', (evt) => {
|
|
93
|
+
const resizedUrl = evt.data.resizedUrl;
|
|
94
|
+
if (!resizedUrl) {
|
|
95
|
+
const notification = editor.plugins.get('Notification');
|
|
96
|
+
const t = editor.locale.t;
|
|
97
|
+
notification.showWarning(t('Could not obtain resized image URL.'), {
|
|
98
|
+
title: t('Selecting resized image failed'),
|
|
99
|
+
namespace: 'ckfinder'
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
insertImages(editor, [resizedUrl]);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
window.CKFinder[openerMethod](options);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function insertImages(editor, urls) {
|
|
110
|
+
const imageCommand = editor.commands.get('insertImage');
|
|
111
|
+
// Check if inserting an image is actually possible - it might be possible to only insert a link.
|
|
112
|
+
if (!imageCommand.isEnabled) {
|
|
113
|
+
const notification = editor.plugins.get('Notification');
|
|
114
|
+
const t = editor.locale.t;
|
|
115
|
+
notification.showWarning(t('Could not insert image at the current position.'), {
|
|
116
|
+
title: t('Inserting image failed'),
|
|
117
|
+
namespace: 'ckfinder'
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
editor.execute('insertImage', { source: urls });
|
|
122
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ckfinder/ckfinderconfig
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the {@link module:ckfinder/ckfinder~CKFinder CKFinder feature}
|
|
10
|
+
* and its {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter upload adapter}.
|
|
11
|
+
*
|
|
12
|
+
* ```
|
|
13
|
+
* ClassicEditor
|
|
14
|
+
* .create( editorElement, {
|
|
15
|
+
* ckfinder: {
|
|
16
|
+
* options: {
|
|
17
|
+
* resourceType: 'Images'
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* } )
|
|
21
|
+
* .then( ... )
|
|
22
|
+
* .catch( ... );
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
26
|
+
*/
|
|
27
|
+
export interface CKFinderConfig {
|
|
28
|
+
/**
|
|
29
|
+
* The configuration options passed to the CKFinder file manager instance.
|
|
30
|
+
*
|
|
31
|
+
* Check the file manager [documentation](https://ckeditor.com/docs/ckfinder/ckfinder3/#!/api/CKFinder.Config-cfg-language)
|
|
32
|
+
* for the complete list of options.
|
|
33
|
+
*/
|
|
34
|
+
options?: CKFinderOptions;
|
|
35
|
+
/**
|
|
36
|
+
* The type of the CKFinder opener method.
|
|
37
|
+
*
|
|
38
|
+
* Supported types are:
|
|
39
|
+
*
|
|
40
|
+
* * `'modal'` – Opens CKFinder in a modal,
|
|
41
|
+
* * `'popup'` – Opens CKFinder in a new "pop-up" window.
|
|
42
|
+
*
|
|
43
|
+
* Defaults to `'modal'`.
|
|
44
|
+
*/
|
|
45
|
+
openerMethod?: 'modal' | 'popup';
|
|
46
|
+
/**
|
|
47
|
+
* The path (URL) to the connector which handles the file upload in CKFinder file manager.
|
|
48
|
+
* When specified, it enables the automatic upload of resources such as images inserted into the content.
|
|
49
|
+
*
|
|
50
|
+
* For instance, to use CKFinder's
|
|
51
|
+
* [quick upload](https://ckeditor.com/docs/ckfinder/ckfinder3-php/commands.html#command_quick_upload)
|
|
52
|
+
* command, your can use the following (or similar) path:
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* ClassicEditor
|
|
56
|
+
* .create( editorElement, {
|
|
57
|
+
* ckfinder: {
|
|
58
|
+
* uploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json'
|
|
59
|
+
* }
|
|
60
|
+
* } )
|
|
61
|
+
* .then( ... )
|
|
62
|
+
* .catch( ... );
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Used by the {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter upload adapter}.
|
|
66
|
+
*/
|
|
67
|
+
uploadUrl?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface CKFinderOptions extends Record<string, unknown> {
|
|
70
|
+
chooseFiles?: boolean;
|
|
71
|
+
onInit?: (finder: any) => void;
|
|
72
|
+
language?: string;
|
|
73
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ckfinder/ckfinderediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { Notification } from 'ckeditor5/src/ui.js';
|
|
10
|
+
/**
|
|
11
|
+
* The CKFinder editing feature. It introduces the {@link module:ckfinder/ckfindercommand~CKFinderCommand CKFinder command}.
|
|
12
|
+
*/
|
|
13
|
+
export default class CKFinderEditing extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName(): "CKFinderEditing";
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get isOfficialPlugin(): true;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires(): readonly [typeof Notification, "LinkEditing"];
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ckfinder/ckfinderediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { Notification } from 'ckeditor5/src/ui.js';
|
|
10
|
+
import { CKEditorError } from 'ckeditor5/src/utils.js';
|
|
11
|
+
import CKFinderCommand from './ckfindercommand.js';
|
|
12
|
+
/**
|
|
13
|
+
* The CKFinder editing feature. It introduces the {@link module:ckfinder/ckfindercommand~CKFinderCommand CKFinder command}.
|
|
14
|
+
*/
|
|
15
|
+
export default class CKFinderEditing extends Plugin {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
static get pluginName() {
|
|
20
|
+
return 'CKFinderEditing';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get isOfficialPlugin() {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
static get requires() {
|
|
32
|
+
return [Notification, 'LinkEditing'];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
init() {
|
|
38
|
+
const editor = this.editor;
|
|
39
|
+
if (!editor.plugins.has('ImageBlockEditing') && !editor.plugins.has('ImageInlineEditing')) {
|
|
40
|
+
/**
|
|
41
|
+
* CKFinder requires at least one plugin providing support for images loaded in the editor. Please
|
|
42
|
+
* make sure either:
|
|
43
|
+
*
|
|
44
|
+
* * {@link module:image/image~Image} (which loads both types of images),
|
|
45
|
+
* * or {@link module:image/imageblock~ImageBlock},
|
|
46
|
+
* * or {@link module:image/imageinline~ImageInline}.
|
|
47
|
+
*
|
|
48
|
+
* is loaded in your editor configuration.
|
|
49
|
+
*
|
|
50
|
+
* @error ckfinder-missing-image-plugin
|
|
51
|
+
*/
|
|
52
|
+
throw new CKEditorError('ckfinder-missing-image-plugin', editor);
|
|
53
|
+
}
|
|
54
|
+
editor.commands.add('ckfinder', new CKFinderCommand(editor));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ckfinder/ckfinderui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
/**
|
|
10
|
+
* Introduces UI components for `CKFinder` plugin.
|
|
11
|
+
*
|
|
12
|
+
* The plugin introduces two UI components to the {@link module:ui/componentfactory~ComponentFactory UI component factory}:
|
|
13
|
+
*
|
|
14
|
+
* * the `'ckfinder'` toolbar button,
|
|
15
|
+
* * the `'menuBar:ckfinder'` menu bar component, which is by default added to the `'Insert'` menu.
|
|
16
|
+
*
|
|
17
|
+
* It also integrates with the `insertImage` toolbar component and `menuBar:insertImage` menu component.
|
|
18
|
+
*/
|
|
19
|
+
export default class CKFinderUI extends Plugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName(): "CKFinderUI";
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get isOfficialPlugin(): true;
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
init(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Creates the base for various kinds of the button component provided by this feature.
|
|
34
|
+
*/
|
|
35
|
+
private _createButton;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a simple toolbar button for files management, with an icon and a tooltip.
|
|
38
|
+
*/
|
|
39
|
+
private _createFileToolbarButton;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a simple toolbar button for images management, with an icon and a tooltip.
|
|
42
|
+
*/
|
|
43
|
+
private _createImageToolbarButton;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a button for images management for the dropdown view, with an icon, text and no tooltip.
|
|
46
|
+
*/
|
|
47
|
+
private _createImageDropdownButton;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a button for files management for the menu bar.
|
|
50
|
+
*/
|
|
51
|
+
private _createFileMenuBarButton;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a button for images management for the menu bar.
|
|
54
|
+
*/
|
|
55
|
+
private _createImageMenuBarButton;
|
|
56
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ckfinder/ckfinderui
|
|
7
|
+
*/
|
|
8
|
+
import { icons, Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { ButtonView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';
|
|
10
|
+
/**
|
|
11
|
+
* Introduces UI components for `CKFinder` plugin.
|
|
12
|
+
*
|
|
13
|
+
* The plugin introduces two UI components to the {@link module:ui/componentfactory~ComponentFactory UI component factory}:
|
|
14
|
+
*
|
|
15
|
+
* * the `'ckfinder'` toolbar button,
|
|
16
|
+
* * the `'menuBar:ckfinder'` menu bar component, which is by default added to the `'Insert'` menu.
|
|
17
|
+
*
|
|
18
|
+
* It also integrates with the `insertImage` toolbar component and `menuBar:insertImage` menu component.
|
|
19
|
+
*/
|
|
20
|
+
export default class CKFinderUI extends Plugin {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get pluginName() {
|
|
25
|
+
return 'CKFinderUI';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
static get isOfficialPlugin() {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
init() {
|
|
37
|
+
const editor = this.editor;
|
|
38
|
+
editor.ui.componentFactory.add('ckfinder', () => this._createFileToolbarButton());
|
|
39
|
+
editor.ui.componentFactory.add('menuBar:ckfinder', () => this._createFileMenuBarButton());
|
|
40
|
+
if (editor.plugins.has('ImageInsertUI')) {
|
|
41
|
+
editor.plugins.get('ImageInsertUI').registerIntegration({
|
|
42
|
+
name: 'assetManager',
|
|
43
|
+
observable: () => editor.commands.get('ckfinder'),
|
|
44
|
+
buttonViewCreator: () => this._createImageToolbarButton(),
|
|
45
|
+
formViewCreator: () => this._createImageDropdownButton(),
|
|
46
|
+
menuBarButtonViewCreator: isOnly => this._createImageMenuBarButton(isOnly ? 'insertOnly' : 'insertNested')
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates the base for various kinds of the button component provided by this feature.
|
|
52
|
+
*/
|
|
53
|
+
_createButton(ButtonClass) {
|
|
54
|
+
const editor = this.editor;
|
|
55
|
+
const locale = editor.locale;
|
|
56
|
+
const view = new ButtonClass(locale);
|
|
57
|
+
const command = editor.commands.get('ckfinder');
|
|
58
|
+
view.bind('isEnabled').to(command);
|
|
59
|
+
view.on('execute', () => {
|
|
60
|
+
editor.execute('ckfinder');
|
|
61
|
+
editor.editing.view.focus();
|
|
62
|
+
});
|
|
63
|
+
return view;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a simple toolbar button for files management, with an icon and a tooltip.
|
|
67
|
+
*/
|
|
68
|
+
_createFileToolbarButton() {
|
|
69
|
+
const t = this.editor.locale.t;
|
|
70
|
+
const button = this._createButton(ButtonView);
|
|
71
|
+
button.icon = icons.browseFiles;
|
|
72
|
+
button.label = t('Insert image or file');
|
|
73
|
+
button.tooltip = true;
|
|
74
|
+
return button;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates a simple toolbar button for images management, with an icon and a tooltip.
|
|
78
|
+
*/
|
|
79
|
+
_createImageToolbarButton() {
|
|
80
|
+
const t = this.editor.locale.t;
|
|
81
|
+
const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
|
|
82
|
+
const button = this._createButton(ButtonView);
|
|
83
|
+
button.icon = icons.imageAssetManager;
|
|
84
|
+
button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ? t('Replace image with file manager') : t('Insert image with file manager'));
|
|
85
|
+
button.tooltip = true;
|
|
86
|
+
return button;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Creates a button for images management for the dropdown view, with an icon, text and no tooltip.
|
|
90
|
+
*/
|
|
91
|
+
_createImageDropdownButton() {
|
|
92
|
+
const t = this.editor.locale.t;
|
|
93
|
+
const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
|
|
94
|
+
const button = this._createButton(ButtonView);
|
|
95
|
+
button.icon = icons.imageAssetManager;
|
|
96
|
+
button.withText = true;
|
|
97
|
+
button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ? t('Replace with file manager') : t('Insert with file manager'));
|
|
98
|
+
button.on('execute', () => {
|
|
99
|
+
imageInsertUI.dropdownView.isOpen = false;
|
|
100
|
+
});
|
|
101
|
+
return button;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a button for files management for the menu bar.
|
|
105
|
+
*/
|
|
106
|
+
_createFileMenuBarButton() {
|
|
107
|
+
const t = this.editor.locale.t;
|
|
108
|
+
const button = this._createButton(MenuBarMenuListItemButtonView);
|
|
109
|
+
button.icon = icons.browseFiles;
|
|
110
|
+
button.withText = true;
|
|
111
|
+
button.label = t('File');
|
|
112
|
+
return button;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Creates a button for images management for the menu bar.
|
|
116
|
+
*/
|
|
117
|
+
_createImageMenuBarButton(type) {
|
|
118
|
+
const t = this.editor.locale.t;
|
|
119
|
+
const button = this._createButton(MenuBarMenuListItemButtonView);
|
|
120
|
+
button.icon = icons.imageAssetManager;
|
|
121
|
+
button.withText = true;
|
|
122
|
+
switch (type) {
|
|
123
|
+
case 'insertOnly':
|
|
124
|
+
button.label = t('Image');
|
|
125
|
+
break;
|
|
126
|
+
case 'insertNested':
|
|
127
|
+
button.label = t('With file manager');
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
return button;
|
|
131
|
+
}
|
|
132
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ckfinder
|
|
7
|
+
*/
|
|
8
|
+
export { default as CKFinder } from './ckfinder.js';
|
|
9
|
+
export { default as CKFinderEditing } from './ckfinderediting.js';
|
|
10
|
+
export { default as CKFinderUI } from './ckfinderui.js';
|
|
11
|
+
export type { CKFinderConfig } from './ckfinderconfig.js';
|
|
12
|
+
export type { default as CKFinderCommand } from './ckfindercommand.js';
|
|
13
|
+
import './augmentation.js';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ckfinder
|
|
7
|
+
*/
|
|
8
|
+
export { default as CKFinder } from './ckfinder.js';
|
|
9
|
+
export { default as CKFinderEditing } from './ckfinderediting.js';
|
|
10
|
+
export { default as CKFinderUI } from './ckfinderui.js';
|
|
11
|
+
import './augmentation.js';
|