UNPKG

2.35 kBTypeScriptView Raw
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 image/imageinsert/imageinsertui
7 */
8import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9import { type Observable } from 'ckeditor5/src/utils.js';
10import { type ButtonView, type DropdownView, type FocusableView } from 'ckeditor5/src/ui.js';
11import ImageUtils from '../imageutils.js';
12/**
13 * The image insert dropdown plugin.
14 *
15 * For a detailed overview, check the {@glink features/images/image-upload/image-upload Image upload feature}
16 * and {@glink features/images/images-inserting Insert images via source URL} documentation.
17 *
18 * Adds the `'insertImage'` dropdown to the {@link module:ui/componentfactory~ComponentFactory UI component factory}
19 * and also the `imageInsert` dropdown as an alias for backward compatibility.
20 */
21export default class ImageInsertUI extends Plugin {
22 /**
23 * @inheritDoc
24 */
25 static get pluginName(): "ImageInsertUI";
26 /**
27 * @inheritDoc
28 */
29 static get requires(): readonly [typeof ImageUtils];
30 /**
31 * The dropdown view responsible for displaying the image insert UI.
32 */
33 dropdownView?: DropdownView;
34 /**
35 * Observable property used to alter labels while some image is selected and when it is not.
36 *
37 * @observable
38 */
39 isImageSelected: boolean;
40 /**
41 * Registered integrations map.
42 */
43 private _integrations;
44 /**
45 * @inheritDoc
46 */
47 constructor(editor: Editor);
48 /**
49 * @inheritDoc
50 */
51 init(): void;
52 /**
53 * Registers the insert image dropdown integration.
54 */
55 registerIntegration({ name, observable, buttonViewCreator, formViewCreator, requiresForm }: {
56 name: string;
57 observable: (Observable & {
58 isEnabled: boolean;
59 }) | (() => Observable & {
60 isEnabled: boolean;
61 });
62 buttonViewCreator: (isOnlyOne: boolean) => ButtonView;
63 formViewCreator: (isOnlyOne: boolean) => FocusableView;
64 requiresForm?: boolean;
65 }): void;
66 /**
67 * Creates the toolbar component.
68 */
69 private _createToolbarComponent;
70 /**
71 * Validates the integrations list.
72 */
73 private _prepareIntegrations;
74}