• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

编辑器选中加粗的代码是什么

php 搞代码 4年前 (2022-01-23) 22次浏览 已收录 0个评论
文章目录[隐藏]

以下代码是在编辑器中通过点击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>'                        }                    ]                }            ],            onl oad: 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>'                        }                    ]                }            ],            onl oad: function () {                //alert('onLoad');            },            onShow: function () {                //alert('onShow');            },            onHide: function () {                //alert('onHide');            },            onOk: function () {                this.commitContent();            },            onCancel: function () {                //alert('onCancel');            },            resizable: false        };<a>本2文来*源gao($daima.com搞@代@#码(网</a><strong>搞gaodaima代码</strong>    }     CKEDITOR.dialog.add('Wecenterh2', function (editor) {        return Wecenterh2Dialog(editor);    });})();</code>

现在我不想让他通过弹窗的方式输入,怎么修改可以通过编辑器中【B】也就是加粗的方式直接,选中文章中某些内容(比如选中文章中的:弹窗输入的内容,然后按下编辑器的H2)后直接输出:[h2]弹窗输入的内容[/h2]


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:编辑器选中加粗的代码是什么
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址