public void Initialize(IBlogPostEditingContext editingContext, IEditorOptions clientOptions, string wysiwygHTML, string previewHTML, bool containsTitle) { // We suppress he editor reload here while we add the inital template because a bit further down // this function we will reload the editor using the BlogPost from editingContext using (SuppressEditorLoad()) SetTheme(wysiwygHTML, previewHTML, containsTitle); _editingContext = editingContext; // @SharedCanvas - Check to make sure we can get rid of this once we get rid of the sidebar if (_editingContext is BlogPostEditingManager) { // Get an event everytime the user tried to publish, so we refesh smart content that might have been updated during published BlogPostEditingManager editingManager = (BlogPostEditingManager)_editingContext; editingManager.UserPublishedPost += new EventHandler(editingManager_UserPublishedPost); } // save whethere we are editing a page _isPage = editingContext.BlogPost.IsPage; // save a reference to the supporting files _supportingFileStorage = editingContext.SupportingFileStorage; //save a reference to the image data list _imageDataList = editingContext.ImageDataList; //save a reference to the extension data list _extensionDataList = editingContext.ExtensionDataList; // if there is already a RefreshableContentManager, which means that the user // is switching blogs or posts, then we need to dispose of it if (_refreshSmartContentManager != null) _refreshSmartContentManager.Dispose(); // Make a new manager for the extension data for this blog/post _refreshSmartContentManager = new RefreshableContentManager(_extensionDataList, this); _fileService = editingContext.SupportingFileService; // Reset the emoticons manager _emoticonsManager = new EmoticonsManager(this, this); // initialize text-editing command manager // this needs to be called before html is loaded into the editor and before an editor gets // focus because that will cause the html commands to be updated InitializeTextEditingCommands(); bool indent = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.TabAsIndent); CommandManager.Get(CommandId.Indent).On = indent; CommandManager.Get(CommandId.Outdent).On = indent; string postContentsHtml = SmartContentWorker.PerformOperation(editingContext.BlogPost.Contents, GetStructuredEditorHtml, true, this, true); postContentsHtml = StripPluginHeadersAndFooters(postContentsHtml); LoadEditorHtml(editingContext.BlogPost.Title, postContentsHtml, _currentEditorAccount.HomepageBaseUrl, false); // There are a lot of reasons that the post might become dirty, that are not from the users, these usually fall in // a very short time period. This is a catch all case, because there is no way to win against find all the different way. // Often times, it can be a css background loading, or mshtml changing around the html. TimerHelper.CallbackOnDelay(new InvokeInUIThreadDelegate(delegate () { _currentEditor.IsDirty = false; }), 50); // make sure the word count is in sync with the new post that has just been loaded wordCountUpdate(this, EventArgs.Empty); //update editing context of the editors _normalHtmlContentEditor.UpdateEditingContext(); if (_codeHtmlContentEditor != null) _codeHtmlContentEditor.UpdateEditingContext(); }
public ContentEditor(IMainFrameWindow mainFrameWindow, Control editorContainer, IBlogPostEditingSite postEditingSite, IInternetSecurityManager internetSecurityManager, BlogPostHtmlEditorControl.TemplateStrategy templateStrategy, int dlControlFlags) { // create a docked panel to host the editor Panel panel = new Panel(); panel.Dock = DockStyle.Fill; if (!BidiHelper.IsRightToLeft) panel.DockPadding.Right = 0; else panel.DockPadding.Left = 0; editorContainer.Controls.Add(panel); panel.Resize += new EventHandler(panel_Resize); if (BidiHelper.IsRightToLeft) editorContainer.RightToLeft = RightToLeft.Yes; // save references _mainFrameWindow = mainFrameWindow; _editorContainer = panel; _postEditingSite = postEditingSite; _commandManager = new CommandManager(); _userPreferencesMonitor = new UserPreferencesMonitor(); // To be high-contrast-aware we need to respond to changes in the high contrast mode // by invalidating commands, forcing the ribbon to ask us for new high contrast images. _userPreferencesMonitor.AccessibilityUserPreferencesChanged += new EventHandler(delegate (object sender, EventArgs args) { _commandManager.InvalidateAllImages(); }); _imageDecoratorsManager = new LazyLoader<ImageDecoratorsManager>(() => new ImageDecoratorsManager(components, CommandManager, GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ImageBorderInherit))); _emoticonsManager = new EmoticonsManager(this, this); // initialize commands InitializeCommands(); // initialize normal editor InitializeNormalEditor(postEditingSite, internetSecurityManager, templateStrategy, dlControlFlags); // initialize source editor if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.SourceEditor)) InitializeSourceEditor(); InitializeViewCommands(); // initialize custom content InitializeContentSources(); // bring main editor panel to front (this must be here for the sidebar to work!!!!) panel.BringToFront(); }