You are here

AnchorLink.php in CKEditor Anchor Link - For Drupal 8 and 9 8

Same filename and directory in other branches
  1. 8.2 src/Plugin/CKEditorPlugin/AnchorLink.php

File

src/Plugin/CKEditorPlugin/AnchorLink.php
View source
<?php

namespace Drupal\anchor_link\Plugin\CKEditorPlugin;

use Drupal\editor\Entity\Editor;
use Drupal\ckeditor\CKEditorPluginBase;

/**
 * Defines the "link" plugin.
 *
 * @CKEditorPlugin(
 *   id = "link",
 *   label = @Translation("CKEditor Web link"),
 *   module = "anchor_link"
 * )
 */
class AnchorLink extends CKEditorPluginBase {

  /**
   * Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile().
   */
  public function getFile() {
    return drupal_get_path('module', 'anchor_link') . '/js/plugins/link/plugin.js';
  }

  /**
   * {@inheritdoc}
   */
  public function getDependencies(Editor $editor) {
    return [
      'fakeobjects',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getLibraries(Editor $editor) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function isInternal() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getButtons() {
    return [
      'Link' => [
        'label' => $this
          ->t('Link'),
        'image' => drupal_get_path('module', 'anchor_link') . '/js/plugins/link/icons/link.png',
      ],
      'Unlink' => [
        'label' => $this
          ->t('Unlink'),
        'image' => drupal_get_path('module', 'anchor_link') . '/js/plugins/link/icons/unlink.png',
      ],
      'Anchor' => [
        'label' => $this
          ->t('Anchor'),
        'image' => drupal_get_path('module', 'anchor_link') . '/js/plugins/link/icons/anchor.png',
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getConfig(Editor $editor) {
    return [];
  }

}

Classes

Namesort descending Description
AnchorLink Defines the "link" plugin.