UNPKG

1.69 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 media-embed/automediaembed
7 */
8import { type Editor, Plugin } from 'ckeditor5/src/core.js';
9import { Clipboard } from 'ckeditor5/src/clipboard.js';
10import { Delete } from 'ckeditor5/src/typing.js';
11import { Undo } from 'ckeditor5/src/undo.js';
12/**
13 * The auto-media embed plugin. It recognizes media links in the pasted content and embeds
14 * them shortly after they are injected into the document.
15 */
16export default class AutoMediaEmbed extends Plugin {
17 /**
18 * @inheritDoc
19 */
20 static get requires(): readonly [typeof Clipboard, typeof Delete, typeof Undo];
21 /**
22 * @inheritDoc
23 */
24 static get pluginName(): "AutoMediaEmbed";
25 /**
26 * The paste–to–embed `setTimeout` ID. Stored as a property to allow
27 * cleaning of the timeout.
28 */
29 private _timeoutId;
30 /**
31 * The position where the `<media>` element will be inserted after the timeout,
32 * determined each time the new content is pasted into the document.
33 */
34 private _positionToInsert;
35 /**
36 * @inheritDoc
37 */
38 constructor(editor: Editor);
39 /**
40 * @inheritDoc
41 */
42 init(): void;
43 /**
44 * Analyzes the part of the document between provided positions in search for a URL representing media.
45 * When the URL is found, it is automatically converted into media.
46 *
47 * @param leftPosition Left position of the selection.
48 * @param rightPosition Right position of the selection.
49 */
50 private _embedMediaBetweenPositions;
51}