SVG Macro

Last modified by Vincent Massol on 2024/07/08 00:09

cogAllows displaying and editing of SVG using svg-edit
TypeXAR
Category
Developed by

Ludovic Dubost, xwiki:XWiki.jirutka

Active Installs41
Rating
1 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

This macro uses SVG Edit Project.

  • This macro is old and requires installing an XWiki 1.0 parser. However, if you're just looking to view SVG content, you can use the HTML macro as is.
  • Important: The Edit feature in this macro depends on Modal Box Application. So please also install this dependency in order to make edit work.

Example

If you copy/paste this example you should see an SVG Drawing below and you can edit it by clicking on the edit icon:

{{svg width="640" height="480"}}
<svg width="640" height="480" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<g>
 <title>Layer 1</title>
 <rect transform="rotate(29.0349, 399.602, 239.6)" stroke-width="5" stroke="#000000" fill="#0000ff" id="svg_1" height="213.948426" width="324.49861" y="132.625181" x="237.349801"/>
 <text x="374.6" y="242.1" id="svg_2" fill="#000000" stroke="#000000" stroke-width="0" font-size="24" font-family="serif" text-anchor="middle" xml:space="preserve" transform="matrix(1, 0, 0, 1, 27, 10)">This is an SVG Drawing</text>
</g>
</svg>
{{/svg}}

Result

svg.png

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Import in an XWiki 2.x installation. Visit the XWiki.SVGMacro page to see a demo.

This macro author has put the default visibility to "current user". It should be changed to "current wiki" in the next release. So for the moment:

  • Open the MacroSVG document and edit its objects
  • Expand the WikiMacroClass object and change the visibility to "current wiki" instead of "current user"

XWiki Enterprise Manager Specific Notes

  • With XEM running XWiki 2.0 and 2.1 you will need to install it in both the Main Wiki and the Wiki you want to use it on. 
  • With XWiki 2.2 and later you can only install it in the Wiki you want to use it on.

Release Notes

v1.4

v1.3

  • Remove useless menu items from SVG Edit (open and export).
  • Modified to use image size from the SVG tag by default, when no width or height parameters are set; thus canvas size can be adjusted from SVG Edit.

v1.2

  • Updated to SVG Edit version 4.6 and refactored JS macro.
  • Added confirmation dialog to save image before closing editor.
  • Disabled closing editor by clicking on overlay (use close button).

v1.1

Fixed the wrong macro scope (from current user to current wiki), plus minor cleanup.

v1.0

It uses the XWiki SVG Plugin which uses FOP to render the SVG to images. On certain platforms there might be slight differences in rendering depending on the way FONTs are rendered.

This version is based on SVG Edit 2.4 for the editing which is supported by browsers supporting SVG.

Get Connected