We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1343 ☆ A M B ☆
    • 2,213 Posts
    Hey,

    I saw tinymce in use somewhere and it was setup so when you try to paste text (ctrl+v) it opens the plain text dialog box thus forcing the user to paste new text as plain text.

    How can I get this setup with modx?

    Thanks
    AMDbuilder
      Patrick | Server Wrangler
      About Me: Website | Tweets |  MODX Hosting
      • 25663 MODX Staff
      • 12,272 Posts
      You’d have to find the plugin first at the Moxie Code forums I’d think, then just drop it in the appropriate folder for Tiny. That’d be super handy for all those MS Word-lovin’ clients indeed!
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 1774
        • 34 Posts
        This seems to be it, but I’m not sure where this code should go...

        http://tinymce.moxiecode.com/punbb/viewtopic.php?id=10967
          Brandon Booth
          Freelance MODx specialist for hire: site construction, template conversion, snippet customization.
          Lucidgreen.net Websites made simple.
          • 3749
          • 24,544 Posts
          Quote from: anselm1109 at Jan 10, 2009, 06:15 PM

          This seems to be it, but I’m not sure where this code should go...

          http://tinymce.moxiecode.com/punbb/viewtopic.php?id=10967

          I think that code is just to allow you to paste with Ctrl-V. It wouldn’t paste plain text unless you changed the ’Paste’ to the Tiny ExecCommand for plain text paste.

          Looking at the TinyMCE code, I see that there are two execCommand arguments that might do the trick:

          execCommand('mcePasteText')
          execCommand('mcePasteWord')


          I’m not sure where that code would go. You might want to poke around in this directory:

          assets/plugins/tinymce####/jscripts/tiny_mce/plugins/paste

          Where #### is the version of TinyMCE.

          You probably know this but, IIRC, there’s a way to have "Paste from Word" as an option on the edit menu in TinyMCE. I don’t remember how to do it though.

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 3749
            • 24,544 Posts
            Ok, I looked a little further and here are the instructions for adding "Paste Text" and "Paste from Word" buttons:

            http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste


            I tried to find a way to convert the regular paste command to "PasteText" or "PasteWord," but it looks like those two are handled directly from the buttons without using the regular paste sequence. I’m not at all familiar with TinyMCE code, so I could be wrong, but I couldn’t see any safe place place to make the switch.

            This code looks like it would work to make Ctrl-V paste plain text (PasteText could be changed to PasteWord):

                          
            
                          if (e.ctrlKey && e.keyCode == 86 && e.type != "keyup") {
                                if (e.preventDefault) {
                                   e.preventDefault(); // DOM style
                                   setTimeout('tinyMCE.execInstanceCommand(\"'+e.target.editorId+'\", \"mcePasteText\", true)',1);
                                } else {
                                   tinyMCE.execInstanceCommand(e.target.editorId, "mcePasteText", true);
                                   tinyMCE.cancelEvent(e);
                                   return false; // IE style
                                }
                            }
            


            It’s an added event handler and someone with more experience with TinyMCE would have to tell you where to put it. If I had to guess, I’d put it just above the switch statement in the handleEvent function in the file assets/plugins/tinymce####/jscripts/tiny_mce/tiny_mce_src.js (around line 1134 in the version I have). It will handle Ctrl-V but won’t affect the regular TMCE paste process.

            I think you might also have to do something to make TMCE load that file instead of the compressed src file.

            Hope this helps.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 16610
              • 634 Posts
              One easy but not flawless solution is to add
              paste_auto_cleanup_on_paste : true

              on TinyMCE plugin Custom Parameters (Resources > Plugins > TinyMCE > Configuration).

              From http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste:
              [paste_auto_cleanup_on_paste] MSIE specific option. If you enable this feature, a word paste will be executed when the user copy/paste content to the editor. This feature is disabled by default.

              This forces Ctrl + V to use word paste in Internet Explorer and in other browsers pressing Ctrl + V brings up the plain text paste pop-up window.
                Mikko Lammi, Owner at Maagit
                • 3749
                • 24,544 Posts
                Quote from: Lammikko at Jan 11, 2009, 02:32 AM

                One easy but not flawless solution is to add
                paste_auto_cleanup_on_paste : true

                on TinyMCE plugin Custom Parameters (Resources > Plugins > TinyMCE > Configuration).

                From http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste:
                [paste_auto_cleanup_on_paste] MSIE specific option. If you enable this feature, a word paste will be executed when the user copy/paste content to the editor. This feature is disabled by default.

                This forces Ctrl + V to use word paste in Internet Explorer and in other browsers pressing Ctrl + V brings up the plain text paste pop-up window.

                Browser’s other than IE do want to pop uo the window. That’s what the if statement in the code above is for -- to make other browsers act like IE on Ctrl-V.

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting