-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve bold text when pasted #459
Conversation
@@ -57,9 +57,10 @@ class Normalizer | |||
node.removeAttribute(attribute) | |||
) | |||
# Chrome turns <b> into style in some cases | |||
if (node.style.fontWeight == 'bold') | |||
if (node.style.fontWeight == 'bold' or node.style.fontWeight > 500) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to > 400? Technically a font-weight of 500 is also considered bolded.
After some reading I am not sure that > 400 is correct. From https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#Fallback:
Therefore I think CSS specs agree: |
You are correct thank you for looking into it and the PR. |
I'm running into this issue now. I have text in word, and some of it is bolded, when I copy and paste it the bolded text reverts to normal. I'm running on 0.20.0. So this fix failed and is not apart of 0.20.0, now what? I can type in to the editor 'This is BOLD text', and save and the bold shows. Then I copy and paste the resulting html in a This is what the saved 'This is BOLD text' looks like:
|
Here's a little more background on what I'm seeing: I'm using Quill Editor to provide rich text editing into my application. I'm also using clipboar.js to copy this text to the clipboard. In mongo when I save off a simple edit session, it looks something like this:
Using Meteor Blaze and Handlebars my code to target this html looks like this:
I also have code to allow me to see what is copied to the clipboard:
When I copy the text to the clipboard, all I see in this example is this in the console:
So when I copy this text from the clipboard to Word, the word BOLD is bolded, but if I copy this from the clipboard back into Quill editor, all the formatting and any color stays, but I loose the bold in the BOLD text. Also, any tips on why the formatting stays when copying to Word but not when I try copying to the Quill Editor. Edit: I'm using ClipMate to see what's actually copied to the clipboard. I have contents in Binary format to see the formatting. Just focusing on the BOLD text element, I see this in the binary:
But when it's copied into Quill, the |
After further research. The bold seems to be working in FF but not in Chrome. I have another example... This is the underlying HTML that clipboar.js is suppose to be copying to the clipboard:
Of course if you look at the text property in Clipboard, the text just looks like so: ** *_Bold Text_* **, but the underlying embedded HTML comes along with it on the clipboard. When I copy from Chrome rich-text (with embedded HTML) to the Quill Editor with clipboar.js, looking at the binary of the clipboard, the bolded text has this for embedded HTML:
In FF the binary for the text looks like this:
In Chrome the *** Bold Text *** is not bolded, in FF it is. This is the mongo field saved from Quill when in Chrome:
Here, the This is the mongo field saved from Quill when in FF:
|
First this PR addresses an issue where Quill loses bolding pasted within itself. Word is out of scope of this PR. That being said it still seems to work. If I copy bolded text or a sentence with bolded words from Word 2016, the formatting stays when pasted into Chrome on the quilljs.com editor. I'm not clear on what interaction there is between clipboard.js and Quill but if you can reduce and reproduce the issue outside of Meteor and clipboard.js, you should make a separate Github issue with reproduction steps. |
Fixes #306