我正在使用tinyMCE React
"tinymce": "^6.7.0",
"@tinymce/tinymce-react": "^4.3.0",
我正在尝试向编辑器添加占位符。及其支持的形式
v5.0.2
,
我的初始化函数
<Editor
init={{
height: 200,
menubar: false,
statusbar: false,
toolbar_location : 'bottom',
placeholder: "placeholder text",
inline_styles : true,
plugins: ['advlist', 'lists'],
toolbar: 'bold italic underline | custom-link | bullist numlist',
content_style: 'body { font-family: -apple-system, BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif; font-size:14px }',
skin: false,
content_css: false,
setup: this.initEditor,
}}
onInit={(evt, editor) => {
this.editorRef.current = editor;
this.controller.setReady()
}}
onEditorChange={this.onChangeEditor}
/>
但是,它没有显示在编辑器中。检查后,我可以看到它将占位符添加到编辑器主体中。
但它没有出现在编辑器中。不工作的原因可能是什么?
TinyMCE 有一个包含占位符的特定配置选项:
https://www.tiny.cloud/docs/tinymce/6/editor-important-options/#placeholder
例如:
tinymce.init({
selector: 'textarea', // change this value according to your HTML
placeholder: 'Type here...'
});