зеркало из https://github.com/mozilla/gecko-dev.git
22655: add API to allow specifying charset when inserting/quoting html. r=rhp
16015: Add API and implementation for delete-to-beginning (^U). r=slamm,rhp 490: Insert formatting newlines when inserting new nodes. r=rhp
This commit is contained in:
Родитель
f3e31a0566
Коммит
0b23aa43ac
|
@ -135,6 +135,9 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
|||
result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// Try to insert formatting whitespace for the new node:
|
||||
mEditor->InsertFormattingForNode(mNewNode);
|
||||
|
||||
// only set selection to insertion point if editor gives permission
|
||||
PRBool bAdjustSelection;
|
||||
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
|
||||
|
|
|
@ -98,6 +98,8 @@ nsEditorController::nsEditorController()
|
|||
mDeleteCharForward = "cmd_deleteCharForward";
|
||||
mDeleteWordBackward = "cmd_deleteWordBackward";
|
||||
mDeleteWordForward = "cmd_deleteWordForward";
|
||||
|
||||
mDeleteToBeginningOfLine = "cmd_deleteToBeginningOfLine";
|
||||
mDeleteToEndOfLine = "cmd_deleteToEndOfLine";
|
||||
}
|
||||
|
||||
|
@ -218,6 +220,7 @@ NS_IMETHODIMP nsEditorController::SupportsCommand(const PRUnichar *aCommand, PRB
|
|||
(PR_TRUE==mDeleteCharBackward.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteWordForward.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteWordBackward.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteToBeginningOfLine.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteToEndOfLine.Equals(aCommand)) ||
|
||||
(PR_TRUE==mSelectAllString.Equals(aCommand)) ||
|
||||
(PR_TRUE==mBeginLineString.Equals(aCommand)) ||
|
||||
|
@ -319,6 +322,12 @@ NS_IMETHODIMP nsEditorController::DoCommand(const PRUnichar *aCommand)
|
|||
NS_ENSURE_SUCCESS(editor->DeleteSelection(nsIEditor::ePreviousWord),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
else if (PR_TRUE==mDeleteToBeginningOfLine.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->DeleteSelection(nsIEditor::eToBeginningOfLine),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mDeleteToEndOfLine.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->DeleteSelection(nsIEditor::eToEndOfLine),
|
||||
|
|
|
@ -116,6 +116,7 @@ protected:
|
|||
nsString mDeleteCharForward;
|
||||
nsString mDeleteWordBackward;
|
||||
nsString mDeleteWordForward;
|
||||
nsString mDeleteToBeginningOfLine;
|
||||
nsString mDeleteToEndOfLine;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -348,7 +348,6 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl)
|
|||
if (NS_SUCCEEDED(rv) && controllers)
|
||||
{
|
||||
nsCOMPtr<nsIEditorController> ieditcontroller = do_QueryInterface(controller);
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
|
||||
ieditcontroller->SetEditor(editor);//weak link
|
||||
|
||||
rv = controllers->InsertControllerAt(0,controller);
|
||||
|
@ -698,6 +697,16 @@ nsEditorShell::DeleteToEndOfLine()
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::DeleteToBeginningOfLine()
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
|
||||
if (!editor) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsresult rv = editor->DeleteSelection(nsIEditor::eToBeginningOfLine);
|
||||
ScrollSelectionIntoView();
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Generic attribute setting and removal
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::SetAttribute(nsIDOMElement *element, const PRUnichar *attr, const PRUnichar *value)
|
||||
|
@ -1975,7 +1984,7 @@ nsEditorShell::PasteAsCitedQuotation(const PRUnichar *cite)
|
|||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
err = mailEditor->PasteAsQuotation();
|
||||
err = mailEditor->PasteAsCitedQuotation(aCiteString);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2015,22 +2024,28 @@ nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText,
|
|||
NS_IMETHODIMP
|
||||
nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText,
|
||||
const PRUnichar *cite,
|
||||
const PRUnichar *charset,
|
||||
nsIDOMNode** aNodeInserted)
|
||||
{
|
||||
nsresult err = NS_NOINTERFACE;
|
||||
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (!mailEditor)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
nsAutoString aQuotedText(quotedText);
|
||||
nsAutoString aCiteString(cite);
|
||||
nsAutoString aCharset(charset);
|
||||
|
||||
switch (mEditorType)
|
||||
{
|
||||
case ePlainTextEditorType:
|
||||
err = mailEditor->InsertAsQuotation(aQuotedText, aNodeInserted);
|
||||
break;
|
||||
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
err = mailEditor->InsertAsQuotation(aQuotedText, aNodeInserted);
|
||||
}
|
||||
err = mailEditor->InsertAsCitedQuotation(aQuotedText, aCiteString,
|
||||
aCharset, aNodeInserted);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2167,6 +2182,33 @@ nsEditorShell::InsertSource(const PRUnichar *aSourceToInsert)
|
|||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::InsertSourceWithCharset(const PRUnichar *aSourceToInsert,
|
||||
const PRUnichar *aCharset)
|
||||
{
|
||||
nsresult err = NS_NOINTERFACE;
|
||||
|
||||
nsAutoString sourceToInsert(aSourceToInsert);
|
||||
nsAutoString charset(aCharset);
|
||||
|
||||
switch (mEditorType)
|
||||
{
|
||||
case ePlainTextEditorType:
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
err = htmlEditor->InsertHTMLWithCharset(sourceToInsert, charset);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
err = NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::InsertBreak()
|
||||
{
|
||||
|
|
|
@ -1295,7 +1295,7 @@ NS_IMETHODIMP nsHTMLEditor::DeleteSelection(nsIEditor::EDirection aAction)
|
|||
// This can't happen inside selection batching --
|
||||
// selection refuses to move if batching is on.
|
||||
if (aAction == eNextWord || aAction == ePreviousWord
|
||||
|| aAction == eToEndOfLine)
|
||||
|| aAction == eToBeginningOfLine || aAction == eToEndOfLine)
|
||||
{
|
||||
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
|
||||
|
@ -1316,6 +1316,10 @@ NS_IMETHODIMP nsHTMLEditor::DeleteSelection(nsIEditor::EDirection aAction)
|
|||
result = selCont->WordMove(PR_FALSE, PR_TRUE);
|
||||
aAction = eNone;
|
||||
break;
|
||||
case eToBeginningOfLine:
|
||||
result = selCont->IntraLineMove(PR_FALSE, PR_TRUE);
|
||||
aAction = eNone;
|
||||
break;
|
||||
case eToEndOfLine:
|
||||
result = selCont->IntraLineMove(PR_TRUE, PR_TRUE);
|
||||
aAction = eNone;
|
||||
|
@ -1400,6 +1404,13 @@ NS_IMETHODIMP nsHTMLEditor::InsertText(const nsString& aStringToInsert)
|
|||
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
|
||||
{
|
||||
nsAutoString charset;
|
||||
return InsertHTMLWithCharset(aInputString, charset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString,
|
||||
const nsString& aCharset)
|
||||
{
|
||||
ForceCompositionEnd();
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
|
@ -3747,7 +3758,8 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
|
|||
return InsertAsPlaintextQuotation(aQuotedText, aNodeInserted);
|
||||
|
||||
nsAutoString citation ("");
|
||||
return InsertAsCitedQuotation(aQuotedText, citation, aNodeInserted);
|
||||
nsAutoString charset ("");
|
||||
return InsertAsCitedQuotation(aQuotedText, citation, charset, aNodeInserted);
|
||||
}
|
||||
|
||||
// text insert.
|
||||
|
@ -3828,6 +3840,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
|
|||
NS_IMETHODIMP
|
||||
nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation,
|
||||
const nsString& aCharset,
|
||||
nsIDOMNode **aNodeInserted)
|
||||
{
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
|
@ -3856,7 +3869,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
|
|||
selection->Collapse(newNode, 0);
|
||||
}
|
||||
|
||||
res = InsertHTML(aQuotedText);
|
||||
res = InsertHTMLWithCharset(aQuotedText, aCharset);
|
||||
if (aNodeInserted)
|
||||
{
|
||||
if (NS_SUCCEEDED(res))
|
||||
|
|
|
@ -109,6 +109,8 @@ public:
|
|||
NS_IMETHOD InsertBreak();
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
NS_IMETHOD InsertHTML(const nsString &aInputString);
|
||||
NS_IMETHOD InsertHTMLWithCharset(const nsString& aInputString,
|
||||
const nsString& aCharset);
|
||||
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
|
||||
|
||||
NS_IMETHOD DeleteSelection(EDirection aAction);
|
||||
|
@ -161,7 +163,10 @@ public:
|
|||
NS_IMETHOD PasteAsQuotation();
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted);
|
||||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, nsIDOMNode **aNodeInserted);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation,
|
||||
const nsString& aCharset,
|
||||
nsIDOMNode **aNodeInserted);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
|
||||
|
|
|
@ -443,6 +443,7 @@ nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
|
|||
NS_IMETHODIMP
|
||||
nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation,
|
||||
const nsString& aCharset,
|
||||
nsIDOMNode **aNodeInserted)
|
||||
{
|
||||
nsAutoHTMLEditorLogLock logLock(this);
|
||||
|
@ -459,7 +460,7 @@ nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
|
|||
}
|
||||
|
||||
return nsHTMLEditor::InsertAsCitedQuotation(aQuotedText, aCitation,
|
||||
aNodeInserted);
|
||||
aCharset, aNodeInserted);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
|
||||
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, nsIDOMNode** aNodeInserted);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, const nsString& aCharset, nsIDOMNode** aNodeInserted);
|
||||
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
|
||||
|
|
|
@ -348,7 +348,6 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl)
|
|||
if (NS_SUCCEEDED(rv) && controllers)
|
||||
{
|
||||
nsCOMPtr<nsIEditorController> ieditcontroller = do_QueryInterface(controller);
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
|
||||
ieditcontroller->SetEditor(editor);//weak link
|
||||
|
||||
rv = controllers->InsertControllerAt(0,controller);
|
||||
|
@ -698,6 +697,16 @@ nsEditorShell::DeleteToEndOfLine()
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::DeleteToBeginningOfLine()
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
|
||||
if (!editor) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsresult rv = editor->DeleteSelection(nsIEditor::eToBeginningOfLine);
|
||||
ScrollSelectionIntoView();
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Generic attribute setting and removal
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::SetAttribute(nsIDOMElement *element, const PRUnichar *attr, const PRUnichar *value)
|
||||
|
@ -1975,7 +1984,7 @@ nsEditorShell::PasteAsCitedQuotation(const PRUnichar *cite)
|
|||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
err = mailEditor->PasteAsQuotation();
|
||||
err = mailEditor->PasteAsCitedQuotation(aCiteString);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2015,22 +2024,28 @@ nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText,
|
|||
NS_IMETHODIMP
|
||||
nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText,
|
||||
const PRUnichar *cite,
|
||||
const PRUnichar *charset,
|
||||
nsIDOMNode** aNodeInserted)
|
||||
{
|
||||
nsresult err = NS_NOINTERFACE;
|
||||
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (!mailEditor)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
nsAutoString aQuotedText(quotedText);
|
||||
nsAutoString aCiteString(cite);
|
||||
nsAutoString aCharset(charset);
|
||||
|
||||
switch (mEditorType)
|
||||
{
|
||||
case ePlainTextEditorType:
|
||||
err = mailEditor->InsertAsQuotation(aQuotedText, aNodeInserted);
|
||||
break;
|
||||
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
err = mailEditor->InsertAsQuotation(aQuotedText, aNodeInserted);
|
||||
}
|
||||
err = mailEditor->InsertAsCitedQuotation(aQuotedText, aCiteString,
|
||||
aCharset, aNodeInserted);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2167,6 +2182,33 @@ nsEditorShell::InsertSource(const PRUnichar *aSourceToInsert)
|
|||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::InsertSourceWithCharset(const PRUnichar *aSourceToInsert,
|
||||
const PRUnichar *aCharset)
|
||||
{
|
||||
nsresult err = NS_NOINTERFACE;
|
||||
|
||||
nsAutoString sourceToInsert(aSourceToInsert);
|
||||
nsAutoString charset(aCharset);
|
||||
|
||||
switch (mEditorType)
|
||||
{
|
||||
case ePlainTextEditorType:
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
err = htmlEditor->InsertHTMLWithCharset(sourceToInsert, charset);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
err = NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::InsertBreak()
|
||||
{
|
||||
|
|
|
@ -148,6 +148,7 @@ interface nsIEditorShell : nsISupports
|
|||
|
||||
void InsertAsQuotation(in wstring quotedText, out nsIDOMNode nodeInserted);
|
||||
void InsertAsCitedQuotation(in wstring quotedText, in wstring cite,
|
||||
in wstring charset,
|
||||
out nsIDOMNode nodeInserted);
|
||||
|
||||
void SelectAll();
|
||||
|
@ -173,6 +174,7 @@ interface nsIEditorShell : nsISupports
|
|||
void TypedText(in wstring textToInsert, in PRInt32 actionToTake);
|
||||
void InsertText(in wstring textToInsert);
|
||||
void InsertSource(in wstring textToInsert);
|
||||
void InsertSourceWithCharset(in wstring textToInsert, in wstring charset);
|
||||
void InsertBreak();
|
||||
|
||||
void MakeOrChangeList(in wstring listType);
|
||||
|
@ -278,6 +280,7 @@ interface nsIEditorShell : nsISupports
|
|||
void DeleteCharBackward();
|
||||
void DeleteWordForward();
|
||||
void DeleteWordBackward();
|
||||
void DeleteToBeginningOfLine();
|
||||
void DeleteToEndOfLine();
|
||||
|
||||
void SelectElement(in nsIDOMElement element);
|
||||
|
|
|
@ -135,6 +135,9 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
|||
result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// Try to insert formatting whitespace for the new node:
|
||||
mEditor->InsertFormattingForNode(mNewNode);
|
||||
|
||||
// only set selection to insertion point if editor gives permission
|
||||
PRBool bAdjustSelection;
|
||||
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
|
||||
|
|
|
@ -98,6 +98,8 @@ nsEditorController::nsEditorController()
|
|||
mDeleteCharForward = "cmd_deleteCharForward";
|
||||
mDeleteWordBackward = "cmd_deleteWordBackward";
|
||||
mDeleteWordForward = "cmd_deleteWordForward";
|
||||
|
||||
mDeleteToBeginningOfLine = "cmd_deleteToBeginningOfLine";
|
||||
mDeleteToEndOfLine = "cmd_deleteToEndOfLine";
|
||||
}
|
||||
|
||||
|
@ -218,6 +220,7 @@ NS_IMETHODIMP nsEditorController::SupportsCommand(const PRUnichar *aCommand, PRB
|
|||
(PR_TRUE==mDeleteCharBackward.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteWordForward.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteWordBackward.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteToBeginningOfLine.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteToEndOfLine.Equals(aCommand)) ||
|
||||
(PR_TRUE==mSelectAllString.Equals(aCommand)) ||
|
||||
(PR_TRUE==mBeginLineString.Equals(aCommand)) ||
|
||||
|
@ -319,6 +322,12 @@ NS_IMETHODIMP nsEditorController::DoCommand(const PRUnichar *aCommand)
|
|||
NS_ENSURE_SUCCESS(editor->DeleteSelection(nsIEditor::ePreviousWord),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
else if (PR_TRUE==mDeleteToBeginningOfLine.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->DeleteSelection(nsIEditor::eToBeginningOfLine),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mDeleteToEndOfLine.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->DeleteSelection(nsIEditor::eToEndOfLine),
|
||||
|
|
|
@ -116,6 +116,7 @@ protected:
|
|||
nsString mDeleteCharForward;
|
||||
nsString mDeleteWordBackward;
|
||||
nsString mDeleteWordForward;
|
||||
nsString mDeleteToBeginningOfLine;
|
||||
nsString mDeleteToEndOfLine;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1295,7 +1295,7 @@ NS_IMETHODIMP nsHTMLEditor::DeleteSelection(nsIEditor::EDirection aAction)
|
|||
// This can't happen inside selection batching --
|
||||
// selection refuses to move if batching is on.
|
||||
if (aAction == eNextWord || aAction == ePreviousWord
|
||||
|| aAction == eToEndOfLine)
|
||||
|| aAction == eToBeginningOfLine || aAction == eToEndOfLine)
|
||||
{
|
||||
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
|
||||
|
@ -1316,6 +1316,10 @@ NS_IMETHODIMP nsHTMLEditor::DeleteSelection(nsIEditor::EDirection aAction)
|
|||
result = selCont->WordMove(PR_FALSE, PR_TRUE);
|
||||
aAction = eNone;
|
||||
break;
|
||||
case eToBeginningOfLine:
|
||||
result = selCont->IntraLineMove(PR_FALSE, PR_TRUE);
|
||||
aAction = eNone;
|
||||
break;
|
||||
case eToEndOfLine:
|
||||
result = selCont->IntraLineMove(PR_TRUE, PR_TRUE);
|
||||
aAction = eNone;
|
||||
|
@ -1400,6 +1404,13 @@ NS_IMETHODIMP nsHTMLEditor::InsertText(const nsString& aStringToInsert)
|
|||
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
|
||||
{
|
||||
nsAutoString charset;
|
||||
return InsertHTMLWithCharset(aInputString, charset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString,
|
||||
const nsString& aCharset)
|
||||
{
|
||||
ForceCompositionEnd();
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
|
@ -3747,7 +3758,8 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
|
|||
return InsertAsPlaintextQuotation(aQuotedText, aNodeInserted);
|
||||
|
||||
nsAutoString citation ("");
|
||||
return InsertAsCitedQuotation(aQuotedText, citation, aNodeInserted);
|
||||
nsAutoString charset ("");
|
||||
return InsertAsCitedQuotation(aQuotedText, citation, charset, aNodeInserted);
|
||||
}
|
||||
|
||||
// text insert.
|
||||
|
@ -3828,6 +3840,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
|
|||
NS_IMETHODIMP
|
||||
nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation,
|
||||
const nsString& aCharset,
|
||||
nsIDOMNode **aNodeInserted)
|
||||
{
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
|
@ -3856,7 +3869,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
|
|||
selection->Collapse(newNode, 0);
|
||||
}
|
||||
|
||||
res = InsertHTML(aQuotedText);
|
||||
res = InsertHTMLWithCharset(aQuotedText, aCharset);
|
||||
if (aNodeInserted)
|
||||
{
|
||||
if (NS_SUCCEEDED(res))
|
||||
|
|
|
@ -109,6 +109,8 @@ public:
|
|||
NS_IMETHOD InsertBreak();
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
NS_IMETHOD InsertHTML(const nsString &aInputString);
|
||||
NS_IMETHOD InsertHTMLWithCharset(const nsString& aInputString,
|
||||
const nsString& aCharset);
|
||||
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
|
||||
|
||||
NS_IMETHOD DeleteSelection(EDirection aAction);
|
||||
|
@ -161,7 +163,10 @@ public:
|
|||
NS_IMETHOD PasteAsQuotation();
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted);
|
||||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, nsIDOMNode **aNodeInserted);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation,
|
||||
const nsString& aCharset,
|
||||
nsIDOMNode **aNodeInserted);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
|
||||
|
|
|
@ -443,6 +443,7 @@ nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
|
|||
NS_IMETHODIMP
|
||||
nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation,
|
||||
const nsString& aCharset,
|
||||
nsIDOMNode **aNodeInserted)
|
||||
{
|
||||
nsAutoHTMLEditorLogLock logLock(this);
|
||||
|
@ -459,7 +460,7 @@ nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
|
|||
}
|
||||
|
||||
return nsHTMLEditor::InsertAsCitedQuotation(aQuotedText, aCitation,
|
||||
aNodeInserted);
|
||||
aCharset, aNodeInserted);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
|
||||
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, nsIDOMNode** aNodeInserted);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, const nsString& aCharset, nsIDOMNode** aNodeInserted);
|
||||
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
ePrevious,
|
||||
eNextWord,
|
||||
ePreviousWord,
|
||||
eToBeginningOfLine,
|
||||
eToEndOfLine
|
||||
} EDirection;
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
*/
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation,
|
||||
const nsString& aCharset,
|
||||
nsIDOMNode** aNodeInserted)=0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -197,10 +197,17 @@ public:
|
|||
NS_IMETHOD InsertText(const nsString& aStringToInsert)=0;
|
||||
|
||||
/**
|
||||
* document me!
|
||||
* Insert some HTML source at the current location.
|
||||
*/
|
||||
NS_IMETHOD InsertHTML(const nsString &aInputString)=0;
|
||||
|
||||
/**
|
||||
* Insert some HTML source at the current location, interpreting
|
||||
* the string argument according to the given charset.
|
||||
*/
|
||||
NS_IMETHOD InsertHTMLWithCharset(const nsString &aInputString,
|
||||
const nsString& aCharset)=0;
|
||||
|
||||
|
||||
/** Insert an element, which may have child nodes, at the selection
|
||||
* Used primarily to insert a new element for various insert element dialogs,
|
||||
|
|
Загрузка…
Ссылка в новой задаче