如何向TinyMCE添加占位符文本?
对于标准textareas,我使用placeholder=""
。 我如何扩展tinymce以便它也能以这种方式工作。
与CKEditor类似: http : //alfonsoml.blogspot.com.es/2012/04/placeholder-text-in-ckeditor.html
占位符插件对我很有用。 此插件为TinyMCE编辑器带来HTML5占位符属性function。
Bhanu Pratap, Tinymce with placeholder...
- 在这里我们添加一个标签并将其传递给tinymce的DOM对象“tinymce.DOM.bind(label.el,’click’,onFocus)的Bind方法;”
- 单击隐藏占位符或编辑器中是否有任何文本。
- 将占位符的颜色设置为#aaaaaa我们可以根据需要进行更改。
- 将填充设置为.25%,边距设置为5px,占位符的字体大小设置为17像素,可以根据需要更改这些设置。
- 我们也可以更改占位符消息并将其设置为有意义的mannar。
谢谢… :)
使用TinyMCE 3及更低版本,插件工作正常。 该插件在TinyMCE 4中不可用,但可以在初始化时添加占位符,然后在焦点上删除它。 记住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("Your nice text here!
"); } }); //and remove it on focus editor.on('focus',function(){ $('iframe').contents().find('#imThePlaceholder').remove(); }); })