Reputation: 4089
I am trying to allow my users to paste content from word processors (MS Word, Open Office..) and have it process the garbage markup into valid html.
Here is a fiddle for my code: http://fiddle.tinymce.com/xLeaab
I want to preserve:
FYI - I've been looking at these questions on Stackoverflow as part of my current solution, however Im not the best with RegEx so Im having a hard time:
Upvotes: 18
Views: 15561
Reputation: 101
WordPress TinyMCE Users:
Dave's answer above solved my issue with this implementation in WordPress:
(using TinyMCE plugin and Advanced TinyMCE Configuration plugin)
Use the following TinyMCE Config overrides:
Name : Value
keep_styles : true
paste_retain_style_properties : true
Image: The settings page implementation
Big thanks to Dave.
Upvotes: 0
Reputation: 32490
I think I have it, Check Fiddle
Confirmed:
My changes:
1) commented out your paste_postprocess
(it was sanitizing styles)
//paste_postprocess: function(plugin, args) {
// args.node.innerHTML = cleanHTML(args.node.innerHTML);
//},
2) defined a set of paste_word_valid_elements
in init (the allowed list)
paste_word_valid_elements: "b,strong,i,em,h1,h2,u,p,ol,ul,li,a[href],
span,color,font-size,font-color,font-family,mark",
3) set paste retain style be to "all" (if you want to be selective, create a custom list)
paste_retain_style_properties: "all",
:
Fiddle Screen Shot
Upvotes: 25