class DrupalImageCaption
Same name in other branches
- 8.9.x core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php \Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalImageCaption
Defines the "drupalimagecaption" plugin.
Plugin annotation
@CKEditorPlugin(
id = "drupalimagecaption",
label = @Translation("Drupal image caption widget"),
module = "ckeditor"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalImageCaption extends \Drupal\Core\Plugin\PluginBase implements \Drupal\ckeditor\CKEditorPluginInterface, \Drupal\ckeditor\CKEditorPluginContextualInterface, \Drupal\ckeditor\CKEditorPluginCssInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of DrupalImageCaption
1 string reference to 'DrupalImageCaption'
- CKEditorPluginManagerTest::testEnabledPlugins in core/
modules/ ckeditor/ tests/ src/ Kernel/ CKEditorPluginManagerTest.php - Tests the enabling of plugins.
File
-
core/
modules/ ckeditor/ src/ Plugin/ CKEditorPlugin/ DrupalImageCaption.php, line 22
Namespace
Drupal\ckeditor\Plugin\CKEditorPluginView source
class DrupalImageCaption extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface, CKEditorPluginCssInterface, ContainerFactoryPluginInterface {
/**
* The module extension list.
*
* @var \Drupal\Core\Extension\ModuleExtensionList
*/
protected $moduleList;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$instance = new static($configuration, $plugin_id, $plugin_definition);
$instance->moduleList = $container->get('extension.list.module');
return $instance;
}
/**
* {@inheritdoc}
*/
public function isInternal() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getDependencies(Editor $editor) {
return [];
}
/**
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
return [
'ckeditor/drupal.ckeditor.plugins.drupalimagecaption',
];
}
/**
* {@inheritdoc}
*/
public function getFile() {
return $this->moduleList
->getPath('ckeditor') . '/js/plugins/drupalimagecaption/plugin.js';
}
/**
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
$format = $editor->getFilterFormat();
return [
'image2_captionedClass' => 'caption caption-img',
'image2_alignClasses' => [
'align-left',
'align-center',
'align-right',
],
'drupalImageCaption_captionPlaceholderText' => $this->t('Enter caption here'),
// Only enable those parts of DrupalImageCaption for which the
// corresponding Drupal text filters are enabled.
'drupalImageCaption_captionFilterEnabled' => $format->filters('filter_caption')->status,
'drupalImageCaption_alignFilterEnabled' => $format->filters('filter_align')->status,
];
}
/**
* {@inheritdoc}
*/
public function getCssFiles(Editor $editor) {
return [
$this->moduleList
->getPath('ckeditor') . '/css/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css',
];
}
/**
* {@inheritdoc}
*/
public function isEnabled(Editor $editor) {
if (!$editor->hasAssociatedFilterFormat()) {
return FALSE;
}
// Automatically enable this plugin if the text format associated with this
// text editor uses the filter_align or filter_caption filter and the
// DrupalImage button is enabled.
$format = $editor->getFilterFormat();
if ($format->filters('filter_align')->status || $format->filters('filter_caption')->status) {
$enabled = FALSE;
$settings = $editor->getSettings();
foreach ($settings['toolbar']['rows'] as $row) {
foreach ($row as $group) {
foreach ($group['items'] as $button) {
if ($button === 'DrupalImage') {
$enabled = TRUE;
}
}
}
}
return $enabled;
}
return FALSE;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
DrupalImageCaption::$moduleList | protected | property | The module extension list. | ||
DrupalImageCaption::create | public static | function | Creates an instance of the plugin. | Overrides ContainerFactoryPluginInterface::create | |
DrupalImageCaption::getConfig | public | function | Returns the additions to CKEDITOR.config for a specific CKEditor instance. | Overrides CKEditorPluginInterface::getConfig | |
DrupalImageCaption::getCssFiles | public | function | Retrieves enabled plugins' iframe instance CSS files. | Overrides CKEditorPluginCssInterface::getCssFiles | |
DrupalImageCaption::getDependencies | public | function | Returns a list of plugins this plugin requires. | Overrides CKEditorPluginInterface::getDependencies | |
DrupalImageCaption::getFile | public | function | Returns the Drupal root-relative file path to the plugin JavaScript file. | Overrides CKEditorPluginInterface::getFile | |
DrupalImageCaption::getLibraries | public | function | Returns a list of libraries this plugin requires. | Overrides CKEditorPluginInterface::getLibraries | |
DrupalImageCaption::isEnabled | public | function | Checks if this plugin should be enabled based on the editor configuration. | Overrides CKEditorPluginContextualInterface::isEnabled | |
DrupalImageCaption::isInternal | public | function | Indicates if this plugin is part of the optimized CKEditor build. | Overrides CKEditorPluginInterface::isInternal | |
PluginInspectionInterface::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | 6 | |
PluginInspectionInterface::getPluginId | public | function | Gets the plugin_id of the plugin instance. | 2 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.