Wordpress change functionality of TinyMCE button U (underline)

天大地大妈咪最大 提交于 2019-12-13 05:53:36

问题


does anybody know how to change functionality of button in wordpress content textarea? There is a "u" button (underline) which makes text

<span style="text-decoration-line: underline;">text underlined</span>

what I need is change functionality of this button to put in content:

<u>text underlined</u>

Can someone help?


回答1:


You can get this formatting once you define the underline format in the init method.

HTML

<form>
    <textarea id='instance1'></textarea>
</form>
<button id='get'>Test</button>
<div id='previewHTML'></div>
<div id='previewFormat'></div>

JS

var textArea_id = "#instance1";

tinymce.init({
   selector: textArea_id,
   toolbar: "underline",
   formats : {
         underline : {inline : 'u', exact : true},
   }
});


var button = document.getElementById('get');

button.onclick = function(){
   var contentHTML = tinymce.activeEditor.getContent({format: 'html'});
   document.getElementById('previewHTML').innerText = contentHTML;
   document.getElementById('previewFormat').innerHTML = contentHTML;
}

See this DEMO



来源:https://stackoverflow.com/questions/32561161/wordpress-change-functionality-of-tinymce-button-u-underline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!