Javascript 如何在 zend 框架上使用 Tinymce?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2271300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-22 23:33:12  来源:igfitidea点击:

how to use Tinymce on zend framework?

javascriptzend-frameworktinymce

提问by ulduz114

i need to use Tinymce in my project on zend framework, but i dont know how to use of it ! anyone may help and give an example?

我需要在我的 Zend 框架项目中使用 Tinymce,但我不知道如何使用它!任何人都可以帮忙并举个例子吗?

thanks

谢谢

回答by Shane O'Grady

There is some discussion and an implementation here

有一些讨论和实施在这里

回答by Htbaa

There are plenty of examples on the TinyMCE website. For easy implementation with Zend Framework and your templates you could write a View Helper.

TinyMCE 网站上有大量示例。为了使用 Zend Framework 和您的模板轻松实现,您可以编写一个视图助手。

回答by Richard Knop

Well, upload the library somewhere to your public folder then in controller action do:

好吧,将库上传到您的公共文件夹,然后在控制器操作中执行以下操作:

$this->view->headScript()->appendFile('/some/path/tiny_mce.js');
$this->view->headScript()->appendFile('/some/path/tiny_mce-init.js');

Where tiny_mce-init.js file could look something like this:

其中 tiny_mce-init.js 文件可能如下所示:

tinyMCE.init({
        theme : "advanced",
        mode : "textareas",
        // styles of the WYSIWYG content
        content_css : "/css/tiny_mce.css",
});

That will turn all textareas to WYSIWYG editors.

这会将所有 textareas 变成 WYSIWYG 编辑器。

回答by Itay Moav -Malimovka

In the following code I created a Decorator I can use with textareas to show the WMD editor (the one used here). https://phpancake.svn.sourceforge.net/svnroot/phpancake/library/lib/decorator/Wmd.php

在下面的代码中,我创建了一个装饰器,我可以与 textareas 一起使用来显示 WMD 编辑器(此处使用的那个)。 https://phpancake.svn.sourceforge.net/svnroot/phpancake/library/lib/decorator/Wmd.php

And in this code I simply extended the Text-area to automaticly use the decorator from above. https://phpancake.svn.sourceforge.net/svnroot/phpancake/library/lib/form/element/WmdTextArea.php

在这段代码中,我只是扩展了文本区域以自动使用上面的装饰器。 https://phpancake.svn.sourceforge.net/svnroot/phpancake/library/lib/form/element/WmdTextArea.php

You can take that and replace with the mark-up of tinymce.
and in the code:

您可以将其替换为 tinymce 的标记。
并在代码中:

$Form=new Zend_Form(....);
$Form->addElement(new lib_form_element_WmdTextArea('my_name'...other text area params);

回答by robjmills

Very similar to Richard Knop's answer i know but i found that it would only work like this for some reason, otherwise the editor was always wrapped round the wrong element:

与我知道的 Richard Knop 的回答非常相似,但我发现由于某种原因它只能像这样工作,否则编辑器总是被错误的元素包裹:

$this->view->headScript()->appendFile("/scripts/vendor/tiny_mce/tiny_mce.js","text/javascript")
                         ->appendFile("/scripts/addtinymce.js","text/javascript");

and in addtinymce.js:

在 addtinymce.js 中:

tinyMCE.init({
    mode : "exact",
    elements : "yourcontent",
    theme : "simple"
});