Angularjs 如何在tinymce v4.0中添加占位符
嗨,有没有办法为tinymce v4.0添加占位符?我需要在tinymce中实现HTML5占位符,但默认情况下它不在那里Angularjs 如何在tinymce v4.0中添加占位符,angularjs,tinymce,tinymce-4,Angularjs,Tinymce,Tinymce 4,嗨,有没有办法为tinymce v4.0添加占位符?我需要在tinymce中实现HTML5占位符,但默认情况下它不在那里 <textarea id="Text" placeholder="Create your prompt here." ui-tinymce="$ctrl.tinymceOptions" ng-model="$ctrl.tmcModel"></textarea> 这对我很有效 var iframe = document.getElementsBy
<textarea id="Text" placeholder="Create your prompt here." ui-tinymce="$ctrl.tinymceOptions" ng-model="$ctrl.tmcModel"></textarea>
这对我很有效
var iframe = document.getElementsByTagName('iframe')[0];
iframe.style.resize = 'vertical';
这对我有用
var iframe = document.getElementsByTagName('iframe')[0];
iframe.style.resize = 'vertical';
假设您使用的是tinyMCE 4,您可以在init上添加占位符,然后在focus上删除它。记住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();
}),
})
tinymce.init({
//下面是所有其他选项
//xxxxx
//添加占位符
设置:函数(编辑器){
on('init',function(){
if(tinymce.get('Text').getContent()=''){
tinymce.get('Text').setContent(您的漂亮文本在这里!
);
}
},
//并在焦点上移除它
on('focus',function(){
$('iframe').contents().find('imThePlaceholder').remove();
}),
})
假设您使用的是tinyMCE 4,您可以在init上添加占位符,然后在focus上删除占位符。记住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();
}),
})
tinymce.init({
//下面是所有其他选项
//xxxxx
//添加占位符
设置:函数(编辑器){
on('init',function(){
if(tinymce.get('Text').getContent()=''){
tinymce.get('Text').setContent(您的漂亮文本在这里!
);
}
},
//并在焦点上移除它
on('focus',function(){
$('iframe').contents().find('imThePlaceholder').remove();
}),
})
也许?也许?