Skip to content
Permalink
Browse files

#15, #16: Preparing for adding more handlers (dmn, cmmn)

  • Loading branch information...
jdehaan committed Jan 13, 2019
1 parent 33b93a7 commit 3653e9bb5eab528805c1ae1e4580af480975feb5
Showing with 45 additions and 36 deletions.
  1. +42 −33 script.js
  2. +3 −3 syntax.php
@@ -1,36 +1,45 @@
jQuery(document).ready(function() {
jQuery("textarea[id^=__bpmnio_]").each(function(i, tag) { try {
var xml = jQuery(tag).text();
xml = decodeURIComponent(escape(window.atob(xml)));
var id = jQuery(tag).attr('id');
// avoid doing it twice
jQuery(tag).removeAttr('id');
jQuery("textarea[id^=__bpmn_js_]").each(function(i, tag) {
try {
var xml = jQuery(tag).text();
xml = decodeURIComponent(escape(window.atob(xml)));
var id = jQuery(tag).attr("id");
// avoid doing it twice
jQuery(tag).removeAttr("id");

// bundle exposes the viewer / modeler via the BpmnJS variable
var BpmnViewer = window.BpmnJS;
var containerdiv = document.createElement('div');
containerdiv.className = "canvas";
jQuery(tag).parent().append(containerdiv);
var viewer = new BpmnViewer({ container: containerdiv });
viewer.importXML(xml, function(err) {
if (err) {
containerdiv.text = err;
console.log('error rendering', err);
} else {
var canvas = viewer.get('canvas');
var bboxViewport = canvas.getDefaultLayer().getBBox();
var bboxSvg = canvas.getSize();
canvas.viewbox({ x: bboxViewport.x, y: bboxViewport.y, width: bboxSvg.width, height: bboxSvg.height });
var height = bboxViewport.height + 4;
// hack: adjust the div height because it doesn't automatically.
containerdiv.style.height = "" + height + 'px';
containerdiv.style.width = "" + bboxViewport.width + 'px';
// Fix #3 by introducing a small space to allow clicks.
containerdiv.style.marginRight = "32px";
}
});
jQuery(tag).remove();
}catch(err){
console.warn(err.message);
}});
// bundle exposes the viewer / modeler via the BpmnJS variable
var BpmnViewer = window.BpmnJS;
var containerdiv = document.createElement("div");
containerdiv.className = "canvas";
jQuery(tag)
.parent()
.append(containerdiv);
var viewer = new BpmnViewer({ container: containerdiv });
viewer.importXML(xml, function(err) {
if (err) {
containerdiv.text = err;
console.log("error rendering", err);
} else {
var canvas = viewer.get("canvas");
var bboxViewport = canvas.getDefaultLayer().getBBox();
var bboxSvg = canvas.getSize();
canvas.viewbox({
x: bboxViewport.x,
y: bboxViewport.y,
width: bboxSvg.width,
height: bboxSvg.height
});
var height = bboxViewport.height + 4;
// hack: adjust the div height because it doesn't automatically.
containerdiv.style.height = "" + height + "px";
containerdiv.style.width = "" + bboxViewport.width + "px";
// Fix #3 by introducing a small space to allow clicks.
containerdiv.style.marginRight = "32px";
}
});
jQuery(tag).remove();
} catch (err) {
console.warn(err.message);
}
});
});
@@ -62,7 +62,7 @@ public function render($mode, Doku_Renderer $renderer, $data)
break;
case DOKU_LEXER_UNMATCHED:
$bpmnid = uniqid('__bpmnio_');
$bpmnid = uniqid('__bpmn_js_');
$sectionEditData = ['target' => 'plugin_bpmnio'];
if (!defined('SEC_EDIT_PATTERN')) {
// backwards-compatibility for Frusterick Manners (2017-02-19)
@@ -71,10 +71,10 @@ public function render($mode, Doku_Renderer $renderer, $data)
$class = $renderer->startSectionEdit($data[$pos], $sectionEditData);
$renderer->doc .= '<div class="' . $class . '">';
$renderer->doc .= '<div style="overflow:auto;">';
$renderer->doc .= '<textarea class="bpmnio_data" id="' . $bpmnid . '" style="visibility:hidden;">';
$renderer->doc .= '<textarea class="bpmn_js_data" id="' . $bpmnid . '" style="visibility:hidden;">';
$renderer->doc .= trim($match);
$renderer->doc .= '</textarea>';
//$renderer->doc .= '<div class="bpmnio_canvas" id="'.$bpmnid.'"></div>';
//$renderer->doc .= '<div class="bpmn_js_canvas" id="'.$bpmnid.'"></div>';
$renderer->doc .= '</div>';
$renderer->doc .= '</div>';
$renderer->finishSectionEdit($data[$end]);

0 comments on commit 3653e9b

Please sign in to comment.
You can’t perform that action at this time.