refactor(editor): Add types to codeNodeEditorEventBus (no-changelog) (#10501)

This commit is contained in:
Tomi Turtiainen 2024-08-22 09:31:40 +03:00 committed by GitHub
parent bcc4bb3c57
commit 18491f6a6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 6 deletions

View file

@ -118,7 +118,7 @@ const i18n = useI18n();
const telemetry = useTelemetry();
onMounted(() => {
if (!props.isReadOnly) codeNodeEditorEventBus.on('error-line-number', highlightLine);
if (!props.isReadOnly) codeNodeEditorEventBus.on('highlightLine', highlightLine);
codeNodeEditorEventBus.on('codeDiffApplied', diffApplied);
@ -188,7 +188,7 @@ onMounted(() => {
onBeforeUnmount(() => {
codeNodeEditorEventBus.off('codeDiffApplied', diffApplied);
if (!props.isReadOnly) codeNodeEditorEventBus.off('error-line-number', highlightLine);
if (!props.isReadOnly) codeNodeEditorEventBus.off('highlightLine', highlightLine);
});
const aiEnabled = computed(() => {

View file

@ -154,7 +154,7 @@ watch(segments, () => {
});
onMounted(() => {
codeNodeEditorEventBus.on('error-line-number', highlightLine);
codeNodeEditorEventBus.on('highlightLine', highlightLine);
if (props.fullscreen) {
focus();
@ -162,7 +162,7 @@ onMounted(() => {
});
onBeforeUnmount(() => {
codeNodeEditorEventBus.off('error-line-number', highlightLine);
codeNodeEditorEventBus.off('highlightLine', highlightLine);
});
function line(lineNumber: number): Line | null {

View file

@ -295,7 +295,7 @@ export function usePushConnection({ router }: { router: ReturnType<typeof useRou
const lineNumber = runDataExecuted?.data?.resultData?.error?.lineNumber;
codeNodeEditorEventBus.emit('error-line-number', lineNumber || 'final');
codeNodeEditorEventBus.emit('highlightLine', lineNumber ?? 'final');
const workflow = workflowHelpers.getCurrentWorkflow();
if (runDataExecuted.waitTill !== undefined) {

View file

@ -1,3 +1,13 @@
import { createEventBus } from 'n8n-design-system/utils';
export const codeNodeEditorEventBus = createEventBus();
export type HighlightLineEvent = number | 'final';
export interface CodeNodeEditorEventBusEvents {
/** Event that a diff have been applied to the code node editor */
codeDiffApplied: never;
/** Command to highlight a specific line in the code node editor */
highlightLine: HighlightLineEvent;
}
export const codeNodeEditorEventBus = createEventBus<CodeNodeEditorEventBusEvents>();