Opened 6 years ago

Closed 6 years ago

#10684 closed Bug (invalid)

Paste from Word leaves margin attribute

Reported by: santaclaus21 Owned by:
Priority: Normal Milestone:
Component: Core : Pasting Version:
Keywords: Cc:

Description

So, I'm trying to use "Paste from Word" for copy html from web browser directly (leatest chrome).

I have used:

config.pasteFromWordRemoveFontStyles = true; config.pasteFromWordRemoveStyles = true;

but,

first: sometimes in html source I can see font size (!) with long fraction and px - even if source had defined it in "em".

second: code contains margin definition (eg. "<p style="margin-left:10px;">[...]</p>")

conclusion: I need only to copy clear html code, with strong, underline etc. without ANY STYLES and CLASS. Paste from Word gives not exactly what I need, "Paste as plain text" also (no strong, italic and underline)..

Any help? :)

Change History (1)

comment:1 Changed 6 years ago by Jakub Ś

Resolution: invalid
Status: newclosed
Version: 4.2

This isn't bug in editor.

  1. If you want to disallow certain attributes permanently (not only on paste) use ACF:

http://ckeditor.com/blog/Upgrading-to-CKEditor-4.1
http://ckeditor.com/blog/CKEditor-4.1-RC-Released
http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter
http://docs.ckeditor.com/#!/api/CKEDITOR.filter-method-addTransformations
http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-allowedContent
http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-extraAllowedContent

  1. If this is only about pasting HTML you could use paste event:
    CKEDITOR.replace( 'editor1', {
    	on: {
    		paste: function() {
    			event.data.dataValue = ...;
    		}
    	}
     } );
    

You could use regex to filter and create new HTML. Property event.data.dataValue holds pasted HTML you can modify it assign new value to it.

  1. I wouldn't recommend changing pasteFromWord filter to get what you want.
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy