-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Handling variations of font-family notations and partial matches #2278
Comments
As for this I think that this is a case in which we have to decide if we want such behavior since it might be (or might be not) different values. Example: <span style="font-family:Arial, sans-serif">
<span style="font-family:Arial">
<!-- OR -->
<span style="font-family:Helvetica, Arial, sans-serif">
<span style="font-family:Arial,sans-serif">
<!-- OR -->
<span style="font-family:Helvetica, Arial, sans-serif">
<span style="font-family:Arial, Helvetica, sans-serif"> All above pairs looks for me as different font-family settings. |
The above 4 are also same. They should work as well. |
On Gitter you wrote:
That's because the following is not correct AFAIR:
Font names must be wrapped with quotes if they contain spaces. Am I right @jodator? I think you've checked this in the spec in the past? |
@Reinmar : Thanks for reply. Then should the font plugin convert |
@Reinmar yes, the font name that is multi-word that contains invalid characters must be wrapped in quoutes. taken from MDN: font-family: Gill Sans Extrabold, sans-serif;
font-family: "Goudy Bookletter 1911", sans-serif; and from specs:
so probably we do overlooked something here as I remembered that quotes must be defined. @gauravjain028: as for now if it does not match
Actually I've found that:
|
OK, it's clear that we need some additional work in order to properly match font names which weren't generated by CKEditor 5 (e.g. were pasted from other websites). This will help in some cases where content created outside the editor is injected into the editor. However, it's not out main goal at the moment to make the editor work with any HTML created anywhere. Our main goal is to make the editor compatible with itself – if you created some content in the editor you should be able to load it back to the editor. Also, this shouldn't be a problem for anyone that CKEditor 5 wraps font names in quotes. That's entirely correct and in terms of "data" it represents exactly the thing which the user wanted to do – it applies a specific font name. |
Wrapping fonts in quotes is not must but recommended. https://stackoverflow.com/questions/7638775/do-i-need-to-wrap-quotes-around-font-family-names-in-css |
I just wasted like 15 minutes trying to figure out what I'm doing wrong that the font styles aren't preserved. I thought that maybe the nested spans are a problem or maybe I made a typo or sth. Then finally I found this issue. The problem with unsupporting simple scenarios such as inline styles with font families without a space character after each comma is painful. It makes it impossible to reuse content created with CKEditor 4 using CKEditor 5:
It was pretty hard to understand WTF considering that CKEditor 5 allows you to configure styles without a comma
Supporting the syntax that CKEditor 4 produced is a must have IMO. In other words, we don't have to solve all possible variations at once (e.g. try to resolve partial matching), let's just try to cover CKEditor 4 backwards compatibility first. |
Is this going anywhere? It would be great to interpret the basics of font size and type from other sources... Could you please show where this parsing is done in the code? I would like to see if I can put together a hack that deals with a couple of my specific use cases. |
@statler You can check the configuration of conversion for font here (by logging it): https://github.com/ckeditor/ckeditor5-font/blob/master/src/fontsize/fontsizeediting.js#L54. The converter definition is build here: https://github.com/ckeditor/ckeditor5-font/blob/master/src/fontsize/utils.js#L105 (for pixel sizes). Might be a similar case: #1389 (comment). So depending on the output of other sources you might need to update how For font family it might be a bit harder due to issue mentioned in first comment. |
Just to put my opinion, the last two are different, but the first should match, because the main desired font is the same, the others fonts are fallback fonts. At least this is how I see it. |
To sum up what we can do here now:
|
Feature: Introduced an option for both `FontSize` and `FontFamily` plugins that allow preserving any `font-family` and `font-size` values when pasting or loading content. Closes ckeditor/ckeditor5#6165. Closes ckeditor/ckeditor5#2278.
When working on the initial implementation of the font family feature @jodator implemented a regexp-based solution which made the editor accept content like:
Such content cannot be produced by the editor but it may pasted from outside of the editor.
During the review we decided to ignore such cases for now. The reasoning is that the editor should only be able to handle data which it produced for now and the whole spectrum of mismatched font name values is much wider:
(source: ckeditor/ckeditor5-font#5 (comment))
We need to understand which cases we should handle. Also, the "how" and "where" questions need to be answered.
The text was updated successfully, but these errors were encountered: