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

Automatically add a protocol to a link #4858

Closed
CepBoJIk opened this issue Sep 17, 2019 · 4 comments · Fixed by #7370
Closed

Automatically add a protocol to a link #4858

CepBoJIk opened this issue Sep 17, 2019 · 4 comments · Fixed by #7370
Assignees
Labels
package:link status:discussion type:feature This issue reports a feature request (an idea for a new functionality or a missing option).

Comments

@CepBoJIk
Copy link

Is this a bug report or feature request?

🆕 Feature request

The plugin should give an option for adding a protocol to a link automatically if a user doesn't provide it.


If you'd like to see this feature implemented, add 👍 to this post.

@CepBoJIk CepBoJIk changed the title Change url (add 'mailto:', 'http//', 'https// Change url (add 'mailto:', 'http//', 'https//' Sep 17, 2019
@Mgsy
Copy link
Member

Mgsy commented Sep 23, 2019

Hi, thanks for the report. I have talked with @mlewand and we consider it as a valid feature request. Currently, if a user doesn't provide a protocol, he won't be able to visit a link.

The question is how it should be implemented? It might be simply configuration option which allows adding a protocol by default if it's not provided.

cc @Reinmar @mlewand

Related - https://github.com/ckeditor/ckeditor5-link/issues/187.

@Mgsy Mgsy changed the title Change url (add 'mailto:', 'http//', 'https//' Automatically add a protocol to a link Sep 23, 2019
@CepBoJIk
Copy link
Author

Correct me if i wrong, now i have ability to add attributes using decorators, provide callback function and check url. Actually, i can change href attribute overwriting it, but i don't have access to url.
I think, it's can be pretty cool change url presonally, it will adds extensibility.
How do i see it? Maybe it's real to add ability provide function as attribute value, and first argument can be - { url: ... }

@Reinmar
Copy link
Member

Reinmar commented Oct 8, 2019

Interesting case, but I think that decorators can't handle this now and I'd like to keep that feature reasonably simple, not to duplicate things that you can do by using converters directly. Because, in fact, link decorators are sugar for converters.

There's a new guide (not published yet in the official docs) which you may find interesting. You can start here: https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/framework/guides/deep-dive/ui/conversion-introduction.html but the meat is here: https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/framework/guides/deep-dive/ui/conversion-extending-output.html#adding-a-css-class-to-certain-inline-elements. It's about adding classes, but you can probably imagine adding the protocols this way too.

This will happen on data retrieval only, so it's not perfect, but it's fairly quick.

The other option is to use a model postfixer to listen to attribute application in the model and just change the URL. This still isn't perfect, because it happens in a way that isn't transparent to the user, but it'll do the job.

@mlewand mlewand transferred this issue from ckeditor/ckeditor5-link Oct 9, 2019
@mlewand mlewand added this to the backlog milestone Oct 9, 2019
@mlewand mlewand added status:discussion type:feature This issue reports a feature request (an idea for a new functionality or a missing option). package:link labels Oct 9, 2019
@jodator jodator modified the milestones: backlog, iteration 33 May 27, 2020
@jodator
Copy link
Contributor

jodator commented May 29, 2020

Things to consider:

  1. Whether do it on UI or model level.
  2. Should be a opt-in feature.
  3. Which protocol to use https:// seems the most used now but quick research is welcome (another idea was to use current web page protocol but this might be tricky as it is not always the same as a link to an external page.

jodator added a commit that referenced this issue Jun 10, 2020
Feature (link): Introduced the `config.link.defaultProtocol` option for automatically adding it to the links when it's not provided by the user in the link form. Closes #4858.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:link status:discussion type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants