/// <summary>
        /// Inserts the extended entry break into the editor.
        /// </summary>
        internal void InsertExtendedEntryBreak()
        {
            IHTMLDocument3 doc3       = (IHTMLDocument3)HTMLElement.document;
            IHTMLElement2  entryBreak = (IHTMLElement2)doc3.getElementById(EXTENDED_ENTRY_ID);

            if (entryBreak == null)
            {
                using (IUndoUnit undo = EditorContext.CreateUndoUnit())
                {
                    using (EditorContext.DamageServices.CreateDamageTracker(ElementRange.Clone(), true))
                    {
                        MarkupPointer insertionPoint =
                            EditorContext.MarkupServices.CreateMarkupPointer(EditorContext.Selection.SelectedMarkupRange.Start);

                        //delete the parent block element of the insertion point if it is empty (bug 421500)
                        DeleteInsertionTargetBlockIfEmpty(insertionPoint);

                        IHTMLElement extendedEntryBreak = InsertExtendedEntryBreak(insertionPoint);

                        //reselect the insertion point
                        MarkupRange selection = EditorContext.MarkupServices.CreateMarkupRange();
                        insertionPoint.MoveAdjacentToElement(extendedEntryBreak, _ELEMENT_ADJACENCY.ELEM_ADJ_AfterEnd);
                        MarkupPointerMoveHelper.MoveUnitBounded(
                            insertionPoint, MarkupPointerMoveHelper.MoveDirection.RIGHT,
                            MarkupPointerAdjacency.AfterEnterBlock | MarkupPointerAdjacency.BeforeText
                            , HTMLElement);
                        selection.Start.MoveToPointer(insertionPoint);
                        selection.End.MoveToPointer(insertionPoint);
                        selection.ToTextRange().select();
                    }
                    undo.Commit();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Select all of the text in the region.
        /// </summary>
        protected void SelectAll()
        {
            MarkupRange selectRange = ElementRange.Clone();

            selectRange.MoveToElement(HTMLElement, false);
            selectRange.ToTextRange().select();
        }
        /// <summary>
        /// Returns true if shift+tab focused region changing is supported for the current edit location
        /// </summary>
        /// <returns></returns>
        private bool ShiftTabFocusChangeSupported()
        {
            //Shift-tab is only supported if the caret is positioned at the beginning of the post
            //If the selection is currently inside a non-blockquote block element with no visible content
            //to the left of it, then focus change is supported.

            if (!EditorContext.Selection.SelectedMarkupRange.IsEmpty())
            {
                return(false);
            }

            MarkupRange range = ElementRange.Clone();

            range.Start.MoveAdjacentToElement(HTMLElement, _ELEMENT_ADJACENCY.ELEM_ADJ_AfterBegin);
            range.End = EditorContext.Selection.SelectedMarkupRange.Start;

            //if there is any text between the caret and the beginning of the post,
            //then ShiftTab focus changing is not allowed.
            string text = range.Text;

            if (text != null && range.Text.Trim() != String.Empty)
            {
                return(false);
            }

            MarkupContext context = new MarkupContext();

            range.Start.Right(true, context);
            int blockElementDepth = 0;

            while (range.Start.IsLeftOfOrEqualTo(range.End))
            {
                if (context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_EnterScope || context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_NoScope)
                {
                    string tagName = context.Element.tagName;
                    if (tagName.Equals("BLOCKQUOTE") || ElementFilters.IsListElement(context.Element) || ElementFilters.IsListItemElement(context.Element))
                    {
                        return(false); //ShiftTab in a blockquote or list implies "un-blockquote" or "un-list"
                    }
                    else if (ElementFilters.IsBlockElement(context.Element))
                    {
                        blockElementDepth++;
                        if (blockElementDepth > 1)
                        {
                            return(false); //there are multiple block elements, so this is not the beginning
                        }
                    }
                    else if (ElementFilters.IsVisibleEmptyElement(context.Element))
                    {
                        return(false); //there is a visible empty element (like an image), so this is not the beginning
                    }
                }
                else if (context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_ExitScope)
                {
                    if (ElementFilters.IsVisibleEmptyElement(context.Element))
                    {
                        return(false); //there is a visible empty element (like an image), so this is not the beginning
                    }
                }
                range.Start.Right(true, context);
            }

            return(true);
        }