UNPKG

2.2 kBTypeScriptView Raw
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 image/image/imageblockediting
7 */
8import { Plugin } from 'ckeditor5/src/core';
9import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
10import ImageEditing from './imageediting';
11import ImageSizeAttributes from '../imagesizeattributes';
12import ImageUtils from '../imageutils';
13import ImagePlaceholder from './imageplaceholder';
14/**
15 * The image block plugin.
16 *
17 * It registers:
18 *
19 * * `<imageBlock>` as a block 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 `'imageTypeBlock'`} command that converts inline images into
22 * block images.
23 */
24export default class ImageBlockEditing 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(): "ImageBlockEditing";
33 /**
34 * @inheritDoc
35 */
36 init(): void;
37 /**
38 * Configures conversion pipelines to support upcasting and downcasting
39 * block images (block 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 **inline** image is
46 * pasted or dropped. If such an image is pasted/dropped:
47 *
48 * * into an empty block (e.g. an empty paragraph),
49 * * on another object (e.g. some block widget).
50 *
51 * it gets converted into a block image on the fly. We assume this is the user's intent
52 * if they decided to put their image there.
53 *
54 * See the `ImageInlineEditing` for the similar integration that works in the opposite direction.
55 *
56 * The feature also sets image `width` and `height` attributes on paste.
57 */
58 private _setupClipboardIntegration;
59}