所以我对 tinymce4 api 有一点问题,iv 创建了一个自定义格式,我想用一个按钮来触发。然而,当按钮被点击时,样式会被应用到按钮上,而不是实际的 contenteditable 字段。
tinymce.init({
selector: '#editable',
inline: true,
menubar: false,
toolbar:false,
statusbar: false,
});
setTimeout(function(){
tinymce.activeEditor.formatter.register('mycustomformat', {
inline : 'span',
styles: {color: 'red'}
});
},200);
$('.js-toggleformat').on('click', function(e) {
tinymce.activeEditor.formatter.apply('mycustomformat');
})
和html:
<button class="js-toggleformat">Toggle</button>
<div id="editable" contenteditable="true"></div>