編輯器選取加粗的程式碼是什麼

WBOY
發布: 2016-10-23 00:12:48
原創
1857 人瀏覽過

以下程式碼是在編輯器中點選H2按鈕,彈跳視窗輸入資訊輸出這個結果:[h2]彈窗輸入的內容[/h2]

<code>(function () {
    function Wecenterh2Dialog(editor) {
 
        return {
            title: 'H2',
            minWidth: 470,
            minHeight: 110,
            buttons: [
                CKEDITOR.dialog.okButton,
                CKEDITOR.dialog.cancelButton
            ],
            contents:
            [
                {
                    elements:
                    [
                        {
                            id: 'text',
                            type: 'text',
                            required: true,
                            commit: function () {
                                if (this.getValue()) {
                                    editor.insertHtml('[h2]' + this.getValue()  + '[/h2]');
                                    //editor.insertText( '!![输入内容](' + this.getValue() + ')' );
                                }
                            }
                        },
                        {
                            type: 'html',
                            html : '<p style="font-size:14px;color:#999;">我们目前支持: h2 !</p>'
                        }
                    ]
                }
            ],
            onLoad: function () {
                //alert('onLoad');
            },
            onShow: function () {
                //alert('onShow');
            },
            onHide: function () {
                //alert('onHide');
            },
            onOk: function () {
                this.commitContent();
            },
            onCancel: function () {
                //alert('onCancel');
            },
            resizable: false
        };
    }
 
    CKEDITOR.dialog.add('Wecenterh2', function (editor) {
        return Wecenterh2Dialog(editor);
    });
})();</code>
登入後複製
登入後複製

現在我不想讓他透過彈跳視窗的方式輸入,怎麼修改可以透過編輯器中【B】也就是加粗的方式直接,選取文章中某些內容(例如選取文章中的:彈跳視窗輸入的內容,然後按下編輯器的H2)後直接輸出:[h2]彈跳視窗輸入的內容[/h2]

回覆內容:

以下程式碼是在編輯器中點選H2按鈕,彈跳視窗輸入資訊輸出這個結果:[h2]彈窗輸入的內容[/h2]

<code>(function () {
    function Wecenterh2Dialog(editor) {
 
        return {
            title: 'H2',
            minWidth: 470,
            minHeight: 110,
            buttons: [
                CKEDITOR.dialog.okButton,
                CKEDITOR.dialog.cancelButton
            ],
            contents:
            [
                {
                    elements:
                    [
                        {
                            id: 'text',
                            type: 'text',
                            required: true,
                            commit: function () {
                                if (this.getValue()) {
                                    editor.insertHtml('[h2]' + this.getValue()  + '[/h2]');
                                    //editor.insertText( '!![输入内容](' + this.getValue() + ')' );
                                }
                            }
                        },
                        {
                            type: 'html',
                            html : '<p style="font-size:14px;color:#999;">我们目前支持: h2 !</p>'
                        }
                    ]
                }
            ],
            onLoad: function () {
                //alert('onLoad');
            },
            onShow: function () {
                //alert('onShow');
            },
            onHide: function () {
                //alert('onHide');
            },
            onOk: function () {
                this.commitContent();
            },
            onCancel: function () {
                //alert('onCancel');
            },
            resizable: false
        };
    }
 
    CKEDITOR.dialog.add('Wecenterh2', function (editor) {
        return Wecenterh2Dialog(editor);
    });
})();</code>
登入後複製
登入後複製

現在我不想讓他透過彈跳視窗的方式輸入,怎麼修改可以透過編輯器中【B】也就是加粗的方式直接,選取文章中某些內容(例如選取文章中的:彈跳視窗輸入的內容,然後按下編輯器的H2)後直接輸出:[h2]彈跳視窗輸入的內容[/h2]

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!