class IndentBlock in CKEditor IndentBlock 8
Defines the "Indent Block" plugin.
NOTE: The plugin ID ('id' key) corresponds to the CKEditor plugin name. It is the first argument of the CKEDITOR.plugins.add() function in the plugin.js file.
Plugin annotation
@CKEditorPlugin(
id = "indentblock",
label = @Translation("Indent Block")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\ckeditor\CKEditorPluginBase implements CKEditorPluginButtonsInterface, CKEditorPluginInterface
- class \Drupal\ckeditor_indentblock\Plugin\CKEditorPlugin\IndentBlock implements CKEditorPluginConfigurableInterface, CKEditorPluginContextualInterface, CKEditorPluginCssInterface
- class \Drupal\ckeditor\CKEditorPluginBase implements CKEditorPluginButtonsInterface, CKEditorPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of IndentBlock
File
- src/
Plugin/ CKEditorPlugin/ IndentBlock.php, line 24
Namespace
Drupal\ckeditor_indentblock\Plugin\CKEditorPluginView source
class IndentBlock extends CKEditorPluginBase implements CKEditorPluginContextualInterface, CKEditorPluginConfigurableInterface, CKEditorPluginCssInterface {
/**
* {@inheritdoc}
*/
public function getCssFiles(Editor $editor) {
return [
drupal_get_path('module', 'ckeditor_indentblock') . '/css/plugins/indentblock/ckeditor.indentblock.css',
];
}
/**
* {@inheritdoc}
*
* NOTE: The keys of the returned array corresponds to the CKEditor button
* names. They are the first argument of the editor.ui.addButton() or
* editor.ui.addRichCombo() functions in the plugin.js file.
*/
public function getButtons() {
return [];
}
/**
* {@inheritdoc}
*/
public function getFile() {
$library_url = $this
->getLibraryURL();
if ($library_url != '') {
return $library_url;
}
else {
// Default value, if CKEditor Indentblock library is not found.
return 'libraries/indentblock/plugin.js';
}
}
/**
* {@inheritdoc}
*/
public function isEnabled(Editor $editor) {
// Enable this plugin, if it is configured as being enabled and at least one
// of the buttons, Indent or Outdent, is enabled.
$settings = $editor
->getSettings();
if (isset($settings['plugins']['indentblock']) && $settings['plugins']['indentblock']['enable']) {
foreach ($settings['toolbar']['rows'] as $row) {
foreach ($row as $group) {
foreach ($group['items'] as $button) {
if ($button === 'Indent' || $button === 'Outdent') {
return TRUE;
}
}
}
}
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function isInternal() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getDependencies(Editor $editor) {
// The Indent plugin is internal for Drupal 8 CKEditor and thus can't be
// defined as a dependency.
return [];
}
/**
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
return [];
}
/**
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
return [
'indentClasses' => [
'Indent1',
'Indent2',
'Indent3',
'Indent4',
'Indent5',
'Indent6',
'Indent7',
'Indent8',
'Indent9',
'Indent10',
],
'indentOffset' => 2,
'indentUnit' => 'em',
];
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
$settings = $editor
->getSettings();
$form['enable'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enable indentation on paragraphs'),
'#default_value' => !empty($settings['plugins']['indentblock']) && $settings['plugins']['indentblock']['enable'] === 1 ? $settings['plugins']['indentblock']['enable'] : 0,
);
if ($this
->getLibraryURL() == '') {
$form['enable']['#disabled'] = TRUE;
$form['enable']['#description'] = $this
->t('CKEditor IndentBlock cannot be enabled, as the plugin has not been found in any libraries path!');
$form['enable']['#default_value'] = 0;
}
return $form;
}
/**
* Get the CKEditor Indentblock library URL.
*/
protected function getLibraryURL() {
// Search for the path under the current site for multisites.
$directories[] = \Drupal::service('site.path') . "/libraries/";
// Search also the root 'libraries' directory.
$directories[] = 'libraries/';
// Search also at the path for ckeditor plugins.
$directories[] = 'libraries/ckeditor/plugins/';
// Installation profiles can place libraries into a 'libraries' directory,
// so search that too.
if ($installProfile = \Drupal::installProfile()) {
$profile_path = drupal_get_path('profile', $installProfile);
$directories[] = "{$profile_path}/libraries/";
}
foreach ($directories as $dir) {
if (file_exists(DRUPAL_ROOT . '/' . $dir . 'indentblock/plugin.js')) {
return $dir . 'indentblock/plugin.js';
}
}
// CKEditor Indentblock library not found.
return '';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
IndentBlock:: |
public | function |
NOTE: The keys of the returned array corresponds to the CKEditor button
names. They are the first argument of the editor.ui.addButton() or
editor.ui.addRichCombo() functions in the plugin.js file. Overrides CKEditorPluginButtonsInterface:: |
|
IndentBlock:: |
public | function |
Returns the additions to CKEDITOR.config for a specific CKEditor instance. Overrides CKEditorPluginInterface:: |
|
IndentBlock:: |
public | function |
Retrieves enabled plugins' iframe instance CSS files. Overrides CKEditorPluginCssInterface:: |
|
IndentBlock:: |
public | function |
Returns a list of plugins this plugin requires. Overrides CKEditorPluginBase:: |
|
IndentBlock:: |
public | function |
Returns the Drupal root-relative file path to the plugin JavaScript file. Overrides CKEditorPluginInterface:: |
|
IndentBlock:: |
public | function |
Returns a list of libraries this plugin requires. Overrides CKEditorPluginBase:: |
|
IndentBlock:: |
protected | function | Get the CKEditor Indentblock library URL. | |
IndentBlock:: |
public | function |
Checks if this plugin should be enabled based on the editor configuration. Overrides CKEditorPluginContextualInterface:: |
|
IndentBlock:: |
public | function |
Indicates if this plugin is part of the optimized CKEditor build. Overrides CKEditorPluginBase:: |
|
IndentBlock:: |
public | function |
Returns a settings form to configure this CKEditor plugin. Overrides CKEditorPluginConfigurableInterface:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |