Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
64
web/core/modules/ckeditor/src/Ajax/AddStyleSheetCommand.php
Normal file
64
web/core/modules/ckeditor/src/Ajax/AddStyleSheetCommand.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ckeditor\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* AJAX command to add style sheets to a CKEditor instance.
|
||||
*/
|
||||
class AddStyleSheetCommand implements CommandInterface {
|
||||
|
||||
/**
|
||||
* The CKEditor instance ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $editorId;
|
||||
|
||||
/**
|
||||
* The style sheet URLs to add to the CKEditor instance.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $styleSheets = [];
|
||||
|
||||
/**
|
||||
* AddStyleSheetCommand constructor.
|
||||
*
|
||||
* @param string $editor_id
|
||||
* The CKEditor instance ID.
|
||||
* @param string[] $stylesheets
|
||||
* The style sheet URLs to add to the CKEditor instance.
|
||||
*/
|
||||
public function __construct($editor_id, array $stylesheets = []) {
|
||||
$this->editorId = $editor_id;
|
||||
$this->styleSheets = $stylesheets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a style sheet to the CKEditor instance.
|
||||
*
|
||||
* @param string $stylesheet
|
||||
* The style sheet URL.
|
||||
*
|
||||
* @return $this
|
||||
* The called object, for chaining.
|
||||
*/
|
||||
public function addStyleSheet($stylesheet) {
|
||||
$this->styleSheets[] = $stylesheet;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render() {
|
||||
return [
|
||||
'command' => 'ckeditor_add_stylesheet',
|
||||
'editor_id' => $this->editorId,
|
||||
'stylesheets' => $this->styleSheets,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -33,22 +33,22 @@ abstract class CKEditorPluginBase extends PluginBase implements CKEditorPluginIn
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function isInternal() {
|
||||
public function isInternal() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function getDependencies(Editor $editor) {
|
||||
return array();
|
||||
public function getDependencies(Editor $editor) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function getLibraries(Editor $editor) {
|
||||
return array();
|
||||
public function getLibraries(Editor $editor) {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ class CKEditorPluginManager extends DefaultPluginManager {
|
|||
public function getEnabledPluginFiles(Editor $editor, $include_internal_plugins = FALSE) {
|
||||
$plugins = array_keys($this->getDefinitions());
|
||||
$toolbar_buttons = $this->getEnabledButtons($editor);
|
||||
$enabled_plugins = array();
|
||||
$additional_plugins = array();
|
||||
$enabled_plugins = [];
|
||||
$additional_plugins = [];
|
||||
|
||||
foreach ($plugins as $plugin_id) {
|
||||
$plugin = $this->createInstance($plugin_id);
|
||||
|
|
@ -139,7 +139,7 @@ class CKEditorPluginManager extends DefaultPluginManager {
|
|||
*/
|
||||
public function getButtons() {
|
||||
$plugins = array_keys($this->getDefinitions());
|
||||
$buttons_plugins = array();
|
||||
$buttons_plugins = [];
|
||||
|
||||
foreach ($plugins as $plugin_id) {
|
||||
$plugin = $this->createInstance($plugin_id);
|
||||
|
|
@ -167,16 +167,16 @@ class CKEditorPluginManager extends DefaultPluginManager {
|
|||
foreach (array_keys($definitions) as $plugin_id) {
|
||||
$plugin = $this->createInstance($plugin_id);
|
||||
if ($plugin instanceof CKEditorPluginConfigurableInterface) {
|
||||
$plugin_settings_form = array();
|
||||
$form['plugins'][$plugin_id] = array(
|
||||
$plugin_settings_form = [];
|
||||
$form['plugins'][$plugin_id] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $definitions[$plugin_id]['label'],
|
||||
'#open' => TRUE,
|
||||
'#group' => 'editor][settings][plugin_settings',
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'data-ckeditor-plugin-id' => $plugin_id,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
// Provide enough metadata for the drupal.ckeditor.admin library to
|
||||
// allow it to automatically show/hide the vertical tab containing the
|
||||
// settings for this plugin. Only do this if it's a CKEditor plugin that
|
||||
|
|
@ -206,7 +206,7 @@ class CKEditorPluginManager extends DefaultPluginManager {
|
|||
*/
|
||||
public function getCssFiles(Editor $editor) {
|
||||
$enabled_plugins = array_keys($this->getEnabledPluginFiles($editor, TRUE));
|
||||
$css_files = array();
|
||||
$css_files = [];
|
||||
|
||||
foreach ($enabled_plugins as $plugin_id) {
|
||||
$plugin = $this->createInstance($plugin_id);
|
||||
|
|
|
|||
|
|
@ -29,31 +29,31 @@ class DrupalImage extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLibraries(Editor $editor) {
|
||||
return array(
|
||||
return [
|
||||
'core/drupal.ajax',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfig(Editor $editor) {
|
||||
return array(
|
||||
'drupalImage_dialogTitleAdd' => t('Insert Image'),
|
||||
'drupalImage_dialogTitleEdit' => t('Edit Image'),
|
||||
);
|
||||
return [
|
||||
'drupalImage_dialogTitleAdd' => $this->t('Insert Image'),
|
||||
'drupalImage_dialogTitleEdit' => $this->t('Edit Image'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getButtons() {
|
||||
return array(
|
||||
'DrupalImage' => array(
|
||||
'label' => t('Image'),
|
||||
return [
|
||||
'DrupalImage' => [
|
||||
'label' => $this->t('Image'),
|
||||
'image' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimage/icons/drupalimage.png',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -66,7 +66,7 @@ class DrupalImage extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
$form_state->loadInclude('editor', 'admin.inc');
|
||||
$form['image_upload'] = editor_image_upload_settings_form($editor);
|
||||
$form['image_upload']['#attached']['library'][] = 'ckeditor/drupal.ckeditor.drupalimage.admin';
|
||||
$form['image_upload']['#element_validate'][] = array($this, 'validateImageUploadSettings');
|
||||
$form['image_upload']['#element_validate'][] = [$this, 'validateImageUploadSettings'];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
|
@ -79,10 +79,10 @@ class DrupalImage extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
* @see \Drupal\editor\Form\EditorImageDialog
|
||||
* @see editor_image_upload_settings_form()
|
||||
*/
|
||||
function validateImageUploadSettings(array $element, FormStateInterface $form_state) {
|
||||
$settings = &$form_state->getValue(array('editor', 'settings', 'plugins', 'drupalimage', 'image_upload'));
|
||||
public function validateImageUploadSettings(array $element, FormStateInterface $form_state) {
|
||||
$settings = &$form_state->getValue(['editor', 'settings', 'plugins', 'drupalimage', 'image_upload']);
|
||||
$form_state->get('editor')->setImageUploadSettings($settings);
|
||||
$form_state->unsetValue(array('editor', 'settings', 'plugins', 'drupalimage'));
|
||||
$form_state->unsetValue(['editor', 'settings', 'plugins', 'drupalimage']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\ckeditor\Plugin\CKEditorPlugin;
|
||||
|
||||
use Drupal\Component\Plugin\PluginBase;
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
use Drupal\editor\Entity\Editor;
|
||||
use Drupal\ckeditor\CKEditorPluginInterface;
|
||||
use Drupal\ckeditor\CKEditorPluginContextualInterface;
|
||||
|
|
@ -30,16 +30,16 @@ class DrupalImageCaption extends PluginBase implements CKEditorPluginInterface,
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDependencies(Editor $editor) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLibraries(Editor $editor) {
|
||||
return array(
|
||||
return [
|
||||
'ckeditor/drupal.ckeditor.plugins.drupalimagecaption',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,30 +54,30 @@ class DrupalImageCaption extends PluginBase implements CKEditorPluginInterface,
|
|||
*/
|
||||
public function getConfig(Editor $editor) {
|
||||
$format = $editor->getFilterFormat();
|
||||
return array(
|
||||
return [
|
||||
'image2_captionedClass' => 'caption caption-img',
|
||||
'image2_alignClasses' => array('align-left', 'align-center', 'align-right'),
|
||||
'drupalImageCaption_captionPlaceholderText' => t('Enter caption here'),
|
||||
'image2_alignClasses' => ['align-left', 'align-center', 'align-right'],
|
||||
'drupalImageCaption_captionPlaceholderText' => $this->t('Enter caption here'),
|
||||
// Only enable those parts of DrupalImageCaption for which the
|
||||
// corresponding Drupal text filters are enabled.
|
||||
'drupalImageCaption_captionFilterEnabled' => $format->filters('filter_caption')->status,
|
||||
'drupalImageCaption_alignFilterEnabled' => $format->filters('filter_align')->status,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCssFiles(Editor $editor) {
|
||||
return array(
|
||||
return [
|
||||
drupal_get_path('module', 'ckeditor') . '/css/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css'
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function isEnabled(Editor $editor) {
|
||||
public function isEnabled(Editor $editor) {
|
||||
if (!$editor->hasAssociatedFilterFormat()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,19 +27,19 @@ class DrupalLink extends CKEditorPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLibraries(Editor $editor) {
|
||||
return array(
|
||||
return [
|
||||
'core/drupal.ajax',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfig(Editor $editor) {
|
||||
return array(
|
||||
'drupalLink_dialogTitleAdd' => t('Add Link'),
|
||||
'drupalLink_dialogTitleEdit' => t('Edit Link'),
|
||||
);
|
||||
return [
|
||||
'drupalLink_dialogTitleAdd' => $this->t('Add Link'),
|
||||
'drupalLink_dialogTitleEdit' => $this->t('Edit Link'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -47,16 +47,16 @@ class DrupalLink extends CKEditorPluginBase {
|
|||
*/
|
||||
public function getButtons() {
|
||||
$path = drupal_get_path('module', 'ckeditor') . '/js/plugins/drupallink';
|
||||
return array(
|
||||
'DrupalLink' => array(
|
||||
'label' => t('Link'),
|
||||
return [
|
||||
'DrupalLink' => [
|
||||
'label' => $this->t('Link'),
|
||||
'image' => $path . '/icons/drupallink.png',
|
||||
),
|
||||
'DrupalUnlink' => array(
|
||||
'label' => t('Unlink'),
|
||||
],
|
||||
'DrupalUnlink' => [
|
||||
'label' => $this->t('Unlink'),
|
||||
'image' => $path . '/icons/drupalunlink.png',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,14 +100,14 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
*/
|
||||
public function getConfig(Editor $editor) {
|
||||
// Reasonable defaults that provide expected basic behavior.
|
||||
$config = array(
|
||||
$config = [
|
||||
'customConfig' => '', // Don't load CKEditor's config.js file.
|
||||
'pasteFromWordPromptCleanup' => TRUE,
|
||||
'resize_dir' => 'vertical',
|
||||
'justifyClasses' => array('text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'),
|
||||
'justifyClasses' => ['text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'],
|
||||
'entities' => FALSE,
|
||||
'disableNativeSpellChecker' => FALSE,
|
||||
);
|
||||
];
|
||||
|
||||
// Add the allowedContent setting, which ensures CKEditor only allows tags
|
||||
// and attributes that are allowed by the text format for this text editor.
|
||||
|
|
@ -144,195 +144,195 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
];
|
||||
};
|
||||
|
||||
return array(
|
||||
return [
|
||||
// "basicstyles" plugin.
|
||||
'Bold' => array(
|
||||
'label' => t('Bold'),
|
||||
'Bold' => [
|
||||
'label' => $this->t('Bold'),
|
||||
'image_alternative' => $button('bold'),
|
||||
'image_alternative_rtl' => $button('bold', 'rtl'),
|
||||
),
|
||||
'Italic' => array(
|
||||
'label' => t('Italic'),
|
||||
],
|
||||
'Italic' => [
|
||||
'label' => $this->t('Italic'),
|
||||
'image_alternative' => $button('italic'),
|
||||
'image_alternative_rtl' => $button('italic', 'rtl'),
|
||||
),
|
||||
'Underline' => array(
|
||||
'label' => t('Underline'),
|
||||
],
|
||||
'Underline' => [
|
||||
'label' => $this->t('Underline'),
|
||||
'image_alternative' => $button('underline'),
|
||||
'image_alternative_rtl' => $button('underline', 'rtl'),
|
||||
),
|
||||
'Strike' => array(
|
||||
'label' => t('Strike-through'),
|
||||
],
|
||||
'Strike' => [
|
||||
'label' => $this->t('Strike-through'),
|
||||
'image_alternative' => $button('strike'),
|
||||
'image_alternative_rtl' => $button('strike', 'rtl'),
|
||||
),
|
||||
'Superscript' => array(
|
||||
'label' => t('Superscript'),
|
||||
],
|
||||
'Superscript' => [
|
||||
'label' => $this->t('Superscript'),
|
||||
'image_alternative' => $button('super script'),
|
||||
'image_alternative_rtl' => $button('super script', 'rtl'),
|
||||
),
|
||||
'Subscript' => array(
|
||||
'label' => t('Subscript'),
|
||||
],
|
||||
'Subscript' => [
|
||||
'label' => $this->t('Subscript'),
|
||||
'image_alternative' => $button('sub script'),
|
||||
'image_alternative_rtl' => $button('sub script', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "removeformat" plugin.
|
||||
'RemoveFormat' => array(
|
||||
'label' => t('Remove format'),
|
||||
'RemoveFormat' => [
|
||||
'label' => $this->t('Remove format'),
|
||||
'image_alternative' => $button('remove format'),
|
||||
'image_alternative_rtl' => $button('remove format', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "justify" plugin.
|
||||
'JustifyLeft' => array(
|
||||
'label' => t('Align left'),
|
||||
'JustifyLeft' => [
|
||||
'label' => $this->t('Align left'),
|
||||
'image_alternative' => $button('justify left'),
|
||||
'image_alternative_rtl' => $button('justify left', 'rtl'),
|
||||
),
|
||||
'JustifyCenter' => array(
|
||||
'label' => t('Align center'),
|
||||
],
|
||||
'JustifyCenter' => [
|
||||
'label' => $this->t('Align center'),
|
||||
'image_alternative' => $button('justify center'),
|
||||
'image_alternative_rtl' => $button('justify center', 'rtl'),
|
||||
),
|
||||
'JustifyRight' => array(
|
||||
'label' => t('Align right'),
|
||||
],
|
||||
'JustifyRight' => [
|
||||
'label' => $this->t('Align right'),
|
||||
'image_alternative' => $button('justify right'),
|
||||
'image_alternative_rtl' => $button('justify right', 'rtl'),
|
||||
),
|
||||
'JustifyBlock' => array(
|
||||
'label' => t('Justify'),
|
||||
],
|
||||
'JustifyBlock' => [
|
||||
'label' => $this->t('Justify'),
|
||||
'image_alternative' => $button('justify block'),
|
||||
'image_alternative_rtl' => $button('justify block', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "list" plugin.
|
||||
'BulletedList' => array(
|
||||
'label' => t('Bullet list'),
|
||||
'BulletedList' => [
|
||||
'label' => $this->t('Bullet list'),
|
||||
'image_alternative' => $button('bulleted list'),
|
||||
'image_alternative_rtl' => $button('bulleted list', 'rtl'),
|
||||
),
|
||||
'NumberedList' => array(
|
||||
'label' => t('Numbered list'),
|
||||
],
|
||||
'NumberedList' => [
|
||||
'label' => $this->t('Numbered list'),
|
||||
'image_alternative' => $button('numbered list'),
|
||||
'image_alternative_rtl' => $button('numbered list', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "indent" plugin.
|
||||
'Outdent' => array(
|
||||
'label' => t('Outdent'),
|
||||
'Outdent' => [
|
||||
'label' => $this->t('Outdent'),
|
||||
'image_alternative' => $button('outdent'),
|
||||
'image_alternative_rtl' => $button('outdent', 'rtl'),
|
||||
),
|
||||
'Indent' => array(
|
||||
'label' => t('Indent'),
|
||||
],
|
||||
'Indent' => [
|
||||
'label' => $this->t('Indent'),
|
||||
'image_alternative' => $button('indent'),
|
||||
'image_alternative_rtl' => $button('indent', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "undo" plugin.
|
||||
'Undo' => array(
|
||||
'label' => t('Undo'),
|
||||
'Undo' => [
|
||||
'label' => $this->t('Undo'),
|
||||
'image_alternative' => $button('undo'),
|
||||
'image_alternative_rtl' => $button('undo', 'rtl'),
|
||||
),
|
||||
'Redo' => array(
|
||||
'label' => t('Redo'),
|
||||
],
|
||||
'Redo' => [
|
||||
'label' => $this->t('Redo'),
|
||||
'image_alternative' => $button('redo'),
|
||||
'image_alternative_rtl' => $button('redo', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "blockquote" plugin.
|
||||
'Blockquote' => array(
|
||||
'label' => t('Blockquote'),
|
||||
'Blockquote' => [
|
||||
'label' => $this->t('Blockquote'),
|
||||
'image_alternative' => $button('blockquote'),
|
||||
'image_alternative_rtl' => $button('blockquote', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "horizontalrule" plugin
|
||||
'HorizontalRule' => array(
|
||||
'label' => t('Horizontal rule'),
|
||||
'HorizontalRule' => [
|
||||
'label' => $this->t('Horizontal rule'),
|
||||
'image_alternative' => $button('horizontal rule'),
|
||||
'image_alternative_rtl' => $button('horizontal rule', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "clipboard" plugin.
|
||||
'Cut' => array(
|
||||
'label' => t('Cut'),
|
||||
'Cut' => [
|
||||
'label' => $this->t('Cut'),
|
||||
'image_alternative' => $button('cut'),
|
||||
'image_alternative_rtl' => $button('cut', 'rtl'),
|
||||
),
|
||||
'Copy' => array(
|
||||
'label' => t('Copy'),
|
||||
],
|
||||
'Copy' => [
|
||||
'label' => $this->t('Copy'),
|
||||
'image_alternative' => $button('copy'),
|
||||
'image_alternative_rtl' => $button('copy', 'rtl'),
|
||||
),
|
||||
'Paste' => array(
|
||||
'label' => t('Paste'),
|
||||
],
|
||||
'Paste' => [
|
||||
'label' => $this->t('Paste'),
|
||||
'image_alternative' => $button('paste'),
|
||||
'image_alternative_rtl' => $button('paste', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "pastetext" plugin.
|
||||
'PasteText' => array(
|
||||
'label' => t('Paste Text'),
|
||||
'PasteText' => [
|
||||
'label' => $this->t('Paste Text'),
|
||||
'image_alternative' => $button('paste text'),
|
||||
'image_alternative_rtl' => $button('paste text', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "pastefromword" plugin.
|
||||
'PasteFromWord' => array(
|
||||
'label' => t('Paste from Word'),
|
||||
'PasteFromWord' => [
|
||||
'label' => $this->t('Paste from Word'),
|
||||
'image_alternative' => $button('paste from word'),
|
||||
'image_alternative_rtl' => $button('paste from word', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "specialchar" plugin.
|
||||
'SpecialChar' => array(
|
||||
'label' => t('Character map'),
|
||||
'SpecialChar' => [
|
||||
'label' => $this->t('Character map'),
|
||||
'image_alternative' => $button('special char'),
|
||||
'image_alternative_rtl' => $button('special char', 'rtl'),
|
||||
),
|
||||
'Format' => array(
|
||||
'label' => t('HTML block format'),
|
||||
],
|
||||
'Format' => [
|
||||
'label' => $this->t('HTML block format'),
|
||||
'image_alternative' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => '<a href="#" role="button" aria-label="{{ format_text }}"><span class="ckeditor-button-dropdown">{{ format_text }}<span class="ckeditor-button-arrow"></span></span></a>',
|
||||
'#context' => [
|
||||
'format_text' => t('Format'),
|
||||
'format_text' => $this->t('Format'),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
// "table" plugin.
|
||||
'Table' => array(
|
||||
'label' => t('Table'),
|
||||
'Table' => [
|
||||
'label' => $this->t('Table'),
|
||||
'image_alternative' => $button('table'),
|
||||
'image_alternative_rtl' => $button('table', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "showblocks" plugin.
|
||||
'ShowBlocks' => array(
|
||||
'label' => t('Show blocks'),
|
||||
'ShowBlocks' => [
|
||||
'label' => $this->t('Show blocks'),
|
||||
'image_alternative' => $button('show blocks'),
|
||||
'image_alternative_rtl' => $button('show blocks', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "sourcearea" plugin.
|
||||
'Source' => array(
|
||||
'label' => t('Source code'),
|
||||
'Source' => [
|
||||
'label' => $this->t('Source code'),
|
||||
'image_alternative' => $button('source'),
|
||||
'image_alternative_rtl' => $button('source', 'rtl'),
|
||||
),
|
||||
],
|
||||
// "maximize" plugin.
|
||||
'Maximize' => array(
|
||||
'label' => t('Maximize'),
|
||||
'Maximize' => [
|
||||
'label' => $this->t('Maximize'),
|
||||
'image_alternative' => $button('maximize'),
|
||||
'image_alternative_rtl' => $button('maximize', 'rtl'),
|
||||
),
|
||||
],
|
||||
// No plugin, separator "button" for toolbar builder UI use only.
|
||||
'-' => array(
|
||||
'label' => t('Separator'),
|
||||
'-' => [
|
||||
'label' => $this->t('Separator'),
|
||||
'image_alternative' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => '<a href="#" role="button" aria-label="{{ button_separator_text }}" class="ckeditor-separator"></a>',
|
||||
'#context' => [
|
||||
'button_separator_text' => t('Button separator'),
|
||||
'button_separator_text' => $this->t('Button separator'),
|
||||
],
|
||||
],
|
||||
'attributes' => array(
|
||||
'class' => array('ckeditor-button-separator'),
|
||||
'attributes' => [
|
||||
'class' => ['ckeditor-button-separator'],
|
||||
'data-drupal-ckeditor-type' => 'separator',
|
||||
),
|
||||
],
|
||||
'multiple' => TRUE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -350,7 +350,7 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
// When no text format is associated yet, assume no tag is allowed.
|
||||
// @see \Drupal\Editor\EditorInterface::hasAssociatedFilterFormat()
|
||||
if (!$editor->hasAssociatedFilterFormat()) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$format = $editor->getFilterFormat();
|
||||
|
|
@ -416,7 +416,7 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
|
||||
// When nothing is disallowed, set allowedContent to true.
|
||||
if (!in_array(FilterInterface::TYPE_HTML_RESTRICTOR, $filter_types)) {
|
||||
return array(TRUE, FALSE);
|
||||
return [TRUE, FALSE];
|
||||
}
|
||||
// Generate setting that accurately reflects allowed tags and attributes.
|
||||
else {
|
||||
|
|
@ -441,10 +441,10 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
// When all HTML is allowed, also set allowedContent to true and
|
||||
// disallowedContent to false.
|
||||
if ($html_restrictions === FALSE) {
|
||||
return array(TRUE, FALSE);
|
||||
return [TRUE, FALSE];
|
||||
}
|
||||
$allowed = array();
|
||||
$disallowed = array();
|
||||
$allowed = [];
|
||||
$disallowed = [];
|
||||
if (isset($html_restrictions['forbidden_tags'])) {
|
||||
foreach ($html_restrictions['forbidden_tags'] as $tag) {
|
||||
$disallowed[$tag] = TRUE;
|
||||
|
|
@ -453,11 +453,11 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
foreach ($html_restrictions['allowed'] as $tag => $attributes) {
|
||||
// Tell CKEditor the tag is allowed, but no attributes.
|
||||
if ($attributes === FALSE) {
|
||||
$allowed[$tag] = array(
|
||||
$allowed[$tag] = [
|
||||
'attributes' => FALSE,
|
||||
'styles' => FALSE,
|
||||
'classes' => FALSE,
|
||||
);
|
||||
];
|
||||
}
|
||||
// Tell CKEditor the tag is allowed, as well as any attribute on it. The
|
||||
// "style" and "class" attributes are handled separately by CKEditor:
|
||||
|
|
@ -465,11 +465,11 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
// attributes, unless you state specific values for them that are
|
||||
// allowed. Or, in this case: any value for them is allowed.
|
||||
elseif ($attributes === TRUE) {
|
||||
$allowed[$tag] = array(
|
||||
$allowed[$tag] = [
|
||||
'attributes' => TRUE,
|
||||
'styles' => TRUE,
|
||||
'classes' => TRUE,
|
||||
);
|
||||
];
|
||||
// We've just marked that any value for the "style" and "class"
|
||||
// attributes is allowed. However, that may not be the case: the "*"
|
||||
// tag may still apply restrictions.
|
||||
|
|
@ -518,11 +518,11 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
elseif (is_array($attributes)) {
|
||||
// Set defaults (these will be overridden below if more specific
|
||||
// values are present).
|
||||
$allowed[$tag] = array(
|
||||
$allowed[$tag] = [
|
||||
'attributes' => FALSE,
|
||||
'styles' => FALSE,
|
||||
'classes' => FALSE,
|
||||
);
|
||||
];
|
||||
// Configure allowed attributes, allowed "style" attribute values and
|
||||
// allowed "class" attribute values.
|
||||
// CKEditor only allows specific values for the "class" and "style"
|
||||
|
|
@ -600,7 +600,7 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
ksort($allowed);
|
||||
ksort($disallowed);
|
||||
|
||||
return array($allowed, $disallowed);
|
||||
return [$allowed, $disallowed];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class Language extends CKEditorPluginBase implements CKEditorPluginConfigurableI
|
|||
}
|
||||
|
||||
$predefined_languages = LanguageManager::getStandardLanguageList();
|
||||
$form['language_list'] = array(
|
||||
$form['language_list'] = [
|
||||
'#title' => $this->t('Language list'),
|
||||
'#title_display' => 'invisible',
|
||||
'#type' => 'select',
|
||||
|
|
@ -118,7 +118,7 @@ class Language extends CKEditorPluginBase implements CKEditorPluginConfigurableI
|
|||
'@count' => count($predefined_languages),
|
||||
]),
|
||||
'#attached' => ['library' => ['ckeditor/drupal.ckeditor.language.admin']],
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
@ -126,10 +126,10 @@ class Language extends CKEditorPluginBase implements CKEditorPluginConfigurableI
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function getCssFiles(Editor $editor) {
|
||||
return array(
|
||||
public function getCssFiles(Editor $editor) {
|
||||
return [
|
||||
drupal_get_path('module', 'ckeditor') . '/css/plugins/language/ckeditor.language.css'
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfig(Editor $editor) {
|
||||
$config = array();
|
||||
$config = [];
|
||||
$settings = $editor->getSettings();
|
||||
if (!isset($settings['plugins']['stylescombo']['styles'])) {
|
||||
return $config;
|
||||
|
|
@ -50,18 +50,18 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getButtons() {
|
||||
return array(
|
||||
'Styles' => array(
|
||||
'label' => t('Font style'),
|
||||
return [
|
||||
'Styles' => [
|
||||
'label' => $this->t('Font style'),
|
||||
'image_alternative' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => '<a href="#" role="button" aria-label="{{ styles_text }}"><span class="ckeditor-button-dropdown">{{ styles_text }}<span class="ckeditor-button-arrow"></span></span></a>',
|
||||
'#context' => [
|
||||
'styles_text' => t('Styles'),
|
||||
'styles_text' => $this->t('Styles'),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,25 +69,25 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
*/
|
||||
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
|
||||
// Defaults.
|
||||
$config = array('styles' => '');
|
||||
$config = ['styles' => ''];
|
||||
$settings = $editor->getSettings();
|
||||
if (isset($settings['plugins']['stylescombo'])) {
|
||||
$config = $settings['plugins']['stylescombo'];
|
||||
}
|
||||
|
||||
$form['styles'] = array(
|
||||
'#title' => t('Styles'),
|
||||
$form['styles'] = [
|
||||
'#title' => $this->t('Styles'),
|
||||
'#title_display' => 'invisible',
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => $config['styles'],
|
||||
'#description' => t('A list of classes that will be provided in the "Styles" dropdown. Enter one or more classes on each line in the format: element.classA.classB|Label. Example: h1.title|Title. Advanced example: h1.fancy.title|Fancy title.<br />These styles should be available in your theme\'s CSS file.'),
|
||||
'#attached' => array(
|
||||
'library' => array('ckeditor/drupal.ckeditor.stylescombo.admin'),
|
||||
),
|
||||
'#element_validate' => array(
|
||||
array($this, 'validateStylesValue'),
|
||||
),
|
||||
);
|
||||
'#description' => $this->t('A list of classes that will be provided in the "Styles" dropdown. Enter one or more classes on each line in the format: element.classA.classB|Label. Example: h1.title|Title. Advanced example: h1.fancy.title|Fancy title.<br />These styles should be available in your theme\'s CSS file.'),
|
||||
'#attached' => [
|
||||
'library' => ['ckeditor/drupal.ckeditor.stylescombo.admin'],
|
||||
],
|
||||
'#element_validate' => [
|
||||
[$this, 'validateStylesValue'],
|
||||
],
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
@ -98,12 +98,12 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
public function validateStylesValue(array $element, FormStateInterface $form_state) {
|
||||
$styles_setting = $this->generateStylesSetSetting($element['#value']);
|
||||
if ($styles_setting === FALSE) {
|
||||
$form_state->setError($element, t('The provided list of styles is syntactically incorrect.'));
|
||||
$form_state->setError($element, $this->t('The provided list of styles is syntactically incorrect.'));
|
||||
}
|
||||
else {
|
||||
$style_names = array_map(function ($style) { return $style['name']; }, $styles_setting);
|
||||
if (count($style_names) !== count(array_unique($style_names))) {
|
||||
$form_state->setError($element, t('Each style must have a unique label.'));
|
||||
$form_state->setError($element, $this->t('Each style must have a unique label.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
* syntax is invalid.
|
||||
*/
|
||||
protected function generateStylesSetSetting($styles) {
|
||||
$styles_set = array();
|
||||
$styles_set = [];
|
||||
|
||||
// Early-return when empty.
|
||||
$styles = trim($styles);
|
||||
|
|
@ -128,7 +128,7 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
return $styles_set;
|
||||
}
|
||||
|
||||
$styles = str_replace(array("\r\n", "\r"), "\n", $styles);
|
||||
$styles = str_replace(["\r\n", "\r"], "\n", $styles);
|
||||
foreach (explode("\n", $styles) as $style) {
|
||||
$style = trim($style);
|
||||
|
||||
|
|
@ -149,14 +149,14 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
|
|||
|
||||
// Build the data structure CKEditor's stylescombo plugin expects.
|
||||
// @see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Styles
|
||||
$configured_style = array(
|
||||
$configured_style = [
|
||||
'name' => trim($label),
|
||||
'element' => trim($element),
|
||||
);
|
||||
];
|
||||
if (!empty($classes)) {
|
||||
$configured_style['attributes'] = array(
|
||||
$configured_style['attributes'] = [
|
||||
'class' => implode(' ', array_map('trim', $classes))
|
||||
);
|
||||
];
|
||||
}
|
||||
$styles_set[] = $configured_style;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,36 +102,36 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultSettings() {
|
||||
return array(
|
||||
'toolbar' => array(
|
||||
'rows' => array(
|
||||
return [
|
||||
'toolbar' => [
|
||||
'rows' => [
|
||||
// Button groups.
|
||||
array(
|
||||
array(
|
||||
'name' => t('Formatting'),
|
||||
'items' => array('Bold', 'Italic',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Links'),
|
||||
'items' => array('DrupalLink', 'DrupalUnlink',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Lists'),
|
||||
'items' => array('BulletedList', 'NumberedList',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Media'),
|
||||
'items' => array('Blockquote', 'DrupalImage',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Tools'),
|
||||
'items' => array('Source',),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
[
|
||||
[
|
||||
'name' => $this->t('Formatting'),
|
||||
'items' => ['Bold', 'Italic'],
|
||||
],
|
||||
[
|
||||
'name' => $this->t('Links'),
|
||||
'items' => ['DrupalLink', 'DrupalUnlink'],
|
||||
],
|
||||
[
|
||||
'name' => $this->t('Lists'),
|
||||
'items' => ['BulletedList', 'NumberedList'],
|
||||
],
|
||||
[
|
||||
'name' => $this->t('Media'),
|
||||
'items' => ['Blockquote', 'DrupalImage'],
|
||||
],
|
||||
[
|
||||
'name' => $this->t('Tools'),
|
||||
'items' => ['Source'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'plugins' => ['language' => ['language_list' => 'un']],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,39 +140,39 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
|
||||
$settings = $editor->getSettings();
|
||||
|
||||
$ckeditor_settings_toolbar = array(
|
||||
$ckeditor_settings_toolbar = [
|
||||
'#theme' => 'ckeditor_settings_toolbar',
|
||||
'#editor' => $editor,
|
||||
'#plugins' => $this->ckeditorPluginManager->getButtons(),
|
||||
);
|
||||
$form['toolbar'] = array(
|
||||
];
|
||||
$form['toolbar'] = [
|
||||
'#type' => 'container',
|
||||
'#attached' => array(
|
||||
'library' => array('ckeditor/drupal.ckeditor.admin'),
|
||||
'#attached' => [
|
||||
'library' => ['ckeditor/drupal.ckeditor.admin'],
|
||||
'drupalSettings' => [
|
||||
'ckeditor' => [
|
||||
'toolbarAdmin' => (string) $this->renderer->renderPlain($ckeditor_settings_toolbar),
|
||||
],
|
||||
],
|
||||
),
|
||||
'#attributes' => array('class' => array('ckeditor-toolbar-configuration')),
|
||||
);
|
||||
],
|
||||
'#attributes' => ['class' => ['ckeditor-toolbar-configuration']],
|
||||
];
|
||||
|
||||
$form['toolbar']['button_groups'] = array(
|
||||
$form['toolbar']['button_groups'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Toolbar buttons'),
|
||||
'#title' => $this->t('Toolbar buttons'),
|
||||
'#default_value' => json_encode($settings['toolbar']['rows']),
|
||||
'#attributes' => array('class' => array('ckeditor-toolbar-textarea')),
|
||||
);
|
||||
'#attributes' => ['class' => ['ckeditor-toolbar-textarea']],
|
||||
];
|
||||
|
||||
// CKEditor plugin settings, if any.
|
||||
$form['plugin_settings'] = array(
|
||||
$form['plugin_settings'] = [
|
||||
'#type' => 'vertical_tabs',
|
||||
'#title' => t('CKEditor plugin settings'),
|
||||
'#attributes' => array(
|
||||
'#title' => $this->t('CKEditor plugin settings'),
|
||||
'#attributes' => [
|
||||
'id' => 'ckeditor-plugin-settings',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->ckeditorPluginManager->injectPluginSettingsForm($form, $form_state, $editor);
|
||||
if (count(Element::children($form['plugins'])) === 0) {
|
||||
unset($form['plugins']);
|
||||
|
|
@ -186,7 +186,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
// settings to be updated accordingly.
|
||||
// Get a list of all external plugins and their corresponding files.
|
||||
$plugins = array_keys($this->ckeditorPluginManager->getDefinitions());
|
||||
$all_external_plugins = array();
|
||||
$all_external_plugins = [];
|
||||
foreach ($plugins as $plugin_id) {
|
||||
$plugin = $this->ckeditorPluginManager->createInstance($plugin_id);
|
||||
if (!$plugin->isInternal()) {
|
||||
|
|
@ -196,37 +196,37 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
// Get a list of all buttons that are provided by all plugins.
|
||||
$all_buttons = array_reduce($this->ckeditorPluginManager->getButtons(), function($result, $item) {
|
||||
return array_merge($result, array_keys($item));
|
||||
}, array());
|
||||
}, []);
|
||||
// Build a fake Editor object, which we'll use to generate JavaScript
|
||||
// settings for this fake Editor instance.
|
||||
$fake_editor = Editor::create(array(
|
||||
$fake_editor = Editor::create([
|
||||
'format' => $editor->id(),
|
||||
'editor' => 'ckeditor',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
// Single toolbar row, single button group, all existing buttons.
|
||||
'toolbar' => array(
|
||||
'rows' => array(
|
||||
0 => array(
|
||||
0 => array(
|
||||
'toolbar' => [
|
||||
'rows' => [
|
||||
0 => [
|
||||
0 => [
|
||||
'name' => 'All existing buttons',
|
||||
'items' => $all_buttons,
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
'plugins' => $settings['plugins'],
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$config = $this->getJSSettings($fake_editor);
|
||||
// Remove the ACF configuration that is generated based on filter settings,
|
||||
// because otherwise we cannot retrieve per-feature metadata.
|
||||
unset($config['allowedContent']);
|
||||
$form['hidden_ckeditor'] = array(
|
||||
$form['hidden_ckeditor'] = [
|
||||
'#markup' => '<div id="ckeditor-hidden" class="hidden"></div>',
|
||||
'#attached' => array(
|
||||
'#attached' => [
|
||||
'drupalSettings' => ['ckeditor' => ['hiddenCKEditorConfig' => $config]],
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
@ -238,7 +238,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
// Modify the toolbar settings by reference. The values in
|
||||
// $form_state->getValue(array('editor', 'settings')) will be saved directly
|
||||
// by editor_form_filter_admin_format_submit().
|
||||
$toolbar_settings = &$form_state->getValue(array('editor', 'settings', 'toolbar'));
|
||||
$toolbar_settings = &$form_state->getValue(['editor', 'settings', 'toolbar']);
|
||||
|
||||
// The rows key is not built into the form structure, so decode the button
|
||||
// groups data into this new key and remove the button_groups key.
|
||||
|
|
@ -246,8 +246,8 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
unset($toolbar_settings['button_groups']);
|
||||
|
||||
// Remove the plugin settings' vertical tabs state; no need to save that.
|
||||
if ($form_state->hasValue(array('editor', 'settings', 'plugins'))) {
|
||||
$form_state->unsetValue(array('editor', 'settings', 'plugin_settings'));
|
||||
if ($form_state->hasValue(['editor', 'settings', 'plugins'])) {
|
||||
$form_state->unsetValue(['editor', 'settings', 'plugin_settings']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +255,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getJSSettings(Editor $editor) {
|
||||
$settings = array();
|
||||
$settings = [];
|
||||
|
||||
// Get the settings for all enabled plugins, even the internal ones.
|
||||
$enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor, TRUE));
|
||||
|
|
@ -279,7 +279,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
|
||||
// Next, set the most fundamental CKEditor settings.
|
||||
$external_plugin_files = $this->ckeditorPluginManager->getEnabledPluginFiles($editor);
|
||||
$settings += array(
|
||||
$settings += [
|
||||
'toolbar' => $this->buildToolbarJSSetting($editor),
|
||||
'contentsCss' => $this->buildContentsCssJSSetting($editor),
|
||||
'extraPlugins' => implode(',', array_keys($external_plugin_files)),
|
||||
|
|
@ -290,15 +290,15 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
// styles.js by default.
|
||||
// See http://dev.ckeditor.com/ticket/9992#comment:9.
|
||||
'stylesSet' => FALSE,
|
||||
);
|
||||
];
|
||||
|
||||
// Finally, set Drupal-specific CKEditor settings.
|
||||
$root_relative_file_url = function ($uri) {
|
||||
return file_url_transform_relative(file_create_url($uri));
|
||||
};
|
||||
$settings += array(
|
||||
$settings += [
|
||||
'drupalExternalPlugins' => array_map($root_relative_file_url, $external_plugin_files),
|
||||
);
|
||||
];
|
||||
|
||||
// Parse all CKEditor plugin JavaScript files for translations.
|
||||
if ($this->moduleHandler->moduleExists('locale')) {
|
||||
|
|
@ -326,7 +326,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
$langcodes = $langcode_cache->data;
|
||||
}
|
||||
if (empty($langcodes)) {
|
||||
$langcodes = array();
|
||||
$langcodes = [];
|
||||
// Collect languages included with CKEditor based on file listing.
|
||||
$files = scandir('core/assets/vendor/ckeditor/lang');
|
||||
foreach ($files as $file) {
|
||||
|
|
@ -341,7 +341,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
// Get language mapping if available to map to Drupal language codes.
|
||||
// This is configurable in the user interface and not expensive to get, so
|
||||
// we don't include it in the cached language list.
|
||||
$language_mappings = $this->moduleHandler->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : array();
|
||||
$language_mappings = $this->moduleHandler->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : [];
|
||||
foreach ($langcodes as $langcode) {
|
||||
// If this language code is available in a Drupal mapping, use that to
|
||||
// compute a possibility for matching from the Drupal langcode to the
|
||||
|
|
@ -363,9 +363,9 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLibraries(Editor $editor) {
|
||||
$libraries = array(
|
||||
$libraries = [
|
||||
'ckeditor/drupal.ckeditor',
|
||||
);
|
||||
];
|
||||
|
||||
// Get the required libraries for any enabled plugins.
|
||||
$enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor));
|
||||
|
|
@ -389,7 +389,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
* An array containing the "toolbar" configuration.
|
||||
*/
|
||||
public function buildToolbarJSSetting(Editor $editor) {
|
||||
$toolbar = array();
|
||||
$toolbar = [];
|
||||
|
||||
$settings = $editor->getSettings();
|
||||
foreach ($settings['toolbar']['rows'] as $row) {
|
||||
|
|
@ -412,15 +412,15 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
* An array containing the "contentsCss" configuration.
|
||||
*/
|
||||
public function buildContentsCssJSSetting(Editor $editor) {
|
||||
$css = array(
|
||||
$css = [
|
||||
drupal_get_path('module', 'ckeditor') . '/css/ckeditor-iframe.css',
|
||||
drupal_get_path('module', 'system') . '/css/components/align.module.css',
|
||||
);
|
||||
];
|
||||
$this->moduleHandler->alter('ckeditor_css', $css, $editor);
|
||||
// Get a list of all enabled plugins' iframe instance CSS files.
|
||||
$plugins_css = array_reduce($this->ckeditorPluginManager->getCssFiles($editor), function($result, $item) {
|
||||
return array_merge($result, array_values($item));
|
||||
}, array());
|
||||
}, []);
|
||||
$css = array_merge($css, $plugins_css);
|
||||
$css = array_merge($css, _ckeditor_theme_css());
|
||||
$css = array_map('file_create_url', $css);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('filter', 'editor', 'ckeditor');
|
||||
public static $modules = ['filter', 'editor', 'ckeditor'];
|
||||
|
||||
/**
|
||||
* A user with the 'administer filters' permission.
|
||||
|
|
@ -33,22 +33,22 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
parent::setUp();
|
||||
|
||||
// Create text format.
|
||||
$filtered_html_format = FilterFormat::create(array(
|
||||
$filtered_html_format = FilterFormat::create([
|
||||
'format' => 'filtered_html',
|
||||
'name' => 'Filtered HTML',
|
||||
'weight' => 0,
|
||||
'filters' => array(),
|
||||
));
|
||||
'filters' => [],
|
||||
]);
|
||||
$filtered_html_format->save();
|
||||
|
||||
// Create admin user.
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer filters'));
|
||||
$this->adminUser = $this->drupalCreateUser(['administer filters']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests configuring a text editor for an existing text format.
|
||||
*/
|
||||
function testExistingFormat() {
|
||||
public function testExistingFormat() {
|
||||
$ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
|
@ -70,43 +70,43 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
$this->assertTrue(((string) $options[0]['selected']) === 'selected', 'Option 1 ("None") is selected.');
|
||||
|
||||
// Select the "CKEditor" editor and click the "Save configuration" button.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'editor[editor]' => 'ckeditor',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
|
||||
$this->assertRaw(t('You must configure the selected text editor.'));
|
||||
|
||||
// Ensure the CKEditor editor returns the expected default settings.
|
||||
$expected_default_settings = array(
|
||||
'toolbar' => array(
|
||||
'rows' => array(
|
||||
$expected_default_settings = [
|
||||
'toolbar' => [
|
||||
'rows' => [
|
||||
// Button groups
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
'name' => 'Formatting',
|
||||
'items' => array('Bold', 'Italic',),
|
||||
),
|
||||
array(
|
||||
'items' => ['Bold', 'Italic'],
|
||||
],
|
||||
[
|
||||
'name' => 'Links',
|
||||
'items' => array('DrupalLink', 'DrupalUnlink',),
|
||||
),
|
||||
array(
|
||||
'items' => ['DrupalLink', 'DrupalUnlink'],
|
||||
],
|
||||
[
|
||||
'name' => 'Lists',
|
||||
'items' => array('BulletedList', 'NumberedList',),
|
||||
),
|
||||
array(
|
||||
'items' => ['BulletedList', 'NumberedList'],
|
||||
],
|
||||
[
|
||||
'name' => 'Media',
|
||||
'items' => array('Blockquote', 'DrupalImage',),
|
||||
),
|
||||
array(
|
||||
'items' => ['Blockquote', 'DrupalImage'],
|
||||
],
|
||||
[
|
||||
'name' => 'Tools',
|
||||
'items' => array('Source',),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'items' => ['Source'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'plugins' => ['language' => ['language_list' => 'un']],
|
||||
);
|
||||
];
|
||||
$this->assertIdentical($this->castSafeStrings($ckeditor->getDefaultSettings()), $expected_default_settings);
|
||||
|
||||
// Keep the "CKEditor" editor selected and click the "Configure" button.
|
||||
|
|
@ -115,11 +115,11 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
$this->assertFalse($editor, 'No Editor config entity exists yet.');
|
||||
|
||||
// Ensure that drupalSettings is correct.
|
||||
$ckeditor_settings_toolbar = array(
|
||||
$ckeditor_settings_toolbar = [
|
||||
'#theme' => 'ckeditor_settings_toolbar',
|
||||
'#editor' => Editor::create(['editor' => 'ckeditor']),
|
||||
'#plugins' => $this->container->get('plugin.manager.ckeditor.plugin')->getButtons(),
|
||||
);
|
||||
];
|
||||
$this->assertEqual(
|
||||
$this->drupalSettings['ckeditor']['toolbarAdmin'],
|
||||
$this->container->get('renderer')->renderPlain($ckeditor_settings_toolbar),
|
||||
|
|
@ -148,9 +148,9 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
|
||||
// Configure the Styles plugin, and ensure the updated settings are saved.
|
||||
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Callout\n\n",
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
|
||||
$expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n";
|
||||
$editor = Editor::load('filtered_html');
|
||||
|
|
@ -161,13 +161,13 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
// done via drag and drop, but here we can only emulate the end result of
|
||||
// that interaction). Test multiple toolbar rows and a divider within a row.
|
||||
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
|
||||
$expected_settings['toolbar']['rows'][0][] = array(
|
||||
$expected_settings['toolbar']['rows'][0][] = [
|
||||
'name' => 'Action history',
|
||||
'items' => array('Undo', '|', 'Redo', 'JustifyCenter'),
|
||||
);
|
||||
$edit = array(
|
||||
'items' => ['Undo', '|', 'Redo', 'JustifyCenter'],
|
||||
];
|
||||
$edit = [
|
||||
'editor[settings][toolbar][button_groups]' => json_encode($expected_settings['toolbar']['rows']),
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
|
||||
$editor = Editor::load('filtered_html');
|
||||
$this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
|
||||
|
|
@ -191,7 +191,7 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
|
||||
// Now enable the ckeditor_test module, which provides one configurable
|
||||
// CKEditor plugin — this should not affect the Editor config entity.
|
||||
\Drupal::service('module_installer')->install(array('ckeditor_test'));
|
||||
\Drupal::service('module_installer')->install(['ckeditor_test']);
|
||||
$this->resetAll();
|
||||
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
|
||||
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
|
||||
|
|
@ -203,9 +203,9 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
|
||||
// Finally, check the "Ultra llama mode" checkbox.
|
||||
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]' => '1',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
|
||||
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
|
||||
$ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and @checked="checked"]');
|
||||
|
|
@ -222,7 +222,7 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
* This test only needs to ensure that the basics of the CKEditor
|
||||
* configuration form work; details are tested in testExistingFormat().
|
||||
*/
|
||||
function testNewFormat() {
|
||||
public function testNewFormat() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalGet('admin/config/content/formats/add');
|
||||
|
||||
|
|
@ -239,11 +239,11 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
|
||||
// Name our fancy new text format, select the "CKEditor" editor and click
|
||||
// the "Configure" button.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'name' => 'My amazing text format',
|
||||
'format' => 'amazing_format',
|
||||
'editor[editor]' => 'ckeditor',
|
||||
);
|
||||
];
|
||||
$this->drupalPostAjaxForm(NULL, $edit, 'editor_configure');
|
||||
$filter_format = FilterFormat::load('amazing_format');
|
||||
$this->assertFalse($filter_format, 'No FilterFormat config entity exists yet.');
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('filter', 'editor', 'ckeditor', 'node');
|
||||
public static $modules = ['filter', 'editor', 'ckeditor', 'node'];
|
||||
|
||||
/**
|
||||
* An untrusted user with access to only the 'plain_text' format.
|
||||
|
|
@ -38,12 +38,12 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
parent::setUp();
|
||||
|
||||
// Create text format, associate CKEditor.
|
||||
$filtered_html_format = FilterFormat::create(array(
|
||||
$filtered_html_format = FilterFormat::create([
|
||||
'format' => 'filtered_html',
|
||||
'name' => 'Filtered HTML',
|
||||
'weight' => 0,
|
||||
'filters' => array(),
|
||||
));
|
||||
'filters' => [],
|
||||
]);
|
||||
$filtered_html_format->save();
|
||||
$editor = Editor::create([
|
||||
'format' => 'filtered_html',
|
||||
|
|
@ -53,28 +53,28 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
|
||||
// Create a second format without an associated editor so a drop down select
|
||||
// list is created when selecting formats.
|
||||
$full_html_format = FilterFormat::create(array(
|
||||
$full_html_format = FilterFormat::create([
|
||||
'format' => 'full_html',
|
||||
'name' => 'Full HTML',
|
||||
'weight' => 1,
|
||||
'filters' => array(),
|
||||
));
|
||||
'filters' => [],
|
||||
]);
|
||||
$full_html_format->save();
|
||||
|
||||
// Create node type.
|
||||
$this->drupalCreateContentType(array(
|
||||
$this->drupalCreateContentType([
|
||||
'type' => 'article',
|
||||
'name' => 'Article',
|
||||
));
|
||||
]);
|
||||
|
||||
$this->untrustedUser = $this->drupalCreateUser(array('create article content', 'edit any article content'));
|
||||
$this->normalUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html'));
|
||||
$this->untrustedUser = $this->drupalCreateUser(['create article content', 'edit any article content']);
|
||||
$this->normalUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests loading of CKEditor CSS, JS and JS settings.
|
||||
*/
|
||||
function testLoading() {
|
||||
public function testLoading() {
|
||||
// The untrusted user:
|
||||
// - has access to 1 text format (plain_text);
|
||||
// - doesn't have access to the filtered_html text format, so: no text editor.
|
||||
|
|
@ -101,13 +101,13 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
|
||||
$ckeditor_plugin = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
|
||||
$editor = Editor::load('filtered_html');
|
||||
$expected = array('formats' => array('filtered_html' => array(
|
||||
$expected = ['formats' => ['filtered_html' => [
|
||||
'format' => 'filtered_html',
|
||||
'editor' => 'ckeditor',
|
||||
'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)),
|
||||
'editorSupportsContentFiltering' => TRUE,
|
||||
'isXssSafe' => FALSE,
|
||||
)));
|
||||
]]];
|
||||
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
|
||||
$this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
|
||||
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
|
||||
|
|
@ -122,7 +122,7 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
// NOTE: the tests in CKEditorTest already ensure that changing the
|
||||
// configuration also results in modified CKEditor configuration, so we
|
||||
// don't test that here.
|
||||
\Drupal::service('module_installer')->install(array('ckeditor_test'));
|
||||
\Drupal::service('module_installer')->install(['ckeditor_test']);
|
||||
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
|
||||
$editor_settings = $editor->getSettings();
|
||||
$editor_settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
|
||||
|
|
@ -130,15 +130,15 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
$editor->save();
|
||||
$this->drupalGet('node/add/article');
|
||||
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
|
||||
$expected = array(
|
||||
'formats' => array(
|
||||
'filtered_html' => array(
|
||||
$expected = [
|
||||
'formats' => [
|
||||
'filtered_html' => [
|
||||
'format' => 'filtered_html',
|
||||
'editor' => 'ckeditor',
|
||||
'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)),
|
||||
'editorSupportsContentFiltering' => TRUE,
|
||||
'isXssSafe' => FALSE,
|
||||
)));
|
||||
]]];
|
||||
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
|
||||
$this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
|
||||
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
|
||||
|
|
@ -158,7 +158,7 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
/**
|
||||
* Tests presence of essential configuration even without Internal's buttons.
|
||||
*/
|
||||
protected function testLoadingWithoutInternalButtons() {
|
||||
public function testLoadingWithoutInternalButtons() {
|
||||
// Change the CKEditor text editor configuration to only have link buttons.
|
||||
// This means:
|
||||
// - 0 buttons are from \Drupal\ckeditor\Plugin\CKEditorPlugin\Internal
|
||||
|
|
@ -197,11 +197,11 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
/**
|
||||
* Tests loading of theme's CKEditor stylesheets defined in the .info file.
|
||||
*/
|
||||
function testExternalStylesheets() {
|
||||
public function testExternalStylesheets() {
|
||||
$theme_handler = \Drupal::service('theme_handler');
|
||||
// Case 1: Install theme which has an absolute external CSS URL.
|
||||
$theme_handler->install(['test_ckeditor_stylesheets_external']);
|
||||
$theme_handler->setDefault('test_ckeditor_stylesheets_external');
|
||||
$this->config('system.theme')->set('default', 'test_ckeditor_stylesheets_external')->save();
|
||||
$expected = [
|
||||
'https://fonts.googleapis.com/css?family=Open+Sans',
|
||||
];
|
||||
|
|
@ -209,7 +209,7 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
|
||||
// Case 2: Install theme which has an external protocol-relative CSS URL.
|
||||
$theme_handler->install(['test_ckeditor_stylesheets_protocol_relative']);
|
||||
$theme_handler->setDefault('test_ckeditor_stylesheets_protocol_relative');
|
||||
$this->config('system.theme')->set('default', 'test_ckeditor_stylesheets_protocol_relative')->save();
|
||||
$expected = [
|
||||
'//fonts.googleapis.com/css?family=Open+Sans',
|
||||
];
|
||||
|
|
@ -217,7 +217,7 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
|
||||
// Case 3: Install theme which has a relative CSS URL.
|
||||
$theme_handler->install(['test_ckeditor_stylesheets_relative']);
|
||||
$theme_handler->setDefault('test_ckeditor_stylesheets_relative');
|
||||
$this->config('system.theme')->set('default', 'test_ckeditor_stylesheets_relative')->save();
|
||||
$expected = [
|
||||
'core/modules/system/tests/themes/test_ckeditor_stylesheets_relative/css/yokotsoko.css',
|
||||
];
|
||||
|
|
@ -226,7 +226,7 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
|
||||
protected function getThingsToCheck() {
|
||||
$settings = $this->getDrupalSettings();
|
||||
return array(
|
||||
return [
|
||||
// JavaScript settings.
|
||||
$settings,
|
||||
// Editor.module's JS settings present.
|
||||
|
|
@ -239,7 +239,7 @@ class CKEditorLoadingTest extends WebTestBase {
|
|||
$this->xpath('//textarea[@id="edit-body-0-value"]'),
|
||||
// Format selector.
|
||||
$this->xpath('//select[contains(@class, "filter-list")]'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class CKEditorStylesComboAdminTest extends WebTestBase {
|
|||
/**
|
||||
* Tests StylesCombo settings for an existing text format.
|
||||
*/
|
||||
function testExistingFormat() {
|
||||
public function testExistingFormat() {
|
||||
$ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
|
||||
$default_settings = $ckeditor->getDefaultSettings();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ckeditor\Tests;
|
||||
|
||||
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\editor\Entity\Editor;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Component\Serialization\Json;
|
||||
|
||||
/**
|
||||
* Tests CKEditor toolbar buttons when the language direction is RTL.
|
||||
*
|
||||
* @group ckeditor
|
||||
*/
|
||||
class CKEditorToolbarButtonTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable for this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['filter', 'editor', 'ckeditor', 'locale'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create a text format and associate this with CKEditor.
|
||||
FilterFormat::create([
|
||||
'format' => 'full_html',
|
||||
'name' => 'Full HTML',
|
||||
'weight' => 1,
|
||||
'filters' => [],
|
||||
])->save();
|
||||
Editor::create([
|
||||
'format' => 'full_html',
|
||||
'editor' => 'ckeditor',
|
||||
])->save();
|
||||
|
||||
// Create a new user with admin rights.
|
||||
$this->admin_user = $this->drupalCreateUser([
|
||||
'administer languages',
|
||||
'access administration pages',
|
||||
'administer site configuration',
|
||||
'administer filters',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method tests CKEditor image buttons.
|
||||
*/
|
||||
public function testImageButtonDisplay() {
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
||||
// Install the Arabic language (which is RTL) and configure as the default.
|
||||
$edit = [];
|
||||
$edit['predefined_langcode'] = 'ar';
|
||||
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
|
||||
|
||||
$edit = ['site_default_language' => 'ar'];
|
||||
$this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
|
||||
// Once the default language is changed, go to the tested text format
|
||||
// configuration page.
|
||||
$this->drupalGet('admin/config/content/formats/manage/full_html');
|
||||
|
||||
// Check if any image button is loaded in CKEditor json.
|
||||
$json_encode = function($html) {
|
||||
return trim(Json::encode($html), '"');
|
||||
};
|
||||
$markup = $json_encode(file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupalimage/icons/drupalimage.png')));
|
||||
$this->assertRaw($markup);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue