BBCode Color Code Development

  1. 4 years ago

    Was wondering if anyone has gotten into the text color for bbcode?
    Something like [color=#006600]Text Here[/color]

    That ending bracket should be obvious...that's why I left it out. but guess I should've put it in.

    edit: There's an issue with multiple [color] codes, gonna try to fix that..

    edit 2: Here's the fix
    Replace the Initial Code I gave

    $sender->content = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/si", "<span style=\"color:\\1\">\\2</span>", $sender->content);
    }

    with

     $sender->content = preg_replace("/\[color=([#a-z0-9]+)\](.*?)\[\/color\]/is", "<span style=\"color:\\1\">\\2</span>", $sender->content);
  2. plugin.php

     
     addToArrayString($controls, "font color". "<a title='".T("font color")."' class='control-color'></a>", 0);
    }
    
     // Font Color: [color=$1]text[/color]
        $sender->content = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/si", "<span style=\"color:\\1\">\\2</span>", $sender->content);

    There's no button so you'll have to manually add that, but I got it working. There's a '0' that appears before the preview button, not sure how to get rid of it .-.

  3. addToArrayString($controls, "font color". "<a title='".T("font color")."' class='control-color'></a>", 0);
    }
    
     // Font Color: [color=$1]text[/color]
        $sender->content = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/si", "<span style=\"color:\\1\">\\2</span>", $sender->content);

    Doesn't work till you do this.

    addToArrayString($controls, "font color". "<a title='".T("font color")."' class='control-color'></a>", 0);
    
     // Font Color: [color=$1]text[/color]
        $sender->content = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/si", "<span style=\"color:\\1\">\\2</span>", $sender->content);
    }

    But thanks.

  4. Edited 4 years ago by Niuwang

    That ending bracket should be obvious...that's why I left it out. but guess I should've put it in.

    edit: There's an issue with multiple [color] codes, gonna try to fix that..

    edit 2: Here's the fix
    Replace the Initial Code I gave

    $sender->content = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/si", "<span style=\"color:\\1\">\\2</span>", $sender->content);
    }

    with

     $sender->content = preg_replace("/\[color=([#a-z0-9]+)\](.*?)\[\/color\]/is", "<span style=\"color:\\1\">\\2</span>", $sender->content);
  5. @Niuwang That ending bracket should be obvious...that's why I left it out. but guess I should've put it in.

    edit: There's an issue with multiple [color] codes, gonna try to fix that..

    edit 2: Here's the fix
    Replace the Initial Code I gave

    $sender->content = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/si", "<span style=\"color:\\1\">\\2</span>", $sender->content);
    }

    with
    $sender->content = preg_replace("/\[color=([#a-z0-9]+)\](.*?)\[\/color\]/is", "<span style=\"color:\\1\">\\2</span>", $sender->content);

    Does work with removing the "0", but it's sad that it doesn't help with adding an image to the bbcode options so that it's easier for those that don't know bbcodes to use it. Anyways thanks!

  6. @Felli Does work with removing the "0", but it's sad that it doesn't help with adding an image to the bbcode options so that it's easier for those that don't know bbcodes to use it. Anyways thanks!

    Yeah I'm Regex isn't my ace in the hole so whenever I make something with it it's problematic for me. If you can find someone who can fix that then please let me know. lol I'm trying to figure out how to span a colour wheel or something instead.

  7. @Niuwang Yeah I'm Regex isn't my ace in the hole so whenever I make something with it it's problematic for me. If you can find someone who can fix that then please let me know. lol I'm trying to figure out how to span a colour wheel or something instead.

    That would be interesting, tho it would take quite a lot of coding to do so.

  8. [deleted]

    13 Feb 2015

    This helped me to get an Icon for the Textcolor BBcode:

    in addons/plugins/BBCode/plugin.php insert in Function handler_conversationController_getEditControls

    addToArrayString($controls, "textcolor", "<a href='javascript:BBCode.textcolor(\"$id\");void(0)' title='".T("Color")."' class='control-textcolor'><i class='icon-tint'></i></a>", 0);

    and

    in addons/plugins/BBCode/plugin.php insert in Function handler_format_format

    // Font Color: [color=$1]text[/color]
        $sender->content = preg_replace("/\[color=([#a-z0-9]+)\](.*?)\[\/color\]/is", "<span style=\"color:\\1\">\\2</span>", $sender->content);

    and

    in addons/plugins/BBCode/resources/bbcode.js insert in hvar BBCode = {

    textcolor: function(id) {ETConversation.wrapText($("#"+id+" textarea"), "[color=darkred]", "[/color]", "darkred", "Color Text");},
  9. @adilbo This helped me to get an Icon for the Textcolor BBcode:

    addToArrayString($controls, "textcolor", "<a href='javascript:BBCode.textcolor(\"$id\");void(0)' title='".T("Color")."' class='control-textcolor'><i class='icon-tint'></i></a>", 0);

    and

    // Font Color: [color=$1]text[/color]
        $sender->content = preg_replace("/\[color=([#a-z0-9]+)\](.*?)\[\/color\]/is", "<span style=\"color:\\1\">\\2</span>", $sender->content);

    and

    textcolor: function(id) {ETConversation.wrapText($("#"+id+" textarea"), "[color=darkred]", "[/color]", "darkred", "Color Text");},

    Awesome! Thanks for the help. I haven't been able to get around to doing it.

  10. plugin for this would be extremely nice?

  11. @Tech plugin for this would be extremely nice?

    All you have to do is add what @adilbo posted to your bbcode plugin.

  12. 3 years ago

    Would be nice though if someone would have the time to make a small plugin with more bbcodes

  13. @Tech Would be nice though if someone would have the time to make a small plugin with more bbcodes

    The simplest, and more easy thing to do is just edit the original plugin.

  14. Edited 3 years ago by Tech

    @Felli The simplest, and more easy thing to do is just edit the original plugin.

    I wouldn't even know where to begin to be honest?

  15. Edited 3 years ago by Niuwang

    I literally provided directions above. If you still don't know where to begin after that then you probably shouldn't even be touching esoTalks code.

    The Plugin.PHP is inside the BBCODE directory of the Plugin Directory. Also someone did make an extension but its chose the worst possible icons for buttons so you'really really better off using what I provides if you want something that functions while still being aesthetically pleasing.

  16. 2 years ago

    [deleted]

    8 Mar 2017

    http://devcodepro.com/view/26/8/esoTalk-BBCode-plugin-with-Color-Tag

 

or Sign Up to reply!