Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove useBpmnModeler #14464

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions frontend/packages/process-editor/src/hooks/useBpmnEditor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useCallback } from 'react';
import { useBpmnContext } from '../contexts/BpmnContext';
import { useBpmnModeler } from './useBpmnModeler';
import { BpmnModelerInstance } from '../utils/bpmnModeler/BpmnModelerInstance';
import { useBpmnConfigPanelFormContext } from '../contexts/BpmnConfigPanelContext';
import { useBpmnApiContext } from '../contexts/BpmnApiContext';
import type { TaskEvent } from '../types/TaskEvent';
Expand All @@ -15,7 +15,6 @@ export type UseBpmnEditorResult = (div: HTMLDivElement) => void;
export const useBpmnEditor = (): UseBpmnEditorResult => {
const { getUpdatedXml, bpmnXml, modelerRef, setBpmnDetails } = useBpmnContext();
const { metadataFormRef, resetForm } = useBpmnConfigPanelFormContext();
const { getModeler, destroyModeler } = useBpmnModeler();
const { addAction } = useStudioRecommendedNextActionContext();

const { saveBpmn, onProcessTaskAdd, onProcessTaskRemove } = useBpmnApiContext();
Expand Down Expand Up @@ -96,10 +95,7 @@ export const useBpmnEditor = (): UseBpmnEditorResult => {
const canvasRef = useCallback((div: HTMLDivElement) => {
if (modelerRef.current) return;

// GetModeler can only be fetched from this hook once since the modeler creates a
// new instance and will attach the same canvasRef container to all instances it fetches.
// Set modelerRef.current to the Context so that it can be used in other components
modelerRef.current = getModeler(div);
modelerRef.current = BpmnModelerInstance.getInstance(div);

initializeEditor().then(() => {
// Wait for the initializeEditor to be initialized before attaching event listeners, to avoid trigger add.shape events on first draw
Expand All @@ -112,7 +108,7 @@ export const useBpmnEditor = (): UseBpmnEditorResult => {
useEffect(() => {
// Destroy the modeler instance when the component is unmounted
return () => {
destroyModeler();
BpmnModelerInstance.destroyInstance();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading