Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 public ContentEditorAccountAdapter()
 {
     // WinLive 182295: Set all the EditorOptions just once so they are immutable.
     RequiresXHTML           = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.XHTML);
     MaxPostTitleLength      = Int32.MaxValue;
     IsRTLTemplate           = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.RTLDirectionDefault);
     HasRTLFeatures          = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.RTLFeatures);
     SupportsImageUpload     = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ImageUpload) ? SupportsFeature.Yes : SupportsFeature.No;
     SupportsScripts         = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.Script) ? SupportsFeature.Yes : SupportsFeature.No;
     SupportsEmbeds          = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.Embeds) ? SupportsFeature.Yes : SupportsFeature.No;
     PostBodyBackgroundColor = Color.White.ToArgb();
     DhtmlImageViewer        = null;
 }
Exemplo n.º 2
0
            public override void OnDocumentComplete(IHTMLDocument2 doc)
            {
                doc.body.style.overflow = "auto";
                doc.body.id             = BODY_FRAGMENT_ID;
                ((IHTMLElement3)doc.body).contentEditable = "true";
                doc.body.style.width = "100%";
                if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.RTLDirectionDefault))
                {
                    doc.body.setAttribute("dir", "rtl", 0);
                }
                else
                {
                    doc.body.setAttribute("dir", "ltr", 0);
                }

                IHTMLElement2 body = (IHTMLElement2)doc.body;

                body.runtimeStyle.padding     = "0px 0px 0px 0px";
                body.runtimeStyle.borderWidth = "0px";
            }
Exemplo n.º 3
0
        private bool ReplaceTypographic(char c, string htmlText)
        {
            if ((c == '\"' || c == '\'') && AutoreplaceSettings.EnableSmartQuotes) // Handle smart quotes
            {
                bool isOpenQuote = true;
                if (htmlText.Length > 0)
                {
                    switch (htmlText[htmlText.Length - 1])
                    {
                    case '-':
                    case '{':
                    case '[':
                    case '(':
                        isOpenQuote = true;
                        break;

                    default:
                        if (!char.IsWhiteSpace(htmlText[htmlText.Length - 1]))
                        {
                            isOpenQuote = false;
                        }
                        break;
                    }
                }

                switch (c)
                {
                case ('\''):
                    ReplaceValue(c, "'", (isOpenQuote ? "&#8216;" : "&#8217;"));
                    break;

                case ('\"'):
                    ReplaceValue(c, "\"", (isOpenQuote ? "&#8220;" : "&#8221;"));
                    break;
                }

                return(true);
            }
            else if ((c == ')' || c == '.') && AutoreplaceSettings.EnableSpecialCharacterReplacement) // Handling for (c), (r), ...
            {
                string replaceValue = null;
                string originalHtml = null;

                if (c == ')' && htmlText.EndsWith("(c", true, CultureInfo.InvariantCulture))
                {
                    replaceValue = "&#0169;";
                    originalHtml = "(c)";
                }
                else if (c == ')' && htmlText.EndsWith("(r", true, CultureInfo.InvariantCulture))
                {
                    replaceValue = "&#0174;";
                    originalHtml = "(r)";
                }
                else if (c == ')' && htmlText.EndsWith("(tm", true, CultureInfo.InvariantCulture))
                {
                    replaceValue = "&#x2122;";
                    originalHtml = "(tm)";
                }
                else if (c == '.' && htmlText.EndsWith("..", true, CultureInfo.InvariantCulture) && GlobalEditorOptions.SupportsFeature(ContentEditorFeature.UnicodeEllipsis))
                {
                    replaceValue = "&#8230;";
                    originalHtml = "...";
                }

                if (replaceValue != null)
                {
                    ReplaceValue(c, originalHtml, replaceValue);
                    return(true);
                }
            }

            return(ReplaceEmoticon(c, htmlText));
        }
Exemplo n.º 4
0
        // Set the alignment of the image
        internal void SetImageHtmlFromAlignment(ImgAlignment value)
        {
            bool needToSelectImage = false;

            switch (value)
            {
            case ImgAlignment.NONE:
                // If we removed the centering node, we need to reselect the image since the selection
                // is invalidated/changed as a result of removing the node.
                needToSelectImage = RemoveCenteringNode();

                _element.removeAttribute("align", 0);
                _element.style.display    = "inline";
                _element.style.styleFloat = null;

                if (_element.style.marginLeft != null && _element.style.marginLeft.ToString() == "auto")
                {
                    _element.style.marginLeft = 0;
                }
                if (_element.style.marginRight != null && _element.style.marginRight.ToString() == "auto")
                {
                    _element.style.marginRight = 0;
                }

                break;

            case ImgAlignment.LEFT:
            case ImgAlignment.RIGHT:
                // If we removed the centering node, we need to reselect the image since the selection
                // is invalidated/changed as a result of removing the node.
                needToSelectImage = RemoveCenteringNode();

                _element.style.display    = "inline";
                _element.style.styleFloat = value.ToString().ToLower(CultureInfo.InvariantCulture);
                if (_element.style.marginLeft != null && _element.style.marginLeft.ToString() == "auto")
                {
                    _element.style.marginLeft = 0;
                }
                if (_element.style.marginRight != null && _element.style.marginRight.ToString() == "auto")
                {
                    _element.style.marginRight = 0;
                }
                // For all other types of alignment we just set the align property on the image
                _element.setAttribute("align", value.ToString().ToLower(CultureInfo.InvariantCulture), 0);

                break;

            case ImgAlignment.CENTER:
                _element.removeAttribute("align", 0);
                _element.style.styleFloat = null;

                if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.CenterImageWithParagraph))
                {
                    IHTMLElement element = FindCenteringNode();
                    if (element == null)
                    {
                        // There is no existing centering node, we need to create a new one.
                        // Creating the new centering node invalidates/changes the existing selection
                        // so we need to reselect the image.
                        needToSelectImage = true;
                        element           = CreateNodeForCentering();
                    }
                    if (element != null)
                    {
                        element.setAttribute("align", "center", 0);
                    }
                }
                else
                {
                    _element.style.display     = "block";
                    _element.style.styleFloat  = "none";
                    _element.style.marginLeft  = "auto";
                    _element.style.marginRight = "auto";
                }
                break;

            default:
                Trace.Fail("Unknown image alignment: " + value.ToString());
                break;
            }

            if (needToSelectImage)
            {
                // If we need to reselect the image, do it after we have set the right
                // alignment in the element above so that when the selection change event
                // refreshes the ribbon commands using the html doc, it sees the new values.
                SelectImage();
            }
        }
Exemplo n.º 5
0
 private bool IsCenteringNode(IHTMLElement element)
 {
     return(GlobalEditorOptions.SupportsFeature(ContentEditorFeature.CenterImageWithParagraph) && element != null &&
            element is IHTMLParaElement && element.getAttribute("align", 2) as string == "center");
 }