refactor: unified cn utils (#29916)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
This commit is contained in:
Stephen Zhou
2025-12-19 12:08:34 +08:00
committed by GitHub
parent 80f11471ae
commit a26881cb24
815 changed files with 1064 additions and 1227 deletions

View File

@@ -5,7 +5,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import VarHighlight from '../../app/configuration/base/var-highlight'
import Toast from '../toast'
import classNames from '@/utils/classnames'
import { cn } from '@/utils/classnames'
import { checkKeys } from '@/utils/var'
// regex to match the {{}} and replace it with a span
@@ -61,7 +61,7 @@ const BlockInput: FC<IBlockInputProps> = ({
}
}, [isEditing])
const style = classNames({
const style = cn({
'block px-4 py-2 w-full h-full text-sm text-gray-900 outline-0 border-0 break-all': true,
'block-input--editing': isEditing,
})
@@ -110,7 +110,7 @@ const BlockInput: FC<IBlockInputProps> = ({
// Prevent rerendering caused cursor to jump to the start of the contentEditable element
const TextAreaContentView = () => {
return (
<div className={classNames(style, className)}>
<div className={cn(style, className)}>
{renderSafeContent(currentValue || '')}
</div>
)
@@ -120,12 +120,12 @@ const BlockInput: FC<IBlockInputProps> = ({
const editAreaClassName = 'focus:outline-none bg-transparent text-sm'
const textAreaContent = (
<div className={classNames(readonly ? 'max-h-[180px] pb-5' : 'h-[180px]', ' overflow-y-auto')} onClick={() => !readonly && setIsEditing(true)}>
<div className={cn(readonly ? 'max-h-[180px] pb-5' : 'h-[180px]', ' overflow-y-auto')} onClick={() => !readonly && setIsEditing(true)}>
{isEditing
? <div className='h-full px-4 py-2'>
<textarea
ref={contentEditableRef}
className={classNames(editAreaClassName, 'block h-full w-full resize-none')}
className={cn(editAreaClassName, 'block h-full w-full resize-none')}
placeholder={placeholder}
onChange={onValueChange}
value={currentValue}
@@ -143,7 +143,7 @@ const BlockInput: FC<IBlockInputProps> = ({
</div>)
return (
<div className={classNames('block-input w-full overflow-y-auto rounded-xl border-none bg-white')}>
<div className={cn('block-input w-full overflow-y-auto rounded-xl border-none bg-white')}>
{textAreaContent}
{/* footer */}
{!readonly && (