@ckeditor/ckeditor5-ckbox 39.0.1 → 40.0.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 (74) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/build/ckbox.js.map +1 -0
  4. package/build/translations/fa.js +1 -1
  5. package/build/translations/gl.js +1 -1
  6. package/lang/translations/ar.po +1 -0
  7. package/lang/translations/az.po +1 -0
  8. package/lang/translations/bg.po +1 -0
  9. package/lang/translations/bn.po +1 -0
  10. package/lang/translations/ca.po +1 -0
  11. package/lang/translations/cs.po +1 -0
  12. package/lang/translations/da.po +1 -0
  13. package/lang/translations/de.po +1 -0
  14. package/lang/translations/el.po +1 -0
  15. package/lang/translations/en-au.po +1 -0
  16. package/lang/translations/en.po +1 -0
  17. package/lang/translations/es-co.po +1 -0
  18. package/lang/translations/es.po +1 -0
  19. package/lang/translations/et.po +1 -0
  20. package/lang/translations/fa.po +2 -1
  21. package/lang/translations/fi.po +1 -0
  22. package/lang/translations/fr.po +1 -0
  23. package/lang/translations/gl.po +3 -2
  24. package/lang/translations/he.po +1 -0
  25. package/lang/translations/hi.po +1 -0
  26. package/lang/translations/hr.po +1 -0
  27. package/lang/translations/hu.po +1 -0
  28. package/lang/translations/id.po +1 -0
  29. package/lang/translations/it.po +1 -0
  30. package/lang/translations/ja.po +1 -0
  31. package/lang/translations/ko.po +1 -0
  32. package/lang/translations/lt.po +1 -0
  33. package/lang/translations/lv.po +1 -0
  34. package/lang/translations/ms.po +1 -0
  35. package/lang/translations/nl.po +1 -0
  36. package/lang/translations/no.po +1 -0
  37. package/lang/translations/pl.po +1 -0
  38. package/lang/translations/pt-br.po +1 -0
  39. package/lang/translations/pt.po +1 -0
  40. package/lang/translations/ro.po +1 -0
  41. package/lang/translations/ru.po +1 -0
  42. package/lang/translations/sk.po +1 -0
  43. package/lang/translations/sq.po +1 -0
  44. package/lang/translations/sr-latn.po +1 -0
  45. package/lang/translations/sr.po +1 -0
  46. package/lang/translations/sv.po +1 -0
  47. package/lang/translations/th.po +1 -0
  48. package/lang/translations/tr.po +1 -0
  49. package/lang/translations/ug.po +1 -0
  50. package/lang/translations/uk.po +1 -0
  51. package/lang/translations/ur.po +1 -0
  52. package/lang/translations/uz.po +1 -0
  53. package/lang/translations/vi.po +1 -0
  54. package/lang/translations/zh-cn.po +1 -0
  55. package/lang/translations/zh.po +1 -0
  56. package/package.json +2 -6
  57. package/src/augmentation.d.ts +22 -22
  58. package/src/augmentation.js +5 -5
  59. package/src/ckbox.d.ts +33 -33
  60. package/src/ckbox.js +37 -37
  61. package/src/ckboxcommand.d.ts +110 -110
  62. package/src/ckboxcommand.js +302 -302
  63. package/src/ckboxconfig.d.ts +283 -283
  64. package/src/ckboxconfig.js +5 -5
  65. package/src/ckboxediting.d.ts +52 -52
  66. package/src/ckboxediting.js +362 -362
  67. package/src/ckboxui.d.ts +21 -21
  68. package/src/ckboxui.js +47 -47
  69. package/src/ckboxuploadadapter.d.ts +38 -38
  70. package/src/ckboxuploadadapter.js +275 -275
  71. package/src/index.d.ts +13 -13
  72. package/src/index.js +11 -11
  73. package/src/utils.d.ts +28 -28
  74. package/src/utils.js +49 -49
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Serbian (Latin) (https://app.transifex.com/ckeditor/teams/11143/sr@latin/)\n"
16
16
  "Language: sr@latin\n"
17
17
  "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Serbian (https://app.transifex.com/ckeditor/teams/11143/sr/)\n"
16
16
  "Language: sr\n"
17
17
  "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Swedish (https://app.transifex.com/ckeditor/teams/11143/sv/)\n"
16
16
  "Language: sv\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Thai (https://app.transifex.com/ckeditor/teams/11143/th/)\n"
16
16
  "Language: th\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Turkish (https://app.transifex.com/ckeditor/teams/11143/tr/)\n"
16
16
  "Language: tr\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n > 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Uyghur (https://app.transifex.com/ckeditor/teams/11143/ug/)\n"
16
16
  "Language: ug\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Ukrainian (https://app.transifex.com/ckeditor/teams/11143/uk/)\n"
16
16
  "Language: uk\n"
17
17
  "Plural-Forms: nplurals=4; plural=(n % 1 == 0 && n % 10 == 1 && n % 100 != 11 ? 0 : n % 1 == 0 && n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14) ? 1 : n % 1 == 0 && (n % 10 ==0 || (n % 10 >=5 && n % 10 <=9) || (n % 100 >=11 && n % 100 <=14 )) ? 2: 3);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Urdu (https://app.transifex.com/ckeditor/teams/11143/ur/)\n"
16
16
  "Language: ur\n"
17
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Uzbek (https://app.transifex.com/ckeditor/teams/11143/uz/)\n"
16
16
  "Language: uz\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Vietnamese (https://app.transifex.com/ckeditor/teams/11143/vi/)\n"
16
16
  "Language: vi\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Chinese (China) (https://app.transifex.com/ckeditor/teams/11143/zh_CN/)\n"
16
16
  "Language: zh_CN\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
@@ -15,6 +15,7 @@ msgstr ""
15
15
  "Language-Team: Chinese (Taiwan) (https://app.transifex.com/ckeditor/teams/11143/zh_TW/)\n"
16
16
  "Language: zh_TW\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
18
19
 
19
20
  msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
21
  msgid "Open file manager"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-ckbox",
3
- "version": "39.0.1",
3
+ "version": "40.0.0",
4
4
  "description": "CKBox integration for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,11 +12,7 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "39.0.1"
16
- },
17
- "engines": {
18
- "node": ">=16.0.0",
19
- "npm": ">=5.7.1"
15
+ "ckeditor5": "40.0.0"
20
16
  },
21
17
  "author": "CKSource (http://cksource.com/)",
22
18
  "license": "GPL-2.0-or-later",
@@ -1,22 +1,22 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- import type { CKBox, CKBoxCommand, CKBoxConfig, CKBoxEditing } from './index';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface EditorConfig {
8
- /**
9
- * The configuration of the {@link module:ckbox/ckbox~CKBox CKBox feature}.
10
- *
11
- * Read more in {@link module:ckbox/ckboxconfig~CKBoxConfig}.
12
- */
13
- ckbox?: CKBoxConfig;
14
- }
15
- interface PluginsMap {
16
- [CKBox.pluginName]: CKBox;
17
- [CKBoxEditing.pluginName]: CKBoxEditing;
18
- }
19
- interface CommandsMap {
20
- ckbox: CKBoxCommand;
21
- }
22
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ import type { CKBox, CKBoxCommand, CKBoxConfig, CKBoxEditing } from './index';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface EditorConfig {
8
+ /**
9
+ * The configuration of the {@link module:ckbox/ckbox~CKBox CKBox feature}.
10
+ *
11
+ * Read more in {@link module:ckbox/ckboxconfig~CKBoxConfig}.
12
+ */
13
+ ckbox?: CKBoxConfig;
14
+ }
15
+ interface PluginsMap {
16
+ [CKBox.pluginName]: CKBox;
17
+ [CKBoxEditing.pluginName]: CKBoxEditing;
18
+ }
19
+ interface CommandsMap {
20
+ ckbox: CKBoxCommand;
21
+ }
22
+ }
@@ -1,5 +1,5 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- export {};
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ export {};
package/src/ckbox.d.ts CHANGED
@@ -1,33 +1,33 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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 ckbox/ckbox
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import CKBoxUI from './ckboxui';
10
- import CKBoxEditing from './ckboxediting';
11
- /**
12
- * The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
13
- *
14
- * This is a "glue" plugin which enables:
15
- *
16
- * * {@link module:ckbox/ckboxediting~CKBoxEditing},
17
- * * {@link module:ckbox/ckboxui~CKBoxUI},
18
- *
19
- * See the {@glink features/file-management/ckbox CKBox integration} guide to learn how to configure and use this feature.
20
- *
21
- * Check out the {@glink features/images/image-upload/image-upload Image upload} guide to learn about other ways to upload
22
- * images into CKEditor 5.
23
- */
24
- export default class CKBox extends Plugin {
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName(): "CKBox";
29
- /**
30
- * @inheritDoc
31
- */
32
- static get requires(): readonly [typeof CKBoxEditing, typeof CKBoxUI];
33
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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 ckbox/ckbox
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import CKBoxUI from './ckboxui';
10
+ import CKBoxEditing from './ckboxediting';
11
+ /**
12
+ * The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
13
+ *
14
+ * This is a "glue" plugin which enables:
15
+ *
16
+ * * {@link module:ckbox/ckboxediting~CKBoxEditing},
17
+ * * {@link module:ckbox/ckboxui~CKBoxUI},
18
+ *
19
+ * See the {@glink features/file-management/ckbox CKBox integration} guide to learn how to configure and use this feature.
20
+ *
21
+ * Check out the {@glink features/images/image-upload/image-upload Image upload} guide to learn about other ways to upload
22
+ * images into CKEditor 5.
23
+ */
24
+ export default class CKBox extends Plugin {
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName(): "CKBox";
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ static get requires(): readonly [typeof CKBoxEditing, typeof CKBoxUI];
33
+ }
package/src/ckbox.js CHANGED
@@ -1,37 +1,37 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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 ckbox/ckbox
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import CKBoxUI from './ckboxui';
10
- import CKBoxEditing from './ckboxediting';
11
- /**
12
- * The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
13
- *
14
- * This is a "glue" plugin which enables:
15
- *
16
- * * {@link module:ckbox/ckboxediting~CKBoxEditing},
17
- * * {@link module:ckbox/ckboxui~CKBoxUI},
18
- *
19
- * See the {@glink features/file-management/ckbox CKBox integration} guide to learn how to configure and use this feature.
20
- *
21
- * Check out the {@glink features/images/image-upload/image-upload Image upload} guide to learn about other ways to upload
22
- * images into CKEditor 5.
23
- */
24
- export default class CKBox extends Plugin {
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName() {
29
- return 'CKBox';
30
- }
31
- /**
32
- * @inheritDoc
33
- */
34
- static get requires() {
35
- return [CKBoxEditing, CKBoxUI];
36
- }
37
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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 ckbox/ckbox
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import CKBoxUI from './ckboxui';
10
+ import CKBoxEditing from './ckboxediting';
11
+ /**
12
+ * The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
13
+ *
14
+ * This is a "glue" plugin which enables:
15
+ *
16
+ * * {@link module:ckbox/ckboxediting~CKBoxEditing},
17
+ * * {@link module:ckbox/ckboxui~CKBoxUI},
18
+ *
19
+ * See the {@glink features/file-management/ckbox CKBox integration} guide to learn how to configure and use this feature.
20
+ *
21
+ * Check out the {@glink features/images/image-upload/image-upload Image upload} guide to learn about other ways to upload
22
+ * images into CKEditor 5.
23
+ */
24
+ export default class CKBox extends Plugin {
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName() {
29
+ return 'CKBox';
30
+ }
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ static get requires() {
35
+ return [CKBoxEditing, CKBoxUI];
36
+ }
37
+ }
@@ -1,110 +1,110 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- import { Command, type Editor } from 'ckeditor5/src/core';
6
- import type { CKBoxAssetDefinition } from './ckboxconfig';
7
- declare global {
8
- var CKBox: {
9
- mount(wrapper: Element, options: Record<string, unknown>): void;
10
- };
11
- }
12
- /**
13
- * The CKBox command. It is used by the {@link module:ckbox/ckboxediting~CKBoxEditing CKBox editing feature} to open the CKBox file manager.
14
- * The file manager allows inserting an image or a link to a file into the editor content.
15
- *
16
- * ```ts
17
- * editor.execute( 'ckbox' );
18
- * ```
19
- *
20
- * **Note:** This command uses other features to perform the following tasks:
21
- * - To insert images it uses the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command from the
22
- * {@link module:image/image~Image Image feature}.
23
- * - To insert links to other files it uses the {@link module:link/linkcommand~LinkCommand 'link'} command from the
24
- * {@link module:link/link~Link Link feature}.
25
- */
26
- export default class CKBoxCommand extends Command {
27
- value: boolean;
28
- /**
29
- * A set of all chosen assets. They are stored temporarily and they are automatically removed 1 second after being chosen.
30
- * Chosen assets have to be "remembered" for a while to be able to map the given asset with the element inserted into the model.
31
- * This association map is then used to set the ID on the model element.
32
- *
33
- * All chosen assets are automatically removed after the timeout, because (theoretically) it may happen that they will never be
34
- * inserted into the model, even if the {@link module:link/linkcommand~LinkCommand `'link'`} command or the
35
- * {@link module:image/image/insertimagecommand~InsertImageCommand `'insertImage'`} command is enabled. Such a case may arise when
36
- * another plugin blocks the command execution. Then, in order not to keep the chosen (but not inserted) assets forever, we delete
37
- * them automatically to prevent memory leakage. The 1 second timeout is enough to insert the asset into the model and extract the
38
- * ID from the chosen asset.
39
- *
40
- * The assets are stored only if
41
- * the {@link module:ckbox/ckboxconfig~CKBoxConfig#ignoreDataId `config.ckbox.ignoreDataId`} option is set to `false` (by default).
42
- *
43
- * @internal
44
- */
45
- readonly _chosenAssets: Set<CKBoxAssetDefinition>;
46
- /**
47
- * The DOM element that acts as a mounting point for the CKBox dialog.
48
- */
49
- private _wrapper;
50
- /**
51
- * @inheritDoc
52
- */
53
- constructor(editor: Editor);
54
- /**
55
- * @inheritDoc
56
- */
57
- refresh(): void;
58
- /**
59
- * @inheritDoc
60
- */
61
- execute(): void;
62
- /**
63
- * Indicates if the CKBox dialog is already opened.
64
- *
65
- * @protected
66
- * @returns {Boolean}
67
- */
68
- private _getValue;
69
- /**
70
- * Checks whether the command can be enabled in the current context.
71
- */
72
- private _checkEnabled;
73
- /**
74
- * Creates the options object for the CKBox dialog.
75
- *
76
- * @returns The object with properties:
77
- * - theme The theme for CKBox dialog.
78
- * - language The language for CKBox dialog.
79
- * - tokenUrl The token endpoint URL.
80
- * - serviceOrigin The base URL of the API service.
81
- * - dialog.onClose The callback function invoked after closing the CKBox dialog.
82
- * - assets.onChoose The callback function invoked after choosing the assets.
83
- */
84
- private _prepareOptions;
85
- /**
86
- * Initializes various event listeners for the `ckbox:*` events, because all functionality of the `ckbox` command is event-based.
87
- */
88
- private _initListeners;
89
- /**
90
- * Inserts the asset into the model.
91
- *
92
- * @param asset The asset to be inserted.
93
- * @param isLastAsset Indicates if the current asset is the last one from the chosen set.
94
- * @param writer An instance of the model writer.
95
- */
96
- private _insertAsset;
97
- /**
98
- * Inserts the image by calling the `insertImage` command.
99
- *
100
- * @param asset The asset to be inserted.
101
- */
102
- private _insertImage;
103
- /**
104
- * Inserts the link to the asset by calling the `link` command.
105
- *
106
- * @param asset The asset to be inserted.
107
- * @param writer An instance of the model writer.
108
- */
109
- private _insertLink;
110
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ import { Command, type Editor } from 'ckeditor5/src/core';
6
+ import type { CKBoxAssetDefinition } from './ckboxconfig';
7
+ declare global {
8
+ var CKBox: {
9
+ mount(wrapper: Element, options: Record<string, unknown>): void;
10
+ };
11
+ }
12
+ /**
13
+ * The CKBox command. It is used by the {@link module:ckbox/ckboxediting~CKBoxEditing CKBox editing feature} to open the CKBox file manager.
14
+ * The file manager allows inserting an image or a link to a file into the editor content.
15
+ *
16
+ * ```ts
17
+ * editor.execute( 'ckbox' );
18
+ * ```
19
+ *
20
+ * **Note:** This command uses other features to perform the following tasks:
21
+ * - To insert images it uses the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command from the
22
+ * {@link module:image/image~Image Image feature}.
23
+ * - To insert links to other files it uses the {@link module:link/linkcommand~LinkCommand 'link'} command from the
24
+ * {@link module:link/link~Link Link feature}.
25
+ */
26
+ export default class CKBoxCommand extends Command {
27
+ value: boolean;
28
+ /**
29
+ * A set of all chosen assets. They are stored temporarily and they are automatically removed 1 second after being chosen.
30
+ * Chosen assets have to be "remembered" for a while to be able to map the given asset with the element inserted into the model.
31
+ * This association map is then used to set the ID on the model element.
32
+ *
33
+ * All chosen assets are automatically removed after the timeout, because (theoretically) it may happen that they will never be
34
+ * inserted into the model, even if the {@link module:link/linkcommand~LinkCommand `'link'`} command or the
35
+ * {@link module:image/image/insertimagecommand~InsertImageCommand `'insertImage'`} command is enabled. Such a case may arise when
36
+ * another plugin blocks the command execution. Then, in order not to keep the chosen (but not inserted) assets forever, we delete
37
+ * them automatically to prevent memory leakage. The 1 second timeout is enough to insert the asset into the model and extract the
38
+ * ID from the chosen asset.
39
+ *
40
+ * The assets are stored only if
41
+ * the {@link module:ckbox/ckboxconfig~CKBoxConfig#ignoreDataId `config.ckbox.ignoreDataId`} option is set to `false` (by default).
42
+ *
43
+ * @internal
44
+ */
45
+ readonly _chosenAssets: Set<CKBoxAssetDefinition>;
46
+ /**
47
+ * The DOM element that acts as a mounting point for the CKBox dialog.
48
+ */
49
+ private _wrapper;
50
+ /**
51
+ * @inheritDoc
52
+ */
53
+ constructor(editor: Editor);
54
+ /**
55
+ * @inheritDoc
56
+ */
57
+ refresh(): void;
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ execute(): void;
62
+ /**
63
+ * Indicates if the CKBox dialog is already opened.
64
+ *
65
+ * @protected
66
+ * @returns {Boolean}
67
+ */
68
+ private _getValue;
69
+ /**
70
+ * Checks whether the command can be enabled in the current context.
71
+ */
72
+ private _checkEnabled;
73
+ /**
74
+ * Creates the options object for the CKBox dialog.
75
+ *
76
+ * @returns The object with properties:
77
+ * - theme The theme for CKBox dialog.
78
+ * - language The language for CKBox dialog.
79
+ * - tokenUrl The token endpoint URL.
80
+ * - serviceOrigin The base URL of the API service.
81
+ * - dialog.onClose The callback function invoked after closing the CKBox dialog.
82
+ * - assets.onChoose The callback function invoked after choosing the assets.
83
+ */
84
+ private _prepareOptions;
85
+ /**
86
+ * Initializes various event listeners for the `ckbox:*` events, because all functionality of the `ckbox` command is event-based.
87
+ */
88
+ private _initListeners;
89
+ /**
90
+ * Inserts the asset into the model.
91
+ *
92
+ * @param asset The asset to be inserted.
93
+ * @param isLastAsset Indicates if the current asset is the last one from the chosen set.
94
+ * @param writer An instance of the model writer.
95
+ */
96
+ private _insertAsset;
97
+ /**
98
+ * Inserts the image by calling the `insertImage` command.
99
+ *
100
+ * @param asset The asset to be inserted.
101
+ */
102
+ private _insertImage;
103
+ /**
104
+ * Inserts the link to the asset by calling the `link` command.
105
+ *
106
+ * @param asset The asset to be inserted.
107
+ * @param writer An instance of the model writer.
108
+ */
109
+ private _insertLink;
110
+ }