Add files via upload

This commit is contained in:
Gregory Bednov 2025-01-16 18:08:10 +03:00 committed by GitHub
commit a3243dd1ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 871 additions and 0 deletions

View file

@ -0,0 +1,43 @@
import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
export default class CustomGlobalConnectRules extends RuleProvider {
static $inject = ['eventBus'];
constructor(eventBus: any) {
super(eventBus);
}
init(): void {
// Правило для начала соединения
this.addRule('connection.start', (context) => {
return true;
const { source } = context;
if (source?.businessObject?.type === 'custom:connectable') {
return true; // Разрешить соединение
}
return false; // Запретить соединение
});
// Правило для создания соединения
this.addRule('connection.create', (context) => {
//return true;
const { source, target } = context;
// console.log(typeof source);
// console.log(source.constructor.name)
// instanceof Shape);
//if (source?.type === Shape)
//if (
// source?.businessObject?.type === 'custom:connectable' &&
// target?.businessObject?.type === 'custom:connectable'
//) {
return { type: 'Connection' };
// { type: 'Connection' }; // Тип соединения
// }
return false; // Запретить соединение
});
}
}