@ckeditor/ckeditor5-media-embed
Version:
Media embed feature for CKEditor 5.
52 lines (51 loc) • 1.68 kB
TypeScript
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module media-embed/automediaembed
*/
import { type Editor, Plugin } from 'ckeditor5/src/core';
import { Clipboard } from 'ckeditor5/src/clipboard';
import { Delete } from 'ckeditor5/src/typing';
import { Undo } from 'ckeditor5/src/undo';
/**
* The auto-media embed plugin. It recognizes media links in the pasted content and embeds
* them shortly after they are injected into the document.
*/
export default class AutoMediaEmbed extends Plugin {
/**
* @inheritDoc
*/
static get requires(): readonly [typeof Clipboard, typeof Delete, typeof Undo];
/**
* @inheritDoc
*/
static get pluginName(): 'AutoMediaEmbed';
/**
* The paste–to–embed `setTimeout` ID. Stored as a property to allow
* cleaning of the timeout.
*/
private _timeoutId;
/**
* The position where the `<media>` element will be inserted after the timeout,
* determined each time the new content is pasted into the document.
*/
private _positionToInsert;
/**
* @inheritDoc
*/
constructor(editor: Editor);
/**
* @inheritDoc
*/
init(): void;
/**
* Analyzes the part of the document between provided positions in search for a URL representing media.
* When the URL is found, it is automatically converted into media.
*
* @param leftPosition Left position of the selection.
* @param rightPosition Right position of the selection.
*/
private _embedMediaBetweenPositions;
}