refactor: 重构 bpmnProcessDesigner => bpmn-process-designer
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
const hljs = require('highlight.js/lib/core');
|
||||
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));
|
||||
hljs.registerLanguage('json', require('highlight.js/lib/languages/json'));
|
||||
|
||||
module.exports = hljs;
|
||||
@@ -0,0 +1,30 @@
|
||||
import BpmnRenderer from 'bpmn-js/lib/draw/BpmnRenderer';
|
||||
|
||||
export default function CustomRenderer(
|
||||
config,
|
||||
eventBus,
|
||||
styles,
|
||||
pathMap,
|
||||
canvas,
|
||||
textRenderer,
|
||||
) {
|
||||
BpmnRenderer.call(
|
||||
this,
|
||||
config,
|
||||
eventBus,
|
||||
styles,
|
||||
pathMap,
|
||||
canvas,
|
||||
textRenderer,
|
||||
2000,
|
||||
);
|
||||
|
||||
this.handlers.label = function () {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
const F = function () {}; // 核心,利用空对象作为中介;
|
||||
F.prototype = BpmnRenderer.prototype; // 核心,将父类的原型赋值给空对象F;
|
||||
CustomRenderer.prototype = new F(); // 核心,将 F的实例赋值给子类;
|
||||
CustomRenderer.prototype.constructor = CustomRenderer; // 修复子类CustomRenderer的构造器指向,防止原型链的混乱;
|
||||
@@ -0,0 +1,6 @@
|
||||
import CustomRenderer from './CustomRenderer';
|
||||
|
||||
export default {
|
||||
__init__: ['customRenderer'],
|
||||
customRenderer: ['type', CustomRenderer],
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import BpmnRules from 'bpmn-js/lib/features/rules/BpmnRules';
|
||||
import inherits from 'inherits';
|
||||
|
||||
export default function CustomRules(eventBus) {
|
||||
BpmnRules.call(this, eventBus);
|
||||
}
|
||||
|
||||
inherits(CustomRules, BpmnRules);
|
||||
|
||||
CustomRules.prototype.canDrop = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
CustomRules.prototype.canMove = function () {
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import CustomRules from './CustomRules';
|
||||
|
||||
export default {
|
||||
__init__: ['customRules'],
|
||||
customRules: ['type', CustomRules],
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* This is a sample file that should be replaced with the actual translation.
|
||||
*
|
||||
* Checkout https://github.com/bpmn-io/bpmn-js-i18n for a list of available
|
||||
* translations and labels to translate.
|
||||
*/
|
||||
export default {
|
||||
'Exclusive Gateway': 'Exklusives Gateway',
|
||||
'Parallel Gateway': 'Paralleles Gateway',
|
||||
'Inclusive Gateway': 'Inklusives Gateway',
|
||||
'Complex Gateway': 'Komplexes Gateway',
|
||||
'Event based Gateway': 'Ereignis-basiertes Gateway',
|
||||
'Message Start Event': '消息启动事件',
|
||||
'Timer Start Event': '定时启动事件',
|
||||
'Conditional Start Event': '条件启动事件',
|
||||
'Signal Start Event': '信号启动事件',
|
||||
'Error Start Event': '错误启动事件',
|
||||
'Escalation Start Event': '升级启动事件',
|
||||
'Compensation Start Event': '补偿启动事件',
|
||||
'Message Start Event (non-interrupting)': '消息启动事件 (非中断)',
|
||||
'Timer Start Event (non-interrupting)': '定时启动事件 (非中断)',
|
||||
'Conditional Start Event (non-interrupting)': '条件启动事件 (非中断)',
|
||||
'Signal Start Event (non-interrupting)': '信号启动事件 (非中断)',
|
||||
'Escalation Start Event (non-interrupting)': '升级启动事件 (非中断)',
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
// outside.js
|
||||
|
||||
const ctx = '@@clickoutsideContext';
|
||||
|
||||
export default {
|
||||
bind(el, binding, vnode) {
|
||||
const ele = el;
|
||||
const documentHandler = (e) => {
|
||||
if (!vnode.context || ele.contains(e.target)) {
|
||||
return false;
|
||||
}
|
||||
// 调用指令回调
|
||||
if (binding.expression) {
|
||||
vnode.context[el[ctx].methodName](e);
|
||||
} else {
|
||||
el[ctx].bindingFn(e);
|
||||
}
|
||||
};
|
||||
// 将方法添加到ele
|
||||
ele[ctx] = {
|
||||
documentHandler,
|
||||
methodName: binding.expression,
|
||||
bindingFn: binding.value,
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
document.addEventListener('touchstart', documentHandler); // 为document绑定事件
|
||||
});
|
||||
},
|
||||
update(el, binding) {
|
||||
const ele = el;
|
||||
ele[ctx].methodName = binding.expression;
|
||||
ele[ctx].bindingFn = binding.value;
|
||||
},
|
||||
unbind(el) {
|
||||
document.removeEventListener('touchstart', el[ctx].documentHandler); // 解绑
|
||||
delete el[ctx];
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
export function debounce(fn, delay = 500) {
|
||||
let timer;
|
||||
return function (...args) {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
timer = setTimeout(fn.bind(this, ...args), delay);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
function xmlStr2XmlObj(xmlStr) {
|
||||
let xmlObj = {};
|
||||
if (document.all) {
|
||||
const xmlDom = new window.ActiveXObject('Microsoft.XMLDOM');
|
||||
xmlDom.loadXML(xmlStr);
|
||||
xmlObj = xmlDom;
|
||||
} else {
|
||||
xmlObj = new DOMParser().parseFromString(xmlStr, 'text/xml');
|
||||
}
|
||||
return xmlObj;
|
||||
}
|
||||
|
||||
function xml2json(xml) {
|
||||
try {
|
||||
let obj = {};
|
||||
if (xml.children.length > 0) {
|
||||
for (let i = 0; i < xml.children.length; i++) {
|
||||
const item = xml.children.item(i);
|
||||
const nodeName = item.nodeName;
|
||||
if (obj[nodeName] === undefined) {
|
||||
obj[nodeName] = xml2json(item);
|
||||
} else {
|
||||
if (obj[nodeName].push === undefined) {
|
||||
const old = obj[nodeName];
|
||||
obj[nodeName] = [];
|
||||
obj[nodeName].push(old);
|
||||
}
|
||||
obj[nodeName].push(xml2json(item));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
obj = xml.textContent;
|
||||
}
|
||||
return obj;
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function xmlObj2json(xml) {
|
||||
const xmlObj = xmlStr2XmlObj(xml);
|
||||
console.log(xmlObj);
|
||||
let jsonObj = {};
|
||||
if (xmlObj.childNodes.length > 0) {
|
||||
jsonObj = xml2json(xmlObj);
|
||||
}
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
export default xmlObj2json;
|
||||
Reference in New Issue
Block a user