mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 15:51:37 +00:00
Moved text properties utility methods as part of image border bug 142093, r=brade, sr=dveditz. Editor.js also has fix for wrong 'Find' component causing missing menuitems, b=142093, r=akkana, sr=alecf
This commit is contained in:
parent
4849cd5eee
commit
462beec449
@ -709,48 +709,6 @@ function updateCharsetPopupMenu(menuPopup)
|
||||
|
||||
// --------------------------- Text style ---------------------------
|
||||
|
||||
var gAtomService;
|
||||
function GetAtomService()
|
||||
{
|
||||
gAtomService = Components.classes["@mozilla.org/atom-service;1"].getService(Components.interfaces.nsIAtomService);
|
||||
}
|
||||
|
||||
function EditorGetTextProperty(property, attribute, value, firstHas, anyHas, allHas)
|
||||
{
|
||||
if (!gIsHTMLEditor) return;
|
||||
try {
|
||||
if (!gAtomService) GetAtomService();
|
||||
var propAtom = gAtomService.getAtom(property);
|
||||
gEditor.getInlineProperty(propAtom, attribute, value,
|
||||
firstHas, anyHas, allHas);
|
||||
}
|
||||
catch(e) {}
|
||||
}
|
||||
|
||||
function EditorSetTextProperty(property, attribute, value)
|
||||
{
|
||||
if (!gIsHTMLEditor) return;
|
||||
try {
|
||||
if (!gAtomService) GetAtomService();
|
||||
var propAtom = gAtomService.getAtom(property);
|
||||
gEditor.setInlineProperty(propAtom, attribute, value);
|
||||
gContentWindow.focus();
|
||||
}
|
||||
catch(e) {}
|
||||
}
|
||||
|
||||
function EditorRemoveTextProperty(property, attribute)
|
||||
{
|
||||
if (!gIsHTMLEditor) return;
|
||||
try {
|
||||
if (!gAtomService) GetAtomService();
|
||||
var propAtom = gAtomService.getAtom(property);
|
||||
gEditor.removeInlineProperty(propAtom, attribute);
|
||||
gContentWindow.focus();
|
||||
}
|
||||
catch(e) {}
|
||||
}
|
||||
|
||||
function onParagraphFormatChange(paraMenuList, commandID)
|
||||
{
|
||||
if (!paraMenuList)
|
||||
@ -2475,7 +2433,8 @@ function IsSpellCheckerInstalled()
|
||||
//-----------------------------------------------------------------------------------
|
||||
function IsFindInstalled()
|
||||
{
|
||||
return "@mozilla.org/appshell/component/find;1" in Components.classes;
|
||||
return "@mozilla.org/embedcomp/rangefind;1" in Components.classes
|
||||
&& "@mozilla.org/find/find_service;1" in Components.classes;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
@ -176,10 +176,84 @@ function ConvertToCDATAString(string)
|
||||
|
||||
function GetSelectionAsText()
|
||||
{
|
||||
return editorShell.GetContentsAs("text/plain", 1); // OutputSelectionOnly
|
||||
try {
|
||||
return GetCurrentEditor().outputToString("text/plain", 1); // OutputSelectionOnly
|
||||
} catch (e) {}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/************* General editing command utilities ***************/
|
||||
|
||||
function GetCurrentEditor()
|
||||
{
|
||||
// Get the actual active editor
|
||||
//XXX Temporarily use a global until new embedding access is finished
|
||||
if ("gEditor" in window)
|
||||
return gEditor;
|
||||
|
||||
// For dialogs: Search up parent chain to find top window with editor
|
||||
var editor = null;
|
||||
var parentWindow = window.opener;
|
||||
try {
|
||||
while ("GetCurrentEditor" in parentWindow)
|
||||
{
|
||||
editor = parentWindow.GetCurrentEditor();
|
||||
if (editor)
|
||||
return editor;
|
||||
|
||||
parentWindow = parentWindow.opener;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var gAtomService;
|
||||
function GetAtomService()
|
||||
{
|
||||
gAtomService = Components.classes["@mozilla.org/atom-service;1"].getService(Components.interfaces.nsIAtomService);
|
||||
}
|
||||
|
||||
function EditorGetTextProperty(property, attribute, value, firstHas, anyHas, allHas)
|
||||
{
|
||||
try {
|
||||
if (!gAtomService) GetAtomService();
|
||||
var propAtom = gAtomService.getAtom(property);
|
||||
|
||||
GetCurrentEditor().getInlineProperty(propAtom, attribute, value,
|
||||
firstHas, anyHas, allHas);
|
||||
}
|
||||
catch(e) {}
|
||||
}
|
||||
|
||||
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) {}
|
||||
}
|
||||
|
||||
function EditorRemoveTextProperty(property, attribute)
|
||||
{
|
||||
try {
|
||||
if (!gAtomService) GetAtomService();
|
||||
var propAtom = gAtomService.getAtom(property);
|
||||
|
||||
GetCurrentEditor().removeInlineProperty(propAtom, attribute);
|
||||
if ("gContentWindow" in window)
|
||||
window.gContentWindow.focus();
|
||||
}
|
||||
catch(e) {}
|
||||
}
|
||||
|
||||
/************* Element enbabling/disabling ***************/
|
||||
|
||||
// this function takes an elementID and a flag
|
||||
|
Loading…
x
Reference in New Issue
Block a user