Skip to content

Commit

Permalink
Merge pull request #2489 from Agenta-AI/hot-fix/-replaced-crypto.rand…
Browse files Browse the repository at this point in the history
…om-with-uuidv4-for-id-generation_v2

[Hot Fix]: Replace crypto.randomUUID with uuidv4 for ID generation
  • Loading branch information
bekossy authored Feb 19, 2025
2 parents 6aabd4e + c570119 commit deeb229
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
17 changes: 6 additions & 11 deletions agenta-web/src/components/Editor/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import {forwardRef, useCallback, useEffect, useRef} from "react"

import {LexicalComposer} from "@lexical/react/LexicalComposer"
import {v4 as uuidv4} from "uuid"
import clsx from "clsx"
import {
$createTextNode,
$insertNodes,
COMMAND_PRIORITY_LOW,
EditorState,
LexicalEditor,
createCommand,
} from "lexical"
import {COMMAND_PRIORITY_LOW, EditorState, LexicalEditor, createCommand} from "lexical"
import {$getRoot} from "lexical"
import {$convertFromMarkdownString, $convertToMarkdownString, TRANSFORMERS} from "@lexical/markdown"

Expand All @@ -17,7 +13,6 @@ import useEditorConfig from "./hooks/useEditorConfig"
import EditorPlugins from "./plugins"

import type {EditorProps} from "./types"
import {forwardRef, useCallback, useEffect, useRef} from "react"
import {mergeRegister} from "@lexical/utils"
import {useLexicalComposerContext} from "@lexical/react/LexicalComposerContext"

Expand Down Expand Up @@ -49,7 +44,7 @@ export const ON_HYDRATE_FROM_REMOTE_CONTENT = createCommand<{
const EditorInner = forwardRef<HTMLDivElement, EditorProps>(
(
{
id = crypto.randomUUID(),
id = uuidv4(),
initialValue = "",
onChange,
placeholder = "Enter some text...",
Expand Down Expand Up @@ -178,7 +173,7 @@ const EditorInner = forwardRef<HTMLDivElement, EditorProps>(
)

const Editor = ({
id = crypto.randomUUID(),
id = uuidv4(),
initialValue = "",
disabled = false,
className,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {v4 as uuidv4} from "uuid"

/** String manipulation utilities */
export const toCamelCase = (str: string): string =>
str.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace(/[-_]/g, ""))

export const toSnakeCase = (str: string): string =>
str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)

export const generateId = () => crypto.randomUUID()
export const generateId = () => uuidv4()
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {v4 as uuidv4} from "uuid"

/** String manipulation utilities */
export const toCamelCase = (str: string): string =>
str.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace(/[-_]/g, ""))

export const toSnakeCase = (str: string): string =>
str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)

export const generateId = () => crypto.randomUUID()
export const generateId = () => uuidv4()

0 comments on commit deeb229

Please sign in to comment.