-
Notifications
You must be signed in to change notification settings - Fork 28
Allows keeping values for font-size/family when pasting #61
Conversation
…eeping fonts that are not defined in the plugins configuration.
…e kept as units instead of preset names.
@Reinmar, what should we do if a user used this new option in the |
A few tests fail, trying to fix that. |
src/fontfamily/fontfamilyediting.js
Outdated
@@ -49,7 +49,8 @@ export default class FontFamilyEditing extends Plugin { | |||
'Times New Roman, Times, serif', | |||
'Trebuchet MS, Helvetica, sans-serif', | |||
'Verdana, Geneva, sans-serif' | |||
] | |||
], | |||
disableValueMatching: false |
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.
TODO find a better name.
editor.conversion.for( 'downcast' ).attributeToElement( { | ||
model: FONT_FAMILY, | ||
view: ( attributeValue, writer ) => { | ||
return writer.createAttributeElement( 'span', { style: 'font-family:' + attributeValue }, { priority: 7 } ); |
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.
Why priority 7?
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.
OK, it was needed to correctly sort the font color and font family and font size styles so they render in a visually correct way. But we need a test for that. Most likely, such a test exist for the previous converter, so it's a matter of copying it.
docs/features/font.md
Outdated
@@ -47,6 +47,25 @@ ClassicEditor | |||
|
|||
{@snippet features/custom-font-family-options} | |||
|
|||
### Prevent removing non-specified values | |||
|
|||
By default, all not specified values of `font-family` are removing during the conversion. You can disable this behaviour using `disableValueMatching` option. |
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.
By default, all not specified values of `font-family` are removing during the conversion. You can disable this behaviour using `disableValueMatching` option. | |
By default, all not specified values of `font-family` are removing during the conversion. You can disable this behaviour using `disableValueMatching` option. |
Suggested merge commit message (convention)
Feature: Introduced an option for both (
FontSize
andFontFamily
) plugins that allow keeping font-family and font-size values when pasting a text. Closes ckeditor/ckeditor5#6165. Closes ckeditor/ckeditor5#2278.Additional information
TODO: Enable the features in "Paste from ..." demos.