xwikisas / application-diagram

Create various types of diagrams using draw.io
GNU Lesser General Public License v2.1
0 stars 8 forks source link

Add option to configure diagram links to open in new tab #14

Open iuliabalan opened 6 years ago

iuliabalan commented 6 years ago

Currently if you add a link to diagram elements you only have the option to insert the URL. The links to external ressources are opened in new tab. If you have a link to a document from your wiki (e.g a PDF document) it's opening it in the same window. It would be nice to be able to configure the link to open in a new tab like it can be done if editing a link in CKEditor

mflorea commented 6 years ago

I checked the draw.io code and ATM it doesn't seem to support specifying the target (e.g. target=blank) per link. The target can be configured per diagram (it affects all the links from the diagram). They call it "link policy", and the supported values are:

target=[auto|self|frame|blank]: Opens links in the same window or frame or in a blank window in chromeless mode (auto is default and opens relative links and anchors in same window in chromeless mode, and all links in new window in editing mode)

See https://www.diagrams.net/doc/faq/supported-url-parameters

There's no UI for this though. We should consider the following options:

  1. Modify Diagram.DiagramViewSheet JSX and change var urlParams = {}; with var urlParams = {target: 'blank'};
  2. Add a property to Diagram.DiagramClass to control how links are opened. We would read this property in Diagram.DiagramViewSheet and set the urlParams accordingly.
  3. Overwrite Graph#labelLinkClicked or GraphViewer#addClickHandler to implement a custom behavior (determine how to open the link based on the link URL or some attribute).
mflorea commented 6 years ago

Link policy is currently read from urlParams, see Graph#linkPolicy.