@processmaker/modeler 1.39.7 → 1.39.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modeler.common.js +142 -94
- package/dist/modeler.common.js.map +1 -1
- package/dist/modeler.umd.js +142 -94
- package/dist/modeler.umd.js.map +1 -1
- package/dist/modeler.umd.min.js +1 -1
- package/dist/modeler.umd.min.js.map +1 -1
- package/package.json +4 -2
- package/src/NodeIdGenerator.js +8 -0
- package/src/components/modeler/Modeler.vue +40 -10
- package/src/components/nodes/node.js +2 -3
- package/src/components/topRail/multiplayerViewUsers/MultiplayerViewUsers.vue +1 -1
- package/src/multiplayer/multiplayer.js +48 -0
- package/src/multiplayer/room.js +10 -0
- package/src/setup/globals.js +1 -1
- package/src/setup/initialLoad.js +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@processmaker/modeler",
|
|
3
|
-
"version": "1.39.
|
|
3
|
+
"version": "1.39.8",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"serve": "vue-cli-service serve",
|
|
6
6
|
"test:unit": "vue-cli-service test:unit",
|
|
@@ -68,7 +68,9 @@
|
|
|
68
68
|
"vue-monaco": "^1.2.1",
|
|
69
69
|
"vue-popperjs": "^2.3.0",
|
|
70
70
|
"vue-upload-component": "^2.8.20",
|
|
71
|
-
"vuex": "^3.5.1"
|
|
71
|
+
"vuex": "^3.5.1",
|
|
72
|
+
"y-websocket": "^1.5.0",
|
|
73
|
+
"yjs": "^13.6.7"
|
|
72
74
|
},
|
|
73
75
|
"devDependencies": {
|
|
74
76
|
"@babel/core": "^7.12.16",
|
package/src/NodeIdGenerator.js
CHANGED
|
@@ -58,6 +58,14 @@ export default class NodeIdGenerator {
|
|
|
58
58
|
this.refreshLastIdCounter();
|
|
59
59
|
return NodeIdGenerator.#counter;
|
|
60
60
|
}
|
|
61
|
+
getDefinitionNumber() {
|
|
62
|
+
return NodeIdGenerator.#counter;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
updateCounters() {
|
|
66
|
+
NodeIdGenerator.#counter++;
|
|
67
|
+
NodeIdGenerator.#diagramCounter++;
|
|
68
|
+
}
|
|
61
69
|
|
|
62
70
|
refreshLastDiagramIdCounter() {
|
|
63
71
|
let lastIdCounter = this.matchIds(new RegExp(`^${NodeIdGenerator.prefix}(\\d+)_di$`), this.definitions.diagrams);
|
|
@@ -327,6 +327,8 @@ export default {
|
|
|
327
327
|
players: [],
|
|
328
328
|
showInspectorButton: true,
|
|
329
329
|
inspectorButtonRight: 65,
|
|
330
|
+
multiplayer: null,
|
|
331
|
+
isMultiplayer: false,
|
|
330
332
|
};
|
|
331
333
|
},
|
|
332
334
|
watch: {
|
|
@@ -1024,7 +1026,21 @@ export default {
|
|
|
1024
1026
|
control,
|
|
1025
1027
|
});
|
|
1026
1028
|
},
|
|
1027
|
-
|
|
1029
|
+
handleDrop(data) {
|
|
1030
|
+
const { clientX, clientY, control} = data;
|
|
1031
|
+
if (this.isMultiplayer) {
|
|
1032
|
+
window.ProcessMaker.EventBus.$emit('multiplayer-addNode', {
|
|
1033
|
+
clientX,
|
|
1034
|
+
clientY,
|
|
1035
|
+
control,
|
|
1036
|
+
id: `node_${this.nodeIdGenerator.getDefinitionNumber()}`,
|
|
1037
|
+
});
|
|
1038
|
+
} else {
|
|
1039
|
+
this.handleDropProcedure(data);
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
async handleDropProcedure(data, selected=true) {
|
|
1043
|
+
const { clientX, clientY, control, nodeThatWillBeReplaced, id } = data;
|
|
1028
1044
|
this.validateDropTarget({ clientX, clientY, control });
|
|
1029
1045
|
if (!this.allowDrop) {
|
|
1030
1046
|
return;
|
|
@@ -1043,9 +1059,11 @@ export default {
|
|
|
1043
1059
|
if (newNode.isBpmnType('bpmn:BoundaryEvent')) {
|
|
1044
1060
|
this.setShapeCenterUnderCursor(diagram);
|
|
1045
1061
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1062
|
+
if (selected) {
|
|
1063
|
+
this.highlightNode(newNode);
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
await this.addNode(newNode, id, selected);
|
|
1049
1067
|
if (!nodeThatWillBeReplaced) {
|
|
1050
1068
|
return;
|
|
1051
1069
|
}
|
|
@@ -1062,6 +1080,7 @@ export default {
|
|
|
1062
1080
|
|
|
1063
1081
|
return newNode;
|
|
1064
1082
|
},
|
|
1083
|
+
|
|
1065
1084
|
setShapeCenterUnderCursor(diagram) {
|
|
1066
1085
|
diagram.bounds.x -= (diagram.bounds.width / 2);
|
|
1067
1086
|
diagram.bounds.y -= (diagram.bounds.height / 2);
|
|
@@ -1073,14 +1092,14 @@ export default {
|
|
|
1073
1092
|
const view = newNodeComponent.shapeView;
|
|
1074
1093
|
await this.$refs.selector.selectElement(view);
|
|
1075
1094
|
},
|
|
1076
|
-
async addNode(node) {
|
|
1095
|
+
async addNode(node, id = null, selected = true) {
|
|
1077
1096
|
if (!node.pool) {
|
|
1078
1097
|
node.pool = this.poolTarget;
|
|
1079
1098
|
}
|
|
1080
1099
|
|
|
1081
1100
|
const targetProcess = node.getTargetProcess(this.processes, this.processNode);
|
|
1082
1101
|
addNodeToProcess(node, targetProcess);
|
|
1083
|
-
node.setIds(this.nodeIdGenerator);
|
|
1102
|
+
node.setIds(this.nodeIdGenerator, id);
|
|
1084
1103
|
|
|
1085
1104
|
this.planeElements.push(node.diagram);
|
|
1086
1105
|
store.commit('addNode', node);
|
|
@@ -1098,9 +1117,11 @@ export default {
|
|
|
1098
1117
|
].includes(node.type)) {
|
|
1099
1118
|
return;
|
|
1100
1119
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1120
|
+
if (selected) {
|
|
1121
|
+
// Select the node after it has been added to the store (does not apply to flows)
|
|
1122
|
+
this.selectNewNode(node);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1104
1125
|
|
|
1105
1126
|
return new Promise(resolve => {
|
|
1106
1127
|
setTimeout(() => {
|
|
@@ -1171,7 +1192,7 @@ export default {
|
|
|
1171
1192
|
this.performSingleUndoRedoTransaction(async() => {
|
|
1172
1193
|
await this.paperManager.performAtomicAction(async() => {
|
|
1173
1194
|
const { x: clientX, y: clientY } = this.paper.localToClientPoint(node.diagram.bounds);
|
|
1174
|
-
const newNode = await this.
|
|
1195
|
+
const newNode = await this.handleDropProcedure({
|
|
1175
1196
|
clientX, clientY,
|
|
1176
1197
|
control: { type: typeToReplaceWith },
|
|
1177
1198
|
nodeThatWillBeReplaced: node,
|
|
@@ -1375,6 +1396,9 @@ export default {
|
|
|
1375
1396
|
this.dragStart = null;
|
|
1376
1397
|
this.isSelecting = false;
|
|
1377
1398
|
},
|
|
1399
|
+
enableMultiplayer() {
|
|
1400
|
+
this.isMultiplayer = true;
|
|
1401
|
+
},
|
|
1378
1402
|
},
|
|
1379
1403
|
created() {
|
|
1380
1404
|
if (runningInCypressTest()) {
|
|
@@ -1540,6 +1564,12 @@ export default {
|
|
|
1540
1564
|
loadXML: async(xml) => {
|
|
1541
1565
|
await this.loadXML(xml);
|
|
1542
1566
|
await undoRedoStore.dispatch('pushState', xml);
|
|
1567
|
+
if (this.isMultiplayer) {
|
|
1568
|
+
window.ProcessMaker.EventBus.$emit('multiplayer-start', {
|
|
1569
|
+
modeler: this,
|
|
1570
|
+
callback: this.enableMultiplayer,
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1543
1573
|
},
|
|
1544
1574
|
addWarnings: warnings => this.$emit('warnings', warnings),
|
|
1545
1575
|
addBreadcrumbs: breadcrumbs => this.breadcrumbData.push(breadcrumbs),
|
|
@@ -70,9 +70,8 @@ export default class Node {
|
|
|
70
70
|
this.definition.id = id;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
setIds(nodeIdGenerator) {
|
|
74
|
-
const [nodeId, diagramId] = nodeIdGenerator.generate();
|
|
75
|
-
|
|
73
|
+
setIds(nodeIdGenerator, id) {
|
|
74
|
+
const [nodeId, diagramId] = id ? [ id + '_di'] : nodeIdGenerator.generate();
|
|
76
75
|
if (!this.id) {
|
|
77
76
|
this.id = nodeId;
|
|
78
77
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<b-avatar-group class="container">
|
|
3
3
|
<template v-for="item in players" >
|
|
4
|
-
<Avatar :badgeBackgroundColor="item.color" :imgSrc=
|
|
4
|
+
<Avatar :badgeBackgroundColor="item.color" :imgSrc="item.imgSrc" :userName="item.name" :key="item.key"/>
|
|
5
5
|
</template>
|
|
6
6
|
</b-avatar-group>
|
|
7
7
|
</template>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { WebsocketProvider } from 'y-websocket';
|
|
3
|
+
import { getNodeIdGenerator } from '../NodeIdGenerator';
|
|
4
|
+
import Room from './room';
|
|
5
|
+
export default class Multiplayer {
|
|
6
|
+
ydoc = null;
|
|
7
|
+
yarray = null;
|
|
8
|
+
modeler = null;
|
|
9
|
+
#nodeIdGenerator = null;
|
|
10
|
+
room = null;
|
|
11
|
+
constructor(modeler) {
|
|
12
|
+
// define document
|
|
13
|
+
this.ydoc = new Y.Doc();
|
|
14
|
+
this.modeler = modeler;
|
|
15
|
+
}
|
|
16
|
+
init() {
|
|
17
|
+
this.#nodeIdGenerator = getNodeIdGenerator(this.modeler.definitions);
|
|
18
|
+
|
|
19
|
+
this.room = new Room('room-' + window.ProcessMaker.modeler.process.id);
|
|
20
|
+
const wsProvider = new WebsocketProvider('ws://localhost:1234', this.room.getRoom(), this.ydoc);
|
|
21
|
+
wsProvider.on('status', () => {
|
|
22
|
+
// todo status handler
|
|
23
|
+
});
|
|
24
|
+
// array of numbers which produce a sum
|
|
25
|
+
this.yarray = this.ydoc.getArray('modeler');
|
|
26
|
+
// observe changes of the diagram
|
|
27
|
+
this.yarray.observe(event => {
|
|
28
|
+
event.changes.delta.forEach((value) =>{
|
|
29
|
+
if (value.insert) {
|
|
30
|
+
value.insert.forEach((value) => {
|
|
31
|
+
this.createShape(value);
|
|
32
|
+
this.#nodeIdGenerator.updateCounters();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
window.ProcessMaker.EventBus.$on('multiplayer-addNode', ( data ) => {
|
|
38
|
+
this.addNode(data);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
addNode(data) {
|
|
42
|
+
this.yarray.push([data]);
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
createShape(value) {
|
|
46
|
+
this.modeler.handleDropProcedure(value, false);
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/setup/globals.js
CHANGED
package/src/setup/initialLoad.js
CHANGED
|
@@ -5,7 +5,7 @@ import './extensions/twitterConnector';
|
|
|
5
5
|
import './extensions/testCustomConnector';
|
|
6
6
|
import './extensions/customMarker';
|
|
7
7
|
import registerNodes from '@/setup/registerNodes';
|
|
8
|
-
|
|
8
|
+
import Multiplayer from '../multiplayer/multiplayer';
|
|
9
9
|
const blank = `
|
|
10
10
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
11
11
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_03dabax" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
|
|
@@ -20,3 +20,9 @@ window.ProcessMaker.EventBus.$on('modeler-init', registerNodes);
|
|
|
20
20
|
window.ProcessMaker.EventBus.$on('modeler-start', ({ loadXML }) => {
|
|
21
21
|
loadXML(blank);
|
|
22
22
|
});
|
|
23
|
+
window.ProcessMaker.EventBus.$on('multiplayer-start', (params) => {
|
|
24
|
+
const multiplayer = new Multiplayer(params.modeler);
|
|
25
|
+
multiplayer.init();
|
|
26
|
+
params.callback();
|
|
27
|
+
});
|
|
28
|
+
|