diff --git a/CHANGELOG.md b/CHANGELOG.md index cddbe690..a52f7398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,61 @@ # Changelog -## 1.4.7 (2023-06-24) +## v1.4.8 (2023-10-22) + +### New + +* Added support for `drawio` diagram extension (#131) [Michele Tessaro] + +### Fix + +* Fixes wrong number of arguments exception. [Liane Hampe] + + The macro drawio_dmsf will raise an exception when a user applies + the macro to a previously uploaded drawio file (file ending does not + matter). + + The error occurs in DmsfFileRevision#disk_file which has changed four + month ago. + +* Fixes uncaught type error. [Liane Hampe] + + Math support will only be provided if the user has checked the + corresponding box in plugin settings. When no math support is required + the javascript snippet should be ignored. + + Since only MathJax will be ignored and not MathJax.Hub, javascript will + raise a type error. This is fixed with a further condition. + +### Other + +* Adds some unit tests. [Liane Hampe] + + Will add some unit tests for drawio macros. + +* Extends error message. [Liane Hampe] + + The extension drawio is missing in an error message listing supported + diagram formats. + +* Changes spelling in heredoc string. [Liane Hampe] + + Will remove inverted comma (') from heredoc string since there are + interpreted as the beginning of a normal string + ('text between inverted comma') which won't be closed. + + The results is an unreadable code in some IDE such that vscode. + +* Changes spelling in heredoc string. [Liane Hampe] + + Will remove inverted comma (') from heredoc string since there are + interpreted as the beginning of a normal string + ('text between inverted comma') which won't be closed. + + The results is an unreadable code in some IDE such that vscode. + + +## v1.4.7 (2023-06-24) ### Fix diff --git a/README.md b/README.md index 871cbd0b..e2358a03 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ This macro handles diagrams saved as attachments of issues or wiki pages. The supported diagrams format are: * `xml`: normal diagram source in XML format +* `drawio`: an alias for `xml`, used to load exported diagrams from the [online ditor](https://app.diagrams.net/) without changing the file extension * `png`: PNG image with an embedded XML source of the diagram (PNG+XML) * `svg`: SVG image with an embedded XML source of the diagram (SVG+XML) diff --git a/app/views/redmine_drawio/_macro_dialog.html.erb b/app/views/redmine_drawio/_macro_dialog.html.erb index fbf369f4..3e1e2d71 100644 --- a/app/views/redmine_drawio/_macro_dialog.html.erb +++ b/app/views/redmine_drawio/_macro_dialog.html.erb @@ -15,6 +15,7 @@ SVG <% end %> XML + DRAWIO

diff --git a/assets/javascripts/drawioEditor.js b/assets/javascripts/drawioEditor.js index f2a643af..47ae6a40 100644 --- a/assets/javascripts/drawioEditor.js +++ b/assets/javascripts/drawioEditor.js @@ -45,6 +45,13 @@ function editDiagram(image, resource, isDmsf, pageName, originalName) { '
'); + attachTable = $(".attachments table tbody"); + } + + var lastRow = attachTable.find('tr').last(); + var hrefCount = 0; + var linkTextCount = 0; + var lastRowHtml = $(lastRow).html(); + + if(!lastRowHtml) { + lastRowHtml = '' + + ' NAME (SIZE KB)' + + ' NAME ' + + ' ' + + ' ' + + ' USER, TIMESTAMP' + + ' ' + + ' ' + + ' Delete' + + ' '; + } + // replace icon link + lastRowHtml = lastRowHtml.replace(/href="[^"]+"/g, function(match) { + var path = lastAttach.content_url.substring(0, lastAttach.content_url.indexOf('/attachments/download/')+'/attachments'.length); + + //var path = lastAttach.content_url.substring(0, lastAttach.content_url.lastIndexOf('/')); + + //path = path.substring(0, path.lastIndexOf('/')); + + switch(hrefCount++) { + case 0: + case 2: return 'href="'+path+'/'+lastAttach.id+'"'; + case 1: return 'href="'+lastAttach.content_url+'"'; + default: return match; + } + }); + // replace file size + lastRowHtml = lastRowHtml.replace(/\((.*?) KB\)/, '('+(lastAttach.filesize/1024).toFixed(2)+' KB)'); + // replace file name + lastRowHtml = lastRowHtml.replace(/>[^<]+<\/a>/g, function(match) { + if(linkTextCount++ < 2) { + return '>'+lastAttach.filename+''; + } else { + return match; + } + }); + // replace author and date + var attachDate = new Date(lastAttach.created_on).toLocaleString(); + lastRowHtml = lastRowHtml.replace(/author">[^<]+/, 'author">'+lastAttach.author.name+', '+ + attachDate.replaceAll('/', '-').substring(0, attachDate.lastIndexOf(':')) + ); + // add the new attachment to the attachments list + attachTable.append(lastRowHtml); + // increment the number of attachments + var numAttachs = $("fieldset legend"); + numAttachs.text(numAttachs.text().replace(/\d+/, function(match) { + return Number(match)+1; + })); + } + } + }); + } + /** * Fix for `{{fnlist}}` duplication with the `redmine_wiki_extensions` plugin. */ @@ -364,7 +455,7 @@ function editDiagram(image, resource, isDmsf, pageName, originalName) { } /** - * Fix for Wiki Extensions header page. + * Fix for Wiki Extensions footer page. */ function fixWikiExtensionsFooter(value) { return value.replace(/\n\n