Anchor.php in CKEditor Anchor Link - For Drupal 8 and 9 3.0.x
File
src/Plugin/CKEditorPlugin/Anchor.php
View source
<?php
namespace Drupal\anchor_link\Plugin\CKEditorPlugin;
use Drupal\editor\Entity\Editor;
use Drupal\ckeditor\CKEditorPluginBase;
class Anchor extends CKEditorPluginBase {
public function getFile() {
return $this
->getLibraryPath() . '/plugin.js';
}
public function getDependencies(Editor $editor) {
return [
'fakeobjects',
];
}
public function getLibraries(Editor $editor) {
return [];
}
public function isInternal() {
return FALSE;
}
public function getButtons() {
$libraryUrl = $this
->getLibraryUrl();
return [
'Anchor' => [
'label' => $this
->t('Anchor'),
'image' => $libraryUrl . '/icons/anchor.png',
],
];
}
public function getConfig(Editor $editor) {
return [];
}
protected function getLibraryPath() {
$module_path = \Drupal::service('module_handler')
->getModule('anchor_link')
->getPath();
return $module_path . '/js/anchor';
}
protected function getLibraryUrl() {
$originUrl = \Drupal::request()
->getSchemeAndHttpHost() . \Drupal::request()
->getBaseUrl();
$module_path = \Drupal::service('module_handler')
->getModule('anchor_link')
->getPath();
return $originUrl . $module_path . '/js/anchor';
}
}
Classes
Name |
Description |
Anchor |
Defines the "anchor" plugin. |