Skip to content

Commit

Permalink
Merge branch 'release-v1.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikitex70 committed Sep 13, 2022
2 parents ecd9e07 + 3ccb2d4 commit 9ed0a1a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitchangelog.rc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ body_process = (ReSub(r'((^|\n)[A-Z]\w+(-\w+)*: .*(\n\s+.*)*)+$', r'') |
subject_process = (strip |
ReSub(r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?(.*)$', r'\4') |
ReSub(r' @\d+(h|m|min)?', r'') |
ReSub(r'pkg changed', r'changed') |
ucfirst | final_dot)


Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
# Changelog


## development (unreleased)

### Changes

* Changed version for the new release. [Michele Tessaro]

### Fix

* Fixed working on Redmine < 5 (refs #121) [Michele Tessaro]

* Fixed init of multiple tinymce editors (refs #119) [Michele Tessaro]

Refactored the TinyMCE editor inizialization detection for adding the
toolbar buttons; now it works also for issue notes.
Fixed also some trouble in inserting macro code after editing.

* Fixed patching of viewer-static.min.js (refs #120) [Michele Tessaro]

The code in `viewer-static.min.js` from `embed.diagrams.net` was
refactored, so the patch code had to be adapted.

* Reduced polling timeout on tinymce initialization (refs #119) [Michele Tessaro]


## v1.4.3 (2022-09-07)

### Changes

* Updated changelog. [Michele Tessaro]

* Updated the changelog for the new release. [Michele Tessaro]

### Fix
Expand Down
11 changes: 9 additions & 2 deletions assets/javascripts/drawioEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,20 @@ window.onDrawioViewerLoad = function() {
// Maybe it will broke in the future, but for now is working.

// Patch the code `mxEvent.addListener(g,"click",b)`
var code = GraphViewer.prototype.addToolbar.toString();
var funcName = 'createToolbarButton';
var code = GraphViewer.prototype.createToolbarButton.toString();

if(typeof(GraphViewer.prototype[funcName]) === "undefined") {
funcName = 'addToolbar';
}

var code = GraphViewer.prototype[funcName].toString();
var searchRegex = /mxEvent\.addListener\(([a-zA-Z]+),"click",([a-zA-Z]+)\)/;
var replaceRules = "mxEvent.addListener($1,\"click\",(typeof($2)==='string'?eval($2):$2))";

code = code.replace(searchRegex, replaceRules);
// Apply the patch
GraphViewer.prototype.addToolbar = eval("("+code+")");
GraphViewer.prototype[funcName] = eval("("+code+")");
// Draw graphs
GraphViewer.processElements();
}
Expand Down
27 changes: 13 additions & 14 deletions assets/javascripts/drawio_jstoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@
replaceSelected: function(newText, insert) {
var text = editor.selection.getRng().startContainer.textContent;

if(insert || !endSel)
endSel = startSel
if(insert || !endSel) {
endSel = startSel;
}

var newText = text.substring(0, startSel)+newText+text.substring(endSel);

if(editor.selection.getRng().startContainer.nodeValue) {
editor.selection.getRng().startContainer.nodeValue = newText;
editor.selection.select(editor.selection.getNode());
editor.execCommand('mceReplaceContent', false, newText);
} else {
editor.selection.getRng().startContainer.innerText = newText;
editor.execCommand('mceInsertContent', false, newText);
}
}
}
Expand Down Expand Up @@ -164,13 +166,12 @@
*/
function updateTinyMCEToolbar() {
// See https://stackoverflow.com/questions/36411839/proper-way-of-modifying-toolbar-after-init-in-tinymce
var editor = tinymce.activeEditor;

if(editor) {
editor.on('init', function() {
tinyMCE.on('AddEditor', function(evt){
evt.editor.on('init', function() {
var editor = this;
var imgPath = Drawio.settings.redmineUrl+'plugin_assets/redmine_drawio/images';
var bg = editor.theme.panel.find('toolbar buttongroup')[2]; // group with links/images/code/...

editor.addButton('drawio_attach', {
title : Drawio.strings['drawio_attach_title'],
image : imgPath+'/jstb_drawio_attach.png',
Expand All @@ -179,10 +180,10 @@
}
});
bg.append(editor.buttons['drawio_attach']);

if(Drawio.settings.DMSF) {
editor.addButton('drawio_dmsf', {
title: Drawio.strings['drawio_dmsf_title' ],
title: Drawio.strings['drawio_dmsf_title'],
image: imgPath+'/jstb_drawio_dmsf.png',
onclick: function() {
openMacroDialog(dlg, getTinymceEditorAdapter(editor), 'drawio_dmsf');
Expand All @@ -191,9 +192,7 @@
bg.append(editor.buttons['drawio_dmsf']);
}
});
}
else
setTimeout(updateTinyMCEToolbar, 200);
});
}

// The dialogs for macro editing must be defined only when the document is ready
Expand Down
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name 'Redmine Drawio plugin'
author 'Michele Tessaro'
description 'Wiki macro plugin for inserting drawio diagrams into Wiki pages and Issues'
version '1.4.3'
version '1.4.4'
url 'https://github.com/mikitex70/redmine_drawio'
author_url 'https://github.com/mikitex70'

Expand Down
29 changes: 2 additions & 27 deletions lib/redmine_drawio/helpers/common_mark_helper.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
# encoding: utf-8
require 'redmine'

# With Rails 5 there is some problem using the `alias_method`, can generate
# a `stack level too deep` exeception.
if Rails::VERSION::STRING < '5.0.0'
# Rails 4, the `alias_method` can be used
module Redmine::WikiFormatting::CommonMark::Helper
def heads_for_wiki_formatter_with_drawio
heads_for_wiki_formatter_without_drawio
unless @heads_for_wiki_formatter_with_drawio_included
# This code is executed only once and inserts a javascript code
# that patches the jsToolBar adding the new buttons.
# After that, all editors in the page will get the new buttons.
content_for :header_tags do
javascript_tag 'if(typeof(Drawio) !== "undefined") Drawio.initToolbar();'
end
@heads_for_wiki_formatter_with_drawio_included = true
end
end

# alias_method_chain is deprecated in Rails 5: replaced with two alias_method
# as a quick workaround. Using the 'prepend' method can generate an
# 'stack level too deep' error in conjunction with other (non ported) plugins.
#alias_method_chain :heads_for_wiki_formatter, :drawio
alias_method :heads_for_wiki_formatter_without_drawio, :heads_for_wiki_formatter
alias_method :heads_for_wiki_formatter, :heads_for_wiki_formatter_with_drawio
end
else
# Rails 5, use new `prepend` method
if Redmine::VERSION::MAJOR >= 5
# CommonMark is available only from Redmine 5
module RedmineDrawio
module Helpers
module CommonMarkHelper
Expand Down

0 comments on commit 9ed0a1a

Please sign in to comment.