@ckeditor/ckeditor5-ckbox 39.0.2 → 40.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
+ }