Trix: Doesn't allow partial link

Created on 25 Apr 2019  路  1Comment  路  Source: basecamp/trix

Doesn't allow route for e.g. "/profile" as href.

Steps to Reproduce
  1. Click text to convert to Link
  2. Try adding a partial link, it will fail
Details
  • Trix version: 1.1.1
  • Browser name and version: Chrome and 73.0.3683.103
    (Official Build) (64-bit)
  • Operating system: Mac

Screen Shot 2019-04-25 at 10 37 27 PM

Most helpful comment

The link dialog uses a standard <input type="url"> along with its default constraints (requiring an absolute URL). Absolute URLs make the resulting HTML more portable so I don't think we'll change anything to allow relative paths by default, but you could do so in your app. Here's an example:

addEventListener("trix-initialize", event => {
  const { toolbarElement } = event.target
  const inputElement = toolbarElement.querySelector("input[name=href]")
  inputElement.type = "text"
  inputElement.pattern = "(https?://|/).+"
})

>All comments

The link dialog uses a standard <input type="url"> along with its default constraints (requiring an absolute URL). Absolute URLs make the resulting HTML more portable so I don't think we'll change anything to allow relative paths by default, but you could do so in your app. Here's an example:

addEventListener("trix-initialize", event => {
  const { toolbarElement } = event.target
  const inputElement = toolbarElement.querySelector("input[name=href]")
  inputElement.type = "text"
  inputElement.pattern = "(https?://|/).+"
})
Was this page helpful?
0 / 5 - 0 ratings

Related issues

benzkji picture benzkji  路  3Comments

javan picture javan  路  4Comments

binchentx picture binchentx  路  5Comments

WhatFreshHellIsThis picture WhatFreshHellIsThis  路  4Comments

lanzhiheng picture lanzhiheng  路  4Comments