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

[TASK] Add Xclass code for cleanup lists (saved in git for later)

parent 14438d19
No related branches found
No related tags found
No related merge requests found
<?php
namespace SGalinski\Tinymce4Rte\Xclass;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Overrides the language parser factory to fix a bug related to language overrides.
*
* Currently language overrides are not working if no related translated language file
* exists already inside the extension or l10n directory. The class fixes this behaviour.
*/
class RteHtmlParser extends \TYPO3\CMS\Core\Html\RteHtmlParser {
/**
* Preprocesses the content that is saved into the database to get rid of dangerous newlines
* in lists. Unfortunately they cause problematic paragraphs in the frontend. Can be evaluated
* with nested lists.
*
* @param string $value Input value
* @param array $specConf Special configuration for a field; This is coming from the types-configuration of the field in the TCA. In the types-configuration you can setup features for the field rendering and in particular the RTE takes al its major configuration options from there!
* @param string $direction Direction of the transformation. Two keywords are allowed; "db" or "rte". If "db" it means the transformation will clean up content coming from the Rich Text Editor and goes into the database. The other direction, "rte", is of course when content is coming from database and must be transformed to fit the RTE.
* @param array $thisConfig Parsed TypoScript content configuring the RTE, probably coming from Page TSconfig.
* @return string Output value
*/
public function RTE_transform($value, $specConf, $direction = 'rte', $thisConfig = []) {
$value = parent::RTE_transform($value, $specConf, $direction, $thisConfig);
if ($direction === 'db') {
$value = preg_replace('/[\n]*<(li|ul|ol)/is', '<$1', $value);
$value = preg_replace('/[\n]*<\/(li|ul|ol)/is', '</$1', $value);
$value = preg_replace('/[>]<(ul|ol)/is', ">\n<$1", $value);
}
return $value;
}
}
?>
\ No newline at end of file
tinymce.init({
selector: '.tinymce4_rte',
browser_spellcheck: true,
paste_as_text: true,
remove_script_host: false,
relative_urls: false,
autoresize_max_height: 500,
plugins: [
'advlist autolink lists charmap hr anchor pagebreak searchreplace wordcount visualblocks visualchars code',
'nonbreaking save table directionality template paste colorpicker autoresize shy contextmenu'
],
toolbar1: 'undo redo | styleselect | bold italic | typo3link typo3image | '
+ 'alignleft aligncenter alignright alignjustify | bullist numlist outdent indent',
external_plugins: {
typo3filemanager: 'EXT:tinymce4_rte/Resources/Public/Plugins/Typo3FileManager/typo3filemanager.min.js',
shy: 'EXT:tinymce/Resources/Public/JavaScript/TinymcePlugins/shy/plugin.min.js'
},
contextmenu: 'typo3link typo3image inserttable | cell row column deletetable'
tinymce.init(
{
selector: '.tinymce4_rte',
browser_spellcheck: true,
paste_as_text: true,
remove_script_host: false,
relative_urls: false,
autoresize_max_height: 500,
plugins: [
'advlist autolink lists charmap hr anchor pagebreak searchreplace wordcount visualblocks visualchars code',
'nonbreaking save table directionality template paste colorpicker autoresize shy contextmenu'
],
toolbar1: 'undo redo | styleselect | bold italic | typo3link typo3image | '
+ 'alignleft aligncenter alignright alignjustify | bullist numlist outdent indent',
external_plugins: {
typo3filemanager: 'EXT:tinymce4_rte/Resources/Public/Plugins/Typo3FileManager/typo3filemanager.min.js',
shy: 'EXT:tinymce/Resources/Public/JavaScript/TinymcePlugins/shy/plugin.min.js'
},
contextmenu: 'typo3link typo3image inserttable | cell row column deletetable'
// Example for adding/changing style formats
// ,style_formats: [
// {
// title: 'Headers', items: [
// {title: 'Header 2', block: 'h2'},
// {title: 'Header 3', block: 'h3'},
// {title: 'Header 4', block: 'h4'}
// ]
// },
// {
// title: 'Inline', items: [
// {title: 'Bold', icon: "bold", inline: 'strong'},
// {title: 'Italic', icon: "italic", inline: 'em'},
// {title: 'Underline', icon: "underline", inline: 'span', styles: {'text-decoration': 'underline'}},
// {title: 'Strikethrough', icon: "strikethrough", inline: 'span', styles: {'text-decoration': 'line-through'}},
// {title: 'Superscript', icon: "superscript", inline: 'sup'},
// {title: 'Subscript', icon: "subscript", inline: 'sub'},
// {title: 'Code', icon: "code", inline: 'code'}
// ]
// },
// {
// title: 'Blocks', items: [
// {title: 'Paragraph', block: 'p'},
// {title: 'Blockquote', block: 'blockquote'},
// {title: 'Div', block: 'div', format: 'greenBox'},
// {title: 'Pre', block: 'pre'}
// ]
// },
// {
// title: 'Alignment', items: [
// {title: 'Left', icon: "alignleft", block: 'div', styles: {'text-align': 'left'}},
// {title: 'Center', icon: "aligncenter", block: 'div', styles: {'text-align': 'center'}},
// {title: 'Right', icon: "alignright", block: 'div', styles: {'text-align': 'right'}}
// ]
// }
// ],
// formats: {
// greenBox: {
// block: 'div',
// wrapper: 1,
// remove: 'all',
// classes: 'box-green'
// }
// }
});
\ No newline at end of file
// Example for adding/changing style formats
// ,style_formats: [
// {
// title: 'Headers', items: [
// {title: 'Header 2', block: 'h2'},
// {title: 'Header 3', block: 'h3'},
// {title: 'Header 4', block: 'h4'}
// ]
// },
// {
// title: 'Inline', items: [
// {title: 'Bold', icon: "bold", inline: 'strong'},
// {title: 'Italic', icon: "italic", inline: 'em'},
// {title: 'Underline', icon: "underline", inline: 'span', styles: {'text-decoration': 'underline'}},
// {
// title: 'Strikethrough',
// icon: "strikethrough",
// inline: 'span',
// styles: {'text-decoration': 'line-through'}
// },
// {title: 'Superscript', icon: "superscript", inline: 'sup'},
// {title: 'Subscript', icon: "subscript", inline: 'sub'},
// {title: 'Code', icon: "code", inline: 'code'}
// ]
// },
// {
// title: 'Blocks', items: [
// {title: 'Paragraph', block: 'p'},
// {title: 'Blockquote', block: 'blockquote'},
// {title: 'Div', block: 'div', format: 'greenBox'},
// {title: 'Pre', block: 'pre'}
// ]
// },
// {
// title: 'Alignment', items: [
// {title: 'Left', icon: "alignleft", block: 'div', styles: {'text-align': 'left'}},
// {title: 'Center', icon: "aligncenter", block: 'div', styles: {'text-align': 'center'}},
// {title: 'Right', icon: "alignright", block: 'div', styles: {'text-align': 'right'}}
// ]
// }
//],
// formats: {
// greenBox: {
// block: 'div',
// wrapper: 1,
// remove: 'all',
// classes: 'box-green'
// }
// }
//}
);
\ No newline at end of file
......@@ -34,4 +34,7 @@ $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg']['tinymce'] = array(
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('tinymce4_rte') .
'Configuration/Hooks/SoftRef/ext_localconf.php';
?>
\ No newline at end of file
// Xclasses
// Remove this XClass if TYPO3 has fixed the rte<->html parser/process
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Core\Html\RteHtmlParser'] =
array('className' => 'SGalinski\Tinymce4Rte\Xclass\RteHtmlParser');
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