@flowuent-org/diagramming-core 1.1.1 → 1.1.2
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/apps/diagramming/src/AutomationDiagramData.ts +8 -8
- package/package.json +1 -1
- package/packages/diagrams/src/lib/components/automation/AISuggestionsPanel.tsx +6 -7
- package/packages/diagrams/src/lib/contexts/DiagramProvider.tsx +1 -1
- package/packages/diagrams/src/lib/hooks/useWorkflowNodeActiont.ts +8 -8
- package/packages/diagrams/src/lib/templates/DiagramContent.tsx +15 -1
- package/packages/diagrams/src/lib/utils/create-updated.tsx +2 -2
|
@@ -5,7 +5,7 @@ export const automationDefaultNodes = [
|
|
|
5
5
|
{
|
|
6
6
|
id: 'start-node',
|
|
7
7
|
type: 'AutomationStartNode',
|
|
8
|
-
position: { x:
|
|
8
|
+
position: { x: 100, y: 200 },
|
|
9
9
|
data: {
|
|
10
10
|
// Display data for the node UI
|
|
11
11
|
label: 'Workflow Trigger',
|
|
@@ -61,7 +61,7 @@ export const automationDefaultNodes = [
|
|
|
61
61
|
{
|
|
62
62
|
id: 'api-call-node',
|
|
63
63
|
type: 'AutomationApiNode',
|
|
64
|
-
position: { x:
|
|
64
|
+
position: { x: 500, y: 200 },
|
|
65
65
|
data: {
|
|
66
66
|
// Display data for the node UI
|
|
67
67
|
label: 'Discover Headlines',
|
|
@@ -152,7 +152,7 @@ export const automationDefaultNodes = [
|
|
|
152
152
|
{
|
|
153
153
|
id: 'ai-suggestion-node',
|
|
154
154
|
type: 'AutomationAISuggestionNode',
|
|
155
|
-
position: { x:
|
|
155
|
+
position: { x: 900, y: 200 },
|
|
156
156
|
data: {
|
|
157
157
|
label: 'Citation Extractor',
|
|
158
158
|
description: 'Extract and format citation from article text.',
|
|
@@ -174,7 +174,7 @@ export const automationDefaultNodes = [
|
|
|
174
174
|
{
|
|
175
175
|
id: 'data-formatting-node',
|
|
176
176
|
type: 'AutomationFormattingNode',
|
|
177
|
-
position: { x:
|
|
177
|
+
position: { x: 700, y: 200 },
|
|
178
178
|
data: {
|
|
179
179
|
// Display data for the node UI
|
|
180
180
|
label: 'Article Analyzer',
|
|
@@ -249,7 +249,7 @@ export const automationDefaultNodes = [
|
|
|
249
249
|
{
|
|
250
250
|
id: 'google-sheets-node',
|
|
251
251
|
type: 'AutomationSheetsNode',
|
|
252
|
-
position: { x:
|
|
252
|
+
position: { x: 1100, y: 200 },
|
|
253
253
|
data: {
|
|
254
254
|
// Display data for the node UI
|
|
255
255
|
label: 'Data Sync Node',
|
|
@@ -357,7 +357,7 @@ export const automationDefaultNodes = [
|
|
|
357
357
|
{
|
|
358
358
|
id: 'note-node-1',
|
|
359
359
|
type: 'AutomationNoteNode',
|
|
360
|
-
position: { x:
|
|
360
|
+
position: { x: 700, y: 50 },
|
|
361
361
|
data: {
|
|
362
362
|
label: 'Article Analyzer',
|
|
363
363
|
description:
|
|
@@ -388,7 +388,7 @@ export const automationDefaultNodes = [
|
|
|
388
388
|
{
|
|
389
389
|
id: 'note-node-2',
|
|
390
390
|
type: 'AutomationNoteNode',
|
|
391
|
-
position: { x:
|
|
391
|
+
position: { x: 500, y: 50 },
|
|
392
392
|
data: {
|
|
393
393
|
label: 'Discover Headlines',
|
|
394
394
|
description:
|
|
@@ -419,7 +419,7 @@ export const automationDefaultNodes = [
|
|
|
419
419
|
{
|
|
420
420
|
id: 'end-node',
|
|
421
421
|
type: 'AutomationEndNode',
|
|
422
|
-
position: { x:
|
|
422
|
+
position: { x: 1500, y: 200 },
|
|
423
423
|
data: {
|
|
424
424
|
// Display data for the node UI
|
|
425
425
|
label: 'Results Display',
|
package/package.json
CHANGED
|
@@ -24,11 +24,10 @@ export const AISuggestionsPanel: React.FC<AISuggestionsPanelProps> = ({
|
|
|
24
24
|
const parentNode = getNode(parentNodeId);
|
|
25
25
|
if (!parentNode) return;
|
|
26
26
|
|
|
27
|
-
// Calculate position for new node -
|
|
28
|
-
// Node
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const newNodeY = parentNode.position.y + nodeHeight + 40 + panelHeight + 40;
|
|
27
|
+
// Calculate position for new node - to the right of the parent node
|
|
28
|
+
// Node width + spacing
|
|
29
|
+
const nodeWidth = parentNode.width || 336;
|
|
30
|
+
const newNodeX = parentNode.position.x + nodeWidth + 50;
|
|
32
31
|
|
|
33
32
|
// Create new AI Suggestion node
|
|
34
33
|
const newNodeId = `ai-suggestion-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
@@ -55,8 +54,8 @@ export const AISuggestionsPanel: React.FC<AISuggestionsPanelProps> = ({
|
|
|
55
54
|
id: newNodeId,
|
|
56
55
|
type: 'AutomationAISuggestionNode',
|
|
57
56
|
position: {
|
|
58
|
-
x:
|
|
59
|
-
y:
|
|
57
|
+
x: newNodeX,
|
|
58
|
+
y: parentNode.position.y,
|
|
60
59
|
},
|
|
61
60
|
data: {
|
|
62
61
|
label: suggestion.title,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
createUpdatedEdges,
|
|
11
11
|
createUpdatedNodes,
|
|
12
12
|
} from '../utils/create-updated';
|
|
13
|
-
import { getNodeHeight } from '../utils/utilities';
|
|
13
|
+
import { getNodeHeight, getNodeWidth } from '../utils/utilities';
|
|
14
14
|
import {
|
|
15
15
|
useDiagram,
|
|
16
16
|
useGetDefaultNodeData,
|
|
@@ -154,7 +154,7 @@ export const useGenerateNodesAndEdges = () => {
|
|
|
154
154
|
position:
|
|
155
155
|
index === 0
|
|
156
156
|
? position
|
|
157
|
-
: { x: position.x
|
|
157
|
+
: { x: position.x + (constantLengths.SUB_NODE_WIDTH + constantLengths.CONNECTION_LENGTH) * index, y: position.y },
|
|
158
158
|
replacingNode: isReplacement && index === 0 ? currentNode : {},
|
|
159
159
|
});
|
|
160
160
|
node.data.branchIndex = nodeInfo.branchIndex;
|
|
@@ -165,7 +165,7 @@ export const useGenerateNodesAndEdges = () => {
|
|
|
165
165
|
const edge = createEdgeConnection({
|
|
166
166
|
sourceId: newNodes[edgeInfo.source].id,
|
|
167
167
|
targetId: newNodes[edgeInfo.target].id,
|
|
168
|
-
sourceHandle: `${newNodes[edgeInfo.source].id}-
|
|
168
|
+
sourceHandle: `${newNodes[edgeInfo.source].id}-right`,
|
|
169
169
|
edgeLabel: edgeInfo.label,
|
|
170
170
|
});
|
|
171
171
|
if (edge) newEdges.push(edge);
|
|
@@ -203,11 +203,11 @@ export const useCalculateNewNodesAndEdges = () => {
|
|
|
203
203
|
: isParallelRoot || addBeforeCurrentNode
|
|
204
204
|
? { x: 0, y: constantLengths.NODE_TOP_HEIGHT }
|
|
205
205
|
: {
|
|
206
|
-
x:
|
|
207
|
-
|
|
208
|
-
currentNode
|
|
209
|
-
getNodeHeight(currentNode) +
|
|
206
|
+
x:
|
|
207
|
+
currentNode.position.x +
|
|
208
|
+
getNodeWidth(currentNode) +
|
|
210
209
|
constantLengths.CONNECTION_LENGTH,
|
|
210
|
+
y: currentNode.position.y,
|
|
211
211
|
};
|
|
212
212
|
|
|
213
213
|
const { nodes, edges } = generateNodesAndEdges(
|
|
@@ -224,7 +224,7 @@ export const useCalculateNewNodesAndEdges = () => {
|
|
|
224
224
|
createEdgeConnection({
|
|
225
225
|
sourceId: currentNode.id,
|
|
226
226
|
targetId: nodes[0].id,
|
|
227
|
-
sourceHandle: `${currentNode.id}-
|
|
227
|
+
sourceHandle: `${currentNode.id}-right`,
|
|
228
228
|
})!,
|
|
229
229
|
);
|
|
230
230
|
}
|
|
@@ -116,12 +116,18 @@ export const DiagramContent: React.FC<DiagramContentProps> = ({
|
|
|
116
116
|
const layoutDirection = useLayoutDirection();
|
|
117
117
|
const setLayoutDirection = useSetLayoutDirection();
|
|
118
118
|
|
|
119
|
+
// Set layout direction to RIGHT for automation diagrams
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (diagramType === 'automation' && layoutDirection !== 'RIGHT') {
|
|
122
|
+
setLayoutDirection('RIGHT');
|
|
123
|
+
}
|
|
124
|
+
}, [diagramType, layoutDirection, setLayoutDirection]);
|
|
119
125
|
|
|
120
126
|
useEffect(() => {
|
|
121
127
|
getLayoutedElements();
|
|
122
128
|
|
|
123
129
|
return () => { };
|
|
124
|
-
}, [nodes.length, edges.length, contentHeights, diagramType]);
|
|
130
|
+
}, [nodes.length, edges.length, contentHeights, diagramType, layoutDirection, getLayoutedElements]);
|
|
125
131
|
|
|
126
132
|
// Listen for layout direction changes
|
|
127
133
|
useEffect(() => {
|
|
@@ -208,6 +214,14 @@ export const DiagramContent: React.FC<DiagramContentProps> = ({
|
|
|
208
214
|
edges={visibleEdges}
|
|
209
215
|
onEdgesChange={onEdgesChange}
|
|
210
216
|
fitView
|
|
217
|
+
fitViewOptions={{
|
|
218
|
+
padding: 0.2,
|
|
219
|
+
minZoom: 0.3,
|
|
220
|
+
maxZoom: 2,
|
|
221
|
+
includeHiddenNodes: false,
|
|
222
|
+
}}
|
|
223
|
+
minZoom={0.1}
|
|
224
|
+
maxZoom={2}
|
|
211
225
|
onNodeDragStart={onNodeDragStart}
|
|
212
226
|
onNodeDragStop={onNodeDragEnd}
|
|
213
227
|
onConnect={onConnect}
|
|
@@ -28,8 +28,8 @@ export const createUpdatedEdges = (
|
|
|
28
28
|
? {
|
|
29
29
|
...e,
|
|
30
30
|
source,
|
|
31
|
-
id: `${source}-
|
|
32
|
-
sourceHandle: `${source}-
|
|
31
|
+
id: `${source}-rightv${e.target}`, // Ensure edge ID includes handle
|
|
32
|
+
sourceHandle: `${source}-right`, // Update the source handle ID for horizontal workflow
|
|
33
33
|
}
|
|
34
34
|
: e,
|
|
35
35
|
);
|