mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
feat: No expression error when node hasn’t executed (#8448)
Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -4,11 +4,17 @@ import { StateField, StateEffect } from '@codemirror/state';
|
||||
import { tags } from '@lezer/highlight';
|
||||
import { syntaxHighlighting, HighlightStyle } from '@codemirror/language';
|
||||
|
||||
import type { ColoringStateEffect, Plaintext, Resolvable } from '@/types/expressions';
|
||||
import type {
|
||||
ColoringStateEffect,
|
||||
Plaintext,
|
||||
Resolvable,
|
||||
ResolvableState,
|
||||
} from '@/types/expressions';
|
||||
|
||||
const cssClasses = {
|
||||
validResolvable: 'cm-valid-resolvable',
|
||||
invalidResolvable: 'cm-invalid-resolvable',
|
||||
pendingResolvable: 'cm-pending-resolvable',
|
||||
brokenResolvable: 'cm-broken-resolvable',
|
||||
plaintext: 'cm-plaintext',
|
||||
};
|
||||
@@ -22,20 +28,25 @@ const resolvablesTheme = EditorView.theme({
|
||||
color: 'var(--color-invalid-resolvable-foreground)',
|
||||
backgroundColor: 'var(--color-invalid-resolvable-background)',
|
||||
},
|
||||
['.' + cssClasses.pendingResolvable]: {
|
||||
color: 'var(--color-pending-resolvable-foreground)',
|
||||
backgroundColor: 'var(--color-pending-resolvable-background)',
|
||||
},
|
||||
});
|
||||
|
||||
const marks = {
|
||||
const resolvableStateToDecoration: Record<ResolvableState, Decoration> = {
|
||||
valid: Decoration.mark({ class: cssClasses.validResolvable }),
|
||||
invalid: Decoration.mark({ class: cssClasses.invalidResolvable }),
|
||||
pending: Decoration.mark({ class: cssClasses.pendingResolvable }),
|
||||
};
|
||||
|
||||
const coloringStateEffects = {
|
||||
addColorEffect: StateEffect.define<ColoringStateEffect.Value>({
|
||||
map: ({ from, to, kind, error }, change) => ({
|
||||
map: ({ from, to, kind, state }, change) => ({
|
||||
from: change.mapPos(from),
|
||||
to: change.mapPos(to),
|
||||
kind,
|
||||
error,
|
||||
state,
|
||||
}),
|
||||
}),
|
||||
removeColorEffect: StateEffect.define<ColoringStateEffect.Value>({
|
||||
@@ -66,7 +77,7 @@ const coloringStateField = StateField.define<DecorationSet>({
|
||||
filter: (from, to) => txEffect.value.from !== from && txEffect.value.to !== to,
|
||||
});
|
||||
|
||||
const decoration = txEffect.value.error ? marks.invalid : marks.valid;
|
||||
const decoration = resolvableStateToDecoration[txEffect.value.state ?? 'pending'];
|
||||
|
||||
if (txEffect.value.from === 0 && txEffect.value.to === 0) continue;
|
||||
|
||||
@@ -81,8 +92,8 @@ const coloringStateField = StateField.define<DecorationSet>({
|
||||
});
|
||||
|
||||
function addColor(view: EditorView, segments: Resolvable[]) {
|
||||
const effects: Array<StateEffect<unknown>> = segments.map(({ from, to, kind, error }) =>
|
||||
coloringStateEffects.addColorEffect.of({ from, to, kind, error }),
|
||||
const effects: Array<StateEffect<unknown>> = segments.map(({ from, to, kind, state }) =>
|
||||
coloringStateEffects.addColorEffect.of({ from, to, kind, state }),
|
||||
);
|
||||
|
||||
if (effects.length === 0) return;
|
||||
|
||||
Reference in New Issue
Block a user