From 7d93fa14c0dd459deb64f9e67b38c9ddecb5109d Mon Sep 17 00:00:00 2001 From: Jozef Marko Date: Fri, 10 Jan 2025 14:23:25 +0100 Subject: [PATCH] pass proper editor instance --- packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx | 7 +++---- packages/online-editor/src/editor/EditorPage.tsx | 1 + .../src/editor/EditorPageDockContextProvider.tsx | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx index ed87734ce80..997be2e6201 100644 --- a/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx +++ b/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx @@ -32,14 +32,13 @@ import setObjectValueByPath from "lodash/set"; import cloneDeep from "lodash/cloneDeep"; import { DmnRunnerProviderActionType } from "./DmnRunnerTypes"; import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider"; -import { useEditorRef } from "@kie-tools-core/editor/dist/embedded"; import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api"; import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi"; +import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded"; -export function DmnRunnerTable() { +export function DmnRunnerTable(props: { editor: EmbeddedEditorRef | undefined }) { // STATEs const [dmnRunnerTableError, setDmnRunnerTableError] = useState(false); - const { editor } = useEditorRef(); // REFs const [inputsContainerRef, setInputsContainerRef] = useState(null); @@ -142,7 +141,7 @@ export function DmnRunnerTable() { jsonSchemaBridge={jsonSchemaBridge} results={results} dmnSpecialCallback={(nodeId: string) => { - const newDmnEditorEnvelopeApi = editor?.getEnvelopeServer() + const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer() .envelopeApi as unknown as MessageBusClientApi; newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId); diff --git a/packages/online-editor/src/editor/EditorPage.tsx b/packages/online-editor/src/editor/EditorPage.tsx index f07e0e515ad..3b8236360b3 100644 --- a/packages/online-editor/src/editor/EditorPage.tsx +++ b/packages/online-editor/src/editor/EditorPage.tsx @@ -468,6 +468,7 @@ Error details: ${err}`); workspaceFile={file.workspaceFile} workspaces={workspaces} dmnLanguageService={dmnLanguageService} + editor={editor} isEditorReady={editor?.isReady ?? false} editorValidate={editor?.validate} > diff --git a/packages/online-editor/src/editor/EditorPageDockContextProvider.tsx b/packages/online-editor/src/editor/EditorPageDockContextProvider.tsx index 692615d5d9e..e4abdd2ce5f 100644 --- a/packages/online-editor/src/editor/EditorPageDockContextProvider.tsx +++ b/packages/online-editor/src/editor/EditorPageDockContextProvider.tsx @@ -35,6 +35,7 @@ import { DmnLanguageService } from "@kie-tools/dmn-language-service"; import { DmnRunnerTable } from "../dmnRunner/DmnRunnerTable"; import { ErrorBoundary } from "../reactExt/ErrorBoundary"; import { DmnRunnerErrorBoundary } from "../dmnRunner/DmnRunnerErrorBoundary"; +import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded"; interface EditorPageDockContextType { panel: PanelId; @@ -74,6 +75,7 @@ interface Props { workspaces: WorkspacesContextType; dmnLanguageService?: DmnLanguageService; isEditorReady: boolean; + editor: EmbeddedEditorRef | undefined; editorValidate?: () => Promise; } @@ -83,6 +85,7 @@ export function EditorPageDockContextProvider({ workspaces, workspaceFile, isEditorReady, + editor, editorValidate, }: React.PropsWithChildren) { const { i18n } = useOnlineI18n(); @@ -186,7 +189,7 @@ export function EditorPageDockContextProvider({ case PanelId.DMN_RUNNER_TABLE: return ( - + ); default: