public void PopulateConfiguration(CKEditorConfigContext config) { // Get CKEditor settings var ckSettings = Services.WorkContext.CurrentSite.As <CKEditorSettingsPart>(); if (ckSettings != null) { if (!String.IsNullOrWhiteSpace(ckSettings.ContentsCss)) { // Push css link(s) into config var currentTheme = _siteThemeService.GetSiteTheme(); var sheets = // Get list of stylesheets ckSettings.ContentsCss.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries) // Transform to full URLs .Select(sheet => string.Format("{0}/{1}/Styles/{2}", currentTheme.Location, currentTheme.Id, sheet)) .Where(path => _virtualPathProvider.FileExists(path)).Select(path => UrlHelper.GenerateContentUrl(path, Services.WorkContext.HttpContext)).ToList(); // Execute at this time to avoid trouble later config.Add(new CKEditorConfigStringList("contentsCss", sheets)); } if (!String.IsNullOrWhiteSpace(ckSettings.ExtraPlugins)) { // TODO: Plugins should add modularly from an ICKEditorPlugin interface? var plugins = ckSettings.ExtraPlugins; config.Add(new CKEditorConfigString("extraPlugins", plugins)); } // For removing standard styles if stylesheet parser is used if (ckSettings.ClearDefaultStyleSets) { config.Add(new CKEditorConfigStringList("stylesSet", Enumerable.Empty <String>())); } } }
public void CKEditor_Config_Displaying(ShapeDisplayingContext displaying) { // Build other key/value pairs var context = new CKEditorConfigContext(); foreach (var provider in _ckEditorConfigProviders.Value) { provider.PopulateConfiguration(context); } displaying.Shape.ConfigPairs = context.Config.Values; }