Skip to content
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

Could the text transformation feature be used to auto-capitalize the first word in a sentence? #3144

Closed
Reinmar opened this issue Jun 27, 2019 · 0 comments · Fixed by ckeditor/ckeditor5-typing#209
Assignees
Labels
package:typing type:feature This issue reports a feature request (an idea for a new functionality or a missing option). type:question This issue asks a question (how to...).
Milestone

Comments

@Reinmar
Copy link
Member

Reinmar commented Jun 27, 2019

I think not, because it does not accept callbacks yet. But if it would, I think we could use it like this.

Regarding the callback – I see it either like this:

{
    from: /(^|\. )(\w)$/g,
    to: '$0$1',
    transform: ( match ) => {
       match[ 1 ] = match[ 1 ].toUpperCase();
    }
}

So the transform() function could only affect the matches object. This reduces its scope and perhaps might make it easier to implement.

But ideally, you should be able to pass a function as to:

{
    from: /(^|\. )(\w)$/g,
    to: ( match ) => {
       return match[ 0 ] + match[ 1 ].toUpperCase();
    }
}

But I wonder if this doesn't create some weird cases that we'd need to handle. Although, I can't think of any at the moment, so perhaps this is the best option.

@jodator jodator self-assigned this Jun 27, 2019
@Reinmar Reinmar changed the title Could the text transformation feature be used to auto-capitalize first word in a sentence? Could the text transformation feature be used to auto-capitalize the first word in a sentence? Jun 27, 2019
Reinmar referenced this issue in ckeditor/ckeditor5-typing Jul 9, 2019
Fix: Text transformations will not remove existing formatting. Closes #203. Closes #196.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-typing Oct 9, 2019
@mlewand mlewand added this to the iteration 25 milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:feature This issue reports a feature request (an idea for a new functionality or a missing option). type:question This issue asks a question (how to...). package:typing labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:typing type:feature This issue reports a feature request (an idea for a new functionality or a missing option). type:question This issue asks a question (how to...).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants