UNPKG

2.39 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/image/imageinlineediting
7 */
8import { Plugin } from 'ckeditor5/src/core.js';
9import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
10import ImageEditing from './imageediting.js';
11import ImageSizeAttributes from '../imagesizeattributes.js';
12import ImageUtils from '../imageutils.js';
13import ImagePlaceholder from './imageplaceholder.js';
14/**
15 * The image inline plugin.
16 *
17 * It registers:
18 *
19 * * `<imageInline>` as an inline element in the document schema, and allows `alt`, `src` and `srcset` attributes.
20 * * converters for editing and data pipelines.
21 * * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeInline'`} command that converts block images into
22 * inline images.
23 */
24export default class ImageInlineEditing extends Plugin {
25 /**
26 * @inheritDoc
27 */
28 static get requires(): readonly [typeof ImageEditing, typeof ImageSizeAttributes, typeof ImageUtils, typeof ImagePlaceholder, typeof ClipboardPipeline];
29 /**
30 * @inheritDoc
31 */
32 static get pluginName(): "ImageInlineEditing";
33 /**
34 * @inheritDoc
35 */
36 init(): void;
37 /**
38 * Configures conversion pipelines to support upcasting and downcasting
39 * inline images (inline image widgets) and their attributes.
40 */
41 private _setupConversion;
42 /**
43 * Integrates the plugin with the clipboard pipeline.
44 *
45 * Idea is that the feature should recognize the user's intent when an **block** image is
46 * pasted or dropped. If such an image is pasted/dropped into a non-empty block
47 * (e.g. a paragraph with some text) it gets converted into an inline image on the fly.
48 *
49 * We assume this is the user's intent if they decided to put their image there.
50 *
51 * **Note**: If a block image has a caption, it will not be converted to an inline image
52 * to avoid the confusion. Captions are added on purpose and they should never be lost
53 * in the clipboard pipeline.
54 *
55 * See the `ImageBlockEditing` for the similar integration that works in the opposite direction.
56 *
57 * The feature also sets image `width` and `height` attributes when pasting.
58 */
59 private _setupClipboardIntegration;
60}