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 | */
|
8 | import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
9 | import { type Observable } from 'ckeditor5/src/utils.js';
|
10 | import { type ButtonView, type DropdownView, type FocusableView, type MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';
|
11 | import 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 | *
|
21 | * Adds the `'menuBar:insertImage'` sub-menu to the {@link module:ui/componentfactory~ComponentFactory UI component factory}, which is
|
22 | * by default added to the `'Insert'` menu.
|
23 | */
|
24 | export default class ImageInsertUI extends Plugin {
|
25 | /**
|
26 | * @inheritDoc
|
27 | */
|
28 | static get pluginName(): "ImageInsertUI";
|
29 | /**
|
30 | * @inheritDoc
|
31 | */
|
32 | static get requires(): readonly [typeof ImageUtils];
|
33 | /**
|
34 | * The dropdown view responsible for displaying the image insert UI.
|
35 | */
|
36 | dropdownView?: DropdownView;
|
37 | /**
|
38 | * Observable property used to alter labels while some image is selected and when it is not.
|
39 | *
|
40 | * @observable
|
41 | */
|
42 | isImageSelected: boolean;
|
43 | /**
|
44 | * Registered integrations map.
|
45 | */
|
46 | private _integrations;
|
47 | /**
|
48 | * @inheritDoc
|
49 | */
|
50 | constructor(editor: Editor);
|
51 | /**
|
52 | * @inheritDoc
|
53 | */
|
54 | init(): void;
|
55 | /**
|
56 | * Registers the insert image dropdown integration.
|
57 | */
|
58 | registerIntegration({ name, observable, buttonViewCreator, formViewCreator, menuBarButtonViewCreator, requiresForm }: {
|
59 | name: string;
|
60 | observable: (Observable & {
|
61 | isEnabled: boolean;
|
62 | }) | (() => Observable & {
|
63 | isEnabled: boolean;
|
64 | });
|
65 | buttonViewCreator: (isOnlyOne: boolean) => ButtonView;
|
66 | formViewCreator: (isOnlyOne: boolean) => FocusableView;
|
67 | menuBarButtonViewCreator: (isOnlyOne: boolean) => MenuBarMenuListItemButtonView;
|
68 | requiresForm?: boolean;
|
69 | }): void;
|
70 | /**
|
71 | * Creates the toolbar component.
|
72 | */
|
73 | private _createToolbarComponent;
|
74 | /**
|
75 | * Creates the menu bar component.
|
76 | */
|
77 | private _createMenuBarComponent;
|
78 | /**
|
79 | * Validates the integrations list.
|
80 | */
|
81 | private _prepareIntegrations;
|
82 | }
|