1

Topic: paste_text_sticky / paste text clicked by default

Hi All

I've been searching around for a while now and would appreciate any help with this

"paste_text_sticky" is great as once I click the pastetext icon, when ever I paste anything in  it removes all the formating. If I want formatting I can click the paste word button.

I'd like to be able to do this by default so that the pastetext icon doesn't need clicking in the first place.

Any ideas on the best way to do this? I was thinking I could maybe simulate the icon being pressed but feel there must be a simpler way.

Either that or is there a way to use pastetext rather than pasteword as its default when pasteing directly.

Many thanks for any help received!!

M

2

Re: paste_text_sticky / paste text clicked by default

Isn't that already a functionality? "paste_text_sticky : true" in your init (just guessing, never tried it)?

3

Re: paste_text_sticky / paste text clicked by default

Thanks for the reply but that's not quite what this does.

Setting "paste_text_sticky : true" means that once you've clicked the "paste as text" icon this remains pressed until you press it again.

I'd like to be able to set this as the default so it doesn't need to be clicked.

Any ideas?

4

Re: paste_text_sticky / paste text clicked by default

I need this as well - how can it be done?

I tried something like:

tinyMCE.init({
...
});

for( edId in tinyMCE.editors ) 
{    tinyMCE.editors[edId].execCommand("pastetext");
}

But the array tinyMCE.editors seems to be empty at this point. So I tried:

tinyMCE.init({
...
setup : function(ed) 
        {    ed.onInit.add(function(ed)
            {    ed.execCommand("pastetext");
            });
           }
});

But this seems to have no effect at all. Then I tried:

tinyMCE.init({
...
setup : function(ed) 
        {    ed.onInit.add(function(ed)
            {    ed.controlManager.setActive("pastetext", true);
            });
           }
});

... which shows the pastetext-button as "pressed", but has no effect on the behavior of paste.

Any other ideas?

Last edited by wuschba (2010-04-14 17:25:05)

5

Re: paste_text_sticky / paste text clicked by default

Analysing the src of the paste-plugin this seems to be working:

tinyMCE.init({
...
setup : function(ed) 
        {    ed.onInit.add(function(ed)
            {    ed.pasteAsPlainText = true;
                ed.controlManager.setActive("pastetext", true);
            });
           }
});

tinymce.Editor.pasteAsPlainText isn't documented, so is it good to use it?

Last edited by wuschba (2010-04-14 17:49:09)

6

Re: paste_text_sticky / paste text clicked by default

Hi Wuschba

Thanks for you code - my initial tests indicate this works! - I'm going to try and not get too excited until I've done some more testing in various browsers. I'll do this tomorrow with fresh eyes!

It might not be documented, but its there and there is even the option to keep the icon pressed. So I'm guessing there is no problem with it.

There isn't a huge amount of documentation on any of the latest version of the paste plugin (http://wiki.moxiecode.com/index.php/Tin … gins/paste)

I'll post back tomorrow with my findings - fingers crossed as we've been trying for ages to make the  CTRL V default to plain text. None of our clients ever press the icon so this helps. I do think that the latest paste plugin handles paste from word really well but in most cases its easier just to make clients start from a clean slate.

If they are inclined to check the code works OK they can still use the paste from word icon.

7

Re: paste_text_sticky / paste text clicked by default

None of our clients ever press the icon so this helps.

Thats what I noticed as well: Everyone seems to write the text in Word and then Copy&Paste it into tinyMce, which always ends up in a mess. The new paste-plugin is much better in that, but setting the default to "plain text" is the best way I think.

8

Re: paste_text_sticky / paste text clicked by default

Yes we changed it too. Good modification! Paste Text should be enabled by default.

9

Re: paste_text_sticky / paste text clicked by default

I've tested this so far on IE7, IE8 and FF 3.59

The sripping it down to text works well on all browser, only slight issue would be that lists can stripped to the same line.

I have noticed another strange issue though. on ie7 and ie8 if you actually use the pasteword icon so it brings up the dialog box, it doesn't strip everything out. For it is still trying to add styles such as "<span style="font" ... etc

This seems to happen even if I don't do anything with paste sticky or use wuschba's code.

Could someone else check this on their install? does using the pasteword dialog do something different to paste V? (in IE)

I guess this wouldn't matter on a normal install as you could create it so that it doesn't show the icon. Does seem strange though as in the new paste plugin's documentation it uses the pasteword icon:

tinyMCE.init({
        theme : "advanced",
        mode : "textareas",
        plugins : "paste",
        theme_advanced_buttons3_add : "pastetext,pasteword,selectall",
        paste_auto_cleanup_on_paste : true,
        paste_preprocess : function(pl, o) {
            // Content string containing the HTML from the clipboard
            alert(o.content);
        },
        paste_postprocess : function(pl, o) {
            // Content DOM node containing the DOM structure of the clipboard
            alert(o.node.innerHTML);
        }
});

10

Re: paste_text_sticky / paste text clicked by default

I've tested this a bit more - tried re-insalling, using the above example initialise code and clearing my browser cache.

In IE6, 7 and 8 - If I click the pasteword dialog and paste there first it doesn't strip it as cleanly as if just go CTRL V.

It seems that with the latest paste plugin using tiny mce 3.3.2 the pasteworld dialog icon should be turned off completely.

For my usage it doesn't really matter. What I intend to do is not show the pasteword icon. I'll automatically activate and press the pastetext icon so most clients who use 'ctrl V' will just get everything stripped out.

If I or a more careful client need to use the pasteword features (so it doesn't strip everything out) I can just click the pastetext to de-activate it. Then go CTRL-V

11

Re: paste_text_sticky / paste text clicked by default

paste_retain_style_properties works good for me with pasteword. Just put everything in it you don't want to get stripped out.