steveathon / bootstrap-wysiwyg

Tiny bootstrap-compatible WYSIWYG rich text editor
MIT License
661 stars 1.71k forks source link

I want to change the tag when paste text from outside #26

Open charles-zh opened 9 years ago

charles-zh commented 9 years ago

The editor is really nice. When I copy/paste text to this editor, every paragraph was converted to "span" tag and add "style" attribute.

paste demo: Transactions are not supported on MySQL's default table convert to: --span-- style="color: rgb(34, 34, 34); font-size: 15px; line-height: 15.6000003814697px;" Transactions are not supported on MySQL's default table --span-- -- is <> I do not want to get this result. But I can not found any code/config related to this behavior. I want set

tag for every paragraph. Is this the default result when paste to editor? How can I change it?

Thanks!

codewithtyler commented 9 years ago

This is not the default behavior for the editor. I tested using Firefox 37.0.2, Chrome 42.0.2311.135, and IE 11, but when I paste that same text into the editor, no inline CSS is added to the document. What browser are you using? Also, how are you setting up the editor? If you could provide some of your HTML and JS we might can help you out with your situation.

charles-zh commented 9 years ago

Thank you for your reply. I test again using chrome/firefox/IE, and change to another computer. I'm not changing anything in editor. I just download from here and use the default configuration.

The test result: 1: If I copy some text within a single paragraph, the editor will use "span" tag. (Press F12 to check the element tag in chrome) 2: If I copy multiple paragraphs from a text and those text contain "p" tag, the editor will use "p" tag. If those text just using "br" to split multiple lines, the editor use "span" tag again. 3: All results in editor will add "style" attribute whatever browser or computer.

Update: I opened editor using IE11 in a test OS within vmware, and editor does not add "style", why?

codewithtyler commented 9 years ago

What version of the browsers are you using on your main computer? It could be that in the newer versions each company changed how they handled pasting text into an input. This would explain why the style tag is not added in IE11, but would be in IE10.

charles-zh commented 9 years ago

Main computer: IE version: 11.0.9600.17728. Update version: 11.0.18 Chrome version: 42.0.2311.135 m Firefox version: 34.0.5

Test browser in Vmware: IE : 11.0.9600.17041 Chrome: 42.0.2311.135 m (more weird: this browser will add "div" tag for paste text and does not add inline "style")

timkley commented 9 years ago

+1

This really bugs me, too. This even occurs when copy-pasting from the same instance in Chrome. All the HTML-styles are added as inline-styles. If you later try to ouput the generated HTML it of course doesn't look like the original input because these styles.

There should be a config which allows you to strip all inline styles and only use paragraphs. Because sometimes the editor uses empty DIVs with
to generate "paragraphs".

spreadred commented 7 years ago

Inline styling is still automatic in IE11, Chrome 57.0.2987.133, and Firefox 52.0.2.

@RandomlyKnighted @steveathon This is the intended behavior, correct? Is this issue about added functionality to have an option to paste formatted text as plain text?