rem: source = gSourceTextEditor.outputToString(kTextMimeType, 0); 
add: source = gSourceTextEditor.outputToString(kTextMimeType, 1024); 
context: function SetEditMode(mode){  if (!IsHTMLEditor())    return;  var bodyElement = GetBodyElement();  if (!bodyElement)  {    dump("SetEditMode: We don't have a body node!\n");    return;  }  // must have editor if here!  var editor = GetCurrentEditor();  // Switch the UI mode before inserting contents  //   so user can't type in source window while new window is being filled  var previousMode = gEditorDisplayMode;  if (!SetDisplayMode(mode))    return;  if (mode == kDisplayModeSource)  {    // Display the DOCTYPE as a non-editable string above edit area    var domdoc;    try { domdoc = editor.document; } catch (e) { dump( e + "\n");}    if (domdoc)    {      var doctypeNode = document.getElementById("doctype-text");      var dt = domdoc.doctype;      if (doctypeNode)      {        if (dt)        {          doctypeNode.collapsed = false;          var doctypeText = "<!DOCTYPE " + domdoc.doctype.name;          if (dt.publicId)            doctypeText += " PUBLIC \"" + domdoc.doctype.publicId;          if (dt.systemId)            doctypeText += " "+"\"" + dt.systemId;          doctypeText += "\">"          doctypeNode.setAttribute("value", doctypeText);        }        else          doctypeNode.collapsed = true;      }    }    // Get the entire document's source string    var flags = (editor.documentCharacterSet == "ISO-8859-1")      ? 32768  // OutputEncodeLatin1Entities      : 16384; // OutputEncodeBasicEntities    try {       var encodeEntity = gPrefs.getCharPref("editor.encode_entity");      switch (encodeEntity) {        case "basic"  : flags = 16384; break; // OutputEncodeBasicEntities        case "latin1" : flags = 32768; break; // OutputEncodeLatin1Entities        case "html"   : flags = 65536; break; // OutputEncodeHTMLEntities        case "none"   : flags = 0;     break;      }    } catch (e) { }    try {       var prettyPrint = gPrefs.getBoolPref("editor.prettyprint");      if (prettyPrint)        flags |= 2; // OutputFormatted    } catch (e) {}    var source = editor.outputToString(kHTMLMimeType, flags);    var start = source.search(/<html/i);    if (start == -1) start = 0;    gSourceTextEditor.insertText(source.slice(start));    gSourceTextEditor.resetModificationCount();    gSourceTextEditor.addDocumentStateListener(gSourceTextListener);    gSourceTextEditor.enableUndo(true);    gSourceContentWindow.commandManager.addCommandObserver(gSourceTextObserver, "cmd_undo");    gSourceContentWindow.contentWindow.focus();    goDoCommand("cmd_moveTop");  }  else if (previousMode == kDisplayModeSource)  {    // Only rebuild document if a change was made in source window    if (IsHTMLSourceChanged())    {      // Reduce the undo count so we don't use too much memory      //   during multiple uses of source window       //   (reinserting entire doc caches all nodes)      try {        editor.transactionManager.maxTransactionCount = 1;      } catch (e) {}      editor.beginTransaction();      try {        // We are comming from edit source mode,        //   so transfer that back into the document        source = gSourceTextEditor.outputToString(kTextMimeType, 0);        editor.rebuildDocumentFromSource(source);        // Get the text for the <title> from the newly-parsed document        // (must do this for proper conversion of "escaped" characters)        var title = "";        var titlenodelist = editor.document.getElementsByTagName("title");        if (titlenodelist)        {          var titleNode = titlenodelist.item(0);          if (titleNode && titleNode.firstChild && titleNode.firstChild.data)            title = titleNode.firstChild.data;        }        if (editor.document.title != title)          SetDocumentTitle(title);      } catch (ex) {        dump(ex);      }      editor.endTransaction();      // Restore unlimited undo count      try {        editor.transactionManager.maxTransactionCount = -1;      } catch (e) {}    }    // Clear out the string buffers    gSourceContentWindow.commandManager.removeCommandObserver(gSourceTextObserver, "cmd_undo");    gSourceTextEditor.removeDocumentStateListener(gSourceTextListener);    gSourceTextEditor.enableUndo(false);    gSourceTextEditor.selectAll();    gSourceTextEditor.deleteSelection(gSourceTextEditor.eNone);    gSourceTextEditor.resetModificationCount();    gContentWindow.focus();  }}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/0fa5242f208231dc40d6503d435f92fbe0fdb397/editor.js/buggy/editor/ui/composer/content/editor.js