• Resolved meushar

    (@meushar)


    In all forms within the Job Manager space (submit company, resume, job,..) the editor has a ‘preformatted” option to paste text.

    This does not preserve the formatting on paste, and further loss occurs on saving

    This is a very important need as most users paste the descriptions from PDF or WORD files.

    How can I fix this??

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Cara

    (@dcka)

    Hi, @meushar! Can you let us know more about what you mean by this?

    the editor has a ‘preformatted” option to paste text.

    I tried to view the link you shared, but I got the following message: “Sorry, but you do not have permission to view this content.”

    In any case, by default, pasting text into WP Job Manager forms does not apply any previous styling. We have an open feature request for rich-text styling here:

    https://github.com/Automattic/WP-Job-Manager/issues/2076

    There’s also some code there that may help you, but please be advised that we cannot support the code on that page. You would be using it at your own risk.

    Thread Starter meushar

    (@meushar)

    Hi Cara

    Thanks for the reply.

    With the error even if preformatted was selected prior to pasting, the formatting was lost.

    I added the following to my functions.php file and it solved the issues. It also gives me more options on the editor controls.

    add_filter('tiny_mce_before_init', 'custom_tinymce_settings');

    function custom_tinymce_settings($initArray) {

    ? ? $initArray['toolbar1'] = 'bold italic underline strikethrough superscript ?subscript | bullist numlist | outdent indent ?| link unlink | alignleft aligncenter alignright alignjustify | removeformat ';

    ? ? $initArray['toolbar2'] = 'formatselect fontselect fontsizeselect';

    ? ? $initArray['toolbar3'] = 'cut copy paste | undo redo | forecolor backcolor';

    ? ? $initArray['content_css'] = get_template_directory_uri() . '/css/custom-editor-styles.css'; // Custom styles for the editor

    ? ? // Preserve line breaks

    ? ? $initArray['wpautop'] = false; // Prevents automatic paragraph tags around content

    ? ? $initArray['forced_root_block'] = ''; // Prevents wrapping content in <p> tags by default

    ? ? // Enable and configure paste plugin

    ? ? $initArray['plugins'] = 'paste'; // Ensure paste plugin is enabled

    ? ? $initArray['paste_as_text'] = false; // Allows rich text to be pasted with formatting

    ? ?// $initArray['paste_enable_default_filters'] = false; // Disable TinyMCE's default paste filters

    ? ? // Configure TinyMCE to allow preformatted text

    ? ? $initArray['preformatted'] = true; // Allows preformatted text, keeping spaces and tabs intact

    ? ? $initArray['force_p_newlines'] = true; // Forces new lines to be preserved as paragraphs

    ? ? $initArray['remove_linebreaks'] = false; // Prevents TinyMCE from removing line breaks

    ? ? // Clean up symbols and formatting from Word

    ? ? $initArray['paste_word_valid_elements'] = "b,strong,i,em,ul,ol,li,p,br,h1,h2,h3,h4,h5,h6";

    ? ? $initArray['paste_remove_styles'] = true; // Strip inline Word styles that may include special symbols

    ? ? $initArray['paste_retain_style_properties'] = ''; // Remove any unwanted style properties on paste

    ? ? // Allow all HTML tags (optional)

    ? ? //$initArray['valid_elements'] = '*[*]'; // Allows all HTML tags and attributes

    ? ? $initArray['extended_valid_elements'] = 'pre[class|style],p,br,b,strong,i,em'; // Extend to specific inline tags if needed

    ? ? return $initArray;

    }
    Plugin Support Cara

    (@dcka)

    @meushar I’m glad you found code that works for what you need. I really appreciate you reporting back too because your code just might help others. Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.