GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.95k stars 395 forks source link

Prevent an empty element from getting removed. #445

Closed wasinator closed 6 years ago

wasinator commented 6 years ago

First of all, I am aware of a similar closed issue (#180: 'Is there a way to set the default empty element for a region?'). My scenario is similar to the issue - A page title with a fixed format; I want only the text editable.

However, my approach is a little different. I patched the code to allow limited functionality on element that is given a class "edit-only". But when the content is removed it gets replaced by a default placeholder < p >. So I want to place a condition to prevent it if the element has the class. I have looked into the method '_preventEmptyRegions', but it seems the code gets run after the element got removed upon empty content, am I correct?

So I was looking for where in the code that the removal happens, but I can't seem to find the code bit. Would my approach work in this case? Please help.

Cheers, Wasin