马根托。正确插入所见即所得

发布于 2024-12-27 08:57:53 字数 3042 浏览 2 评论 0原文

我想要的是将 TinyMce wysiwyg 编辑器插入前端。目前我所拥有的是:在首页上通过按钮单击ajax请求使用tinymce.init脚本加载textarea。 tiny_mce.js 文件被加载到 head 中。当我打开可编辑文本区域时,我可以写一些东西,但是我在 html 结构中的内容类似于

false > 。假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假>假等等。

更新1

问题是:我需要在前端使用所见即所得。我已将tiny_mce.js 添加到前端,并运行init。但不知何故它无法正常工作。按钮不起作用,如果我输入文本,则不会创建 html。所以我总是在 html 节点中得到 false false false 。

更新2 我当前的tinymce配置如下。我能够显示所见即所得编辑器窗口。此外,我可以得到上传窗口,无需magento 的文件选择。

    <script language="javascript" type="text/javascript">
    //NB: the single quotes for the doctype param must be backslashed; wiki format is removing them.
    // Event.observe(window, 'load', function() {
        tinyMCE.init({
            mode : "exact",
            theme : "advanced",
            strict_loading_mode : true, 
            elements : "block_content",
            plugins : "preview,media,iespell,insertdatetime,advimage,advlink,emotions,table,save,advhr,style,layer,inlinepopups,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",        
            theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,|,visualchars,nonbreaking",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_path_location : "bottom",        
            theme_advanced_resize_horizontal : "true",
            theme_advanced_resizing : "true",
            apply_source_formatting : "true",
            convert_urls : "false",
            doctype : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',

            force_p_newlines : 'false',
            force_br_newlines : 'true',
            forced_root_block : 'false',             //btw, I still get <p> tags if this is false
            remove_trailing_nbsp : 'false',
            verify_html : false,
            extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],tr"        
        });  
    // });

    </script>

What I want is to insert TinyMce wysiwyg editor onto frontend. Currently what I have is: on frontpage by button click ajax request loads textarea with tinymce.init script. tiny_mce.js file is loaded into head. When I open editable textarea I am able to write something, BUT what I in html structure is something like

false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false > false And so on and so forth.

UPDATE 1

The problem is: I need wysiwyg on frontend. I'v added tiny_mce.js to frontend, and run init. But it doesn't work properly somewhy. Buttons don't work, and if I enter the text, no html created. So I always get false false false in html nodes.

UPDATE 2
My current tinymce config is following. I am able to display WYSIWYG editor window. Moreover I can get uploader window, without magento's file selection.

    <script language="javascript" type="text/javascript">
    //NB: the single quotes for the doctype param must be backslashed; wiki format is removing them.
    // Event.observe(window, 'load', function() {
        tinyMCE.init({
            mode : "exact",
            theme : "advanced",
            strict_loading_mode : true, 
            elements : "block_content",
            plugins : "preview,media,iespell,insertdatetime,advimage,advlink,emotions,table,save,advhr,style,layer,inlinepopups,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",        
            theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,|,visualchars,nonbreaking",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_path_location : "bottom",        
            theme_advanced_resize_horizontal : "true",
            theme_advanced_resizing : "true",
            apply_source_formatting : "true",
            convert_urls : "false",
            doctype : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',

            force_p_newlines : 'false',
            force_br_newlines : 'true',
            forced_root_block : 'false',             //btw, I still get <p> tags if this is false
            remove_trailing_nbsp : 'false',
            verify_html : false,
            extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],tr"        
        });  
    // });

    </script>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟雨扶苏 2025-01-03 08:57:53

好的。我想我发现了 false 的问题。

forced_root_block : 'false'

告诉tinyMce 将元素包装为 false。

OK. I think I Found the problem with false.

forced_root_block : 'false'

tells tinyMce to wrap elements into false.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文