-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Link requires protocol and gives no feedback (error message or otherwise) #44
Comments
👍 |
I see the problem, the problem is the pattern, that is this: If you put a letter and then ":" always works. The pattern should be corrected |
I reproduced this when integrating Trix into a project of mine as well. Excellent project, btw - very easy to work with and does exactly what it says on the tin. 👍 |
I think it's important to be able to create relative links. I was confused when testing the editor and tried entering "/contact-us" to see what happened and it wouldn't let me create a link. |
The link input is an Firefox doesn't appear to be affected and correctly highlights the field as invalid: If you want to change the element to allow any input, you could change it to a text field: input = Trix.config.toolbar.content.querySelector("input[type=url]")
input.type = "text" Customizing the toolbar like this is undocumented currently because it's likely to change, but it should work fine for now. |
@javan thx! |
I fixed up the invalid link input styles in the latest release, 0.9.1. |
It's still bad UX for an editor to not allow someone to type something more friendly like |
@philfreo, totally agree. I'd be happy to review a PR that improves things. |
What about using autolinker.js. It seems to work pretty fine. Maybe even easier would be to make this a plugin which makes links automatically as you type. So through the toolbar you have to enter a precise URL. But if you enter it in the text, like type it in, it auto-links it. |
When link created: clicking on it do nothing! Its possible to open link only via browser menu (right mouse click) |
since Trix has changed the suggested fix no longer works (the feedback works fine). here's how I did it const { toolbarElement } = event.target;
const urlInput = toolbarElement.querySelector('input[name=href]');
urlInput.type = 'text';
// Beware the double escape. since we pass regex as a string we have to double escape the backslashes
urlInput.pattern = '^((?:https?:\\/\\/)?[^./]+(?:\\.[^./]{2,})+(?:\\/.*)?)$'; |
In case somebody is interested. I'm using this to help the user and insert https:// for them:
|
Repro steps: on http://trix-editor.org, select some regular text and click the link toolbar button. Type “example.com” and hit ENTER. Observe that nothing happens. Prepending “http://” and hitting ENTER does create the link.
If a protocol is required, this should be explained or something should happen. Otherwise, the experience just feels confusing and broken.
The text was updated successfully, but these errors were encountered: