需要自动保存TinyMCE的自动保存、TinyMCE

2023-09-10 20:15:23 作者:菊花的刺

我要寻找一些帮助自动保存TinyMCE的。我想在微小的内容保存到其各自的textarea的内容后,已更新。所以,当我做一个AJAX调用的内容是textarea的准备发布。

目前我有code这一点,但它仅更新文本区域,当你preSS在狭小的一个按钮(如粗体,斜体,下划线等)。我也有,我发现了code的连接。任何帮助将是AP preciated。

  $('。AjaxEdit textarea.tiny)。TinyMCE的({

    //其他初始化选项

    //需要这个功能,以节省微小的数据Ajax调用之前
    //http://www.webmasterkitchen.com/article/tinymce-ajax-form-submission/
    设置:功能(ED){
    ed.onChange.add(函数(ED){
    tinyMCE.triggerSave();
    });
    }
});
 

解决方案

你是最好的办法是让它拉直接从TinyMCE的或triggerSave内容仅仅是AJAX调用之前,而不是试图不断有调整AJAX调用textarea的与编辑内容同步。连载和过滤整个文档,因此它可以被存储在每一个变化是一个重要的性能损失。

TinyMCE实现word图片自动转存

如果您的真正的需要保持同步textarea的,你必须DOM修改监听器添加到了TinyMCE在创建的用于存储内容的iframe的文档 - 您可以用检索getDoc()函数(见的http://tinymce.ephox.com/documentation/api/index.html#class_tinymce.Editor.html-getDoc).你将有重大的性能问题,在这里虽然。

问候,

阿德里安·萨顿 http://tinymce.ephox.com

I am looking for some help autosaving tinyMCE. I want to save the content within tiny into its respective textarea after content has been updated. So that when I make an ajax call the content is in the textarea ready to be posted.

Currently I have this little bit of code but it only updates the text area when you press a button in tiny (like bold, italics, underline, etc). I also have the link where I found the code. Any help would be appreciated.

$('.AjaxEdit textarea.tiny').tinymce({

    //other init options

    //need this function to save tiny data before Ajax call
    //http://www.webmasterkitchen.com/article/tinymce-ajax-form-submission/
    setup : function(ed) {
    	ed.onChange.add(function(ed) {
    		tinyMCE.triggerSave();
    	});
    }
});

解决方案

You're best bet is to adjust your AJAX call so it pulls the content straight from TinyMCE or triggerSave just before the AJAX call rather than trying to constantly have the textarea in sync with the editor content. Serialising and filtering the entire document so it can be stored on every change is a major performance hit.

If you really need to keep the textarea in sync, you'd have to add DOM modification listeners to the document in the iframe that TinyMCE creates to store the content - you can retrieve it with the getDoc() function (see http://tinymce.ephox.com/documentation/api/index.html#class_tinymce.Editor.html-getDoc). You are going to have major performance problems here though.

Regards,

Adrian Sutton http://tinymce.ephox.com