View Single Post
Old 26 Sep 2011, 06:14 AM   #4
n5bb
Intergalactic Postmaster
 
Join Date: May 2004
Location: Irving, Texas
Posts: 8,930
Arrow Adding HTML editor for Files Edit Contents box

You can use a javascipt tweak to use the Fastmail HTML editor in the Files screen. This will allow you to edit simple websites. Many (but not all) of the editor features can be used. Don't try to use the Save (disk icon) feature -- it will temporarily produce a crash.

To use this feature you will need to change the MIME type of the file from Auto (text/html) to just text/html (and save that change) so that the file will be detected as HTML and cause the editor to switch from plain text to HTML.

The detailed instructions are shown below. Be sure to use the exact folder and file names as shown (including case).
  • In the online Fastmail interface, be sure that the Options>Account Preferences>Display>Custom Styles box is checked. Click Save Settings at the top of the screen after you check this.
  • Click Files at the top of the screen.
  • If you don't have it already, create the top-level folder named exactly (including case): {My Files}/custom-ui
    • To create the new folder, first click {My Files} in the folders list at the left
    • Then open (click) the More actions tool at the top and choose Create subfolder
    • In the new entry box (after called), enter custom-ui then click Do
  • If you don't have them already, create subfolders of that folder named exactly (including case): {My Files}/custom-ui/css and {My Files}/custom-ui/js. The changes below don't use the css folder, but that will be where you place any tweaks.css file you might create.
    • To create these new subfolders, click custom-ui in the folder list at the left
    • Then create the css and js subfolders in a similar manner to the earlier instructions
  • Create the tweaks.js file in the {My Files}/custom-ui/js folder using the following code. I did this by copying/pasting into Windows Notepad on my PC, then saving the file on my PC, then uploading it and changing the name during the upload process. You could also upload any small text file to that Fastmail Files folder, then click the (details) link for that file to edit it, then paste the javascript, then save your edit.
Code:
/* Rich Text editor in Files details screen -- Bill n5bb 2009.10.19  */
window.addEvent('domready', function() {
    var detailsEditor = $$('textarea[name=FFP-Contents]')[0];
    if(detailsEditor && $$('option[selected]')[0].value == "text/html")
    {
        detailsEditor.set('id','FFP-Contents');
        new Asset.javascript('https://www.fastmail.fm/3pp/fck-latest/fckeditor.js');
        setTimeout(function() {
            var oFCKeditor = new FCKeditor('FFP-Contents') ;
            oFCKeditor.BasePath = "/3pp/fck-latest/";
            oFCKeditor.Height   = document.documentElement.clientHeight-20; //Set the height to the initial window size - 20 for the scrollbar.
            oFCKeditor.ReplaceTextarea();
        }, 200);
    }
});
Bill

Last edited by n5bb : 26 Sep 2011 at 06:19 AM.
n5bb is offline   Reply With Quote