在默認的工具欄中自帶一個格式的選項,能夠編輯文字的段落屬性,將文字轉換爲標題。ckeditor中提供了方法能夠對這個標籤進行修改。javascript
正在作的項目中不叫標題1標題2,叫章、節、條... 。 須要進行配置,下面是配置方法。java
ckeditor 中在於段落格式的設置中有兩種格式一種是格式,format,另外一種是style(能夠自定義);app
格式中的下拉菜單中的名稱只能經過修改ckeditor的源代碼或者修改語言文件對應的名稱來修改。編輯器
樣式中的能夠本身的定義包含塊狀元素和行內元素,以及其餘的元素。工具
在我作的項目中只須要修改語言文件中的個標題對應的名字(label)就i行。插件
項目中還有一個需求,須要對下拉菜單中選擇的每一個標題帶上id。沒辦法只能去修改format插件中的代碼了。在點擊的方法中添加idorm
其中defineObj是對元素的標籤預設的集合。style,class attribute等等均可以設置。blog
onClick: function( value ) { editor.focus(); editor.fire( 'saveSnapshot' ); var style = styles[ value ], elementPath = editor.elementPath(); // Always apply style, do not allow to toggle it by clicking on corresponding list item (#584). if ( !style.checkActive( elementPath, editor ) ) { var defineObj = style.getDefinition(); if(!defineObj.attributes) { defineObj.attributes = { } } defineObj.attributes['id'] = Date.now(); editor.applyStyle( style ); } // Save the undo snapshot after all changes are affected. (https://dev.ckeditor.com/ticket/4899) setTimeout( function() { editor.fire( 'saveSnapshot' ); }, 0 ); },
最重要的一點是要對ACF進行設置。別讓編輯器把你的內容給過濾了ip
。element