Repository: novuhq/novu
File: apps/dashboard/src/components/maily/maily-config.tsx (TypeScript)

Code before:
        );
      },
      addAttributes() {
        const attributes = this.parent?.();
        return {
          ...attributes,
          aliasFor: {
            default: null,
          },
        };
      },
    }).configure({
      suggestion: {
        ...getVariableSuggestions(VARIABLE_TRIGGER_CHARACTER),
        command: ({ editor, range, props }) => {
          const query = props.id + '}}';

          const existsInSchema = parsedVariables.variables.some((v) => v.name === props.id);
          const isNewVariable = !existsInSchema;

          if (props.id === TRANSLATION_NAMESPACE_SEPARATOR) {
            // just insert "{{t." (not closed) to trigger the translation extension
            editor.chain().focus().insertContentAt(range, TRANSLATION_TRIGGER_CHARACTER).run();

            return;
          }

          if (isNewVariable) {
            // todo test current repeat stuff
            const variableName = props.id.replace('current.', '');
            onCreateNewVariable?.(variableName);

            insertVariableToEditor({
              query,
              editor,
              range,
            });
          } else {
            // Calculate aliasFor before validation to properly handle "current." variables
            const aliasFor = resolveRepeatBlockAlias(props.id, editor);
            const isAllowed = parsedVariables.isAllowedVariable({
              name: props.id,
              aliasFor,
            });

            if (!isAllowed) {
              return;
            }

            insertVariableToEditor({
              query,

Review comment (bug):
This seems to be all redundant - we check these things already when calculating the variable suggestions, I haven't spot any regression after removing this

Also, `current.payload.*` would create a new payload variable in regular payload, which is incorrect/bug - `current` indicates some iterable, therefore `current.payload` would need to create a payload variable within that iterable not in current step top-level payload.  

Code after:
        );
      },
      addAttributes() {
        const attributes = this.parent?.();
        return {
          ...attributes,
          aliasFor: {
            default: null,
          },
        };
      },
    }).configure({
      suggestion: {
        ...getVariableSuggestions(VARIABLE_TRIGGER_CHARACTER),
        command: ({ editor, range, props }) => {
          const query = props.id + '}}';

          const existsInSchema = parsedVariables.variables.some((v) => v.name === props.id);
          const isNewVariable = !existsInSchema && !props.id.startsWith('current.');

          if (props.id === TRANSLATION_NAMESPACE_SEPARATOR) {
            // just insert "{{t." (not closed) to trigger the translation extension
            editor.chain().focus().insertContentAt(range, TRANSLATION_TRIGGER_CHARACTER).run();

            return;
          }

          if (isNewVariable) {
            const variableName = props.id;
            onCreateNewVariable?.(variableName);

            insertVariableToEditor({
              query,
              editor,
              range,
            });
          } else {
            // Calculate aliasFor before validation to properly handle "current." variables
            const aliasFor = resolveRepeatBlockAlias(props.id, editor);
            const isAllowed = parsedVariables.isAllowedVariable({
              name: props.id,
              aliasFor,
            });

            if (!isAllowed) {
              return;
            }

            insertVariableToEditor({
              query,
              editor,