-
-
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
Implement font size editing plugin #2275
Comments
Starting from proposed configuration: config.fontSize = {
items: [
{
label: 'Tiny',
// Used as attribute name:
model: 'text-tiny',
stopValue: 10,
// Uses the ViewElementConfigDefinition interface:
view: {
name: 'span',
classes: 'text-tiny'
}
},
// Using styles:
{
label: 'Small',
model: 'text-small',
stopValue: 12,
view: {
name: 'span',
styles: 'font-size: 12px'
}
}
]
} I'm thinking is defining sizes in pixels the only way to define sizes (I'm pretty sure that it is not the best way). A bit better in my opinion behaves relative sizing using
Also the CSS font-size property might accept other values as well. The model-to-view is rather straightforward - take the defined size and that's it. The harder part is when loading existing markup to the editor and how to translate those (especially relative) values into model's attribute value. |
IDK if this is a correct issue as there is a few of them, but, AFAIU, |
@scofalik yeah it's a main problem for me with this feature - how to convert those values and do we want to support them? Probably I'll do some research on this if we can use calculated values somehow. |
We can't convert them reliably if we get However, this isn't crucial. We never supported that cause it was never possible. I wouldn't also worry here. Actually, we may not even have stop values initially. I might've gone a bit too far with that. It's an option that we can test a bit later, unless you already have it implemented :D |
@Reinmar I havn't implemented that yet but maybe if we put emphasis that default values should be relative then we could calculate those values somehow. In my fiddle on this is rather simple case with getting class name based on relative font size. It might fail with default size (normal size) but this is something that I might dig into more. |
You can't get computed styles during pasting or data loading. That's the problem here. We might do that inside the editor, when the content would already be there, but it'd be crazy. We'd need to allow such content into the editor first and post-fix those values after that. Besides, if you get |
Thinking more on this:
|
As for the feature defaulting to One thing's for sure – in many cases people will expect So, perhaps our default styles for the |
So I'm going to present predefined presets that will cover both:
|
BTW shouldn't numerical values have labels as values as well? config.fontSize = {
items: [
{
label: '10',
// Used as attribute value:
model: '10',
stopValue: 10,
// Uses the ViewElementConfigDefinition interface:
view: {
name: 'span',
styles: 'font-size: 10px'
}
}
]
} Also second question as I've missed that earlier from @Reinmar's configuration that
Shouldn't this be model's attribute value? I mean that the FontSize feature would operate on attribute named From description I would assume attribute named I'm rather for |
Hmm.. I thinking about presets for numerical values, and it would be actually a generator: config.fontSize = {
items: [
10,
11,
12,
13,
'normal',
15,
16,
17,
]
}
// somewhere in order to not have those values defined anywhere
function generatePixelConfig( size ) {
return {
label: String( size ),
model: size,
stopValue: size,
view: {
name: 'span',
styles: `font-size: ${ size }px`
}
}
} This would give users a flexibility in configuration and we would not have to define "deafult" (but still very opinionated) set of presets for |
As works for conversions helpers and view definitions are undergoing let's drop |
I also don't like this value. I think that we may let people define numberic values of each sizes ('large': 42) or how to converted relative to absolute units (em to px), but the font size feature should take case of finding the best size to be used if one paste the content with a not supported size. |
Feature: The initial font feature implementation. Closes #2. Closes #3. Closes #4.
Please my ckeditor loads the smallest font as the default, how do i change the default font to "big" or "huge"? |
Implement a Font Size editing plugin as part of ckeditor5-font plugin.
This issue gathers mostly requirements for editing part of that feature:
fontSize
attributes should be enabled in all contexts like paragraphs, headings, etc (so probaly inside Image caption also) (if not please comment /cc @Reinmar )The text was updated successfully, but these errors were encountered: