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

feature: supports link on connections #1955

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

danielsuh05
Copy link
Contributor

Connections now support link: (fixes issue #1827)

Some notes:

  • Every single test file changed because all of the class names changed when adding link: "".
  • Links don't work yet on connections in PDFs, not sure exactly how to do that.
  • Check link-on-connections for the test I used.

Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what adding an empty <a> tag does. There's nothing for users to click and no indication it's clickable.

I was imagining something like this: link on the connection makes the label a hyperlink. So google here would be underlined and be in link-style blue (or purple if clicked). If there's a link and no label, the link becomes the label.

Screenshot 2024-05-29 at 2 21 40 PM

d2exporter/export.go Outdated Show resolved Hide resolved
ci/release/changelogs/next.md Outdated Show resolved Hide resolved
@danielsuh05
Copy link
Contributor Author

Oh I see what you mean. I was trying to figure out how exactly you wanted it implemented so I decided to do this for now and get a review. I'll work on it

@danielsuh05
Copy link
Contributor Author

Was this more what you were thinking?

Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

Comment on lines 1553 to 1555
if edge.Link != nil {
g.Edges[i].Label.Value = edge.Link.Value
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be in this function named set dimensions. probably in compiler.go.

Also the link shouldn't replace the label if there is one. The test should show an example of where the link turns the label into a hyperlink

d2renderers/d2svg/d2svg.go Outdated Show resolved Hide resolved
d2compiler/compile.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh also i think it's a security issue if the edge label is a URL and the edge link is a URL and they are not the same URL. can you make that a compiler error and add a test for it please? (i'm pretty sure we do this for tooltips and links or something already)

d2compiler/compile.go Outdated Show resolved Hide resolved
d2compiler/compile.go Outdated Show resolved Hide resolved
@huyz
Copy link

huyz commented Sep 2, 2024

Hi, what's the status on this PR?

@alixander
Copy link
Collaborator

Oops I did not realize the ball was in my court for reviewing. Sorry @danielsuh05 . I'm not sure if you've moved on. No worries if so I can take over, otherwise will leave a review ASAP

@huyz
Copy link

huyz commented Sep 5, 2024

I hope to see this soon. Links on connections are pretty important. They open up a lot of possibilities for letting diagrams act as jump points to, e.g., code.

@danielsuh05
Copy link
Contributor Author

I'm ok continuing with this issue.

@huyz
Copy link

huyz commented Sep 6, 2024

Thank you @danielsuh05 and @alixander!

Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you squash all the implementation commits into one and the test diffs into another? makes it easier to review to just see the diff for the implementation


the conflicts should just be a test rerun after rebasing master

d2compiler/compile.go Outdated Show resolved Hide resolved
d2compiler/compile.go Outdated Show resolved Hide resolved
d2compiler/compile_test.go Outdated Show resolved Hide resolved
},
{
name: "url_link_and_path_url_label_ok",
text: `x -> y note: {link: https://not-google.com}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the colon is not in the right place, should be x -> y: note {...}

},
{
name: "url_link_and_path_url_label_concurrently",
text: `x -> y: hello world {link: https://google.com}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same test as above?


fmt.Fprintf(writer, `<a href="%s" xlink:href="%[1]s">`, svg.EscapeText(connection.Link))
} else {
textEl.Fill = connection.GetFontColor()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is fill dependent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants