我尝试将所见即所得的tinymce添加到我的Zend Framework 3应用程序中。
将 src 文件夹设置为公共\js\tinymce
包含到 \Post\view\layout\layout.phtml
`<?= $this->headScript()`
->prependFile($this->basePath('js/bootstrap.min.js'))
->prependFile($this->basePath('js/jquery-2.2.4.min.js'))
->prependFile($this->basePath('js/tinymce/tinymce.min.js'))
?>
在视图:
<div class="form-group">
<?= $this->formLabel($form->get('text')); ?>
<br>
<?= $this->formElement($form->get('text')); ?>
<?= $this->formElementErrors($form->get('text')); ?>
</div>
但结果,编辑器无法打开。我忘记了什么?
在
head 标签结束之前将下面的代码添加到视图布局中
<script language="javascript" type="text/javascript">
tinymce.init({
selector: 'textarea', // change this value according to your HTML
theme: 'modern',
plugins: [
'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
'save table contextmenu directionality emoticons template paste textcolor'
],
toolbar: [
'insertfile undo redo | fontselect fontsizeselect | bold italic | alignleft aligncenter alignright alignjustify | n
bullist numlist outdent indent | formatselect forecolor backcolor emoticons code | table n
nonbreaking template pagebreak | blockquote | link image | print preview media fullpage removeformat'
]
});
</script>