Auto Save not working

Aug 17, 2012 at 12:24 PM

Hi guys, I recently did the changes shown here (at the bottom) in order to implement the spell checker.

 

The problem is that it doesn't work at all. I can type 500 words, hit back, and loose everything.

 

Is there something wrong in the coding shown on that page?

Aug 18, 2012 at 12:20 PM
Edited Aug 18, 2012 at 12:35 PM

Hi, 

I'm still using a version of that solution (well up until now), it does work, but requires quite a number of changes to tinyMCE.ascx and Add_entry.aspx, it's quite bitty.

In the modified version, code is added to trigger auto save on blur (whenever the cursor leaves the editor for any reason), since the timed auto save results in post backs refreshing the content and clearing the spell check.

Your question on this prompted me to revisit this, there is a single line of code that can be added to tinyMCE.init that enables built in browser spell checking, which doesn't work in IE, but that's OK since IE spell checker is available by default anyway. 

I can't remember if this was in earlier versions of BE, but it's there by default in more recent versions.

gecko_spellcheck : true,

 

 

 


Aug 18, 2012 at 5:47 PM
Andy_McKay wrote:

Hi, 

I'm still using a version of that solution (well up until now), it does work, but requires quite a number of changes to tinyMCE.ascx and Add_entry.aspx, it's quite bitty.

In the modified version, code is added to trigger auto save on blur (whenever the cursor leaves the editor for any reason), since the timed auto save results in post backs refreshing the content and clearing the spell check.

Your question on this prompted me to revisit this, there is a single line of code that can be added to tinyMCE.init that enables built in browser spell checking, which doesn't work in IE, but that's OK since IE spell checker is available by default anyway. 

I can't remember if this was in earlier versions of BE, but it's there by default in more recent versions.

gecko_spellcheck : true,

 

 

 


Will try this and get back with the changes.

Aug 18, 2012 at 7:32 PM

Just for reference, here's the code from BE 2.6 tinyMCE.ascx (might save you a download if you don't have it).

I tested this in Chrome, Safari, Opera and Firefox, only caveat is you need to hold the ctrl key when right clicking underlined words, otherwise you get the tinyMCE menu.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="tinyMCE.ascx.cs" Inherits="Admin.TinyMce" %>
<%@ Import Namespace="BlogEngine.Core" %>

<script type="text/javascript" src="<%=Utils.RelativeWebRoot %>editors/tiny_mce_3_4_3_1/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode: "exact",
		elements : "<%=txtContent.ClientID %>",
		theme: "advanced",
		plugins: "inlinepopups,fullscreen,contextmenu,emotions,table,iespell,advlink,insertcode",
		convert_urls: false,
		
	  // Theme options
		theme_advanced_buttons1: "fullscreen,code,|,cut,copy,paste,pastetext,pasteword,|,undo,redo,|,bold,italic,underline,strikethrough,|,blockquote,sub,sup,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,outdent,indent",
		theme_advanced_buttons2: "iespell,link,unlink,removeformat,cleanup,charmap,emotions,|,formatselect,fontselect,fontsizeselect,|,forecolor,backcolor,insertcode",
        theme_advanced_buttons3: "",
		theme_advanced_toolbar_location: "top",
		theme_advanced_toolbar_align: "left",
		theme_advanced_statusbar_location: "bottom",
		theme_advanced_resizing: true,
        theme_advanced_resize_horizontal : false,
        tab_focus: ":prev,:next",        
		gecko_spellcheck : true,
        
        //Character count        
        theme_advanced_path : false,
        setup : function(ed) {
            ed.onKeyUp.add(function (ed, e) {  
                
                var strip = (tinyMCE.activeEditor.getContent()).replace(/(<([^>]+)>)/ig,"");
                var text = strip.split(' ').length + " Words, " +  strip.length + " Characters"
                tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text);   
            });
        },
        auto_focus: "<%=txtContent.ClientID %>"
	});
</script>

<asp:TextBox runat="Server" ID="txtContent" CssClass="post" Width="100%" Height="250px" TextMode="MultiLine" />

Aug 21, 2012 at 7:07 PM

Hey guys, I did some more research on the topic and saw how the coding works etc.

 

Basically, there are a couple of things you need to know about:

  • The autosave uses sessionstate and "inproc" save mode
  • This means that if you close the browser, the autosave is lost
  • It also means that if the server recylces its memory, your autosave will also be lost
  • If you don't send requests to the website for more than 30 minutes, your autosave will also be lost

 

To increase the time you have until the autosave is lost, you can add this to your web.config:

    <sessionState mode="InProc" cookieless="false" timeout="60"/>

Remember, if you want to close your browser make sure you save the post and untick published so that it is saved in a more permanent location.

 

Hope this helps someone.