-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Links do not work for mscgen.js in chrome and IE #244
Comments
@daledude thanks for raising this. This issue seems to occur in Chrome only - in Firefox & Safari links in the svg still work as expected) - I'll dive into it. => Is Chrome the browser you're using? |
I should have put the browsers I tested. Chrome 57.0.2987.110 and MS Edge 38.14393.0.0. Slightly off topic. It would be useful if the link didn't open in a new window since I use anchors to scroll to the id's on the current page outside the svg. As a test the below works as intended.
|
Or an onClick would be useful. |
Thanks for the browser versions - I've confirmed on IE11 as well. Weirdly:
onClickI'll look into that as well. What would you use it for? open in 'new window'About that open in 'new window' (xlink:show): ouch 😬 I'll remove that a.s.a.p. Seemed like a good idea back in the day, but I agree that it's actually super annoying. |
@daledude a small update:
|
Thanks! I think it's a problem of these browsers not handling nested xlinks. A simple test below shows the links outside the "use" tags work but linked from the "use" do not. Or there is something overriding their events. I haven't been able to find anything specific to this due the words needed to search google for it!
|
The reason for the onClick request is that's what I currently use in mscgen generated svg's. I "hack" the svg with javascript to replace the links so it will call my javascript function. My javascript function in turn smooth scrolls to the anchor on the page. At the moment it's useless since it doesn't work within a "use" tag either. But, once the problem with the link is resolved I can use the #id syntax instead. Thanks for taking the time. |
Maybe this part of https://www.w3.org/TR/SVG2/linking.html#Links is relevant. Not sure if it just means nested a elements or any element that has an href.
|
The problem for chrome & IE definitely lies in the construction with I have a working proof of concept that wraps the The permanent solution is probably to restructure the svg to not use Strangely, both chrome & IE do recognise the links, and are able to follow them (left-click => open link in new tab/ open link in new window work fine for both). Bug or not I'm not going to hold my breath for Google & Microsoft to fix it. B.t.w.: Thanks for your prompt feedback & helpful additions. I really appreciate that. |
I was going to propose just in-lining the "use" sections. You would know better than I the pro's and con's of doing that. I've spent quite awhile trying to find something related but haven't. The closest was a jquery ticket about attaching click events. https://bugs.jquery.com/ticket/13180 Thanks for the effort you have put in for this! |
Inlining (replacing the I'll probably do the simple fix first and the refactoring later. I've tried to parse the w3c document as well - it seems it only forbids nesting real links which totally makes sense ( |
The simple fix started to get very hacky, so I'm refactoring the graphics renderer to 'inline' elements. I've done the entities and I like the result. The links work and the rendered svg snippet with the entities is a lot easier to read. I hope I can do the arcs this weekend... |
Looking forward to using it. Thanks again for all the effort! Will be nice to replace mscgen and my hacks to its output. |
@daledude Incidentally I've just finished development. If you want to, you can test it - I've deployed it on a feature branch on mscgen.js.org - let me know what you think.
These links will work for a few days - until I've made a release (I hope to do that tomorrow - if there's no regressions) |
Almost rick rolled... Seems to work good. #id scrolls to anchors. http://... loads url. Off topic...is there a way to customize the Named Styles without modifying the code? |
👍 @ customizing named styles - yes and no
This said, I'm interested in what type of customizations you want to make. Maybe I can make things more customization friendly (and maybe the customizations you have are useful for others as well). <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>mscgen.js style tweaking sample</title>
<script src="https://mscgen.js.org/mscgen-inpage.js" defer></script>
<!--
available entities and classes
- `svg, line, rect, path, text`
- `rect`: `.entity .box .rbox .inline_expression .label-text-background
.bglayer`
- `line` and `path` (for selfs): `.arc .directional .nondirectional,
.bidirectional .signal .method .return .callback .lost .emphasised`
- `line` and `path`: `.box`
- `line` only: `.comment .inline_expression_divider`
- `path` only: `.note .abox .inline_expression_label`
- `text`: `.entity-text .box-text .note-text .rbox-text .abox-text
.empty-row-text .directional-text .nondirectional-text .bidirectional-text
.signal-text .method-text .return-text .callback-text .lost-text
.emphasised-text`
- `.watermark`
-->
<style>
svg {
font-family: monospace; /* gets overriden in the svg */
}
.entity-text {
font-family: serif; /* entities currently inherrit these from
`svg`=> .entity-text is more specific
than this inheritance, so this'll be
applied */
}
.return-text { /* these'll work */
font-weight: lighter;
font-style: italic;
fill: green;
}
.return {
stroke: green; /* the svg has a (line. /path.) return class
with stroke:black and that'd override this*/
}
.lost-text { /* this will work */
fill: red;
font-weight: bold;
}
.watermark { /* this will work as well */
font-family: cursive;
}
</style>
</head>
<body>
<script type="text/x-mscgen">
# OpenId Connect protocol
# https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.1.3
msc {
wordwraparcs="true", watermark="cursive watermark";
eu [label="end-user"],
rp [label="relying party"],
op [label="OpenID provider"];
eu =>> rp [label="log me in"];
rp =>> op [label="authentication request"];
op =>> eu [label="authentication and authorization request"];
eu >> op [label="authenticate and authorize"];
op >> rp [label="authentication response"];
rp =>> op [label="UserInfo request"];
op >> rp [label="UserInfo response"];
rp >> eu [label="Hi. You're logged in with {UserInfo.name}"];
rp -x op [label="lost"];
}
</script>
</body>
</html> |
@daledude I've published the changes that should fix the issue for mscgenjs-core, _ mscgenjs-inpage_ and mscgenjs-cli to npm, and updated mscgen.js.org and the atom-mscgen-preview package. Enjoy! |
@daledude I'll close this issue as the changes released in v1.9.10 & v1.9.11 resolve it as far as I can see If you want to know more about (/ have suggestions to imrpove) customizing styling I'm happy to discuss in a separate issue. |
I haven't had a chance to worry about the css yet but will open a new issue when ready. The new version is working great! |
The below example from the documentation produces links but clicking them does nothing.
https://mscgen.js.org/tutorial.html#url-id-idurl
The text was updated successfully, but these errors were encountered: