Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Dragging a block into the Rich Text Editor without paragraph break?


We  are using Episerver CMS

When dragging a block into the TinyMCE editor, it creates a new paragraph (<p/>) in effect and the rest of the content is above/below that block area. Our users would like to be able to drag and drop a block and have the block be inline with the other content. Has anyone seen this done before?

Feb 03, 2021 16:28

I think this config would help.

(TinyMceConfiguration).Default() //or any specific content model
          .AddSetting("forced_root_block", string.Empty)
          .AddSetting("force_p_newlines", false)
Feb 04, 2021 8:19

Will this make all blocks as inline?
If the requirement is to be able to inline only some of the blocks, the following works:

  1. Have an interface that implements IContentData, say IInlineBlock.
  2. Use this interface for the block types that will be inlined.
  3. Create an API controller that checks whether the block with a given contentId implements IInlineBlock.
  4. Create a TinyMce plugin that hooks 'BeforeSetContent' event and send a request to the new API controller. The callback function to this hook gets a parameter (e) which is an HTML code. The element (e.content) includes the contentId in data-contentlink attribute. Using this value, send a request to the newly created controller to see whether the block should be inlined. If so, replace the div tags with span tags in e.content.
  5. Register the TinyMce plugin in the TinyMce initialization module.

Sadly, I can't share the exact code.

Feb 05, 2021 10:22
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.