簡體   English   中英

TintMCE-單擊按鈕后更改文本字體大小

[英]TintMCE - Change text font size after button click

在單擊“ Change Font的字體按鈕后,我想更改所選文本的大小:但是使用該行后,它沒有改變:

editor.execCommand("fontSize", false, e.data.source)

這是帶有小提琴的代碼:

<script type="text/javascript">
tinymce.init({
    selector: "textarea",
    plugins: [
        "advlist autolink lists link image charmap print preview anchor",
        "searchreplace visualblocks code fullscreen",
        "insertdatetime media table contextmenu paste"
    ],
    toolbar: "wrapselection | code | insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
    setup: function (editor) {
       editor.addButton('wrapselection', {
          text: 'Change Font',
          icon: false,
          onclick: function () {


                    editor.windowManager.open({
                    title: 'Enter Font Size',
                    body: [
                        {type: 'textbox', name: 'source', label: 'Font Size'}
                    ],
                    onsubmit: function(e) {
                        alert(e.data.source);
                        editor.focus();
                        editor.execCommand("fontSize", false, e.data.source);

                    }
                });


          }
       });
    }

});
</script>

<form method="post" action="dump.php">
    <textarea name="content">This is content in the editor</textarea>
</form>

http://fiddle.tinymce.com/a7gaab

用戶單擊大小后如何更改字體大小?

只需在警報消息之后添加以下代碼行

editor.getBody().style.fontSize = e.data.source + 'px';

更新的代碼

http://fiddle.tinymce.com/b7gaab

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM