public void ExecuteSelectionOperation(HtmlEditorSelectionOperation op) { //suspend selection change events while the real HTML selection is temporarily adjusted //to include the smart content element while the selection operation executes. _editorComponentContext.BeginSelectionChange(); try { IHTMLDocument2 document = (IHTMLDocument2)HTMLElement.document; MarkupRange elementRange = CreateElementClingMarkupRange(); MarkupRange insertionRange = CreateSelectionBoundaryMarkupRange(); elementRange.ToTextRange().select(); op(this); //reset the selection if (elementRange.Start.Positioned && elementRange.End.Positioned) { document.selection.empty(); _editorComponentContext.Selection = this; } else { insertionRange.ToTextRange().select(); } } finally { _editorComponentContext.EndSelectionChange(); } }
protected static ContentSelection SelectElementCore(IHtmlEditorComponentContext editorComponentContext, IHTMLElement e, ContentSelection smartContentSelection) { Debug.Assert(e.sourceIndex > -1, "Cannot select an unpositioned element"); if (e.sourceIndex > -1) //avoid unhandled exception reported by bug 291968 { //suspend selection change events while the selection object is replaced editorComponentContext.BeginSelectionChange(); try { //clear the DOM selection so that whatever is currently selected gets unselected. editorComponentContext.EmptySelection(); //select the newly smart content element editorComponentContext.Selection = smartContentSelection; return(smartContentSelection); } finally { editorComponentContext.EndSelectionChange(); } } return(null); }
protected static ContentSelection SelectElementCore(IHtmlEditorComponentContext editorComponentContext, IHTMLElement e, ContentSelection smartContentSelection) { Debug.Assert(e.sourceIndex > -1, "Cannot select an unpositioned element"); if (e.sourceIndex > -1) //avoid unhandled exception reported by bug 291968 { //suspend selection change events while the selection object is replaced editorComponentContext.BeginSelectionChange(); try { //clear the DOM selection so that whatever is currently selected gets unselected. editorComponentContext.EmptySelection(); //select the newly smart content element editorComponentContext.Selection = smartContentSelection; return smartContentSelection; } finally { editorComponentContext.EndSelectionChange(); } } return null; }