Hi all! I'm trying to get TinyMCE to work on the front end of a site I'm building. I've actually got almost everything working correctly; however, I can't get Tiny to abide by the width I'm setting for it.
I'm using a script written by Bob Ray to instantiate the editor:
<?php
$props = $scriptProperties;
/* set rich text content placeholders and includes necessary js files */
$tinyPath = $modx->getOption('core_path') . 'components/tinymce/';
$modx->regClientStartupScript($modx->getOption('manager_url') .
'assets/ext3/adapter/ext/ext-base.js');
$modx->regClientStartupScript($modx->getOption('manager_url') .
'assets/ext3/ext-all.js');
$modx->regClientStartupScript($modx->getOption('manager_url') .
'assets/modext/core/modx.js');
$whichEditor = $modx->getOption('which_editor', null, '');
$plugin = $modx->getObject('modPlugin', array('name' => $whichEditor));
if ($whichEditor == 'TinyMCE') {
//$tinyUrl = $this->modx->getOption('assets_url').'components/tinymcefe/';
$tinyUrl = $modx->getOption('assets_url') . 'components/tinymce/';
/* OnRichTextEditorInit */
$tinyproperties = $plugin->getProperties();
require_once $tinyPath . 'tinymce.class.php';
$tiny = new TinyMCE($modx, $tinyproperties, $tinyUrl);
// if (isset($this->props['forfrontend']) || $this->modx->isFrontend()) {
if (isset($props['forfrontend']) || $modx->context->get('key') !=
'mgr') {
$def = $modx->getOption('cultureKey', null, $modx->getOption('manager_language', null,
'en'));
$tinyproperties['language'] = $modx->getOption('fe_editor_lang', array(),
$def);
$tinyproperties['frontend'] = true;
unset($def);
}
$tinyproperties['cleanup'] = true;
/* prevents "bogus" bug */
$tinyproperties['width'] = empty($props['tinywidth']) ? '95%' : $props['tinywidth'];
$tinyproperties['height'] = empty($props['tinyheight']) ? '400px' : $props['tinyheight'];
//$tinyproperties['tiny.custom_buttons1'] = 'image';
//$tinyproperties['tiny.custom_buttons2'] = '';
$tiny->setProperties($tinyproperties);
$html = $tiny->initialize();
$modx->regClientStartupScript($tiny->config['assetsUrl'] .
'jscripts/tiny_mce/langs/' . $tiny->properties['language'] . '.js');
$modx->regClientStartupScript($tiny->config['assetsUrl'] .
'tiny.browser.js');
//mod by Bruno
if ($props['hasimagetv']) {
$rt_configs = array("selector" => "rt_imagetv", "width" => $props['imageTvWidth'],
"height" => $props['imageTvHeight'], "buttons1" => "image", "buttons2" => "",
"theme_advanced_buttons1" => "image", "theme_advanced_buttons2" => "", );
$cfg = '';
foreach ($rt_configs as $cf_key => $cf_value) {
$cfg .= 'Tiny.config.' . $cf_key . ' = "' . $cf_value . '";';
}
$js .= $cfg . ' MODx.loadRTE();';
}
$modx->regClientStartupHTMLBlock('<script type="text/javascript">
Ext.onReady(function() {
MODx.loadRTE();
' . $js . '
});
</script>');
}
/* end if ($whichEditor == 'TinyMCE') */
You will notice this line:
$tinyproperties['width'] = empty($props['tinywidth']) ? '95%' : $props['tinywidth'];
However, changing that number to a fixed pixel width (either in this script or in the property set) doesn't work, and if I set a percentage, the editor will narrow, but the content continues to scroll horizontally. I've also played around with setting a width on the textarea, or wrapping the textarea in a div and setting a width on it, and neither fixes the issue.
Can anyone help? I can provide a link via PM but would prefer not to share the page publicly quite yet. Thanks!