Esempio n. 1
0
        private void InitializeEditor()
        {
            config = TinyMceConfiguration.GetConfig();

            Editor.AdvancedBlockFormats = config.AdvancedFormatBlocks;

            Editor.AdvancedStyles  = SiteUtils.BuildStylesListForTinyMce();
            Editor.TemplatesUrl    = SiteUtils.GetNavigationSiteRoot() + "/Services/TinyMceTemplates.ashx?cb=" + Guid.NewGuid().ToString(); //cache busting guid
            Editor.EmotionsBaseUrl = Editor.ResolveUrl("~/Data/SiteImages/emoticons/tinymce/");

            Editor.DialogType = config.DialogType;

            Editor.Height = editorHeight;
            Editor.Width  = editorWidth;

            Editor.AdvancedSourceEditorWidth  = config.AdvancedSourceEditorWidth;
            Editor.AdvancedSourceEditorHeight = config.AdvancedSourceEditorHeight;
            Editor.AdvancedToolbarLocation    = config.AdvancedToolbarLocation;
            Editor.AdvancedToolbarAlign       = config.AdvancedToolbarAlign;
            Editor.AdvancedStatusBarLocation  = config.AdvancedStatusBarLocation;


            if (setFocusOnStart)
            {
                Editor.AutoFocus = true;
            }


            Editor.BasePath = WebConfigSettings.TinyMceBasePath;
            Editor.Skin     = WebConfigSettings.TinyMceSkin;


            SetToolBar();
        }
        /// <summary>
        /// Sets custom TinyMceSettings on all XhtmlString properties
        /// decorated with a specific attribute.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="customTinyMceSettings">The custom TinyMceSettings</param>
        public static void RegisterCustomTinyMceSettingsAttribute(TinyMceConfiguration config,
                                                                  TinyMceSettings customTinyMceSettings)
        {
            // Get MethodInfo for the extension method usually used to designate
            // custom TinyMceSettings for an XhtmlProperty, viz.
            // config.For<StandardPage>(x => x.MainBody, customTinyMceSettings);
            var theForMethod = typeof(TinyMceConfiguration).GetMethod("For");

            if (theForMethod == null)
            {
                return;
            }

            foreach (var contentType in _listOfEpiserverContentDataTypes)
            {
                // Get the properties decorated with the attribute used for designating the custom TinyMceSettings.
                var properties = contentType
                                 .GetProperties().Where(x => x.CustomAttributes.Any(att => att.AttributeType == typeof(T))).ToList();

                if (!properties.Any())
                {
                    continue;
                }

                // Make the For method generic.
                var theGenericMethod = theForMethod.MakeGenericMethod(contentType);

                foreach (var propertyInfo in properties)
                {
                    // Continue if the attribute is inadvertently applied to a
                    // property which is not an XhtmlString.
                    if (propertyInfo.PropertyType.Name != "XhtmlString")
                    {
                        continue;
                    }

                    var parameter = Expression.Parameter(contentType, "entity");
                    var property  = Expression.Property(parameter, propertyInfo);
                    var funcType  = typeof(Func <,>).MakeGenericType(contentType, typeof(object));
                    var lambda    = Expression.Lambda(funcType, property, parameter);

                    var parameters = new object[] { lambda, customTinyMceSettings };

                    try
                    {
                        theGenericMethod.Invoke(config, parameters);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
Esempio n. 3
0
        private void InitializeEditor()
        {
            config = TinyMceConfiguration.GetConfig();
            Editor.EmotionsBaseUrl = Editor.ResolveUrl("~/Data/SiteImages/emoticons/tinymce/");


            Editor.Height = editorHeight;
            Editor.Width  = editorWidth;

            if (setFocusOnStart)
            {
                Editor.AutoFocus = true;
            }

            Editor.BasePath = WebConfigSettings.TinyMceBasePath;
            //Editor.Skin = WebConfigSettings.TinyMceSkin;

            SetToolBar();
        }