2017-06-01 324 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(); 
    }), 
})