Exemple #1
0
        private void UpdateImageLink(string href, IHTMLElement ImgElement, ILinkOptions defaultOptions)
        {
            MshtmlMarkupServices markupServices = new MshtmlMarkupServices((IMarkupServicesRaw)ImgElement.document);
            IHTMLElement         parentElement  = ImgElement.parentElement;

            if (!(parentElement is IHTMLAnchorElement))
            {
                parentElement = markupServices.CreateElement(_ELEMENT_TAG_ID.TAGID_A, null);
                MarkupRange range = markupServices.CreateMarkupRange();
                range.MoveToElement(ImgElement, true);
                markupServices.InsertElement(parentElement, range.Start, range.End);

                //set the default target attribute for the new element
                string             target            = defaultOptions.ShowInNewWindow ? "_blank" : null;
                IHTMLAnchorElement htmlAnchorElement = (parentElement as IHTMLAnchorElement);
                if (htmlAnchorElement.target != target) //don't set the target to null if its already null (avoids adding empty target attr)
                {
                    htmlAnchorElement.target = target;
                }

                ImageViewer viewer = DhtmlImageViewers.GetImageViewer(DhtmlImageViewer);
                if (viewer != null)
                {
                    if (defaultOptions.UseImageViewer)
                    {
                        viewer.Apply(htmlAnchorElement, defaultOptions.ImageViewerGroupName);
                    }
                }
            }
            parentElement.setAttribute("href", href, 0);
        }
Exemple #2
0
        protected override void LoadEditor()
        {
            base.LoadEditor();
            HtmlImageTargetSettings = new HtmlImageTargetDecoratorSettings(EditorContext.Settings, EditorContext.ImgElement);
            LoadLinkTargetsCombo();

            string imgUrl = (string)EditorContext.ImgElement.getAttribute("src", 2);

            LinkToSourceImageEnabled = UrlHelper.IsFileUrl(imgUrl) && GlobalEditorOptions.SupportsFeature(ContentEditorFeature.SupportsImageClickThroughs);

            if (ImageEditingContext.EditorOptions.DhtmlImageViewer != null)
            {
                imageViewer = DhtmlImageViewers.GetImageViewer(ImageEditingContext.EditorOptions.DhtmlImageViewer);
            }
        }