GetmeUK / ContentTools

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

Fixtures shouldn't allow shift+enter to create new paragraphs #481

Open koutsenko opened 6 years ago

koutsenko commented 6 years ago

I want to create single only editable element. I already set ContentEdit.PREFER_LINE_BREAKS to true;

But if user press Shift+Enter, he can anyway create another block, wrapped into p tag. It breaks selections, it requires a p tag styling etc.

How can i make Shift+Enter acts same as Enter? Or completely disable it?

anthonyjb commented 6 years ago

@koutsenko it sounds like you want to use fixtures:


<div data-fixture data-ce-tag="p">
    Enter content...
</div>
koutsenko commented 6 years ago

@anthonyjb , sorry for delay. I tried to add data-fixture attribute both to parent div and content p tag, and added test function to init method. Still can add new p tag via shift+enter. Where can i read docs about fixtures? Thanks.

anthonyjb commented 6 years ago

Can you use the following example to add a fixture (and make sure you're on the latest release):

<a
    data-ce-tag="p"
    data-fixture
    data-name="my-button"
    href="/test"
    class="button"
    >
    CLICK HERE!!!
</a>

If you can still insert new paragraphs using shift+enter then that would be a bug.

koutsenko commented 6 years ago

image

anthonyjb commented 6 years ago

OK That's not the intended behaviour - I'll mark this up as a bug. Thanks for the flagging :+1:

koutsenko commented 6 years ago

And please document it clearly somewhere ... Nothing about it in docs..

anthonyjb commented 6 years ago

@koutsenko agreed fixtures were added late on and are currently undocumented.

ghost commented 6 years ago

shift+enter don't add a new paragraph actually, but it create a line break

To me, it sound as a normal behavior, (it's possible you want to use line break in a fixture).

If you want to prevent line break in fixture, you could do something like that in CSS :

[data-fixture] br { display:none; }

Should do the job