Forum closed. New forum available at http://community.wymeditor.org/

BBCode and Smiley Menus

Support forum for WYMeditor.

BBCode and Smiley Menus

Postby cyaneo on Sat Oct 17, 2009 9:04 pm

Hi
I want use WYMeditor for my Drupal integrated advanced forum - so far if works like a charm!

But - as in this forum - I want add some custom buttons/menus:
BBcodes: Quote; Code; Img; URL;
and some Smileys


Ho can this be done?
PS: Please beware: I am a non-programmer, I just can insert code-snippets... :-(
cyaneo
 
Posts: 1
Joined: Sat Oct 17, 2009 8:57 pm

Re: BBCode and Smiley Menus

Postby mr_lundis on Tue Oct 27, 2009 11:15 pm

Hi cyaneo!
Unfortunately I can't provide you with the full code to make what you describe work, but take a look at the wrap/unwrap test page. With a little customization you should be able to achieve the functionality you described.

The following lines are the ones that should be most interesting:
Code: Select all
            //construct the wrap button's html
            var html = "<li class='wym_tools_wrap'>"
                     + "<a name='Wrap' href='#'"
                     + " style='background-image:"
                     + " url(../wymeditor/skins/default/icons.png)'>"
                     + "Wrap"
                     + "<\/a><\/li>";

            //add the button to the tools box
            jQuery(wym._box)
            .find(wym._options.toolsSelector + wym._options.toolsListSelector)
            .append(html);

            //handle click event
            jQuery(wym._box)
            .find('li.wym_tools_wrap a').click(function() {
                wym.wrap( '<span>', '<\/span>');
                return(false);
            });


Its the wym.wrap()-line that's doing all the magic. It will wrap the current selection in whichever two strings you pass as arguments.

Cheers! ;)
Jonatan Lundin - designer, developer and forum moderator. You should follow me on Twitter!
mr_lundis
 
Posts: 335
Joined: Sun Dec 02, 2007 10:59 am
Location: Sweden


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests