260826_01_ENH: notihub 수정으로 인한 후속 조치
This commit is contained in:
@@ -26,6 +26,7 @@ export function KriEditorSms({
|
||||
isSmsReadOnly = false,
|
||||
smsMaxBytes = 90,
|
||||
lmsMaxBytes = 2000,
|
||||
smsPreviewSuffix = '',
|
||||
}: SmsEditorProps) {
|
||||
const [text, setText] = React.useState(value || '')
|
||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
||||
@@ -33,7 +34,8 @@ export function KriEditorSms({
|
||||
const lastTypeRef = React.useRef<'SMS' | 'LMS' | null>(null)
|
||||
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
||||
const textareaInsert = useTextareaInsert(textareaRef)
|
||||
const byteSize = React.useMemo(() => calculateBytes(text), [text])
|
||||
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 maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
||||
|
||||
@@ -97,7 +99,8 @@ export function KriEditorSms({
|
||||
value={text}
|
||||
onChange={(event) => {
|
||||
const next = event.target.value
|
||||
if (calculateBytes(next) <= lmsMaxBytes) commitText(next)
|
||||
const nextPreview = smsPreviewSuffix ? `${next}\n${smsPreviewSuffix}` : next
|
||||
if (calculateBytes(nextPreview) <= lmsMaxBytes) commitText(next)
|
||||
}}
|
||||
onBlur={() => flushChange(latestTextRef.current)}
|
||||
placeholder={placeholder}
|
||||
@@ -105,6 +108,11 @@ export function KriEditorSms({
|
||||
style={{ minHeight: smsTitle ? '320px' : '360px' }}
|
||||
{...textareaInsert.bindSelectionHandlers}
|
||||
/>
|
||||
{smsPreviewSuffix ? (
|
||||
<div className="whitespace-pre-wrap px-4 pb-4 text-sm leading-relaxed text-gray-700">
|
||||
{smsPreviewSuffix}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{byteSize > maxBytes ? (
|
||||
<p className="mt-2 px-2 text-center text-xs font-medium text-red-600">
|
||||
|
||||
@@ -74,6 +74,7 @@ export type KriEditorProps = {
|
||||
isSmsReadOnly?: boolean
|
||||
smsMaxBytes?: number
|
||||
lmsMaxBytes?: number
|
||||
smsPreviewSuffix?: string
|
||||
toolbar?: KriEditorToolbarConfig | false
|
||||
fontFamilyOptions?: KriEditorFontFamilyOption[]
|
||||
renderToolbarEnd?: (context: KriEditorToolbarContext) => ReactNode
|
||||
|
||||
Reference in New Issue
Block a user