@ckeditor/ckeditor5-ckfinder 48.8.1-alpha.3 → 49.0.0-alpha.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.
Files changed (160) hide show
  1. package/dist/augmentation.d.ts +20 -20
  2. package/dist/ckfinder.d.ts +37 -37
  3. package/dist/ckfindercommand.d.ts +31 -31
  4. package/dist/ckfinderconfig.d.ts +66 -66
  5. package/dist/ckfinderediting.d.ts +26 -26
  6. package/dist/ckfinderui.d.ts +51 -51
  7. package/dist/index-content.css +3 -0
  8. package/dist/index-content.css.map +1 -0
  9. package/dist/index-editor.css +3 -0
  10. package/dist/index-editor.css.map +1 -0
  11. package/dist/index.d.ts +11 -11
  12. package/dist/index.js +332 -310
  13. package/dist/index.js.map +1 -1
  14. package/dist/translations/af.js +1 -1
  15. package/dist/translations/af.umd.js +5 -3
  16. package/dist/translations/ar.js +1 -1
  17. package/dist/translations/ar.umd.js +5 -3
  18. package/dist/translations/ast.js +1 -1
  19. package/dist/translations/ast.umd.js +5 -3
  20. package/dist/translations/az.js +1 -1
  21. package/dist/translations/az.umd.js +5 -3
  22. package/dist/translations/be.js +1 -1
  23. package/dist/translations/be.umd.js +5 -3
  24. package/dist/translations/bg.js +1 -1
  25. package/dist/translations/bg.umd.js +5 -3
  26. package/dist/translations/bn.js +1 -1
  27. package/dist/translations/bn.umd.js +5 -3
  28. package/dist/translations/bs.js +1 -1
  29. package/dist/translations/bs.umd.js +5 -3
  30. package/dist/translations/ca.js +1 -1
  31. package/dist/translations/ca.umd.js +5 -3
  32. package/dist/translations/cs.js +1 -1
  33. package/dist/translations/cs.umd.js +5 -3
  34. package/dist/translations/da.js +1 -1
  35. package/dist/translations/da.umd.js +5 -3
  36. package/dist/translations/de-ch.js +1 -1
  37. package/dist/translations/de-ch.umd.js +5 -3
  38. package/dist/translations/de.js +1 -1
  39. package/dist/translations/de.umd.js +5 -3
  40. package/dist/translations/el.js +1 -1
  41. package/dist/translations/el.umd.js +5 -3
  42. package/dist/translations/en-au.js +1 -1
  43. package/dist/translations/en-au.umd.js +5 -3
  44. package/dist/translations/en-gb.js +1 -1
  45. package/dist/translations/en-gb.umd.js +5 -3
  46. package/dist/translations/en.js +1 -1
  47. package/dist/translations/en.umd.js +5 -3
  48. package/dist/translations/eo.js +1 -1
  49. package/dist/translations/eo.umd.js +5 -3
  50. package/dist/translations/es-co.js +1 -1
  51. package/dist/translations/es-co.umd.js +5 -3
  52. package/dist/translations/es.js +1 -1
  53. package/dist/translations/es.umd.js +5 -3
  54. package/dist/translations/et.js +1 -1
  55. package/dist/translations/et.umd.js +5 -3
  56. package/dist/translations/eu.js +1 -1
  57. package/dist/translations/eu.umd.js +5 -3
  58. package/dist/translations/fa.js +1 -1
  59. package/dist/translations/fa.umd.js +5 -3
  60. package/dist/translations/fi.js +1 -1
  61. package/dist/translations/fi.umd.js +5 -3
  62. package/dist/translations/fr.js +1 -1
  63. package/dist/translations/fr.umd.js +5 -3
  64. package/dist/translations/gl.js +1 -1
  65. package/dist/translations/gl.umd.js +5 -3
  66. package/dist/translations/gu.js +1 -1
  67. package/dist/translations/gu.umd.js +5 -3
  68. package/dist/translations/he.js +1 -1
  69. package/dist/translations/he.umd.js +5 -3
  70. package/dist/translations/hi.js +1 -1
  71. package/dist/translations/hi.umd.js +5 -3
  72. package/dist/translations/hr.js +1 -1
  73. package/dist/translations/hr.umd.js +5 -3
  74. package/dist/translations/hu.js +1 -1
  75. package/dist/translations/hu.umd.js +5 -3
  76. package/dist/translations/hy.js +1 -1
  77. package/dist/translations/hy.umd.js +5 -3
  78. package/dist/translations/id.js +1 -1
  79. package/dist/translations/id.umd.js +5 -3
  80. package/dist/translations/it.js +1 -1
  81. package/dist/translations/it.umd.js +5 -3
  82. package/dist/translations/ja.js +1 -1
  83. package/dist/translations/ja.umd.js +5 -3
  84. package/dist/translations/jv.js +1 -1
  85. package/dist/translations/jv.umd.js +5 -3
  86. package/dist/translations/kk.js +1 -1
  87. package/dist/translations/kk.umd.js +5 -3
  88. package/dist/translations/km.js +1 -1
  89. package/dist/translations/km.umd.js +5 -3
  90. package/dist/translations/kn.js +1 -1
  91. package/dist/translations/kn.umd.js +5 -3
  92. package/dist/translations/ko.js +1 -1
  93. package/dist/translations/ko.umd.js +5 -3
  94. package/dist/translations/ku.js +1 -1
  95. package/dist/translations/ku.umd.js +5 -3
  96. package/dist/translations/lt.js +1 -1
  97. package/dist/translations/lt.umd.js +5 -3
  98. package/dist/translations/lv.js +1 -1
  99. package/dist/translations/lv.umd.js +5 -3
  100. package/dist/translations/ms.js +1 -1
  101. package/dist/translations/ms.umd.js +5 -3
  102. package/dist/translations/nb.js +1 -1
  103. package/dist/translations/nb.umd.js +5 -3
  104. package/dist/translations/ne.js +1 -1
  105. package/dist/translations/ne.umd.js +5 -3
  106. package/dist/translations/nl.js +1 -1
  107. package/dist/translations/nl.umd.js +5 -3
  108. package/dist/translations/no.js +1 -1
  109. package/dist/translations/no.umd.js +5 -3
  110. package/dist/translations/oc.js +1 -1
  111. package/dist/translations/oc.umd.js +5 -3
  112. package/dist/translations/pl.js +1 -1
  113. package/dist/translations/pl.umd.js +5 -3
  114. package/dist/translations/pt-br.js +1 -1
  115. package/dist/translations/pt-br.umd.js +5 -3
  116. package/dist/translations/pt.js +1 -1
  117. package/dist/translations/pt.umd.js +5 -3
  118. package/dist/translations/ro.js +1 -1
  119. package/dist/translations/ro.umd.js +5 -3
  120. package/dist/translations/ru.js +1 -1
  121. package/dist/translations/ru.umd.js +5 -3
  122. package/dist/translations/si.js +1 -1
  123. package/dist/translations/si.umd.js +5 -3
  124. package/dist/translations/sk.js +1 -1
  125. package/dist/translations/sk.umd.js +5 -3
  126. package/dist/translations/sl.js +1 -1
  127. package/dist/translations/sl.umd.js +5 -3
  128. package/dist/translations/sq.js +1 -1
  129. package/dist/translations/sq.umd.js +5 -3
  130. package/dist/translations/sr-latn.js +1 -1
  131. package/dist/translations/sr-latn.umd.js +5 -3
  132. package/dist/translations/sr.js +1 -1
  133. package/dist/translations/sr.umd.js +5 -3
  134. package/dist/translations/sv.js +1 -1
  135. package/dist/translations/sv.umd.js +5 -3
  136. package/dist/translations/th.js +1 -1
  137. package/dist/translations/th.umd.js +5 -3
  138. package/dist/translations/ti.js +1 -1
  139. package/dist/translations/ti.umd.js +5 -3
  140. package/dist/translations/tk.js +1 -1
  141. package/dist/translations/tk.umd.js +5 -3
  142. package/dist/translations/tr.js +1 -1
  143. package/dist/translations/tr.umd.js +5 -3
  144. package/dist/translations/tt.js +1 -1
  145. package/dist/translations/tt.umd.js +5 -3
  146. package/dist/translations/ug.js +1 -1
  147. package/dist/translations/ug.umd.js +5 -3
  148. package/dist/translations/uk.js +1 -1
  149. package/dist/translations/uk.umd.js +5 -3
  150. package/dist/translations/ur.js +1 -1
  151. package/dist/translations/ur.umd.js +5 -3
  152. package/dist/translations/uz.js +1 -1
  153. package/dist/translations/uz.umd.js +5 -3
  154. package/dist/translations/vi.js +1 -1
  155. package/dist/translations/vi.umd.js +5 -3
  156. package/dist/translations/zh-cn.js +1 -1
  157. package/dist/translations/zh-cn.umd.js +5 -3
  158. package/dist/translations/zh.js +1 -1
  159. package/dist/translations/zh.umd.js +5 -3
  160. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -2,325 +2,347 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import { Plugin, Command } from '@ckeditor/ckeditor5-core/dist/index.js';
6
- import { CKFinderUploadAdapter } from '@ckeditor/ckeditor5-adapter-ckfinder/dist/index.js';
7
- import { LinkEditing, Link } from '@ckeditor/ckeditor5-link/dist/index.js';
8
- import { ButtonView, MenuBarMenuListItemButtonView, Notification } from '@ckeditor/ckeditor5-ui/dist/index.js';
9
- import { IconBrowseFiles, IconImageAssetManager } from '@ckeditor/ckeditor5-icons/dist/index.js';
10
- import { CKEditorError } from '@ckeditor/ckeditor5-utils/dist/index.js';
5
+ import { Command, Plugin } from "@ckeditor/ckeditor5-core";
6
+ import { CKFinderUploadAdapter } from "@ckeditor/ckeditor5-adapter-ckfinder";
7
+ import { Link, LinkEditing } from "@ckeditor/ckeditor5-link";
8
+ import { ButtonView, MenuBarMenuListItemButtonView, Notification } from "@ckeditor/ckeditor5-ui";
9
+ import { IconBrowseFiles, IconImageAssetManager } from "@ckeditor/ckeditor5-icons";
10
+ import { CKEditorError } from "@ckeditor/ckeditor5-utils";
11
11
 
12
12
  /**
13
- * Introduces UI components for `CKFinder` plugin.
14
- *
15
- * The plugin introduces two UI components to the {@link module:ui/componentfactory~ComponentFactory UI component factory}:
16
- *
17
- * * the `'ckfinder'` toolbar button,
18
- * * the `'menuBar:ckfinder'` menu bar component, which is by default added to the `'Insert'` menu.
19
- *
20
- * It also integrates with the `insertImage` toolbar component and `menuBar:insertImage` menu component.
21
- */ class CKFinderUI extends Plugin {
22
- /**
23
- * @inheritDoc
24
- */ static get pluginName() {
25
- return 'CKFinderUI';
26
- }
27
- /**
28
- * @inheritDoc
29
- */ static get isOfficialPlugin() {
30
- return true;
31
- }
32
- /**
33
- * @inheritDoc
34
- */ init() {
35
- const editor = this.editor;
36
- editor.ui.componentFactory.add('ckfinder', ()=>this._createFileToolbarButton());
37
- editor.ui.componentFactory.add('menuBar:ckfinder', ()=>this._createFileMenuBarButton());
38
- if (editor.plugins.has('ImageInsertUI')) {
39
- editor.plugins.get('ImageInsertUI').registerIntegration({
40
- name: 'assetManager',
41
- observable: ()=>editor.commands.get('ckfinder'),
42
- buttonViewCreator: ()=>this._createImageToolbarButton(),
43
- formViewCreator: ()=>this._createImageDropdownButton(),
44
- menuBarButtonViewCreator: (isOnly)=>this._createImageMenuBarButton(isOnly ? 'insertOnly' : 'insertNested')
45
- });
46
- }
47
- }
48
- /**
49
- * Creates the base for various kinds of the button component provided by this feature.
50
- */ _createButton(ButtonClass) {
51
- const editor = this.editor;
52
- const locale = editor.locale;
53
- const view = new ButtonClass(locale);
54
- const command = editor.commands.get('ckfinder');
55
- view.bind('isEnabled').to(command);
56
- view.on('execute', ()=>{
57
- editor.execute('ckfinder');
58
- editor.editing.view.focus();
59
- });
60
- return view;
61
- }
62
- /**
63
- * Creates a simple toolbar button for files management, with an icon and a tooltip.
64
- */ _createFileToolbarButton() {
65
- const t = this.editor.locale.t;
66
- const button = this._createButton(ButtonView);
67
- button.icon = IconBrowseFiles;
68
- button.label = t('Insert image or file');
69
- button.tooltip = true;
70
- return button;
71
- }
72
- /**
73
- * Creates a simple toolbar button for images management, with an icon and a tooltip.
74
- */ _createImageToolbarButton() {
75
- const t = this.editor.locale.t;
76
- const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
77
- const button = this._createButton(ButtonView);
78
- button.icon = IconImageAssetManager;
79
- button.bind('label').to(imageInsertUI, 'isImageSelected', (isImageSelected)=>isImageSelected ? t('Replace image with file manager') : t('Insert image with file manager'));
80
- button.tooltip = true;
81
- return button;
82
- }
83
- /**
84
- * Creates a button for images management for the dropdown view, with an icon, text and no tooltip.
85
- */ _createImageDropdownButton() {
86
- const t = this.editor.locale.t;
87
- const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
88
- const button = this._createButton(ButtonView);
89
- button.icon = IconImageAssetManager;
90
- button.withText = true;
91
- button.bind('label').to(imageInsertUI, 'isImageSelected', (isImageSelected)=>isImageSelected ? t('Replace with file manager') : t('Insert with file manager'));
92
- button.on('execute', ()=>{
93
- imageInsertUI.dropdownView.isOpen = false;
94
- });
95
- return button;
96
- }
97
- /**
98
- * Creates a button for files management for the menu bar.
99
- */ _createFileMenuBarButton() {
100
- const t = this.editor.locale.t;
101
- const button = this._createButton(MenuBarMenuListItemButtonView);
102
- button.icon = IconBrowseFiles;
103
- button.withText = true;
104
- button.label = t('File');
105
- return button;
106
- }
107
- /**
108
- * Creates a button for images management for the menu bar.
109
- */ _createImageMenuBarButton(type) {
110
- // Use t() stored in a variable with a different name to reuse existing translations from another package.
111
- const translateVariableKey = this.editor.locale.t;
112
- const t = this.editor.locale.t;
113
- const button = this._createButton(MenuBarMenuListItemButtonView);
114
- button.icon = IconImageAssetManager;
115
- button.withText = true;
116
- switch(type){
117
- case 'insertOnly':
118
- button.label = translateVariableKey('Image');
119
- break;
120
- case 'insertNested':
121
- button.label = t('With file manager');
122
- break;
123
- }
124
- return button;
125
- }
126
- }
13
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
14
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
15
+ */
16
+ /**
17
+ * @module ckfinder/ckfinderui
18
+ */
19
+ /**
20
+ * Introduces UI components for `CKFinder` plugin.
21
+ *
22
+ * The plugin introduces two UI components to the {@link module:ui/componentfactory~ComponentFactory UI component factory}:
23
+ *
24
+ * * the `'ckfinder'` toolbar button,
25
+ * * the `'menuBar:ckfinder'` menu bar component, which is by default added to the `'Insert'` menu.
26
+ *
27
+ * It also integrates with the `insertImage` toolbar component and `menuBar:insertImage` menu component.
28
+ */
29
+ var CKFinderUI = class extends Plugin {
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get pluginName() {
34
+ return "CKFinderUI";
35
+ }
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ static get isOfficialPlugin() {
40
+ return true;
41
+ }
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ init() {
46
+ const editor = this.editor;
47
+ editor.ui.componentFactory.add("ckfinder", () => this._createFileToolbarButton());
48
+ editor.ui.componentFactory.add("menuBar:ckfinder", () => this._createFileMenuBarButton());
49
+ /* v8 ignore else -- @preserve */
50
+ if (editor.plugins.has("ImageInsertUI")) editor.plugins.get("ImageInsertUI").registerIntegration({
51
+ name: "assetManager",
52
+ observable: () => editor.commands.get("ckfinder"),
53
+ buttonViewCreator: () => this._createImageToolbarButton(),
54
+ formViewCreator: () => this._createImageDropdownButton(),
55
+ menuBarButtonViewCreator: (isOnly) => this._createImageMenuBarButton(isOnly ? "insertOnly" : "insertNested")
56
+ });
57
+ }
58
+ /**
59
+ * Creates the base for various kinds of the button component provided by this feature.
60
+ */
61
+ _createButton(ButtonClass) {
62
+ const editor = this.editor;
63
+ const locale = editor.locale;
64
+ const view = new ButtonClass(locale);
65
+ const command = editor.commands.get("ckfinder");
66
+ view.bind("isEnabled").to(command);
67
+ view.on("execute", () => {
68
+ editor.execute("ckfinder");
69
+ editor.editing.view.focus();
70
+ });
71
+ return view;
72
+ }
73
+ /**
74
+ * Creates a simple toolbar button for files management, with an icon and a tooltip.
75
+ */
76
+ _createFileToolbarButton() {
77
+ const t = this.editor.locale.t;
78
+ const button = this._createButton(ButtonView);
79
+ button.icon = IconBrowseFiles;
80
+ button.label = t("Insert image or file");
81
+ button.tooltip = true;
82
+ return button;
83
+ }
84
+ /**
85
+ * Creates a simple toolbar button for images management, with an icon and a tooltip.
86
+ */
87
+ _createImageToolbarButton() {
88
+ const t = this.editor.locale.t;
89
+ const imageInsertUI = this.editor.plugins.get("ImageInsertUI");
90
+ const button = this._createButton(ButtonView);
91
+ button.icon = IconImageAssetManager;
92
+ button.bind("label").to(imageInsertUI, "isImageSelected", (isImageSelected) => isImageSelected ? t("Replace image with file manager") : t("Insert image with file manager"));
93
+ button.tooltip = true;
94
+ return button;
95
+ }
96
+ /**
97
+ * Creates a button for images management for the dropdown view, with an icon, text and no tooltip.
98
+ */
99
+ _createImageDropdownButton() {
100
+ const t = this.editor.locale.t;
101
+ const imageInsertUI = this.editor.plugins.get("ImageInsertUI");
102
+ const button = this._createButton(ButtonView);
103
+ button.icon = IconImageAssetManager;
104
+ button.withText = true;
105
+ button.bind("label").to(imageInsertUI, "isImageSelected", (isImageSelected) => isImageSelected ? t("Replace with file manager") : t("Insert with file manager"));
106
+ button.on("execute", () => {
107
+ imageInsertUI.dropdownView.isOpen = false;
108
+ });
109
+ return button;
110
+ }
111
+ /**
112
+ * Creates a button for files management for the menu bar.
113
+ */
114
+ _createFileMenuBarButton() {
115
+ const t = this.editor.locale.t;
116
+ const button = this._createButton(MenuBarMenuListItemButtonView);
117
+ button.icon = IconBrowseFiles;
118
+ button.withText = true;
119
+ button.label = t("File");
120
+ return button;
121
+ }
122
+ /**
123
+ * Creates a button for images management for the menu bar.
124
+ */
125
+ _createImageMenuBarButton(type) {
126
+ const translateVariableKey = this.editor.locale.t;
127
+ const t = this.editor.locale.t;
128
+ const button = this._createButton(MenuBarMenuListItemButtonView);
129
+ button.icon = IconImageAssetManager;
130
+ button.withText = true;
131
+ switch (type) {
132
+ case "insertOnly":
133
+ button.label = translateVariableKey("Image");
134
+ break;
135
+ case "insertNested": button.label = t("With file manager");
136
+ }
137
+ return button;
138
+ }
139
+ };
127
140
 
128
141
  /**
129
- * The CKFinder command. It is used by the {@link module:ckfinder/ckfinderediting~CKFinderEditing CKFinder editing feature}
130
- * to open the CKFinder file manager to insert an image or a link to a file into the editor content.
131
- *
132
- * ```ts
133
- * editor.execute( 'ckfinder' );
134
- * ```
135
- *
136
- * **Note:** This command uses other features to perform tasks:
137
- * - To insert images the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command
138
- * from the {@link module:image/image~Image Image feature}.
139
- * - To insert links to files the {@link module:link/linkcommand~LinkCommand 'link'} command
140
- * from the {@link module:link/link~Link Link feature}.
141
- */ class CKFinderCommand extends Command {
142
- /**
143
- * @inheritDoc
144
- */ constructor(editor){
145
- super(editor);
146
- // The CKFinder command does not affect data by itself.
147
- this.affectsData = false;
148
- // Remove default document listener to lower its priority.
149
- this.stopListening(this.editor.model.document, 'change');
150
- // Lower this command listener priority to be sure that refresh() will be called after link & image refresh.
151
- this.listenTo(this.editor.model.document, 'change', ()=>this.refresh(), {
152
- priority: 'low'
153
- });
154
- }
155
- /**
156
- * @inheritDoc
157
- */ refresh() {
158
- const imageCommand = this.editor.commands.get('insertImage');
159
- const linkCommand = this.editor.commands.get('link');
160
- // The CKFinder command is enabled when one of image or link command is enabled.
161
- this.isEnabled = imageCommand.isEnabled || linkCommand.isEnabled;
162
- }
163
- /**
164
- * @inheritDoc
165
- */ execute() {
166
- const editor = this.editor;
167
- const openerMethod = this.editor.config.get('ckfinder.openerMethod') || 'modal';
168
- if (openerMethod != 'popup' && openerMethod != 'modal') {
169
- /**
170
- * The `ckfinder.openerMethod` must be one of: "popup" or "modal".
171
- *
172
- * @error ckfinder-unknown-openermethod
173
- */ throw new CKEditorError('ckfinder-unknown-openermethod', editor);
174
- }
175
- const options = this.editor.config.get('ckfinder.options') || {};
176
- options.chooseFiles = true;
177
- // Cache the user-defined onInit method
178
- const originalOnInit = options.onInit;
179
- // Pass the lang code to the CKFinder if not defined by user.
180
- if (!options.language) {
181
- options.language = editor.locale.uiLanguage;
182
- }
183
- // The onInit method allows to extend CKFinder's behavior. It is used to attach event listeners to file choosing related events.
184
- options.onInit = (finder)=>{
185
- // Call original options.onInit if it was defined by user.
186
- if (originalOnInit) {
187
- originalOnInit(finder);
188
- }
189
- finder.on('files:choose', (evt)=>{
190
- const files = evt.data.files.toArray();
191
- // Insert links
192
- const links = files.filter((file)=>!file.isImage());
193
- const images = files.filter((file)=>file.isImage());
194
- for (const linkFile of links){
195
- editor.execute('link', linkFile.getUrl());
196
- }
197
- const imagesUrls = [];
198
- for (const image of images){
199
- const url = image.getUrl();
200
- imagesUrls.push(url ? url : finder.request('file:getProxyUrl', {
201
- file: image
202
- }));
203
- }
204
- if (imagesUrls.length) {
205
- insertImages(editor, imagesUrls);
206
- }
207
- });
208
- finder.on('file:choose:resizedImage', (evt)=>{
209
- const resizedUrl = evt.data.resizedUrl;
210
- if (!resizedUrl) {
211
- const notification = editor.plugins.get('Notification');
212
- const t = editor.locale.t;
213
- notification.showWarning(t('Could not obtain resized image URL.'), {
214
- title: t('Selecting resized image failed'),
215
- namespace: 'ckfinder'
216
- });
217
- return;
218
- }
219
- insertImages(editor, [
220
- resizedUrl
221
- ]);
222
- });
223
- };
224
- window.CKFinder[openerMethod](options);
225
- }
226
- }
142
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
143
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
144
+ */
145
+ /**
146
+ * @module ckfinder/ckfindercommand
147
+ */
148
+ /**
149
+ * The CKFinder command. It is used by the {@link module:ckfinder/ckfinderediting~CKFinderEditing CKFinder editing feature}
150
+ * to open the CKFinder file manager to insert an image or a link to a file into the editor content.
151
+ *
152
+ * ```ts
153
+ * editor.execute( 'ckfinder' );
154
+ * ```
155
+ *
156
+ * **Note:** This command uses other features to perform tasks:
157
+ * - To insert images the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command
158
+ * from the {@link module:image/image~Image Image feature}.
159
+ * - To insert links to files the {@link module:link/linkcommand~LinkCommand 'link'} command
160
+ * from the {@link module:link/link~Link Link feature}.
161
+ */
162
+ var CKFinderCommand = class extends Command {
163
+ /**
164
+ * @inheritDoc
165
+ */
166
+ constructor(editor) {
167
+ super(editor);
168
+ this.affectsData = false;
169
+ this.stopListening(this.editor.model.document, "change");
170
+ this.listenTo(this.editor.model.document, "change", () => this.refresh(), { priority: "low" });
171
+ }
172
+ /**
173
+ * @inheritDoc
174
+ */
175
+ refresh() {
176
+ const imageCommand = this.editor.commands.get("insertImage");
177
+ const linkCommand = this.editor.commands.get("link");
178
+ this.isEnabled = imageCommand.isEnabled || linkCommand.isEnabled;
179
+ }
180
+ /**
181
+ * @inheritDoc
182
+ */
183
+ execute() {
184
+ const editor = this.editor;
185
+ const openerMethod = this.editor.config.get("ckfinder.openerMethod") || "modal";
186
+ if (openerMethod != "popup" && openerMethod != "modal")
187
+ /**
188
+ * The `ckfinder.openerMethod` must be one of: "popup" or "modal".
189
+ *
190
+ * @error ckfinder-unknown-openermethod
191
+ */
192
+ throw new CKEditorError("ckfinder-unknown-openermethod", editor);
193
+ const options = this.editor.config.get("ckfinder.options") || {};
194
+ options.chooseFiles = true;
195
+ const originalOnInit = options.onInit;
196
+ if (!options.language) options.language = editor.locale.uiLanguage;
197
+ options.onInit = (finder) => {
198
+ if (originalOnInit) originalOnInit(finder);
199
+ finder.on("files:choose", (evt) => {
200
+ const files = evt.data.files.toArray();
201
+ const links = files.filter((file) => !file.isImage());
202
+ const images = files.filter((file) => file.isImage());
203
+ for (const linkFile of links) editor.execute("link", linkFile.getUrl());
204
+ const imagesUrls = [];
205
+ for (const image of images) {
206
+ const url = image.getUrl();
207
+ imagesUrls.push(url ? url : finder.request("file:getProxyUrl", { file: image }));
208
+ }
209
+ if (imagesUrls.length) insertImages(editor, imagesUrls);
210
+ });
211
+ finder.on("file:choose:resizedImage", (evt) => {
212
+ const resizedUrl = evt.data.resizedUrl;
213
+ if (!resizedUrl) {
214
+ const notification = editor.plugins.get("Notification");
215
+ const t = editor.locale.t;
216
+ notification.showWarning(t("Could not obtain resized image URL."), {
217
+ title: t("Selecting resized image failed"),
218
+ namespace: "ckfinder"
219
+ });
220
+ return;
221
+ }
222
+ insertImages(editor, [resizedUrl]);
223
+ });
224
+ };
225
+ window.CKFinder[openerMethod](options);
226
+ }
227
+ };
227
228
  function insertImages(editor, urls) {
228
- const imageCommand = editor.commands.get('insertImage');
229
- // Check if inserting an image is actually possible - it might be possible to only insert a link.
230
- if (!imageCommand.isEnabled) {
231
- const notification = editor.plugins.get('Notification');
232
- const t = editor.locale.t;
233
- notification.showWarning(t('Could not insert image at the current position.'), {
234
- title: t('Inserting image failed'),
235
- namespace: 'ckfinder'
236
- });
237
- return;
238
- }
239
- editor.execute('insertImage', {
240
- source: urls
241
- });
229
+ if (!editor.commands.get("insertImage").isEnabled) {
230
+ const notification = editor.plugins.get("Notification");
231
+ const t = editor.locale.t;
232
+ notification.showWarning(t("Could not insert image at the current position."), {
233
+ title: t("Inserting image failed"),
234
+ namespace: "ckfinder"
235
+ });
236
+ return;
237
+ }
238
+ editor.execute("insertImage", { source: urls });
242
239
  }
243
240
 
244
241
  /**
245
- * The CKFinder editing feature. It introduces the {@link module:ckfinder/ckfindercommand~CKFinderCommand CKFinder command}.
246
- */ class CKFinderEditing extends Plugin {
247
- /**
248
- * @inheritDoc
249
- */ static get pluginName() {
250
- return 'CKFinderEditing';
251
- }
252
- /**
253
- * @inheritDoc
254
- */ static get isOfficialPlugin() {
255
- return true;
256
- }
257
- /**
258
- * @inheritDoc
259
- */ static get requires() {
260
- return [
261
- Notification,
262
- LinkEditing
263
- ];
264
- }
265
- /**
266
- * @inheritDoc
267
- */ init() {
268
- const editor = this.editor;
269
- if (!editor.plugins.has('ImageBlockEditing') && !editor.plugins.has('ImageInlineEditing')) {
270
- /**
271
- * CKFinder requires at least one plugin providing support for images loaded in the editor. Please
272
- * make sure either:
273
- *
274
- * * {@link module:image/image~Image} (which loads both types of images),
275
- * * or {@link module:image/imageblock~ImageBlock},
276
- * * or {@link module:image/imageinline~ImageInline}.
277
- *
278
- * is loaded in your editor configuration.
279
- *
280
- * @error ckfinder-missing-image-plugin
281
- */ throw new CKEditorError('ckfinder-missing-image-plugin', editor);
282
- }
283
- editor.commands.add('ckfinder', new CKFinderCommand(editor));
284
- }
285
- }
242
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
243
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
244
+ */
245
+ /**
246
+ * @module ckfinder/ckfinderediting
247
+ */
248
+ /**
249
+ * The CKFinder editing feature. It introduces the {@link module:ckfinder/ckfindercommand~CKFinderCommand CKFinder command}.
250
+ */
251
+ var CKFinderEditing = class extends Plugin {
252
+ /**
253
+ * @inheritDoc
254
+ */
255
+ static get pluginName() {
256
+ return "CKFinderEditing";
257
+ }
258
+ /**
259
+ * @inheritDoc
260
+ */
261
+ static get isOfficialPlugin() {
262
+ return true;
263
+ }
264
+ /**
265
+ * @inheritDoc
266
+ */
267
+ static get requires() {
268
+ return [Notification, LinkEditing];
269
+ }
270
+ /**
271
+ * @inheritDoc
272
+ */
273
+ init() {
274
+ const editor = this.editor;
275
+ if (!editor.plugins.has("ImageBlockEditing") && !editor.plugins.has("ImageInlineEditing"))
276
+ /**
277
+ * CKFinder requires at least one plugin providing support for images loaded in the editor. Please
278
+ * make sure either:
279
+ *
280
+ * * {@link module:image/image~Image} (which loads both types of images),
281
+ * * or {@link module:image/imageblock~ImageBlock},
282
+ * * or {@link module:image/imageinline~ImageInline}.
283
+ *
284
+ * is loaded in your editor configuration.
285
+ *
286
+ * @error ckfinder-missing-image-plugin
287
+ */
288
+ throw new CKEditorError("ckfinder-missing-image-plugin", editor);
289
+ editor.commands.add("ckfinder", new CKFinderCommand(editor));
290
+ }
291
+ };
286
292
 
287
293
  /**
288
- * The CKFinder feature, a bridge between the CKEditor 5 WYSIWYG editor and the
289
- * [CKFinder](https://ckeditor.com/ckfinder) file manager and uploader.
290
- *
291
- * This is a "glue" plugin which enables:
292
- *
293
- * * {@link module:ckfinder/ckfinderediting~CKFinderEditing},
294
- * * {@link module:ckfinder/ckfinderui~CKFinderUI},
295
- * * {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter}.
296
- *
297
- * See the {@glink features/file-management/ckfinder "CKFinder integration" guide} to learn how to configure
298
- * and use this feature.
299
- *
300
- * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload" guide} to learn about
301
- * other ways to upload images into CKEditor 5.
302
- */ class CKFinder extends Plugin {
303
- /**
304
- * @inheritDoc
305
- */ static get pluginName() {
306
- return 'CKFinder';
307
- }
308
- /**
309
- * @inheritDoc
310
- */ static get isOfficialPlugin() {
311
- return true;
312
- }
313
- /**
314
- * @inheritDoc
315
- */ static get requires() {
316
- return [
317
- Link,
318
- CKFinderUploadAdapter,
319
- CKFinderEditing,
320
- CKFinderUI
321
- ];
322
- }
323
- }
294
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
295
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
296
+ */
297
+ /**
298
+ * @module ckfinder/ckfinder
299
+ */
300
+ /**
301
+ * The CKFinder feature, a bridge between the CKEditor 5 WYSIWYG editor and the
302
+ * [CKFinder](https://ckeditor.com/ckfinder) file manager and uploader.
303
+ *
304
+ * This is a "glue" plugin which enables:
305
+ *
306
+ * * {@link module:ckfinder/ckfinderediting~CKFinderEditing},
307
+ * * {@link module:ckfinder/ckfinderui~CKFinderUI},
308
+ * * {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter}.
309
+ *
310
+ * See the {@glink features/file-management/ckfinder "CKFinder integration" guide} to learn how to configure
311
+ * and use this feature.
312
+ *
313
+ * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload" guide} to learn about
314
+ * other ways to upload images into CKEditor 5.
315
+ */
316
+ var CKFinder = class extends Plugin {
317
+ /**
318
+ * @inheritDoc
319
+ */
320
+ static get pluginName() {
321
+ return "CKFinder";
322
+ }
323
+ /**
324
+ * @inheritDoc
325
+ */
326
+ static get isOfficialPlugin() {
327
+ return true;
328
+ }
329
+ /**
330
+ * @inheritDoc
331
+ */
332
+ static get requires() {
333
+ return [
334
+ Link,
335
+ CKFinderUploadAdapter,
336
+ CKFinderEditing,
337
+ CKFinderUI
338
+ ];
339
+ }
340
+ };
341
+
342
+ /**
343
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
344
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
345
+ */
324
346
 
325
347
  export { CKFinder, CKFinderCommand, CKFinderEditing, CKFinderUI };
326
- //# sourceMappingURL=index.js.map
348
+ //# sourceMappingURL=index.js.map