English 中文(简体)
NicEditor font volume mody from <font amount= 1 > tag to <span作= font-size: 8px>
原标题:NicEditor font size mody from <font size= 1 > tag to <span style= font-size: 8px >

Hi I am using NicEditor and I want the font size work in defferent way bec. rightnow the editor uses the:

<font amount= 1..7 >the selected text here</font>

I wan t it to become a span tag i.e.

<span Format= font-size:30px >the selected text here</span>

Here is the code for the dropdown:

var nicEditorFontSizeSelect = nicEditorSelect.extend({
    sel : {1 :  1&nbsp;(8pt) , 2 :  2&nbsp;(10pt) , 3 :  3&nbsp;(12pt) , 4 :  4&nbsp;(14pt) , 5 :  5&nbsp;(18pt) , 6 :  6&nbsp;(24pt) , 7 :  7&nbsp;(36pt) , 8 :  8&nbsp;(48pt) , 9 :  9&nbsp;(72pt) , 10 :  10&nbsp;90pt) , 11 :  11&nbsp;(100pt) },
    init : function() {
        this.setDisplay( Font&nbsp;Size... );
        for(itm in this.sel) {
            this.add(itm, <font size=" +itm+ "> +this.sel[itm]+ </font> );
        }       
    }
});

but I can not find the code to modify so that it will replace the font into a span tag inside the textarea.

任何建议都受到欢迎。

Thank you

问题回答

众所周知,这是一个老问题,但任何人都需要回答。

值得注意的是,这非常基本,而且可能与改进有关,例如,它造成了nes。

Anyway, add this JS code before you initialise your nicEditor, create a custom plugin:

var nicSelectOptionsCustomFormat = {
    buttons : {
         fontCustomSize  : {name : __( Font size ), type :  nicEditorCustomFormatSelect }
    }
};
var nicEditorCustomFormatSelect = nicEditorSelect.extend({
    sel : { 11px  :  11px ,  13px  :  13px ,  15px  :  15px ,  19px  :  19px ,  22px  :  22px },

    init : function() {
        this.setDisplay( Font size );
        for(itm in this.sel) {
            this.add(itm, <span style="size: +itm+ "> +this.sel[itm]+ </span> );
        }
    }

    ,update : function(elm) {
        var newNode = document.createElement( span );
        newNode.style.fontSize = elm;
        var rng = this.ne.selectedInstance.getRng().surroundContents(newNode);
        this.close();
    }
});
nicEditors.registerPlugin(nicPlugin,nicSelectOptionsCustomFormat);

然后使用<条码>。 当你创建编辑时,例如:

var config = {
    buttonList: ["bold", "italic", "underline","fontCustomSize"]
};
var e = new nicEditor(config);
e.panelInstance("page-description");




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签