CkeditorTableSelection.php in CKEditor Table Selection 9.1.x
File
src/Plugin/CKEditorPlugin/CkeditorTableSelection.php
View source
<?php
namespace Drupal\ckeditor_tableselection\Plugin\CKEditorPlugin;
use Drupal\Core\Plugin\PluginBase;
use Drupal\editor\Entity\Editor;
use Drupal\ckeditor\CKEditorPluginInterface;
use Drupal\ckeditor\CKEditorPluginContextualInterface;
use Drupal\ckeditor\CKEditorPluginCssInterface;
class CkeditorTableSelection extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface, CKEditorPluginCssInterface {
public function isInternal() {
return FALSE;
}
private function getPluginPath() {
return 'libraries/tableselection';
}
public function getFile() {
return $this
->getPluginPath() . '/plugin.js';
}
public function isEnabled(Editor $editor) {
if (!$editor
->hasAssociatedFilterFormat()) {
return FALSE;
}
$format = $editor
->getFilterFormat();
if ($format
->filters('filter_align')->status || $format
->filters('filter_caption')->status) {
$settings = $editor
->getSettings();
foreach ($settings['toolbar']['rows'] as $row) {
foreach ($row as $group) {
foreach ($group['items'] as $button) {
if ($button === 'Table') {
return TRUE;
}
}
}
}
}
return FALSE;
}
public function getCssFiles(Editor $editor) {
return [
$this
->getPluginPath() . '/styles/tableselection.css',
];
}
public function getLibraries(Editor $editor) {
return [];
}
public function getConfig(Editor $editor) {
return [];
}
public function getDependencies(Editor $editor) {
return [];
}
public function getButtons() {
return [];
}
}