🔧 fix(constants.ts): add specialCharsRegex constant to match special characters in strings
🔧 fix(reactflowUtils.ts): update handleKeyDown function to prevent deletion of block when a special character is the last character in the input value
This commit is contained in:
parent
e2f0f2069e
commit
9acf9e39aa
2 changed files with 7 additions and 1 deletions
|
|
@ -29,6 +29,7 @@ export const INVALID_CHARACTERS = [
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const regexHighlight = /\{([^}]+)\}/g;
|
export const regexHighlight = /\{([^}]+)\}/g;
|
||||||
|
export const specialCharsRegex = /[!@#$%^&*()\-_=+[\]{}|;:'",.<>/?\\]/;
|
||||||
|
|
||||||
export const programmingLanguages: languageMap = {
|
export const programmingLanguages: languageMap = {
|
||||||
javascript: ".js",
|
javascript: ".js",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { APITemplateType } from "../types/api";
|
||||||
import { FlowType, NodeType } from "../types/flow";
|
import { FlowType, NodeType } from "../types/flow";
|
||||||
import { cleanEdgesType } from "../types/utils/reactflowUtils";
|
import { cleanEdgesType } from "../types/utils/reactflowUtils";
|
||||||
import { toNormalCase } from "./utils";
|
import { toNormalCase } from "./utils";
|
||||||
|
import { specialCharsRegex } from "../constants/constants";
|
||||||
|
|
||||||
export function cleanEdges({
|
export function cleanEdges({
|
||||||
flow: { edges, nodes },
|
flow: { edges, nodes },
|
||||||
|
|
@ -235,7 +236,11 @@ export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) {
|
||||||
|
|
||||||
export function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>, inputValue: string | string[] | null, block: string)
|
export function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>, inputValue: string | string[] | null, block: string)
|
||||||
{
|
{
|
||||||
if (typeof inputValue === "string" && e.ctrlKey && e.key === "Backspace" && (inputValue === block || inputValue?.charAt(inputValue?.length - 1) === ' ')) {
|
|
||||||
|
if (typeof inputValue === "string" && e.ctrlKey && e.key === "Backspace" &&
|
||||||
|
(inputValue === block || inputValue?.charAt(inputValue?.length - 1) === ' '
|
||||||
|
|| specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1))
|
||||||
|
)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue