如何在Drupal 8中添加ckeditor块?没有形成



我有自定义模块Block与模板文件。

如何在小树枝模板中添加简单的ckeditor ?

我已经在module.library.yml中添加了library dependencies

table:
dependencies:
- core/ckeditor
- ckeditor/drupal.ckeditor

有一个使用WYSIWYG的block示例

<?php
namespace Drupalmy_modulePluginBlock;
use DrupalCoreFormFormStateInterface;
/**
*
* @Block(
*  id = "content_block",
*  admin_label = @Translation("content_block"),
*  category = @Translation("content_block")
* )
*/
class ContentBlock extends AbstractWebConfigurableBlock {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function blockForm($form, FormStateInterface $form_state) {
$form['title'] = [
'#type' => 'textfield',
'#title' => $this->t('Title'),
'#default_value' => $this->configuration['title'],
'#maxlength' => 50,
'#size' => 50,
'#weight' => '1',
'#required' => TRUE,
];
$form['content'] = [
'#type' => 'text_format',
'#title' => $this->t('Content'),
'#default_value' => $this->configuration['content'],
'#format' => 'full_html',
'#weight' => '2',
'#required' => TRUE,
];

return $form;
}
/**
* {@inheritdoc}
*/
public function blockSubmit($form, FormStateInterface $form_state) {
$this->configuration['title'] = $form_state->getValue('title');
$this->configuration['content'] = $form_state->getValue('content')['value'];
}
/**
* {@inheritdoc}
*/
public function build() {
return [
'title' => [
'#markup' => $this->configuration['title'],
],
'content' => [
'#markup' => $this->configuration['content'],
],
];
}
}

最新更新