UNPKG

1.46 kBJavaScriptView 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 media-embed/mediaembedtoolbar
7 */
8import { Plugin } from 'ckeditor5/src/core';
9import { WidgetToolbarRepository } from 'ckeditor5/src/widget';
10import { getSelectedMediaViewWidget } from './utils';
11import './mediaembedconfig';
12/**
13 * The media embed toolbar plugin. It creates a toolbar for media embed that shows up when the media element is selected.
14 *
15 * Instances of toolbar components (e.g. buttons) are created based on the
16 * {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#toolbar `media.toolbar` configuration option}.
17 */
18export default class MediaEmbedToolbar extends Plugin {
19 /**
20 * @inheritDoc
21 */
22 static get requires() {
23 return [WidgetToolbarRepository];
24 }
25 /**
26 * @inheritDoc
27 */
28 static get pluginName() {
29 return 'MediaEmbedToolbar';
30 }
31 /**
32 * @inheritDoc
33 */
34 afterInit() {
35 const editor = this.editor;
36 const t = editor.t;
37 const widgetToolbarRepository = editor.plugins.get(WidgetToolbarRepository);
38 widgetToolbarRepository.register('mediaEmbed', {
39 ariaLabel: t('Media toolbar'),
40 items: editor.config.get('mediaEmbed.toolbar') || [],
41 getRelatedElement: getSelectedMediaViewWidget
42 });
43 }
44}