-
-
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 and family feature #638
Comments
I've also bootstraped a feature talks on Editor Recommendations repo: ckeditor/editor-recommendations#61. |
I'd like to propose implementation details. The feature should be developed in the dependency injection–friendly way (as in alignment feature bootstrap): Model and data
UI
|
☝️ @fredck & @oleq are welcome to comment :) Also as Font Family feature will be similar I'd probably use the output from this topic as a template for it. |
Is there a reason to have a separate command for each size? Why is it like this in headings? /cc @oleq |
@scofalik at first I thought that it must be this way to have parametrized commands. But obviously It might be as single commoand |
Yup. Separate commands mean modularity. Check out this discussion in ckeditor5-heading we had in the past. |
Just one note – the titles of these options will need go the same way as titles of heading and image style options – they need to be translateable. The goal is to allow developers to define this config option (so, define titles that will be used) but make the editor still use translations for them. See how it's done in the heading and image features. |
BTW, since it's the 3rd use case for such feature – maybe we can find some common part of it? Like "translate this object". |
ATM the heading feature localizes the We could bring some automatic translation but we would need to define what should be translated first, e.g. by defininig some syntax: getTranslatedObject( {
modelElement: 'paragraph',
title: '[t]Paragraph',
class: 'ck-heading_paragraph'
} ); The method would then recursively analyze all string values in the object, figure out which should be passed through Edit: Maybe |
I'm not sure if I understand your point @oleq, but we need explicit These |
You're right, I completely forgot. That would require lots of additional work :( |
I think it can be done easily. First, you generate a hash of available translations: const translations = {
'Bold': t( 'Bold' ),
'Do it!': t( 'Do it!' )
}; And then you pass it to this function as a dictionary: const translatedObject = translateObject( {
title: configItem.title,
message: configItem.message
}, translations ); This will use the translations when they are present in That's what the code does now. We just need a nice helper for that. |
I'd rather create |
I think that it's a bit tricky here:
We need to think how these two features (font family and font size) will be presented in the toolbar. The "Normal" label makes no sense for the dropdown's main button (imagine two "Normal" buttons next to each other ;)). So it seems that we need some icons for both of them. But then, do we also want to show the current size/family? Also, in terms of UI, we may consider a single dropdown for both these features but I'd rather go with separate ones to not overcomplicate the initial implementation. Especially, if we'll choose to have just normal, small icons in those dropdown's main buttons. |
Regarding the view element config defition, it could work somehow like below. Note that we may already have similar interfaces in some converter builders and this should be unified as much as possible. // Using presets:
config.fontSize = {
items: [
'tiny'
'small',
'normal',
'big',
'huge'
]
}
// Using presets (px values):
config.fontSize = {
items: [
10
12,
'normal',
16,
20
]
}
// Using full flavor:
config.fontSize = {
items: [
{
label: 'Tiny',
// Used as attribute name:
model: 'text-tiny',
stopValue: 10,
// Uses the ViewElementConfigDefinition interface:
view: {
name: 'span',
classes: 'text-tiny'
}
},
{
label: 'Small',
model: 'text-small',
stopValue: 12,
view: {
name: 'span',
classes: 'text-small'
}
},
// etc...
]
}
// Or:
config.fontSize = {
items: [
{
label: 'Tiny',
stopValue: 10,
view: {
name: 'span',
styles: 'font-size: 10px'
}
},
{
label: 'Small',
stopValue: 12,
view: {
name: 'span',
styles: 'font-size: 12px'
}
},
// etc...
]
} Also, the heading feature requires (see #651 and https://github.com/ckeditor/ckeditor5-heading/issues/72) alternative view forms for V->M conversion (so pasting works fine): // Or:
config.heading = {
items: [
{
label: 'Heading 1',
view: {
name: 'h2', // renders to that
alternatives: [
{ name: 'h1' } // but handles also that
]
}
},
{
label: 'Heading 2',
view: { name: 'h3' }
},
// etc...
]
} |
Completely agree, remember that we have also heading, so it's equal to 3 dropdowns in a row, it's too much for the toolbar.
IMHO displaying enabled type like in headings it's not necessary. We just need to properly present |
Guys, I've created separate issues for:
Please continue talks there (especially on UI part as this might take a while ;) ) |
I'm closing this one as ckeditor/ckeditor5-font#5 got merged. |
Why? When I try to add fontSize and linehieght in vue js it is not work? but for other it is work.
|
Similarly to the font feature I'd like to bootstrap works on font size feature.
Again this looks like another feature using configurable set of sizes but this also may be redefined. Any ideas and insights much appreciated.
The text was updated successfully, but these errors were encountered: