1 |
|
2 |
|
3 |
|
4 |
|
5 | import { Command, type Editor } from 'ckeditor5/src/core.js';
|
6 | import type { Writer, Element } from 'ckeditor5/src/engine.js';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | export default class ReplaceImageSourceCommand extends Command {
|
20 | value: string | null;
|
21 | constructor(editor: Editor);
|
22 | /**
|
23 | * @inheritDoc
|
24 | */
|
25 | refresh(): void;
|
26 | /**
|
27 | * Executes the command.
|
28 | *
|
29 | * @fires execute
|
30 | * @param options Options for the executed command.
|
31 | * @param options.source The image source to replace.
|
32 | */
|
33 | execute(options: {
|
34 | source: string;
|
35 | }): void;
|
36 | /**
|
37 | * Cleanup image attributes that are not relevant to the new source.
|
38 | *
|
39 | * Removed attributes are: 'srcset', 'sizes', 'sources', 'width', 'height', 'alt'.
|
40 | *
|
41 | * This method is decorated, to allow custom cleanup logic.
|
42 | * For example, to remove 'myImageId' attribute after 'src' has changed:
|
43 | *
|
44 | * ```ts
|
45 | * replaceImageSourceCommand.on( 'cleanupImage', ( eventInfo, [ writer, image ] ) => {
|
46 | * writer.removeAttribute( 'myImageId', image );
|
47 | * } );
|
48 | * ```
|
49 | */
|
50 | cleanupImage(writer: Writer, image: Element): void;
|
51 | }
|