htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: WYSIWYG Forums: WYSIWYG Editor Discussion:
html area 3.0 want a preview button


 


nascarup
New User

May 17, 2005, 1:13 PM

Post #1 of 4 (90983 views)
Shortcut
html area 3.0 want a preview button Can't Post

Hi,

Can anyone tell me if it is possible to add a preview button to the editor?

If it is possible how to do it?

Jerry


tykuo
Novice

May 18, 2005, 9:38 AM

Post #2 of 4 (90684 views)
Shortcut
Post deleted by tykuo [In reply to]

 


nascarup
New User

May 18, 2005, 7:34 PM

Post #3 of 4 (90667 views)
Shortcut
Re: [tykuo] html area 3.0 want a preview button [In reply to] Can't Post

tykuo,

Thanks for the reply! I did everything you suggested but the last part "put the following code in the swith block"

I found the HTMLArea.prototype.execCommand section but do not know where the switch block is!

I added the code to the "end" of the HTMLArea.prototype.execCommand area but it did not work where i added?

Please define the switch block.

Thank you!




And in the function HTMLArea.prototype.execCommand , put the following code in the switch block,

case "preview":
var win=null;
if (HTMLArea.is_ie) {
{
win=window.open("","",
"toolbar=no,location=no,directories=no,status=no,menubar=no," +
"scrollbars=yes,resizable=yes");
}
} else {
win=window.open("","",
"toolbar=no,menubar=no,personalbar=no," +
"scrollbars=yes,resizable=yes");
}
var html=this.getInnerHTML();
var doc=win.document.open();
win.resizeTo(640,480);
doc.writeln('<html>\n');
doc.writeln(html);
doc.writeln('\n</html>\n');
doc.close();
setTimeout(function(){win.focus();},20);
break;


Please visit my test page for more information. http://nomiss.nttu.edu.tw/htmlarea3/example.html

Hope this helps.

--tykuo



tykuo
Novice

May 18, 2005, 10:47 PM

Post #4 of 4 (90657 views)
Shortcut
Re: [nascarup] html area 3.0 want a preview button [In reply to] Can't Post

Hi,

Code here:

HTMLArea.prototype.execCommand = function(cmdID, UI, param) {
var editor = this; // for nested functions
this.focusEditor();
cmdID = cmdID.toLowerCase();
if (HTMLArea.is_gecko) try { this._doc.execCommand('useCSS', false, true); } catch (e) {};
switch (cmdID) {
case "preview":
var win=null;
if (HTMLArea.is_ie) {
{
win=window.open("","",
"toolbar=no,location=no,directories=no,status=no,menubar=no," +
"scrollbars=yes,resizable=yes");
}
} else {
win=window.open("","",
"toolbar=no,menubar=no,personalbar=no," +
"scrollbars=yes,resizable=yes");
}
var html=this.getInnerHTML();
var doc=win.document.open();
win.resizeTo(640,480);
doc.writeln('<html>\n');
doc.writeln(html);
doc.writeln('\n</html>\n');
doc.close();
setTimeout(function(){win.focus();},20);
break;


case "htmlmode" : this.setMode(); break;
case "hilitecolor":
(HTMLArea.is_ie) && (cmdID = "backcolor");
case "forecolor":
this._popupDialog("select_color.html", function(color) {
if (color) { // selection not canceled
editor._doc.execCommand(cmdID, false, "#" + color);
}
}, HTMLArea._colorToRgb(this._doc.queryCommandValue(cmdID)));
break;
case "createlink":
this._createLink();
break;
case "popupeditor":
// this object will be passed to the newly opened window
HTMLArea._object = this;
if (HTMLArea.is_ie) {
//if (confirm(HTMLArea.I18N.msg["IE-sucks-full-screen"]))
{
window.open(this.popupURL("fullscreen.html"), "ha_fullscreen",
"toolbar=no,location=no,directories=no,status=no,menubar=no," +
"scrollbars=no,resizable=yes,width=640,height=480");
}
} else {
window.open(this.popupURL("fullscreen.html"), "ha_fullscreen",
"toolbar=no,menubar=no,personalbar=no,width=640,height=480," +
"scrollbars=no,resizable=yes");
}
break;
case "undo":
case "redo":
if (this._customUndo)
this[cmdID]();
else
this._doc.execCommand(cmdID, UI, param);
break;
case "inserttable": this._insertTable(); break;
case "insertimage": this._insertImage(); break;
case "about" : this._popupDialog("about.html", null, this); break;
case "showhelp" : window.open(_editor_url + "reference.html", "ha_help"); break;

case "killword": this._wordClean(); break;

case "cut":
case "copy":
case "paste":
try {
this._doc.execCommand(cmdID, UI, param);
if (this.config.killWordOnPaste)
this._wordClean();
} catch (e) {
if (HTMLArea.is_gecko) {
if (typeof HTMLArea.I18N.msg["Moz-Clipboard"] == "undefined") {
HTMLArea.I18N.msg["Moz-Clipboard"] =
"Unprivileged scripts cannot access Cut/Copy/Paste programatically " +
"for security reasons. Click OK to see a technical note at mozilla.org " +
"which shows you how to allow a script to access the clipboard.\n\n" +
"[FIXME: please translate this message in your language definition file.]";
}
if (confirm(HTMLArea.I18N.msg["Moz-Clipboard"]))
window.open("http://mozilla.org/editor/midasdemo/securityprefs.html");
}
}
break;
case "lefttoright":
case "righttoleft":
var dir = (cmdID == "righttoleft") ? "rtl" : "ltr";
var el = this.getParentElement();
while (el && !HTMLArea.isBlockElement(el))
el = el.parentNode;
if (el) {
if (el.style.direction == dir)
el.style.direction = "";
else
el.style.direction = dir;
}
break;
default: try { this._doc.execCommand(cmdID, UI, param); }
catch(e) { if (this.config.debug) { alert(e + "\n\nby execCommand(" + cmdID + ");"); } }
}
this.updateToolbar();
return false;
};



--tykuo

 
 
 


Search for (options)