mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Soft-code CSS explicit height and compute against rows
This commit is contained in:
parent
078a508d71
commit
ae97c15e42
@ -51,7 +51,14 @@ class HTMLEditorField extends TextareaField
|
||||
* @config
|
||||
* @var int
|
||||
*/
|
||||
private static $default_rows = 30;
|
||||
private static $default_rows = 20;
|
||||
|
||||
/**
|
||||
* Extra height per row
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $fixed_row_height = 20;
|
||||
|
||||
/**
|
||||
* ID or instance of editorconfig
|
||||
@ -110,7 +117,17 @@ class HTMLEditorField extends TextareaField
|
||||
|
||||
public function getAttributes()
|
||||
{
|
||||
// Fix CSS height based on rows
|
||||
$rowHeight = $this->config()->get('fixed_row_height');
|
||||
$attributes = [];
|
||||
if ($rowHeight) {
|
||||
$height = $this->getRows() * $rowHeight;
|
||||
$attributes['style'] = sprintf('height: %dpx;', $height);
|
||||
}
|
||||
|
||||
// Merge attributes
|
||||
return array_merge(
|
||||
$attributes,
|
||||
parent::getAttributes(),
|
||||
$this->getEditorConfig()->getAttributes()
|
||||
);
|
||||
|
@ -332,7 +332,6 @@ class TinyMCEConfig extends HTMLEditorConfig
|
||||
return [
|
||||
'data-editor' => 'tinyMCE', // Register ss.editorWrappers.tinyMCE
|
||||
'data-config' => Convert::array2json($this->getConfig()),
|
||||
'style' => 'height:350px'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorConfig;
|
||||
use SilverStripe\Forms\HTMLEditor\TinyMCECombinedGenerator;
|
||||
use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
class TinyMCECombinedGeneratorTest extends SapphireTest
|
||||
{
|
||||
@ -18,6 +19,7 @@ class TinyMCECombinedGeneratorTest extends SapphireTest
|
||||
// Set custom base_path for tinymce
|
||||
Director::config()->set('alternate_base_folder', __DIR__ . '/TinyMCECombinedGeneratorTest');
|
||||
Director::config()->set('alternate_base_url', 'http://www.mysite.com/basedir/');
|
||||
SSViewer::config()->set('themes', [ SSViewer::DEFAULT_THEME ]);
|
||||
TinyMCEConfig::config()->set('base_dir', 'tinymce');
|
||||
}
|
||||
|
||||
@ -45,7 +47,7 @@ class TinyMCECombinedGeneratorTest extends SapphireTest
|
||||
/** @var TinyMCECombinedGenerator $generator */
|
||||
$generator = Injector::inst()->create(TinyMCECombinedGenerator::class);
|
||||
$this->assertEquals(
|
||||
'_tinymce/tinymce-testconfig-8d695fc0be.js',
|
||||
'_tinymce/tinymce-testconfig-6422b3814d.js',
|
||||
$generator->generateFilename($c),
|
||||
"Filename for config: " . json_encode($c->getAttributes()) . " should match expected value"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user