wiki icon indicating copy to clipboard operation
wiki copied to clipboard

Changes for interactive plantuml

Open bharatrajagopalan opened this issue 5 years ago • 3 comments

This is a copy of the original pull request here

Creating this pull request on dev branch as discussed with @NGPixel . I had originally created this a while ago by forking the master branch and hence needed to rewrite this using DOMPurify.

Summary: Plantuml is currently created as an image which means that links do not work and the plantuml content is treated as a picture and is not searchable

This PR does the following:

  • Renders plantuml as svg using object tag so that it is interactive and selectable (e.g. you can now copy paste text from within the diagram) with a backup non-interactive img tag if browser will not render object
  • Places the original plantuml content inline inside the object tag to ensure that this is not visible but included in wikijs search index

As object tag is typically insecure, it is checked and sanitised to make sure that

  • Only the configured plantuml server, image format (e.g. https://plantuml.requarks.io/svg/) are allowed in the url parameter passed in data; Any other value results in the node being discarded
  • Only attributes required for plantuml+wikijs are allowed (style/class/type/data/alt); mismatch in number of attributes being passed in will result in the node being discarded.
  • Allowed attributes other than data are overriden to the required values for plantuml to work with wikijs explicitly to avoid any code injection scenarios

Tested using sample markdown

bharatrajagopalan avatar Nov 24 '20 22:11 bharatrajagopalan

any idea when it could be merged? I need this! :D

DraakBZH avatar Jul 19 '21 15:07 DraakBZH

Requesting a followup on this, one year later!

ImBoop avatar Sep 06 '22 19:09 ImBoop

+1 for this. The interactivity is a must for plantuml-C4.

hernrup-modelon avatar Oct 23 '23 05:10 hernrup-modelon