Skip to content

Commit

Permalink
Merge pull request #695 from creative-commoners/pulls/4.1/trim-tiny-mce
Browse files Browse the repository at this point in the history
FIX Drop the TinyMCE toolbar but increase the row count
  • Loading branch information
robbieaverill authored Jul 22, 2019
2 parents f267155 + 6b28dd9 commit a87a1f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
18 changes: 14 additions & 4 deletions src/Forms/EditFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\FormField;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;

class EditFormFactory extends DefaultFormFactory
{
Expand Down Expand Up @@ -34,10 +35,19 @@ protected function getFormFields(RequestHandler $controller = null, $name, $cont
{
$fields = parent::getFormFields($controller, $name, $context);

/** @var HTMLEditorField $contentField */
$contentField = $fields->fieldByName('Root.Main.HTML');
if ($contentField) {
$contentField->setRows(5);
// Configure a slimmed down HTML editor for use with blocks
/** @var HTMLEditorField|null $editorField */
$editorField = $fields->fieldByName('Root.Main.HTML');
if ($editorField) {
$editorField->setRows(7);

$editorConfig = $editorField->getEditorConfig();

// Only configure if the editor is TinyMCE
if ($editorConfig instanceof TinyMCEConfig) {
$editorConfig->setOption('statusbar', false);
$editorField->setEditorConfig($editorConfig);
}
}

return $fields;
Expand Down
9 changes: 6 additions & 3 deletions src/Models/ElementContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace DNADesign\Elemental\Models;

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
use SilverStripe\ORM\FieldType\DBField;

class ElementContent extends BaseElement
Expand All @@ -29,10 +31,11 @@ class ElementContent extends BaseElement
public function getCMSFields()
{
$this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields
->fieldByName('Root.Main.HTML')
->setTitle(_t(__CLASS__ . '.ContentLabel', 'Content'));
/** @var HTMLEditorField $editorField */
$editorField = $fields->fieldByName('Root.Main.HTML');
$editorField->setTitle(_t(__CLASS__ . '.ContentLabel', 'Content'));
});

return parent::getCMSFields();
}

Expand Down

0 comments on commit a87a1f3

Please sign in to comment.