TemplateSelector.php in Wysiwyg API template plugin 3.0.x
File
src/Plugin/CKEditorPlugin/TemplateSelector.php
View source
<?php
namespace Drupal\wysiwyg_template\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\Core\Url;
use Drupal\editor\Entity\Editor;
class TemplateSelector extends CKEditorPluginBase {
public function getButtons() : array {
return [
'TemplateSelector' => [
'label' => $this
->t('Insert templates'),
'image' => drupal_get_path('module', 'wysiwyg_template') . '/js/plugins/templateselector/icons/templateselector.png',
],
];
}
public function getFile() {
return drupal_get_path('module', 'wysiwyg_template') . '/js/plugins/templateselector/plugin.js';
}
public function getConfig(Editor $editor) : array {
return [
'templates_files' => [
Url::fromRoute('wysiwyg_template.list_js.type', [
'entity_type' => 'dummy',
'bundle' => 'dummy',
])
->toString(),
],
'templates_replaceContent' => FALSE,
];
}
public function getLibraries(Editor $editor) : array {
return [
'core/drupal.ajax',
];
}
public function getDependencies(Editor $editor) : array {
return [
'templates',
];
}
}