Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
|
@ -0,0 +1,6 @@
|
|||
name: CKEditor test
|
||||
type: module
|
||||
description: Support module for the CKEditor module tests.
|
||||
core: 8.x
|
||||
package: Testing
|
||||
version: VERSION
|
15
core/modules/ckeditor/tests/modules/ckeditor_test.module
Normal file
15
core/modules/ckeditor/tests/modules/ckeditor_test.module
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Helper module for the CKEditor tests.
|
||||
*/
|
||||
|
||||
use Drupal\editor\Entity\Editor;
|
||||
|
||||
/**
|
||||
* Implements hook_ckeditor_css_alter().
|
||||
*/
|
||||
function ckeditor_test_ckeditor_css_alter(array &$css, Editor $editor) {
|
||||
$css[] = drupal_get_path('module', 'ckeditor_test') . '/ckeditor_test.css';
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
ckeditor.plugin.llama_contextual_and_button:
|
||||
type: mapping
|
||||
label: 'Contextual Llama With Button'
|
||||
mapping:
|
||||
ultra_llama_mode:
|
||||
type: boolean
|
||||
label: 'Ultra llama mode'
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\ckeditor_test\Plugin\CKEditorPlugin\Llama.
|
||||
*/
|
||||
|
||||
namespace Drupal\ckeditor_test\Plugin\CKEditorPlugin;
|
||||
|
||||
use Drupal\ckeditor\CKEditorPluginInterface;
|
||||
use Drupal\Component\Plugin\PluginBase;
|
||||
use Drupal\editor\Entity\Editor;
|
||||
|
||||
/**
|
||||
* Defines the "Llama" plugin, with a CKEditor "llama" feature.
|
||||
*
|
||||
* This feature does not correspond to a toolbar button. Because this plugin
|
||||
* does not implement the CKEditorPluginContextualInterface nor the
|
||||
* CKEditorPluginButtonsInterface interface, there is no way of actually loading
|
||||
* this plugin.
|
||||
*
|
||||
* @see MetaContextual
|
||||
* @see MetaButton
|
||||
* @see MetaContextualAndButton
|
||||
*
|
||||
* @CKEditorPlugin(
|
||||
* id = "llama",
|
||||
* label = @Translation("Llama")
|
||||
* )
|
||||
*/
|
||||
class Llama extends PluginBase implements CKEditorPluginInterface {
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getDependencies().
|
||||
*/
|
||||
function getDependencies(Editor $editor) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getLibraries().
|
||||
*/
|
||||
function getLibraries(Editor $editor) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::isInternal().
|
||||
*/
|
||||
function isInternal() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile().
|
||||
*/
|
||||
function getFile() {
|
||||
return drupal_get_path('module', 'ckeditor_test') . '/js/llama.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getConfig().
|
||||
*/
|
||||
public function getConfig(Editor $editor) {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\ckeditor_test\Plugin\CKEditorPlugin\LlamaButton.
|
||||
*/
|
||||
|
||||
namespace Drupal\ckeditor_test\Plugin\CKEditorPlugin;
|
||||
|
||||
use Drupal\ckeditor\CKEditorPluginButtonsInterface;
|
||||
use Drupal\Component\Plugin\PluginBase;
|
||||
|
||||
/**
|
||||
* Defines a "LlamaButton" plugin, with a toolbar builder-enabled "llama" feature.
|
||||
*
|
||||
* @CKEditorPlugin(
|
||||
* id = "llama_button",
|
||||
* label = @Translation("Llama Button")
|
||||
* )
|
||||
*/
|
||||
class LlamaButton extends Llama implements CKEditorPluginButtonsInterface {
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginButtonsInterface::getButtons().
|
||||
*/
|
||||
function getButtons() {
|
||||
return array(
|
||||
'Llama' => array(
|
||||
'label' => t('Insert Llama'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile().
|
||||
*/
|
||||
function getFile() {
|
||||
return drupal_get_path('module', 'ckeditor_test') . '/js/llama_button.js';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\ckeditor_test\Plugin\CKEditorPlugin\LlamaContextual.
|
||||
*/
|
||||
|
||||
namespace Drupal\ckeditor_test\Plugin\CKEditorPlugin;
|
||||
|
||||
use Drupal\ckeditor\CKEditorPluginContextualInterface;
|
||||
use Drupal\Component\Plugin\PluginBase;
|
||||
use Drupal\editor\Entity\Editor;
|
||||
|
||||
/**
|
||||
* Defines a "Llama" plugin, with a contextually enabled "llama" feature.
|
||||
*
|
||||
* @CKEditorPlugin(
|
||||
* id = "llama_contextual",
|
||||
* label = @Translation("Contextual Llama")
|
||||
* )
|
||||
*/
|
||||
class LlamaContextual extends Llama implements CKEditorPluginContextualInterface {
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginContextualInterface::isEnabled().
|
||||
*/
|
||||
function isEnabled(Editor $editor) {
|
||||
// Automatically enable this plugin if the Underline button is enabled.
|
||||
$settings = $editor->getSettings();
|
||||
foreach ($settings['toolbar']['rows'] as $row) {
|
||||
foreach ($row as $group) {
|
||||
if (in_array('Strike', $group['items'])) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile().
|
||||
*/
|
||||
function getFile() {
|
||||
return drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual.js';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\ckeditor_test\Plugin\CKEditorPlugin\LlamaContextualAndButton.
|
||||
*/
|
||||
|
||||
namespace Drupal\ckeditor_test\Plugin\CKEditorPlugin;
|
||||
|
||||
use Drupal\ckeditor\CKEditorPluginButtonsInterface;
|
||||
use Drupal\ckeditor\CKEditorPluginContextualInterface;
|
||||
use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
|
||||
use Drupal\Component\Plugin\PluginBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\editor\Entity\Editor;
|
||||
|
||||
/**
|
||||
* Defines a "LlamaContextualAndbutton" plugin, with a contextually OR toolbar
|
||||
* builder-enabled "llama" feature.
|
||||
*
|
||||
* @CKEditorPlugin(
|
||||
* id = "llama_contextual_and_button",
|
||||
* label = @Translation("Contextual Llama With Button")
|
||||
* )
|
||||
*/
|
||||
class LlamaContextualAndButton extends Llama implements CKEditorPluginContextualInterface, CKEditorPluginButtonsInterface, CKEditorPluginConfigurableInterface {
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginContextualInterface::isEnabled().
|
||||
*/
|
||||
function isEnabled(Editor $editor) {
|
||||
// Automatically enable this plugin if the Strike button is enabled.
|
||||
$settings = $editor->getSettings();
|
||||
foreach ($settings['toolbar']['rows'] as $row) {
|
||||
foreach ($row as $group) {
|
||||
if (in_array('Strike', $group['items'])) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginButtonsInterface::getButtons().
|
||||
*/
|
||||
function getButtons() {
|
||||
return array(
|
||||
'Llama' => array(
|
||||
'label' => t('Insert Llama'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile().
|
||||
*/
|
||||
function getFile() {
|
||||
return drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual_and_button.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\ckeditor\Plugin\CKEditorPluginConfigurableInterface::settingsForm().
|
||||
*/
|
||||
function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
|
||||
// Defaults.
|
||||
$config = array('ultra_llama_mode' => FALSE);
|
||||
$settings = $editor->getSettings();
|
||||
if (isset($settings['plugins']['llama_contextual_and_button'])) {
|
||||
$config = $settings['plugins']['llama_contextual_and_button'];
|
||||
}
|
||||
|
||||
$form['ultra_llama_mode'] = array(
|
||||
'#title' => t('Ultra llama mode'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $config['ultra_llama_mode'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue