Try our conversational search powered by Generative AI!

Prevent wrapping P tag in TinyMCE editor

Vote:
 

Hey

How do I remove/prevent TinyMce to wrap my Imagevault tag in a p tag?

Now im getting the following html:

But I want this:

#118924
Mar 17, 2015 15:40
Vote:
 

Im using EPiServer 7.1 btw.

I found the following code but where do I put it? Can I pass some options in a attribute on the property perhaps?

tinyMCE.init({
      mode : "textareas",
      theme : "advanced",
      force_br_newlines : false,
      force_p_newlines : false,
      forced_root_block : '',
  });
#118925
Edited, Mar 17, 2015 15:42
Vote:
 
#118934
Mar 17, 2015 19:03
Vote:
 

Thanks! Will try that tomorrow. I've tried the following today, im just courious why this doesn't work?

I created a custom EditorDescriptor and decorated my property with it. Then in my EditorDescriptor I did the following:

public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        { 
            var model = (PropertyData) metadata.Model;
            var settings = (TinyMCESettings)(model).GetSetting(typeof(TinyMCESettings));
 
            var options = new TinyMCEInitOptions(TinyMCEInitOptions.InitType.EditMode, settings, (IContent)null);
            options.Add("forced_root_block", string.Empty);
            metadata.EditorConfiguration["settings"] = options.InitOptions;
 
            base.ModifyMetadata(metadata, attributes);
        }

I can see all the options when debugging but I get a 500 error when loading this in Edit mode.
Can update tomorrow with a more detailed error.

#118938
Edited, Mar 17, 2015 22:08
Vote:
 

Jonas, your solution worked, but now Im not getting any p tags wrapping my text(obviously).

Do you guys know any setting that just prevents wrapping a img element with a p tag?

I could use regex to remove it but that's really ugly...

#118968
Edited, Mar 18, 2015 9:09
Vote:
 

hi

i used two solutions for this problem

1. went to the tinymce file and in the appdata ( in the zip ) added the force_br_newlines false also added alot of other issues and zipeed again and it worked 

use the a dev toolbar to get the file location

this is the hammer approch

2. after i got helped from the support you need to create a plugin to tinymce and set the values 

this is the default add the one you need, also you need to write the same as the example ('' and , ) if not all the cms ui stops working

[TinyMCEPluginNonVisualAttribute(
AlwaysEnabled = true,
PlugInName = "NonVisualPlugin",
DisplayName = "Custom editor init options",
Description = "Loads custom editor init options.",
EditorInitConfigurationOptions = @"{
paste_auto_cleanup_on_paste : true,
convert_urls: false,
valid_elements : ""a[href],strong/b,em/i,br,ul,ol,li,-h2,-h3,-h4,-h5,-h6,-p"",
theme_advanced_blockformats : ""h2,h3,h4,h5,h6,p"",
theme_advanced_resizing : false,
body_class : ""module-text""
}")]

public class NonVisualPlugin
{

}

You also need to create the a blank javascript file named editor_plugin.js at this location:

 

Util\Editor\tinymce\plugins\<your_plugin_name>\

#118972
Mar 18, 2015 9:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.