angular-ui / ui-tinymce

AngularUI wrapper for TinyMCE
MIT License
488 stars 371 forks source link

Problem with links, next character being included into <a> tag #250

Closed guilherme6191 closed 8 years ago

guilherme6191 commented 8 years ago

Hello, guys. Thanks for the support!

I ran into an issue and I'm really struggling to find a workaround or solution. This might be wrong setup or maybe I am missing something. But so far, I think it's a bug.

I have this setup for TinyMce being applied in a Div (editable).

setup: function (editor) {
                forced_root_block: false,
                force_p_newlines: false,
                plugins: 'autolink link paste',
                valid_elements: 'a[href|rel|target=_blank],br,p',
                toolbar: false,
                menubar: false,
                statusbar: false,
                paste_auto_cleanup_on_paste: true,
                inline: true,
                default_link_target: '_blank'
            };

When I type a link in the div and press Enter, the next character, and also the
is included in the generated. It stays like this: <a href="http://www.google.co">www.google.com<br>a</a>sda</div>

If I type Space instead, it works fine.

Do you guys have an idea of what can be happening?

guilherme6191 commented 8 years ago

Plunker for that: http://embed.plnkr.co/Q89KMX/

deeg commented 8 years ago

It seems that the following option is the culpurit.

forced_root_block: false,

If you remove that setting, it seems to work correctly. Is there a reason you need that to be false? This seems like an issue with TinyMCE and not this library. I recommend you report this on their github if you need it to work with that setting enabled.

I am going to close as I don't believe this is a bug, but I am happy to continue the conversation here.

guilherme6191 commented 8 years ago

That setting is false because I didn't want <p> elements being created.

I found a workaround though. I took that forced_root_block setting out and styled the <p> elements so they'd have no margins. Also, to save the content, I used innerText so I won't get any HTML element.

Yeah, it might be TinyMCE issue, but I think it's a weird behavior, probably a bug.

Thanks for the support.