1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.
    Dismiss Notice
  3. 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

Discussion in 'Code Modifications [Archive]' started by dieketzer, Jan 22, 2011.

  1. dieketzer

    dieketzer Well-Known Member

    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,
     
    DeltaHF, bousaid, Fuhrmann and 4 others like this.
  2. dieketzer

    dieketzer Well-Known Member

    updated the code for 1.02.
    this will now also prevent people from manually using color tags.
     
  3. dieketzer

    dieketzer Well-Known Member

    updated for 1.1.0
    you may need a few hard refreshes of the browser before the colour button actually goes away.
     
    LondonDragon and MrC like this.

Share This Page