internal override void FromHtml(IElement element)
        {
            base.FromHtml(element);

            var div = element.GetElementsByTagName("div").Where(a => a.HasAttribute(TextRteAttribute)).FirstOrDefault();

            if (div != null)
            {
                this.rte = div.GetAttribute(TextRteAttribute);
            }
            else
            {
                // supporting updated rendering of Text controls, no nested DIV tag with the data-sp-rte attribute...so HTML content is embedded at the root
                this.rte = "";
                div      = element;
            }

            // By default simple plain text is wrapped in a Paragraph, need to drop it to avoid getting multiple paragraphs on page edits.
            // Only drop the paragraph tag when there's only one Paragraph element underneath the DIV tag
            if ((div.FirstChild != null && (div.FirstChild as IElement) != null && (div.FirstChild as IElement).TagName.Equals("P", StringComparison.InvariantCultureIgnoreCase)) &&
                (div.ChildElementCount == 1))
            {
                this.Text = (div.FirstChild as IElement).InnerHtml;
            }
            else
            {
                this.Text = div.InnerHtml;
            }

            // load data from the data-sp-controldata attribute
            var jsonSerializerSettings = new JsonSerializerSettings()
            {
                MissingMemberHandling = MissingMemberHandling.Ignore
            };

            this.spControlData = JsonConvert.DeserializeObject <ClientSideTextControlData>(element.GetAttribute(CanvasControl.ControlDataAttribute), jsonSerializerSettings);
            this.controlType   = this.spControlData.ControlType;
        }
        /// <summary>
        /// Converts this <see cref="ClientSideText"/> control to it's html representation
        /// </summary>
        /// <param name="controlIndex">The sequence of the control inside the section</param>
        /// <returns>Html representation of this <see cref="ClientSideText"/> control</returns>
        public override string ToHtml(float controlIndex)
        {
            // Can this control be hosted in this section type?
            if (this.Section.Type == CanvasSectionTemplate.OneColumnFullWidth)
            {
                throw new Exception("You cannot host text controls inside a one column full width section, only an image web part or hero web part are allowed");
            }

            // Obtain the json data
            ClientSideTextControlData controlData = new ClientSideTextControlData()
            {
                ControlType = this.ControlType,
                Id          = this.InstanceId.ToString("D"),
                Position    = new ClientSideCanvasControlPosition()
                {
                    ZoneIndex     = this.Section.Order,
                    SectionIndex  = this.Column.Order,
                    SectionFactor = this.Column.ColumnFactor,
                    LayoutIndex   = this.Column.LayoutIndex,
                    ControlIndex  = controlIndex,
                },
                Emphasis = new ClientSideSectionEmphasis()
                {
                    ZoneEmphasis = this.Column.VerticalSectionEmphasis.HasValue ? this.Column.VerticalSectionEmphasis.Value : this.Section.ZoneEmphasis,
                },
                EditorType = "CKEditor"
            };


            if (this.section.Type == CanvasSectionTemplate.OneColumnVerticalSection)
            {
                if (this.section.Columns.First().Equals(this.Column))
                {
                    controlData.Position.SectionFactor = 12;
                }
            }

            jsonControlData = JsonConvert.SerializeObject(controlData);

            try
            {
                var nodeList = new HtmlParser().ParseFragment(this.Text, null);
                this.previewText = string.Concat(nodeList.Select(x => x.Text()));
            }
            catch { }

            StringBuilder html = new StringBuilder(100);

            html.Append($@"<div {CanvasControlAttribute}=""{this.CanvasControlData}"" {CanvasDataVersionAttribute}=""{ this.DataVersion}""  {ControlDataAttribute}=""{this.jsonControlData.Replace("\"", "&quot;")}"">");
            html.Append($@"<div {TextRteAttribute}=""{this.Rte}"">");
            if (this.Text.Trim().StartsWith("<p>", StringComparison.InvariantCultureIgnoreCase))
            {
                html.Append(this.Text);
            }
            else
            {
                html.Append($@"<p>{this.Text}</p>");
            }
            html.Append("</div>");
            html.Append("</div>");
            return(html.ToString());
        }