Skip to content
Snippets Groups Projects
Commit f7d8917c authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[FEATURE] Use the new API possibilities of tinymce 4.1.4

This means:
- load files with the page renderer
- fix missing RTE in inline elements
parent e702ef02
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ namespace SGalinski\Tinymce4Rte\Editors;
use TYPO3\CMS\Backend\Form\FormEngine;
use TYPO3\CMS\Backend\Rte\AbstractRte;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -63,6 +64,9 @@ class RteBase extends AbstractRte {
FormEngine $parentObject, $table, $field, $row, $PA, $specConf,
$thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue
) {
/** @var PageRenderer $pageRenderer */
$pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
// render the tinymce textarea
$value = $this->transformContent(
'rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue
......@@ -75,29 +79,7 @@ class RteBase extends AbstractRte {
name="' . htmlspecialchars($PA['itemFormElName']) . '"
rows="20" cols="100">' . GeneralUtility::formatForTextarea($value) . '</textarea>';
// add dedicated RTE configuration
$elementParts = preg_replace('/^(TSFE_EDIT\\[data\\]\\[|data\\[)/', '', $PA['itemFormElName']);
$elementParts = preg_replace('/\\]$/', '', $elementParts);
$elementParts = explode('][', $elementParts);
list($typoscriptConfigurationPid, $pid) = BackendUtility::getTSCpid(
trim($elementParts[0]), trim($elementParts[1]), $thePidValue
);
$rteConfiguration = rawurlencode(
$this->getRteConfiguration($specConf, $RTEtypeVal, $pid, $typoscriptConfigurationPid, $elementParts)
);
$languageId = max($row['sys_language_uid'], 0);
$language = ($GLOBALS['LANG']->lang === '' ? 'default' : $GLOBALS['LANG']->lang);
$code .= '
<script type = "text/javascript" >
var RTE = RTE || {};
RTE["editor' . $editorId . '"] = {};
RTE["editor' . $editorId . '"].rteConfiguration = "' . $rteConfiguration . '";
RTE["editor' . $editorId . '"].typo3ContentLanguage = "' . $language . '";
RTE["editor' . $editorId . '"].sys_language_content = parseInt(' . $languageId . ');
</script>';
// load the tinymce code and it's configuration
// add the tinymce code and it's configuration
if (!self::$coreLoaded) {
self::$coreLoaded = TRUE;
$userOrPageProperties = BackendUtility::getModTSconfig($thePidValue, 'RTE');
......@@ -112,18 +94,41 @@ class RteBase extends AbstractRte {
'/' . $userOrPageProperties['properties']['default.']['contentCSS']
);
}
$code .= $tinyMCE->getJS();
$tinyMCE->loadJsViaPageRenderer($pageRenderer, TRUE);
$imageModule = BackendUtility::getModuleUrl('rtehtmlarea_wizard_select_image');
$linkModule = BackendUtility::getModuleUrl('rtehtmlarea_wizard_element_browser');
$code .= '
<script type = "text/javascript" >
var RTE = RTE || {};
RTE.linkToImageModule = ' . GeneralUtility::quoteJSvalue($imageModule) . ';
RTE.linkToLinkModule = ' . GeneralUtility::quoteJSvalue($linkModule) . ';
</script>';
$pageRenderer->addJsInlineCode(
'RTEbasic',
'window.RTE = window.RTE || {};
window.RTE.linkToImageModule = ' . GeneralUtility::quoteJSvalue($imageModule) . ';
window.RTE.linkToLinkModule = ' . GeneralUtility::quoteJSvalue($linkModule) . ';'
);
}
// calculate the dedicated RTE configuration
$elementParts = preg_replace('/^(TSFE_EDIT\\[data\\]\\[|data\\[)/', '', $PA['itemFormElName']);
$elementParts = preg_replace('/\\]$/', '', $elementParts);
$elementParts = explode('][', $elementParts);
list($typoscriptConfigurationPid, $pid) = BackendUtility::getTSCpid(
trim($elementParts[0]), trim($elementParts[1]), $thePidValue
);
$rteConfiguration = rawurlencode(
$this->getRteConfiguration($specConf, $RTEtypeVal, $pid, $typoscriptConfigurationPid, $elementParts)
);
// add RTE specific configuration data
$languageId = max($row['sys_language_uid'], 0);
$language = ($GLOBALS['LANG']->lang === '' ? 'default' : $GLOBALS['LANG']->lang);
$pageRenderer->addJsInlineCode(
'RTE' . $editorId,
'window.RTE = window.RTE || {};
window.RTE["editor' . $editorId . '"] = {};
window.RTE["editor' . $editorId . '"].rteConfiguration = "' . $rteConfiguration . '";
window.RTE["editor' . $editorId . '"].typo3ContentLanguage = "' . $language . '";
window.RTE["editor' . $editorId . '"].sys_language_content = parseInt(' . $languageId . ');'
);
return $code;
}
......
......@@ -23,7 +23,7 @@ $EM_CONF[$_EXTKEY] = array(
'depends' => array(
'php' => '5.3.0-5.5.99',
'typo3' => '6.2.0-6.2.99',
'tinymce' => '4.1.3-4.1.99'
'tinymce' => '4.1.4-4.1.99'
),
'conflicts' => array(
'ch_rterecords' => '',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment