Tinymce html5 placeholder by reading attribute from textarea

前端 未结 8 537
北恋
北恋 2020-12-31 19:41

For standard textareas I use this plugin to create a placeholder. How can I extend tinymce so that this works in this way also.

E.g the default value is read from the

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 20:42

    Gaurav's solution works OK, but needs a few changes. I used this modification to make it nearly perfect:

    editor.on("init", function(){
        tinymce.DOM.addClass( editor.bodyElement, 'content-editor' );
        if ( editor.getContent() === "" ) {
            tinymce.DOM.addClass( editor.bodyElement, 'empty' );
            var pseudoBeforeHeight = window.getComputedStyle(editor.bodyElement, ':before').height;
            tinymce.DOM.setStyles( editor.bodyElement, { 'height': pseudoBeforeHeight } );
        }
    });
    

提交回复
热议问题