@@ -3,12 +3,12 @@ jQuery(function () {
33 /* DOKUWIKI:include script/service.js */
44 /* DOKUWIKI:include script/elements.js */
55
6- // add diagram edit button to all SVGs included in wiki pages
7- const $images = jQuery ( 'img ' ) . filter ( '.media, .medialeft, .mediacenter, .mediaright ' ) ;
6+ // add diagram edit button to diagram SVGs included in wiki pages
7+ const $images = jQuery ( 'object ' ) . filter ( '.diagrams-svg ' ) ;
88
99 // collect image IDs with file extension
1010 const imageIds = $images . map ( function ( key , image ) {
11- return extractIdFromMediaUrl ( image . src ) ;
11+ return extractIdFromMediaUrl ( image . data ) ;
1212 } ) . toArray ( ) ;
1313
1414 let ajaxData = { } ;
@@ -19,7 +19,7 @@ jQuery(function () {
1919 const attachButtons = function ( result ) {
2020 const diagrams = JSON . parse ( result ) ;
2121 $images . each ( function ( ) {
22- const id = extractIdFromMediaUrl ( this . src ) ;
22+ const id = extractIdFromMediaUrl ( this . data ) ;
2323 const $current = jQuery ( this ) ;
2424 if ( diagrams . includes ( id ) ) {
2525 let $editButton = editDiagramButton ( id ) ;
@@ -111,3 +111,11 @@ jQuery(function () {
111111 observer . observe ( targetNode , config ) ;
112112 } ) ;
113113} ) ;
114+
115+ // open links in diagrams in the browser window instead of SVG frame
116+ // TODO this will not work with DokuWiki master as of February 2021 (contentDocument is null)
117+ jQuery ( window ) . on ( 'load' , function ( ) {
118+ jQuery ( 'object.diagrams-svg' ) . each ( function ( ) {
119+ jQuery ( this . contentDocument ) . find ( 'svg' ) . find ( 'a' ) . attr ( 'target' , '_parent' ) ;
120+ } ) ;
121+ } ) ;
0 commit comments