PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

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

原创
2016-10-23 00:12:48 1581浏览

以下代码是在编辑器中通过点击H2按钮,弹窗输入信息输出这个结果:[h2]弹窗输入的内容[/h2]

(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 : '

我们目前支持: h2 !

' } ] } ], 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); }); })();

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

回复内容:

以下代码是在编辑器中通过点击H2按钮,弹窗输入信息输出这个结果:[h2]弹窗输入的内容[/h2]

(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 : '

我们目前支持: h2 !

' } ] } ], 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); }); })();

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

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。