Linebreaks.php in Wysiwyg Linebreaks 8
File
src/Plugin/CKEditorPlugin/Linebreaks.php
View source
<?php
namespace Drupal\wysiwyg_linebreaks\Plugin\CKEditorPlugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\ckeditor\CKEditorPluginInterface;
use Drupal\ckeditor\CKEditorPluginContextualInterface;
use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\editor\Entity\Editor;
class Linebreaks extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface, CKEditorPluginConfigurableInterface {
use StringTranslationTrait;
public function isInternal() {
return FALSE;
}
public function getDependencies(Editor $editor) {
return [];
}
public function getLibraries(Editor $editor) {
return [];
}
public function getFile() {
return drupal_get_path('module', 'wysiwyg_linebreaks') . '/js/plugins/linebreaks/linebreaks.js';
}
public function getConfig(Editor $editor) {
$settings = $editor
->getSettings();
return [
'linebreaks_method' => isset($settings['plugins']['linebreaks']) ? $settings['plugins']['linebreaks']['method'] : 'force',
];
}
public function isEnabled(Editor $editor) {
return TRUE;
}
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
$default = $this
->getConfig($editor);
$form['method'] = [
'#type' => 'radios',
'#title' => $this
->t('Conversion Method'),
'#default_value' => $default['linebreaks_method'],
'#options' => [
'force' => $this
->t('Force linebreaks'),
'convert' => $this
->t('Convert linebreaks'),
],
'#description' => $this
->t('Set to Force linebreaks if you never want to see <code><p></code> and
<code><br /></code> tags in your content when editing without a Wysiwyg editor. Set to Convert linebreaks
if you have content without <code><p></code> and <code><br /></code> tags that needs to be
converted so it is still formatted correctly in the Wysiwyg editor.'),
];
return $form;
}
}