GetmeUK / ContentTools

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

Content is prefixed with ... if trying to set content on empty region with setContent #417

Closed dirkjacobs closed 7 years ago

dirkjacobs commented 7 years ago

Editor is in edit mode and we have an empty region.

When content of this region is set by means of setContent, the content data will be prefixed by means of ellipsis ...

(see screenshot)

image

dirkjacobs commented 7 years ago

Seems like when setting the content of an empty region (with setContent), there was a check before or after to check for empty regions who is adding automatically a paragraph tag.

I think when setting the content of a region, with setContent (nono-empty), the whole content of the region should be replaced and the paragraph with ellipsis shouldn't be there no longer

anthonyjb commented 7 years ago

Hi @dirkjacobs,

There's not a public interface for this currently but as a suggestion as to how you might resolve this here are a couple of approaches to disabling this behaviour.

If you want to disable this behaviour (e.g the prevention of empty regions) you can set a flag against the editor like so:

ContentTools.EditorApp.get()._emptyRegionsAllowed = false

Alternatively if you just want to disable it for a given set of instructions you can do the following:

ContentTools.EditorApp.get()._allowEmptyRegions () ->
    # Do something here with the prevent empty regions behaviour disabled...