@@ -3,12 +3,12 @@ jQuery(function () {
3
3
/* DOKUWIKI:include script/service.js */
4
4
/* DOKUWIKI:include script/elements.js */
5
5
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 ' ) ;
8
8
9
9
// collect image IDs with file extension
10
10
const imageIds = $images . map ( function ( key , image ) {
11
- return extractIdFromMediaUrl ( image . src ) ;
11
+ return extractIdFromMediaUrl ( image . data ) ;
12
12
} ) . toArray ( ) ;
13
13
14
14
let ajaxData = { } ;
@@ -19,7 +19,7 @@ jQuery(function () {
19
19
const attachButtons = function ( result ) {
20
20
const diagrams = JSON . parse ( result ) ;
21
21
$images . each ( function ( ) {
22
- const id = extractIdFromMediaUrl ( this . src ) ;
22
+ const id = extractIdFromMediaUrl ( this . data ) ;
23
23
const $current = jQuery ( this ) ;
24
24
if ( diagrams . includes ( id ) ) {
25
25
let $editButton = editDiagramButton ( id ) ;
@@ -111,3 +111,11 @@ jQuery(function () {
111
111
observer . observe ( targetNode , config ) ;
112
112
} ) ;
113
113
} ) ;
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