you may try the function used in the composer to change insert inline style : in editor.js, EditorSetTextProperty(property,attribute,value).
It produce a "span" block with style "property" set to "value". Only problem is that it seems to work only on selected text, i.e. you can not choose to change font size, then write a text whose size would be changed.
Below is the needed code extracted from editor.js & associated files. You may just take it and modify i to fit your needs.
---------
function GetCurrentEditor( )
{
var editor;
try {
var editorElement = document.getElementById("YOUR_IFRAME_ID") ;
editor = editorElement.getEditor(editorElement.contentWindow);// Do QIs now so editor users won't have to figure out which interface to use
// Using "instanceof" does the QI for us.
editor instanceof Components.interfaces.nsIPlaintextEditor;
editor instanceof Components.interfaces.nsIHTMLEditor;
} catch (e) { dump (e)+"\n"; }
return editor; }
function EditorSetTextProperty(property, attribute, value)
{
try {
if (!gAtomService) GetAtomService();
var propAtom = gAtomService.getAtom(property);GetCurrentEditor().setInlineProperty(propAtom, attribute, value);
if ("gContentWindow" in window) window.gContentWindow.focus();
} catch(e) {}
}
var gAtomService;
function GetAtomService()
{
gAtomService = Components.classes["@mozilla.org/atom-service;1"].getService(Components.interfaces.nsIAtomService);
}
Daniel Kirsch wrote:
Hi,
I use execCommand("fontsize", false, "150%") to set font size in an editable Iframe within my XUL app. This results in a HTML string using the deprecated font element: <font size="150"> instead of something like <span style="font-size:150%">
How can I change that?
Well, I could replace the font element in the resulting html string, but that will lead to a couple of other problems when editing the same element again.
Any ideas are welcome.
Thanks Daniel
