2017-06-01 325 views
0

嗨有没有办法为tinymce v4.0添加占位符?我需要在tinymce中使用html 5占位符实现,但默认情况下它不存在。如何添加占位符在tinymce v4.0

<textarea id="Text" placeholder="Create your prompt here." ui-tinymce="$ctrl.tinymceOptions" ng-model="$ctrl.tmcModel"></textarea> 
+0

https://stackoverflow.com/questions/27237876/how-do-i-add-placeholder-text-to-tinymce也许? – tanmay

回答

0

这对我有效。

var iframe = document.getElementsByTagName('iframe')[0]; 
    iframe.style.resize = 'vertical'; 
0

假设你正在使用tinyMCE 4,你可以在init中添加一个占位符,然后在焦点上删除它。请记住TinyMCE使用iframe。 需要抛光的更有效率,但这里是一个快速的方法:

tinymce.init({ 
    //here all the rest of the options 
    //xxxxx 
    //Add the placeholder 
    setup: function (editor) { 
    editor.on('init', function(){ 
     if (tinymce.get('Text').getContent() == ''){ 
     tinymce.get('Text').setContent("<p id='#imThePlaceholder'>Your nice text here!</p>"); 
     } 
    }, 
    //and remove it on focus 
    editor.on('focus',function(){ 
     $('iframe').contents().find('#imThePlaceholder').remove(); 
    }), 
})