• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum is for release discussion only. Discussions that do not relate specifically to the resource release should be discussed in another, more appropriate forum.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

disable text colour-formatting in editor

dieketzer

Well-known member
#1
xf 1.1.0

due to chrome pasting issues (pasting colour-formatted text), i have elected to completely disable all colour functionality from tinyMCE.
  • pasted colour-formatting will be stripped when posted
  • colour-format button will not be visible
  • manually entered [color] tags will silently fail
  • php code colour-formatting is unaffected (syntax highlighting)
  • the effect is not retroactive
in the php file: /library/XenForo/Html/Renderer/BbCode.php
(line 51)
find:
PHP:
        'color'          => array('$this', 'handleCssColor'),
comment it out:
Code:
/*        'color'          => array('$this', 'handleCssColor'),*/
(line 645)
find:
PHP:
public function handleCssColor($text, $color)
    {
        return "[COLOR=$color]{$text}[/COLOR]";
    }
comment it out:
Code:
/*public function handleCssColor($text, $color)
    {
        return "[COLOR=$color]{$text}[/COLOR]";
    }*/
in the file /library/XenForo/BbCode/Formatter/Base.php
(line 296)
find:
PHP:
'color' => array(
'hasOption' => true,
'optionRegex' => '/^(rgb\(\s*\d+%?\s*,\s*\d+%?\s*,\s*\d+%?\s*\)|#[a-f0-9]{6}|#[a-f0-9]{3}|[a-z]+)$/i',
'replace' => array('<span style="color: %s">', '</span>')
),
replace with:
Code:
'color' => array(
'hasOption' => true,
'optionRegex' => '/^(rgb\(\s*\d+%?\s*,\s*\d+%?\s*,\s*\d+%?\s*\)|#[a-f0-9]{6}|#[a-f0-9]{3}|[a-z]+)$/i',
'replace' => array('<span>', '</span>')
),
in the js file: /js/tinymce/themes/xenforo/editor_template.js
(line 985)

find:
PHP:
theme_xenforo_buttons1 : 'removeformat,|,fontselect,fontsizeselect,forecolor,xenforo_smilies,|,' + undoRedoButtons,
remove 'forecolor':
Code:
theme_xenforo_buttons1 : 'removeformat,|,fontselect,fontsizeselect,xenforo_smilies,|,' + undoRedoButtons,