261001_01_ENH: mms 파일 미리보기 추가
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "kri-ui-registry",
|
||||
"version": "0.12.0",
|
||||
"version": "0.13.0",
|
||||
"private": true,
|
||||
"description": "KRI internal shadcn UI registry",
|
||||
"scripts": {
|
||||
|
||||
@@ -27,6 +27,8 @@ export function KriEditorSms({
|
||||
smsMaxBytes = 90,
|
||||
lmsMaxBytes = 2000,
|
||||
smsPreviewSuffix = '',
|
||||
smsHasAttachment = false,
|
||||
smsImages = [],
|
||||
}: SmsEditorProps) {
|
||||
const [text, setText] = React.useState(value || '')
|
||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
||||
@@ -36,7 +38,7 @@ export function KriEditorSms({
|
||||
const textareaInsert = useTextareaInsert(textareaRef)
|
||||
const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text
|
||||
const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText])
|
||||
const messageType: 'SMS' | 'LMS' = byteSize > smsMaxBytes || Boolean(smsTitle) ? 'LMS' : 'SMS'
|
||||
const messageType: 'SMS' | 'LMS' = byteSize > smsMaxBytes || Boolean(smsTitle) || smsHasAttachment ? 'LMS' : 'SMS'
|
||||
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
||||
|
||||
const commitText = React.useCallback((next: string, immediate = false) => {
|
||||
@@ -88,11 +90,19 @@ export function KriEditorSms({
|
||||
<div className="mb-3 flex items-center justify-between px-2">
|
||||
<span className="text-xs font-medium text-gray-600">{byteSize}/{maxBytes}byte</span>
|
||||
<span className={cn('rounded-md px-3 py-1 text-xs font-bold text-white', messageType === 'LMS' ? 'bg-blue-500' : 'bg-red-500')}>
|
||||
{messageType}
|
||||
{messageType === 'LMS' ? 'LMS/MMS' : 'SMS'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-1 flex-col overflow-hidden rounded-2xl bg-white shadow-sm">
|
||||
<div className={cn('flex flex-1 flex-col rounded-2xl bg-white shadow-sm', smsImages.length > 0 ? 'overflow-y-auto' : 'overflow-hidden')}>
|
||||
{smsTitle ? <div className="px-4 pt-3 pb-2 text-sm font-bold text-gray-800">{smsTitle}</div> : null}
|
||||
{smsImages.length > 0 ? (
|
||||
<div className="flex shrink-0 flex-col gap-2 px-4 pt-3">
|
||||
{smsImages.map((image) => (
|
||||
// eslint-disable-next-line @next/next/no-img-element -- data/Object URL 미리보기라 next/image 최적화 대상이 아님
|
||||
<img key={image.fileName} src={image.src} alt={image.fileName} title={image.fileName} className="w-full rounded-md object-contain" />
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<textarea
|
||||
ref={textareaRef}
|
||||
className="w-full flex-1 resize-none bg-transparent p-4 text-sm leading-relaxed text-gray-700 outline-none"
|
||||
@@ -105,7 +115,7 @@ export function KriEditorSms({
|
||||
onBlur={() => flushChange(latestTextRef.current)}
|
||||
placeholder={placeholder}
|
||||
readOnly={isSmsReadOnly}
|
||||
style={{ minHeight: smsTitle ? '320px' : '360px' }}
|
||||
style={{ minHeight: smsImages.length > 0 ? '160px' : smsTitle ? '320px' : '360px' }}
|
||||
{...textareaInsert.bindSelectionHandlers}
|
||||
/>
|
||||
{smsPreviewSuffix ? (
|
||||
|
||||
@@ -50,6 +50,11 @@ export type KriEditorFontFamilyOption = {
|
||||
value: string
|
||||
}
|
||||
|
||||
export type KriEditorSmsImage = {
|
||||
fileName: string
|
||||
src: string
|
||||
}
|
||||
|
||||
export type KriEditorProps = {
|
||||
onEditorReady?: (editor: Editor | HTMLTextAreaElement | null) => void
|
||||
onCommandReady?: (command: KriEditorCommand | null) => void
|
||||
@@ -80,6 +85,10 @@ export type KriEditorProps = {
|
||||
smsMaxBytes?: number
|
||||
lmsMaxBytes?: number
|
||||
smsPreviewSuffix?: string
|
||||
/** 첨부파일이 있으면 길이·제목과 무관하게 LMS/MMS로 판정한다. */
|
||||
smsHasAttachment?: boolean
|
||||
/** 문자 미리보기의 제목과 본문 사이에 표시할 첨부 이미지 */
|
||||
smsImages?: KriEditorSmsImage[]
|
||||
toolbar?: KriEditorToolbarConfig | false
|
||||
fontFamilyOptions?: KriEditorFontFamilyOption[]
|
||||
renderToolbarEnd?: (context: KriEditorToolbarContext) => ReactNode
|
||||
|
||||
Reference in New Issue
Block a user