We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43810
    • 62 Posts
    The reminder of what this question came from:

    In Evolution 1.0.14 adding / pasting as plain text:

    Text about something line one
    Text about something line two

    Results into:

    <p>Text about something line one</p>
    <p>Text about something line two</p>

    Right now in Revolution 2.3.2 adding / pasting as plain text:

    Text about something line one
    Text about something line two

    Results into:

    <p>Text about something line one"<"br /">"Text about something line two</p>

    (less-than and greater-than are without "" in real case, surely)

    -- How can one change it to be like in the Evolution TinyMCE?

    https://forums.modx.com/thread/95667/tinymce-problem-with-new-lines

    - In other words, the Evolution 1.0.14 default settings TinyMCE puts a line into <p></p> if there is one CR+LF or \r\n. But the Revolution 2.3.2 default settings TinyMCE requires two instances of CR+LF or \r\n for the same. Otherwise it puts just '<'br /'>' at the end of lines.

    It happens to be the paste_text_linebreaktype option of the TinyMCE paste plugin that handles the issue: http://www.tinymce.com/wiki.php/Plugin3x:paste

    So now the question is how to Create New Setting for the TinyMCE paste plugin option of paste_text_linebreaktype?

    I have never tried to do with Revolution anything like this before and all in all, I have only tried Revolution very lightly just a couple of times before. So I just imitated how it is done with other options of other plugins. And so I have no idea if I did it right, but it does work:

    ================================================================================

    1) Edit core/components/tinymce/tinymce.class.php , add to the section of /* now do user/context/system setting overrides - these must override properties */:

    'paste_text_linebreaktype' => $this->context->getOption('tiny.paste_text_linebreaktype',true,$this->properties),

    2) Edit core/components/tinymce/lexicon/en/default.inc.php (if the system language in English, otherwise edit the file from a different folder, not en), add:

    $_lang['setting_tiny.paste_text_linebreaktype'] = 'Paste Text Line Break Type';
    $_lang['setting_tiny.paste_text_linebreaktype_desc'] = 'Converts plaintext linebreaks to br or p elements. This can be set to br, p or combined.';

    3) MODX Revolution backend --> System Settings --> tinymce --> Create New Setting:

    Key: tiny.paste_text_linebreaktype
    Field Type: Textfield
    Name: setting_tiny.paste_text_linebreaktype
    Namespace: tinymce
    Description: setting_tiny.paste_text_linebreaktype_desc
    Area Lexicon Entry: cleanup-output
    Value: p

    Right click on the entry, which is going to be setting_tiny.paste_text_linebreaktype by name yet, then Update Setting and the name turns into Paste Text Line Break Type as intended.

    ================================================================================

    I would like to know if all this done in the right way - I could overpass something, there may be reefs of some sort.

    But anyway, my opinion is that this option should be in Revolution by default, by two main reasons:

    - End users of Evolution engined web sites, common-not-so-much-computer-folks are reluctant to migrate to something different in everyday work experience.

    - Very often it is very convenient to have it like one CR+LF or \r\n means a line in <p></p>. Since it is very often that end users prepare texts more or less untidy. Or copy texts from web pages. So texts must be cleansed before pasted into the MODX editor. Cleansed: mostly trimming leading and trailing space + removing empty lines. By hand or by a script. Removing unnecessary empty lines then deciding where there have to be necessary ones and then inserting them there - is too much bother. So it is just removing all empty lines and letting MODX rich text editor put every new line into <p></p>.

    It is my personal opinion and other individuals may have it different, but it is a detail serious enough and there better be a choice: "p", "br" or that indistinct "combined". [ed. note: viener last edited this post 11 years, 8 months ago.]
      • 49529
      • 196 Posts
      I think the best way is to create an issue in the TinyMCE repo - https://github.com/modxcms/TinyMCE/issues. Maintainers probably know the proper way of enabling this feature + it may be added to the future releases and let us do not reinvent the wheel every time.
        • 43810
        • 62 Posts
        Quote from: whitebyte at Jan 07, 2015, 10:11 PM
        I think the best way is to create an issue in the TinyMCE repo - https://github.com/modxcms/TinyMCE/issues. Maintainers probably know the proper way of enabling this feature + it may be added to the future releases and let us do not reinvent the wheel every time.

        - It is not an issue of or for TinyMCE. It is nothing wrong with setting paste_text_linebreaktype to "combined" by default. My idea is to have a setting option in System Settings of Revolution, letting to choose a value for paste_text_linebreaktype: "p" or "br" or "combined". Like there is one for forced_root_block, for example.