зеркало из https://github.com/mozilla/pjs.git
Bug 312930 - rich text editor doesn't have context menu items for cut/copy/paste/spellcheck, r=brettw
This commit is contained in:
Родитель
9aed286cff
Коммит
344e9ed310
|
@ -4249,6 +4249,7 @@ function nsContextMenu( xulMenu ) {
|
|||
this.isContentSelected = false;
|
||||
this.inDirList = false;
|
||||
this.shouldDisplay = true;
|
||||
this.isDesignMode = false;
|
||||
|
||||
// Initialize new menu.
|
||||
this.initMenu( xulMenu );
|
||||
|
@ -4437,7 +4438,7 @@ nsContextMenu.prototype = {
|
|||
this.showItem( "context-paste", this.onTextInput );
|
||||
this.showItem( "context-delete", this.onTextInput );
|
||||
this.showItem( "context-sep-paste", this.onTextInput );
|
||||
this.showItem( "context-selectall", !( this.onLink || this.onImage ) );
|
||||
this.showItem( "context-selectall", !( this.onLink || this.onImage ) || this.isDesignMode );
|
||||
this.showItem( "context-sep-selectall", this.isContentSelected );
|
||||
|
||||
// XXX dr
|
||||
|
@ -4524,14 +4525,14 @@ nsContextMenu.prototype = {
|
|||
this.onTextInput = this.isTargetATextBox(this.target);
|
||||
// allow spellchecking UI on all writable text boxes except passwords
|
||||
if (this.onTextInput && ! this.target.readOnly && this.target.type != "password") {
|
||||
InlineSpellCheckerUI.init(this.target);
|
||||
InlineSpellCheckerUI.init(this.target.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor);
|
||||
InlineSpellCheckerUI.initFromEvent(rangeParent, rangeOffset);
|
||||
}
|
||||
this.onKeywordField = this.isTargetAKeywordField(this.target);
|
||||
} else if ( this.target instanceof HTMLTextAreaElement ) {
|
||||
this.onTextInput = true;
|
||||
if (! this.target.readOnly) {
|
||||
InlineSpellCheckerUI.init(this.target);
|
||||
InlineSpellCheckerUI.init(this.target.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor);
|
||||
InlineSpellCheckerUI.initFromEvent(rangeParent, rangeOffset);
|
||||
}
|
||||
} else if ( this.target instanceof HTMLHtmlElement ) {
|
||||
|
@ -4669,6 +4670,30 @@ nsContextMenu.prototype = {
|
|||
this.inFrame = true;
|
||||
}
|
||||
|
||||
// if the document is editable, show context menu like in text inputs
|
||||
var win = this.target.ownerDocument.defaultView;
|
||||
if (win) {
|
||||
var editingSession = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIEditingSession);
|
||||
if (editingSession.windowIsEditable(win)) {
|
||||
this.onTextInput = true;
|
||||
this.onKeywordField = false;
|
||||
this.onImage = false;
|
||||
this.onLoadedImage = false;
|
||||
this.onMetaDataItem = false;
|
||||
this.onMathML = false;
|
||||
this.inFrame = false;
|
||||
this.hasBGImage = false;
|
||||
this.isDesignMode = true;
|
||||
InlineSpellCheckerUI.init(editingSession.getEditorForWindow(win));
|
||||
var canSpell = InlineSpellCheckerUI.canSpellCheck;
|
||||
InlineSpellCheckerUI.initFromEvent(rangeParent, rangeOffset);
|
||||
this.showItem("spell-check-enabled", canSpell);
|
||||
this.showItem("spell-separator", canSpell);
|
||||
}
|
||||
}
|
||||
},
|
||||
// Returns the computed style attribute for the given element.
|
||||
getComputedStyle: function( elem, prop ) {
|
||||
|
|
|
@ -48,11 +48,11 @@ var InlineSpellCheckerUI = {
|
|||
mLanguageBundle: null, // language names
|
||||
mRegionBundle: null, // region names
|
||||
|
||||
// Call this function to initialize for a given edit element
|
||||
init: function(inputElt)
|
||||
// Call this function to initialize for a given editor
|
||||
init: function(aEditor)
|
||||
{
|
||||
this.uninit();
|
||||
this.mEditor = inputElt.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor;
|
||||
this.mEditor = aEditor;
|
||||
try {
|
||||
this.mInlineSpellChecker = this.mEditor.getInlineSpellChecker(true);
|
||||
// note: this might have been NULL if there is no chance we can spellcheck
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
loader.loadSubScript("chrome://global/content/inlineSpellCheckUI.js", this);
|
||||
// watch out - that could have failed
|
||||
if (this.InlineSpellCheckerUI)
|
||||
this.InlineSpellCheckerUI.init(this.inputField);
|
||||
this.InlineSpellCheckerUI.init(this.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor);
|
||||
}
|
||||
return this.InlineSpellCheckerUI;
|
||||
]]></getter>
|
||||
|
|
Загрузка…
Ссылка в новой задаче