Jump to content
bcartier

TinyMCE - Paste as plain text by default?

Recommended Posts

I'd like to request that TinyMCE be configured to paste as plain text by default. This tends to save a lot of headaches with special characters coming in from Word and reduces support calls about the WYSIWYG ;-)

It doesn't seem like something I can override in the admin theme, but if I'm wrong please let me know the secret...

I found this example on stack exchange on how to do it:

tinyMCE.init({
...
plugins : "paste",
paste_text_sticky : true,
setup : function(ed) {
ed.onInit.add(function(ed) {
 ed.pasteAsPlainText = true;
});
}
....
})

Thanks!

  • Like 2

Share this post


Link to post
Share on other sites

In the Field setting screen of a TinyMCE field you can configure much if not everything. Tab "Input" you see the TinyMCE Advanced Configuration Options.

Add "paste" to the plugins string.

Add

paste_text_sticky: true
paste_text_sticky_default: true

to the Additional TinyMCE Setting field.

If you want to add it globally to al TinyMCE fields you could add following to the default.php in your admin theme.

Before closing </head>


<script>
// overwrite TinyMCE skin setting globally
// as defined in /wire/modules/Inputfields/InputfieldTinyMCE/InputfieldTinyMCE.js
// and loaded before
if('undefined' != typeof InputfieldTinyMCEConfigDefaults) {
 InputfieldTinyMCEConfigDefaults.plugins += ",paste";
 InputfieldTinyMCEConfigDefaults.paste_text_sticky = true;
 InputfieldTinyMCEConfigDefaults.paste_text_sticky_default = true;
}
</script>
  • Like 2

Share this post


Link to post
Share on other sites

Have you tried adding this to the "TinyMCE Advanced Configuration Options" - go to the field which has TinyMCE and look under the Input tab.

If that does not work you can also add the paste text button quite easily - pastetext

Also the paste word button - pasteword

  • Like 1

Share this post


Link to post
Share on other sites

I agree with bcartier, this should be the default behavior. I know that I can use ctl+shift+v, but try telling that to your clients :)

In this case, there could be a button to paste with formatting

Share this post


Link to post
Share on other sites

Thanks Soma, that's a great solution.

I tried out the field settings as you suggested and it works perfectly. I have yet to try the admin theme change but that should do the trick for future sites. If not the pw default, at least I can make it my own default :) .

Thanks again for you help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Eunico Cornelius
      I am trying to filter my $pages with a find($selector method). 
      $matches = $pages->find($selector); and this is an example of what my selector looks like
      $selector = "include=all, title|body~=$q, limit=50"; In this case, it only searches according to the matching exact words.
      For example:we search="art", the result="art times","these art",....
      Is there any way to search based on the alphabet?
      For example: we search="ab", the result="absolutely correct","abstract art",....
    • By hellomoto
      I have a Pages field with a PageListSelectMultiple input fieldtype, and I cannot limit it through the "custom PHP code" filter in its settings. I don't want hidden pages to be selectable, because the field is supposed to be to select pages to be included in a frontend menu. How can I do this? and it would be nice to be able to use the custom php code way to filter...
      Also, I cannot install, or activate, rather, TinyMCE. It's claimed to be compatible with 2.5... I install it, and when I try to activate it, without fail, it "activates" CKEditor, which is already activated by default, and installs its files into the /site/modules/ directory. TinyMCE is still in there, just inactivated and useless, being that there's no workaround to activating modules besides from the admin (that I know of, and it should work via the admin anyway). I also tried using BatchChildEditor (supposed to work with 2.5) -- don't seem to do anything when activated. I selected some settings and nada.
      Does anybody have any idea why I might be having these problems? I got all green for all the install compatibility checks...
    • By Thomas108
      Hi everybody,

      I am trying for a while now to display the alt tags as captions from images inserted via tinymce.
      I read this (and a few other) threads: https://processwire.com/talk/topic/1344-captions-for-images-in-tinymce/

      ... and I installed Adrian's tinymce-image-caption,
      but it didn't work at all for me.

      Then I installed Teppo's TextformatterImageWrapper,
      again no change in the frontend.

      Finally I tried Ryan's approach which is also mentioned in the linked thread above.
      https://github.com/ryancramerdesign/FoundationSiteProfile/blob/master/templates/scripts/main.js
      and again no change in the frontend output.

      The last days I felt like I fell in love with processwire, everything went very smooth, but today seems to be not my day.
      I have no clue what's wrong, maybe some pw (2.4.7) or php (5.4.32) version  problem? My template is valid html5.

      I just made a fiddle with ryans approach: http://jsfiddle.net/wqo4fk8o/10/
      Maybe someone can have a look and point me in the right direction?

      Thanks in advance,

      Thomas
    • By Kae
      Hey, guys!!!
      I'm having a very big problem with Tinymce in processwire. I feel so stupid about it, but can't find the solution. Hope someone can help me.
      When I change to html and paste html tags inside a <code> tag, they get converted and disapear. How can I avoid this?
      All Iwanted was to show some code examples. I feel so noob right now '-'
      Thank you =)
    • By gRegor
      Hello,
      I have built a form that allows authenticated members to submit articles through a front-end form. I was under the impression that 2 newlines would automatically be converted to paragraph elements, but I'm pretty sure that's incorrect as I re-acquaint myself with this aspect of PW.**

      Then I was thinking there was a TinyMCE configuration to convert newlines to paragraphs. There is, but I'm pretty sure that applies only during entry into the textarea, not when the text data is first loaded into the TinyMCE textarea.
      First, is there a built-in PW paragraph formatting function that I'm missing/forgetting?
      If not, would the "preferred" method to achieve this be using TinyMCE on the front-end form, so newlines are converted to paragraphs before the form is submitted and the page fields are stored? If so, can someone point me to an example of using the PW API to include a TinyMCE field input?

      Or would the preferred method be to process the raw input to convert newlines to paragraphs (through another module, or custom code) before saving the page fields?

      I'm aware there is an Auto Paragraph TextFormatter module, but I believe that only applies when the data is output — not when the data is shown in backend.

      Thanks for any assistance!

      ** I have confirmed that the newlines are stored in the database, so I've confirmed they're neither being removed nor converted.
×
×
  • Create New...