/// <summary> /// Clones active smart content contained in the provided HTML, and disables unknown smart content. /// </summary> public static string PrepareSmartContentHtmlForEditorInsertion(string html, IContentSourceSidebarContext sourceContext) { StringBuilder output = new StringBuilder(); ContentSourceManager.SmartContentPredicate predicate = new ContentSourceManager.SmartContentPredicate(); SimpleHtmlParser p = new SimpleHtmlParser(html); for (Element el; null != (el = p.Next());) { if (predicate.IsMatch(el)) { BeginTag bt = el as BeginTag; Attr idAttr = bt.GetAttribute("id"); String contentSourceId, contentItemId; ContentSourceManager.ParseContainingElementId(idAttr.Value, out contentSourceId, out contentItemId); ISmartContent smartContent = sourceContext.FindSmartContent(contentItemId); if (smartContent != null) { String newId = Guid.NewGuid().ToString(); sourceContext.CloneSmartContent(contentItemId, newId); if (RefreshableContentManager.ContentSourcesWithRefreshableContent.Contains(contentSourceId)) { IExtensionData extensionData = sourceContext.FindExtentsionData(newId); Debug.Assert(extensionData != null); // Since we just made a new id for the smart content just about to be inserted // we want to give it a chance to get a callback because its callback might have happened while // it was on the clipboard(in the event of cut). This means the refreshable content manager doesnt know // to watch out for this smart content on paste, it only knows to look out for who created it. Thus // we just force the callback, and if it didnt need it, nothing will happen. if (extensionData.RefreshCallBack == null) { extensionData.RefreshCallBack = DateTime.UtcNow; } } idAttr.Value = ContentSourceManager.MakeContainingElementId(contentSourceId, newId); } else { ContentSourceManager.RemoveSmartContentAttributes(bt); } } output.Append(el.ToString()); } return(output.ToString()); }
/// <summary> /// Clones active smart content contained in the provided HTML, and disables unknown smart content. /// </summary> public static string PrepareSmartContentHtmlForEditorInsertion(string html, IContentSourceSidebarContext sourceContext) { StringBuilder output = new StringBuilder(); ContentSourceManager.SmartContentPredicate predicate = new ContentSourceManager.SmartContentPredicate(); SimpleHtmlParser p = new SimpleHtmlParser(html); for (Element el; null != (el = p.Next());) { if (predicate.IsMatch(el)) { BeginTag bt = el as BeginTag; Attr idAttr = bt.GetAttribute("id"); String contentSourceId, contentItemId; ContentSourceManager.ParseContainingElementId(idAttr.Value, out contentSourceId, out contentItemId); ISmartContent smartContent = sourceContext.FindSmartContent(contentItemId); if (smartContent != null) { String newId = Guid.NewGuid().ToString(); sourceContext.CloneSmartContent(contentItemId, newId); if (RefreshableContentManager.ContentSourcesWithRefreshableContent.Contains(contentSourceId)) { IExtensionData extensionData = sourceContext.FindExtentsionData(newId); Debug.Assert(extensionData != null); // Since we just made a new id for the smart content just about to be inserted // we want to give it a chance to get a callback because its callback might have happened while // it was on the clipboard(in the event of cut). This means the refreshable content manager doesnt know // to watch out for this smart content on paste, it only knows to look out for who created it. Thus // we just force the callback, and if it didnt need it, nothing will happen. if (extensionData.RefreshCallBack == null) { extensionData.RefreshCallBack = DateTime.UtcNow; } } idAttr.Value = ContentSourceManager.MakeContainingElementId(contentSourceId, newId); } else { ContentSourceManager.RemoveSmartContentAttributes(bt); } } output.Append(el.ToString()); } return output.ToString(); }
public EditableSmartContent(IContentSourceSidebarContext context, SmartContentSource contentSource, IHTMLElement smartContentElement) { GC.SuppressFinalize(this); _contentSourceContext = context; _contentSource = contentSource; _smartContentElement = smartContentElement; ContentSourceManager.ParseContainingElementId(_smartContentElement.id, out _contentSourceId, out _smartContentId); _smartContent = _contentSourceContext.FindSmartContent(_smartContentId); _extensionData = _contentSourceContext.FindExtentsionData(_smartContentId); _properties = new EditableRootProperties(); _layout = new EditableLayoutStyle(); _supportingFiles = new EditableSupportingFiles(); MakeSmartContentEditable(); }
public EditableSmartContent(IContentSourceSidebarContext context, SmartContentSource contentSource, IHTMLElement smartContentElement) { GC.SuppressFinalize(this); _contentSourceContext = context; _contentSource = contentSource; _smartContentElement = smartContentElement; ContentSourceManager.ParseContainingElementId(_smartContentElement.id, out _contentSourceId, out _smartContentId); _smartContent = _contentSourceContext.FindSmartContent(_smartContentId); _extensionData = _contentSourceContext.FindExtentsionData(_smartContentId); _properties = new EditableRootProperties(); _layout = new EditableLayoutStyle(); _supportingFiles = new EditableSupportingFiles(); MakeSmartContentEditable(); }