ContentTools icon indicating copy to clipboard operation
ContentTools copied to clipboard

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

Open koutsenko opened this issue 6 years ago • 8 comments

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?

koutsenko avatar Mar 02 '18 08:03 koutsenko

@koutsenko it sounds like you want to use fixtures:

<div data-fixture data-ce-tag="p">
    Enter content...
</div>

anthonyjb avatar Mar 02 '18 08:03 anthonyjb

@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.

koutsenko avatar Mar 06 '18 10:03 koutsenko

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.

anthonyjb avatar Apr 05 '18 13:04 anthonyjb

image

koutsenko avatar Apr 05 '18 14:04 koutsenko

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

anthonyjb avatar Apr 05 '18 14:04 anthonyjb

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

koutsenko avatar Apr 05 '18 14:04 koutsenko

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

anthonyjb avatar Apr 05 '18 14:04 anthonyjb

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

ghost avatar Jun 06 '18 14:06 ghost