public void InsertHtml(string content, HtmlInsertionOptions options) { sourceControl.InsertHtml(content, options); }
public void InsertHtml(string content, HtmlInsertionOptions options) { _textBox.Paste(content); }
public void InsertHtml(string content, HtmlInsertionOptions options) { sourceControl.InsertHtml(content, options); }
public void InsertHtml(string html, HtmlInsertionOptions options) { //Use gravity/cling to make the selection pointers to stay with the outer edges //of the content so that they are surrounding the new HTML after the insertion //is completed. MarkupRange range; switch (options & (HtmlInsertionOptions.InsertAtBeginning | HtmlInsertionOptions.InsertAtEnd)) { case HtmlInsertionOptions.InsertAtBeginning: range = MarkupServices.CreateMarkupRange(PostBodyElement, false); range.Collapse(true); break; case HtmlInsertionOptions.InsertAtEnd: range = MarkupServices.CreateMarkupRange(PostBodyElement, false); range.Collapse(false); break; case HtmlInsertionOptions.Default: range = SelectedMarkupRange; break; case HtmlInsertionOptions.InsertAtBeginning | HtmlInsertionOptions.InsertAtEnd: throw new ArgumentException("Invalid flag combination: InsertAtBeginning|InsertAtEnd"); default: throw new ArgumentException("Invalid flag combination"); } Trace.Assert(range != null, "SelectedMarkupRange should not be null"); Trace.Assert(range.Start.Positioned && range.End.Positioned, "InsertHtml with bad markup pointers"); range.Start.Gravity = _POINTER_GRAVITY.POINTER_GRAVITY_Left; range.End.Gravity = _POINTER_GRAVITY.POINTER_GRAVITY_Right; range.Start.Cling = false; range.End.Cling = false; bool allowBlockBreakout = (options & HtmlInsertionOptions.AllowBlockBreakout) == HtmlInsertionOptions.AllowBlockBreakout; InsertHtml(range.Start, range.End, html, null, allowBlockBreakout); // Now drive the selection to the left or right of the newly inserted bool selectHandled = false; MarkupRange selectionRange = range.Clone(); if (HtmlInsertionOptions.SelectFirstControl == (options & HtmlInsertionOptions.SelectFirstControl)) { IHTMLElement[] controlElements = range.GetElements(ElementFilters.CreateControlElementFilter(), true); for (int i = 0; !selectHandled && i < controlElements.Length; i++) { selectHandled = SelectByTagId(controlElements[i]); } } if (!selectHandled) { selectionRange.Collapse(HtmlInsertionOptions.MoveCursorAfter != (options & HtmlInsertionOptions.MoveCursorAfter)); IHTMLTxtRange textRange = selectionRange.ToTextRange(); if (textRange != null) textRange.select(); } // Allow subclasses to do postprocessing on the inserted HTML OnInsertHtml(range, options); }
protected virtual void OnInsertHtml(MarkupRange newContentRange, HtmlInsertionOptions options) { if (HtmlInsertionOptions.ClearUndoStack == (options & HtmlInsertionOptions.ClearUndoStack)) { ClearUndoStack(); } }
public void InsertHtml(string content, HtmlInsertionOptions options) { _textBox.Paste(content); }
protected override void OnInsertHtml(MarkupRange newContentRange, HtmlInsertionOptions options) { base.OnInsertHtml(newContentRange, options); //the inserted element will be the element directly to the right of the range. MarkupContext markupContext = newContentRange.Start.Right(false); IHTMLElement insertedElement = markupContext.Element; MshtmlEditor.BeginInvoke(new ThreadStart(RefreshEmbeds), null); //automatically select the element if it is a smart content element. SmartContentSelection.SelectIfSmartContentElement(this, insertedElement); if (HtmlInsertionOptions.SuppressSpellCheck == (options & HtmlInsertionOptions.SuppressSpellCheck)) { MshtmlEditor.BeginInvoke(new ThreadStart(() => { _spellingManager.DamagedRange(newContentRange, false); _spellingManager.IgnoreOnce(newContentRange); }), null); } }
private void InsertContentBlock(string contentSourceId, string content, IExtensionData extensionData, HtmlInsertionOptions insertionOptions) { // generate a new unique id for this content block string blockId = extensionData.Id; using (new HtmlEditorControl.InitialInsertionNotify(_normalHtmlContentEditor)) { // insert the appropriate html InsertHtml(SmartContentInsertionHelper.GenerateContentBlock(contentSourceId, blockId, content, extensionData), insertionOptions); } }
void IContentSourceSite.InsertContent(string contentSourceId, string content, IExtensionData extensionData, HtmlInsertionOptions insertionOptions) { //Insert gestures are only supported in the body, so force focus to the body FocusBody(); InsertContentBlock(contentSourceId, content, extensionData, insertionOptions); }
public void InsertSmartContentFromFile(string[] files, string contentSourceID, HtmlInsertionOptions insertionOptions, object context) { files = RemoveInvalidImages(files); if (files == null || files.Length == 0) return; // Get a reference to the video plugin ISupportsDragDropFile contentSource = (ISupportsDragDropFile)ContentSourceManager.GetContentSourceInfoById(contentSourceID).Instance; if (contentSource == null) return; IExtensionData extensionData = (this as IContentSourceSite).CreateExtensionData(Guid.NewGuid().ToString()); ISmartContent sContent = new SmartContent(extensionData); if (context == null) context = new InternalSmartContentContext(this, contentSourceID); using (EditorUndoUnit undo = new EditorUndoUnit(_currentEditor)) { // Have the plugin try to make some new content from the path that we just got through the drag and drop if (contentSource.CreateContentFromFile(_mainFrameWindow, sContent, files, context) == DialogResult.OK) { string content = ((SmartContentSource)contentSource).GenerateEditorHtml(sContent, this); if (content != null) { ((IContentSourceSite)this).InsertContent(contentSourceID, content, extensionData, insertionOptions); undo.Commit(); } Focus(); } } }
public void InsertHtml(string content, HtmlInsertionOptions options) { string fixedUpHtml = content; if (!((options & HtmlInsertionOptions.ExternalContent) == HtmlInsertionOptions.ExternalContent)) fixedUpHtml = FixUpLocalFileReferenceForInsertion(fixedUpHtml); if ((options & HtmlInsertionOptions.PlainText) == HtmlInsertionOptions.PlainText) { fixedUpHtml = TextHelper.GetHTMLFromText(fixedUpHtml, true, this.DefaultBlockElement); } // We dont want to apply both the default font tag and 'reset' style to the same block of html // We also dont want to apply the reset style if there is nothing to reset. if ((options & HtmlInsertionOptions.ApplyDefaultFont) == HtmlInsertionOptions.ApplyDefaultFont) fixedUpHtml = _normalHtmlContentEditor.CurrentDefaultFont.ApplyFont(fixedUpHtml); else if (((options & HtmlInsertionOptions.ExternalContent) == HtmlInsertionOptions.ExternalContent) && CurrentEditingMode != EditingMode.PlainText && !string.IsNullOrEmpty(fixedUpHtml)) fixedUpHtml = "<div style='color:#000000;font-size:small;font-family:\"Calibri\";font-weight:normal;display:inline;font-style:normal;text-decoration:none'>" + fixedUpHtml + "</div>"; if ((options & HtmlInsertionOptions.Indent) == HtmlInsertionOptions.Indent) fixedUpHtml = ApplyIndent(fixedUpHtml); if ((options & HtmlInsertionOptions.InsertNewLineBefore) == HtmlInsertionOptions.InsertNewLineBefore) { if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.DivNewLine)) fixedUpHtml = "<div> </div>" + fixedUpHtml; else fixedUpHtml = "<br/>" + fixedUpHtml; } if (CurrentEditingMode == EditingMode.PlainText) UpdateHtmlForPlainText(ref fixedUpHtml, true); _currentEditor.InsertHtml(fixedUpHtml, options); }
public void InsertHtml(string content, HtmlInsertionOptions options) { }