ListStylePlugin.php in CKEditor List Style 8
File
src/Plugin/CKEditorPlugin/ListStylePlugin.php
View source
<?php
namespace Drupal\ckeditor_liststyle\Plugin\CKEditorPlugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\editor\Entity\Editor;
use Drupal\ckeditor\CKEditorPluginInterface;
use Drupal\ckeditor\CKEditorPluginContextualInterface;
class ListStylePlugin extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface {
public function getButtons() {
return [];
}
public function isEnabled(Editor $editor) {
$enabled = FALSE;
$settings = $editor
->getSettings();
foreach ($settings['toolbar']['rows'] as $row) {
foreach ($row as $group) {
foreach ($group['items'] as $button) {
if ($button === 'BulletedList' || $button === 'NumberedList') {
$enabled = TRUE;
}
}
}
}
return $enabled;
}
public function isInternal() {
return FALSE;
}
public function getDependencies(Editor $editor) {
return [];
}
public function getLibraries(Editor $editor) {
return [];
}
public function getFile() {
$plugin_paths = [
'libraries/liststyle/plugin.js',
'libraries/ckeditor/plugins/liststyle/plugin.js',
'libraries/ckeditor_liststyle/plugin.js',
];
$plugin = FALSE;
foreach ($plugin_paths as $plugin_path) {
if (file_exists(DRUPAL_ROOT . '/' . $plugin_path)) {
$plugin = $plugin_path;
break;
}
}
return $plugin;
}
public function getConfig(Editor $editor) {
return [];
}
}