代码拉取完成,页面将自动刷新
module.exports._getCommentsElement = function(element, create) {
var bo = element.businessObject;
var docs = bo.get('documentation');
var comments;
// get comments node
docs.some(function(d) {
return d.textFormat === 'text/x-comments' && (comments = d);
});
// create if not existing
if (!comments && create) {
comments = bo.$model.create('bpmn:Documentation', { textFormat: 'text/x-comments' });
docs.push(comments);
}
return comments;
};
module.exports.getComments = function(element) {
var doc = this._getCommentsElement(element);
if (!doc || !doc.text) {
return [];
} else {
return doc.text.split(/;\r?\n;/).map(function(str) {
return str.split(/:/, 2);
});
}
};
module.exports.setComments = function(element, comments) {
var doc = this._getCommentsElement(element, true);
var str = comments.map(function(c) {
return c.join(':');
}).join(';\n;');
doc.text = str;
};
module.exports.addComment = function(element, author, str) {
var comments = this.getComments(element);
comments.push([ author, str ]);
this.setComments(element, comments);
};
module.exports.removeComment = function(element, comment) {
var comments = this.getComments(element);
var idx = -1;
comments.some(function(c, i) {
var matches = c[0] === comment[0] && c[1] === comment[1];
if (matches) {
idx = i;
}
return matches;
});
if (idx !== -1) {
comments.splice(idx, 1);
}
this.setComments(element, comments);
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。