2014-04-27 20:10:30 +00:00
|
|
|
define([
|
|
|
|
"jquery",
|
|
|
|
"underscore",
|
|
|
|
"utils",
|
|
|
|
"logger",
|
|
|
|
"classes/Extension",
|
|
|
|
"text!html/umlDiagramsSettingsBlock.html",
|
|
|
|
'crel',
|
2014-08-21 23:14:58 +00:00
|
|
|
'Diagram',
|
2014-04-27 20:10:30 +00:00
|
|
|
'flow-chart'
|
2014-08-21 23:14:58 +00:00
|
|
|
], function($, _, utils, logger, Extension, umlDiagramsSettingsBlockHTML, crel, Diagram, flowChart) {
|
2014-04-27 20:10:30 +00:00
|
|
|
|
|
|
|
var umlDiagrams = new Extension("umlDiagrams", "UML Diagrams", true);
|
|
|
|
umlDiagrams.settingsBlock = umlDiagramsSettingsBlockHTML;
|
|
|
|
|
2014-05-27 23:36:37 +00:00
|
|
|
umlDiagrams.onPagedownConfigure = function(editor) {
|
|
|
|
var previewContentsElt = document.getElementById('preview-contents');
|
|
|
|
editor.hooks.chain("onPreviewRefresh", function() {
|
|
|
|
_.each(previewContentsElt.querySelectorAll('.prettyprint > .language-sequence'), function(elt) {
|
|
|
|
try {
|
2014-08-21 23:14:58 +00:00
|
|
|
var diagram = Diagram.parse(elt.textContent);
|
2014-05-27 23:36:37 +00:00
|
|
|
var preElt = elt.parentNode;
|
|
|
|
var containerElt = crel('div', {
|
|
|
|
class: 'sequence-diagram'
|
|
|
|
});
|
|
|
|
preElt.parentNode.replaceChild(containerElt, preElt);
|
|
|
|
diagram.drawSVG(containerElt, {
|
|
|
|
theme: 'simple'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
2014-04-27 20:10:30 +00:00
|
|
|
});
|
2014-05-27 23:36:37 +00:00
|
|
|
_.each(previewContentsElt.querySelectorAll('.prettyprint > .language-flow'), function(elt) {
|
|
|
|
try {
|
|
|
|
var chart = flowChart.parse(elt.textContent);
|
|
|
|
var preElt = elt.parentNode;
|
|
|
|
var containerElt = crel('div', {
|
|
|
|
class: 'flow-chart'
|
|
|
|
});
|
|
|
|
preElt.parentNode.replaceChild(containerElt, preElt);
|
|
|
|
chart.drawSVG(containerElt, {
|
2014-06-09 16:37:58 +00:00
|
|
|
'line-width': 2,
|
|
|
|
'font-family': 'sans-serif',
|
|
|
|
'font-weight': 'normal'
|
2014-05-27 23:36:37 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2014-04-27 20:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return umlDiagrams;
|
|
|
|
});
|