jordandelozier / wysibb

WYSIWYG BBcode editor
http://www.wysibb.com
246 stars 86 forks source link

default font size #146

Open lafriakh opened 8 years ago

lafriakh commented 8 years ago

i can't change default size font.

speedygfw commented 8 years ago

use css?

lafriakh commented 8 years ago

i mean in select menu when i write the default option is small, i want to change it.

speedygfw commented 8 years ago

just override the options

var wbbOpt = {
  allButtons: {
    fontsize: {
                    type: 'select',
                    title: CURLANG.fontsize,
                                        //here you can change the order 
                    options: "fs_verysmall,fs_small,fs_normal,fs_big,fs_verybig"
                },...
lafriakh commented 8 years ago

not work just move the small to 3rd place

KnightYoshi commented 8 years ago

You need to edit the fs_* values. The forum I'm working in uses px so I had to change it. You will need to modify the exvalue and the HTML transform. I actually removed exvalue and excmd, because it didn't like px very much with those. I haven't noticed any repercussions and as far as I can tell the excmd is not actually used unlike bold, italic, underline, and strikeThrough, https://github.com/wbb/wysibb/blob/master/jquery.wysibb.js#L1337

// select options
                fs_verysmall : {
                    title : CURLANG.fs_verysmall,
                    buttonText : "fs1",
                    excmd : 'fontSize',
                    exvalue : "1",
                    transform : {
                        '<font size="1">{SELTEXT}</font>' : '[size=50]{SELTEXT}[/size]'
                    }
                },
                fs_small : {
                    title : CURLANG.fs_small,
                    buttonText : "fs2",
                    excmd : 'fontSize',
                    exvalue : "2",
                    transform : {
                        '<font size="2">{SELTEXT}</font>' : '[size=85]{SELTEXT}[/size]'
                    }
                },
                fs_normal : {
                    title : CURLANG.fs_normal,
                    buttonText : "fs3",
                    excmd : 'fontSize',
                    exvalue : "3",
                    transform : {
                        '<font size="3">{SELTEXT}</font>' : '[size=100]{SELTEXT}[/size]'
                    }
                },
                fs_big : {
                    title : CURLANG.fs_big,
                    buttonText : "fs4",
                    excmd : 'fontSize',
                    exvalue : "4",
                    transform : {
                        '<font size="4">{SELTEXT}</font>' : '[size=150]{SELTEXT}[/size]'
                    }
                },
                fs_verybig : {
                    title : CURLANG.fs_verybig,
                    buttonText : "fs5",
                    excmd : 'fontSize',
                    exvalue : "6",
                    transform : {
                        '<font size="6">{SELTEXT}</font>' : '[size=200]{SELTEXT}[/size]'
                    }
                },
CaptainHypertext commented 7 years ago

@Knight-Yoshi Thanks for posting that information. For anyone else, it took me a while to figure out, but in order to get rid of the <font> tags and use your own transformations for the font sizes, you have to set the excmd to null for each font size. Otherwise, it will ignore your transformations and use native browser commands.

If you want to get rid of font tags for color, you're going to have to modify the source as of this posting, it relies on browser commands, but you only need to add this to use transformation instead:

Line 1399
wbbInsertCallback: function(command,paramobj) {
    if (typeof(paramobj)!="object") {
        // Custom code: Add this inside this if statement //
        if (command == 'fontcolor') {
            paramobj = {
                color: paramobj
            };
        else {
            paramobj = {};
        }
        // End custom code //   
    };
    $.log("wbbInsertCallback: "+command);
    var data = this.getCodeByCommand(command,paramobj);
    this.insertAtCursor(data);
    ...
},

This is because font color passes a string into paramobj, which is expected to be an object, so this function will silently override the chosen color with a blank object. I hope this helps someone else out, because this is the best BB code editor I could find! Just needed some tweaking for me.

vinceblake commented 3 years ago

For the people following in my dumb footsteps:

The "font size" dropdown in the editor is simply used to insert bbcode into the textarea, which the WYSIWIG editor displays. The notes above will help you change what actual code gets inserted by clicking each selection. Maybe that's what you cared about, but it's not what I came here looking for.

If you noticed that selecting the "Normal" font size makes the text look how you want in the WYSIWIG editor, and what you are trying to do is make the text onscreen reflect that "Normal size" by default, what you actually need to do is very simple.

Just modify the CSS.

.wysibb{
    font-size: 16px;
}