Redactor 2 -- swap enter and shift+enter functionality

  • For my forum, having the default enter insert a new paragraph tag breaks a custom functionality that most of my members use. This issue would be fixed if I could either prevent the paragraph tags altogether, or (preferably) swap the enter and shift+enter functions (so enter didn't do insert a paragraph tag, but a line break instead). Searching online didn't reveal much help for Redactor 2 (only Redactor 1, which wasn't giving me any trouble).


    Any thoughts?

    • Official Post

    The Enter/Shift+Enter keys are handled by the browser itself, the editor only listens for these keystrokes and performs cleanup tasks to unify the generated markup. Paragraphs are natively recognized by browsers and work best across the board, with a minimum amount of implementation issues, including rather precise selection handling when it comes to fancy formatting.


    Considering that we've forced paragraphs to masquerade as simple line breaks, how does this behavior have an actual impact on your users' experience?

  • The paragraph being a block level element breaks the functionality of Fancyposts. I've updated them to the newest version, I just have submitted an updated package.


    If I change Fancyposts to "represent a block level element" the issue is resolved, but then Spoilers don't work quite as one would expect. Perhaps there's a combination of settings I haven't quite hit on yet?

    • Official Post

    If I change Fancyposts to "represent a block level element" the issue is resolved, but then Spoilers don't work quite as one would expect. Perhaps there's a combination of settings I haven't quite hit on yet?

    Block-level elements are basically elements that span multiple lines and can legitimately contain more than one line/paragraph, such as a spoiler. Inline elements on the other hand affect only up to a single paragraph, usually found with text formatting (bold, color, etc.). This does however not affect how the elements are rendered at the end, but dictates how the parser should handles these tags during input processing. You can still force your formatting to appear as a block element during the output generation, but it would still appear as inline in the editor.


    Do you mind explaining to me, why you would need the block-level parser setting?

  • The BBCode for the Fancypost gets replicated for each new block level tag (I think?).


    This is the text the member types into the regular editor:

    Code
    [fancypost="background-color: #00FF00; height: 100px"]this
    is
    a
    fancypost[/fancypost]

    This is the code shown in the HTML Editor for the above text:

    Code
    <p>[fancypost="background-color: #00FF00; height: 100px"]this</p>
    <p>is</p>
    <p>a</p>
    <p>fancypost[/fancypost]</p>


    If the post is submitted, and then you click Edit for the post, it shows that the parser turned the above into this in the regular editor:

    Code
    [fancypost='background-color: #00FF00; height: 100px']this [/fancypost]
    [fancypost='background-color: #00FF00; height: 100px']is [/fancypost]
    [fancypost='background-color: #00FF00; height: 100px']a [/fancypost]
    [fancypost='background-color: #00FF00; height: 100px']fancypost[/fancypost]

    Which is shown as this in the HTML editor:

    Code
    <p>[fancypost='background-color: #00FF00; height: 100px']this
    [/fancypost]</p>
    <p>[fancypost='background-color: #00FF00; height: 100px']is
    [/fancypost]</p>
    <p>[fancypost='background-color: #00FF00; height: 100px']a
    [/fancypost]</p>
    <p>[fancypost='background-color: #00FF00; height: 100px']fancypost[/fancypost]</p>
    • Official Post

    I see, that certainly isn't what you're looking for, mostly because it is displayed right into the editor and is not hidden markup. That said, you definitely want the block-level functionality - may I ask what issues you ran into with the spoiler? They should work just fine with each other, so I'm a bit curious?

  • in wordpress , i have a similar problem with another plugin


    we change the <p> into <br/> inside the balise of the plugin. but no idea here , if it is possible or works

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!