CKEditor Plugins in Drupal 8 installieren/registrieren

Gewusst wie, ist es mit CKEditor Plugins in Drupal 8 fast so einfach wie in Drupal 7

Drupal 8 release ist mittlerweile schon längere Zeit am Markt und die meisten Module und Funktionalitäten sind ausgereift, um mit einem Versuch in Drupal 8 zu starten. Da in Drupal 8 der CKEditor für die komfortable Textbearbeitung bereits seriemäßig enthalten ist, hat sich auch das Verwalten von Plugins zu Drupal 7 verändert. Nach unseren ersten Versuchen, die eigene Plugins hinzuzufügen um zu aktivieren, sind wir beinahe verzweifelt. Aber mit etwas Recherche und getüftel sind wir doch zum Ziel gekommen :-) In den folgenden Schritten möchten wir dir kurz erläutern, wie auch du CKEditor Plugins in Drupal 8 registrieren bzw. verwenden kannst.

CKEditor Plugin herunterladen

Wir demonstrieren es in folgendem Beispiel mit dem DIV Container Manager. Zunächst lädst du dir unter http://ckeditor.com/addon/div das Plugin herunter. Nun entpackst du das Plugin in den Ordner /libraries, welcher sich im Root-Verzeichnis deiner Drupal 8 Installation befinden sollte. Wenn nicht => anlegen.

 

1. Ein Modul für das Plugin anlegen

Es genügt dem Editor leider nicht, einfach nur das Plugin in ein Verzeichnis abzulegen. Daher müssen wir dem Editor nun beibringen, dass er das Plugin registrieren soll. Dies lösen wir über ein kleines eigenes Modul.

  • Du wechselst in das Verzeichnis /modules und legst einen neuen Ordner ckeditor_div an
    • In diesem Verzeichnis erstellst du eine neue Datei namens ckeditor_div.module. Diese Datei enthält ausschließlich nur ein öffnendes php tag (<?php)
    • Auch legst du folgende Ordner in der Reihenfolge an
      • src
        • Plugin
          • CKEditorPlugin
    • Danach erstellst du die Datei ckeditor_div.info.yml und füllst sie mit
name: CKEditor Div Container Manager 
type: module 
description: Adds a Div toolbar button. 
core: 8.x 
package: CKEditor 
dependencies: 
  - ckeditor

Danach speicherst du alle Dateien.

 

2. Das Plugin installieren

  • In der zuvor erstellten Ordnerhierarchie legst du nun eine neue PHP-Datei namens Div.php an
  • Diese Datei hat folgenden Inhalt (welches du übrigens als Template für andere Plugins verwenden kannst)
    • Wichtig: Achte darauf, die richtige plugin class, plugin ID und den richtigen button name zu setzen
<?php

namespace Drupal\ckeditor_div\Plugin\CKEditorPlugin;

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

/**
 * Defines the "div" plugin.
 *
 * NOTE: The plugin ID ('id' key) corresponds to the CKEditor plugin name.
 * It is the first argument of the CKEDITOR.plugins.add() function in the
 * plugin.js file.
 *
 * @CKEditorPlugin(
 *   id = "div", // Die ID des Plugins, zu finden in der plugin.js, direkt bei CKEDITOR.plugins.add(...
 *   label = @Translation("Create Div Container")
 * )
 */
class Div extends CKEditorPluginBase { // Die class ist quasi frei wählbar

  /**
   * {@inheritdoc}
   *
   * NOTE: The keys of the returned array corresponds to the CKEditor button
   * names. They are the first argument of the editor.ui.addButton() or
   * editor.ui.addRichCombo() functions in the plugin.js file.
   */
  public function getButtons() { 
    // Make sure that the path to the image matches the file structure of
    // the CKEditor plugin you are implementing.
    return [
      'CreateDiv' => [ // dies ist der button name und dieser korrespondiert zum Plugin button name, zu finden in der plugin.js bei editor.ui.addButton( ...
        'label' => t('Create Div Container'),
        'image' => libraries_get_path('div') . '/icons/creatediv.png' // Pfad des libraries-Verzeichnis

      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFile() {
    // Make sure that the path to the plugin.js matches the file structure of
    // the CKEditor plugin you are implementing.
    return libraries_get_path('div') . '/plugin.js'; // Pfad des libraries-Verzeichnis
  }

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

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

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

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

}

 

3. Modul aktivieren und CKEditor konfigurieren

Nachdem du das Modul ckeditor_div aktiviert hast, navigierst du zu Verwaltung > Konfiguration > Inhaltserstellung > Textformate und -editoren und editierst dein Textformat – in unserem Fall HTML. Nun sollte das neue Icon sichtbar sein.

Das wars! So einfach funktioniert es letztendlich.

PS: If your button is not visible while editing a node but it is visible in the configuration file, that means that the value you have on the getButtons() function doesn't match with the values from plugin.js. This got me back and forth for a while.

Anmerkung: Falls der Button während du den Content editierst nicht sichtbar ist, jedoch in der Konfiguration des CKEditors, bedeutet dies, dass die gesetzten values in der getButtons() Funktion nicht mit den values der plugin.js übereinstimmen. Unbedingt prüfen!

Text

  • Keine HTML-Tags erlaubt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.

Meinungen und Kommentare

I and my guys came analyzing the excellent secrets and techniques found on the website and then all of the sudden got a terrible suspicion I had not thanked the website owner for those secrets. Most of the young men ended up for this reason stimulated to read through them and have simply been using them. We appreciate you simply being well kind and then for figuring out varieties of essential information most people are really desirous to discover. My very own honest regret for not expressing gratitude to earlier.
westbrook shoes http://www.russellwestbrookshoes.us.com

<a href="http://prednisonefastsecure.com/">buy prednisone no prescription</a>

Jordan 12 Gym Red http://www.jordan12gymred.us.com/
nike factory outlet http://www.nikefactoryoutletstoreonline.com/
Nike Outlet satore http://www.nikefactoryoutletstoreonline.us/
Nike Outlet http://www.nikestores.us.com/
retro jordan 33 http://www.jordan33.us/
cheapjerseysfromchina http://www.cheapjerseysfromchina.us/
nfl jerseys http://www.customnfljerseys.us/
air jordan 11 concord http://www.jordan11concord.us.com/
Jordan 12 Gym Red 2018 http://www.jordan12gymred.us/
Jordan 12 Gym Red http://www.redjordan12.us/
Yeezy http://www.yeezy.com.co/
Yeezy Shoes http://www.yeezys.us.com/
Yeezy Shoes http://www.yeezysupply.us.com/
Yeezy Sneakers http://www.yeezy-shoes.us.com/
Yeezy Boost 350 V2 http://www.yeezy-boost350.com/
Yeezy Boost 350 V2 http://www.yeezyboost350.us.com/
Yeezy Blue Tint http://www.yeezybluetint.com/
Yeezy 500 http://www.yeezy500utilityblack.com/
Yeezy 500 Utility Black http://www.yeezy500utilityblack.us/
Nike VaporMax http://www.vapor-max.org.uk/
Salomon UK http://www.salomon-shoes.org.uk/
Salomon http://www.salomons.me.uk/
Salomon Shoes http://www.salomonspeedcross4.org.uk/
Off White Jordan http://www.offwhitejordan1.com/
Vapor Max http://www.nikevapormax.org.uk/
Nike React Element 87 http://www.nikereactelement87.us.com/
Nike Element 87 http://www.nikereactelement87.us/
Nike Air Vapormax Plus http://www.nikeplus.us/
Nike Outlet http://www.nike--outlet.us/
Nike Outlet Store Online Shopping http://www.nikeoutletstoreonlineshopping.us/
Nike Outlet http://www.nikeoutletonlineshopping.us/
NBA Jerseys http://www.nikenbajerseys.us/
Air Max 97 http://www.nikeairmax.us/
Nike Air Max 2017 http://www.max2017.us/
Air Jordan Shoes http://www.jordan-com.com/
Jordan 11 Concord 2018 http://www.jordan11-concord.com/
Cheap Yeezy Shoes http://www.cs7boots1.com/
Wholesale Cheap NBA Jerseys http://www.cheapnba-jerseys.us/
Birkenstock Sandals http://www.birkenstocksandalsuk.me.uk/
NBA Jerseys http://www.basketball-jersey.us/
Balenciaga UK http://www.balenciaga.me.uk/
Balenciaga UK http://www.balenciagauk.org.uk/
Balenciaga http://www.balenciagatriples.org.uk/
Balenciaga http://www.birkenstocks.me.uk/
Balenciaga Trainers http://www.balenciagatrainers.org.uk/
Nike Air Max http://www.airmax270.org.uk/
Yeezy Shoes http://www.adidasyeezyshoes.org.uk/
Yeezy Shoes http://www.adidasyeezyshoes.org.uk/

Jordan 11 Concord http://www.jordan11-concord.com/

Thank you a lot for providing individuals with remarkably spectacular chance to discover important secrets from this site. It is always very brilliant plus stuffed with fun for me personally and my office acquaintances to search the blog at least thrice in a week to find out the newest things you have got. Of course, we are actually motivated with your mind-blowing secrets you serve. Some 3 ideas on this page are easily the finest we have ever had.
golden goose sneakers http://www.goldengoosesneakers.us

<a href="http://proscar.golf/">proscar</a> <a href="http://buyallopurinol.network/">buy allopurinol</a> <a href="http://effexor.network/">buy effexor xr 150mg</a> <a href="http://synthroid.capetown/">levothyroxine ordering online</a>

I would like to show my gratitude for your generosity giving support to individuals that absolutely need assistance with your concern. Your real dedication to getting the solution all around turned out to be pretty functional and have usually empowered individuals much like me to attain their objectives. The valuable tips and hints entails a whole lot to me and substantially more to my fellow workers. Regards; from all of us.
yeezy boost http://urlr.be/short/yzyinc

<a href="http://buycipro.team/">buy cipro</a>

<a href="http://plavix.network/">purchase plavix online</a>

I simply needed to say thanks once more. I am not sure the things that I would've done in the absence of the entire opinions documented by you relating to this area. Entirely was a very troublesome difficulty for me personally, nevertheless discovering the very skilled manner you resolved that forced me to leap with happiness. Extremely thankful for your help as well as sincerely hope you comprehend what a powerful job you happen to be putting in teaching most people using your webpage. I am sure you haven't got to know all of us.
golden goose outlet http://www.goldengoose-outlet.us.com

Thank you a lot for giving everyone an exceptionally brilliant chance to read from here. It is always very enjoyable plus stuffed with a great time for me and my office friends to visit your site minimum three times every week to find out the fresh guidance you have got. And of course, we're always happy with your dazzling ideas you serve. Certain 2 points on this page are certainly the simplest we have all had.
jimmy choo shoes http://www.jimmychoo-shoes.us.com

I wish to convey my passion for your kind-heartedness in support of those who require help on this important theme. Your very own commitment to getting the solution throughout ended up being particularly good and has continually enabled others much like me to reach their targets. Your entire warm and helpful useful information signifies a lot to me and far more to my office colleagues. Warm regards; from all of us.
[url=http://www.jordansforcheap.us.com]cheap jordans[/url]

<a href="http://metformin.durban/">where can i get metformin</a>

<b>iTunes Cards available now!</b> > <a href="https://www.thegamesmachine.it/forum/members/17377.html">free itunes gift</a>

Itunes Redeem Code Free 2019 APRIL
Free Itunes Gift Card 2019 APRIL
Free Itunes Gift Card Codes No Surveys 2019 APRIL
Free Itunes Card Redeem Code 2019 APRIL
Free Itunes Cards 2019 APRIL
Free Itunes Card Codes 2019 APRIL
Free Itunes Codes 2019 APRIL
Free Itunes Cards 2019 APRIL
Itunes Reedem Codes 2019 APRIL
Free Itunes Gift Card 2019 APRIL
Free Itunes Cards 2019 APRIL
Free Itunes Card Redeem Code 2019 APRIL
Itunes Redeem Code Free 2019 APRIL
Get Free Itunes Gift Card 2019 APRIL
Free Apple Gift Card 2019 APRIL
Itunes Gift Card Code 2019 APRIL

I must express my admiration for your kindness for men and women who must have help with this one area of interest. Your very own commitment to passing the message along has been wonderfully effective and has constantly helped men and women just like me to achieve their aims. The interesting help and advice indicates so much to me and further more to my colleagues. With thanks; from each one of us.
off white http://www.offwhite.us.com

Seiten

Bild des Benutzers florian
Erstellt von florian
13.07.2017 - 17:53
476 Kommentare

Aus der Kategorie

Drupal