Home >Backend Development >PHP Tutorial >What is the bold code selected by the editor?
The following code is to click the H2 button in the editor and input information in the pop-up window to output the result: [h2] Content input in the pop-up window[/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>
Now I don’t want him to input through the pop-up window. How to modify it? You can directly use [B] in the editor, which is the bold method, to select certain content in the article (for example, select the content in the article: the content entered in the pop-up window, Then press H2) on the editor and directly output: [h2] Content entered in the pop-up window[/h2]
The following code is to click the H2 button in the editor and input information in the pop-up window to output the result: [h2] Content input in the pop-up window[/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>
Now I don’t want him to input through the pop-up window. How to modify it? You can directly use [B] in the editor, which is the bold method, to select certain content in the article (for example, select the content in the article: the content entered in the pop-up window, Then press H2) on the editor and directly output: [h2] Content entered in the pop-up window[/h2]