Merge commit '8c700b1e080a29a02375664e856bc6e5b757c7c3' into feature/negodata
This commit is contained in:
commit
9ac8fe6363
26 files changed
+530
-62
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { DataTable } from '@/components/ui/data-table';
|
||||
import { renderEmphasis } from '@/lib/emphasis';
|
||||
import type { NegotiationCard } from '../types';
|
||||
|
||||
type CardTableProps = {
|
||||
@@ -67,7 +68,8 @@ export function CardTable({ data, onEdit, footer }: CardTableProps) {
|
||||
mobileBlock: true, // 긴 미리보기 블록 → 모바일 카드뷰에서 라벨 아래 풀폭
|
||||
cell: (card) => (
|
||||
<div className="max-w-[22rem] truncate bg-muted/20 px-2 py-1 rounded border border-border/30 text-[11px] leading-snug">
|
||||
{card.scriptPreview}
|
||||
{/* 마커(**굵게**·{{색}})를 스타일로 렌더 — 표 미리보기에 원시 마커가 보이지 않게 */}
|
||||
{renderEmphasis(card.scriptPreview)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export { CardScriptEditor } from './CardScriptEditor';
|
||||
// deserialize() 는 항상 새 배열을 반환 → Slate initialValue 로 안전. 공용 mutable 상수는 export 하지 않는다.
|
||||
export { deserialize, serializeToText } from './slate';
|
||||
export { deserialize, serializeToText, serializeToMarker } from './slate';
|
||||
export { CARD_VARIABLES } from './variables';
|
||||
@@ -96,6 +96,38 @@ function serializeNode(node: Descendant): string {
|
||||
return node.text;
|
||||
}
|
||||
|
||||
// ── 직렬화: Slate 값 → 마커 문자열(script) ──────────────────
|
||||
// bold/underline/color 마크를 경량 마커로 인코딩해 저장한다(edit_script=Slate 원본은 재편집용).
|
||||
// agent 는 이 문자열을 불투명 텍스트로 전달하고, 각 프론트 emphasis.tsx 가 마커를 렌더한다.
|
||||
// 고정 팔레트(검정/빨강/파랑) → 시맨틱 토큰. 검정(#151515)은 기본이라 마커 없음.
|
||||
const COLOR_TO_TOKEN: Record<string, string> = {
|
||||
'#ED2024': '강조', // 빨강
|
||||
'#4880EF': '안내', // 파랑
|
||||
};
|
||||
|
||||
export function serializeToMarker(nodes: Descendant[]): string {
|
||||
return nodes.map(serializeMarkerNode).join('\n');
|
||||
}
|
||||
|
||||
function serializeMarkerNode(node: Descendant): string {
|
||||
if (SlateElement.isElement(node)) {
|
||||
if (node.type === 'variable') return applyMarks(`{${node.name}}`, node.children[0]);
|
||||
return node.children.map(serializeMarkerNode).join('');
|
||||
}
|
||||
return applyMarks(node.text, node);
|
||||
}
|
||||
|
||||
// 텍스트/변수 리프의 마크를 마커로 감싼다. 중첩 순서: 색(바깥) → 굵게 → 밑줄(안). 빈 문자열은 그대로.
|
||||
function applyMarks(text: string, leaf?: CustomText): string {
|
||||
if (!text || !leaf) return text;
|
||||
let s = text;
|
||||
if (leaf.underline) s = `__${s}__`;
|
||||
if (leaf.bold) s = `**${s}**`;
|
||||
const token = leaf.color ? COLOR_TO_TOKEN[leaf.color] : undefined;
|
||||
if (token) s = `{{${token}|${s}}}`;
|
||||
return s;
|
||||
}
|
||||
|
||||
// ── 역직렬화: edit_script(JSON) 또는 평문(script) → Slate 값 ──
|
||||
// 저장된 edit_script 가 있으면 그대로, 없으면(레거시 평문 카드) {name} 토큰을 변수 노드로 복원.
|
||||
// Slate 는 initialValue 를 레퍼런스로 직접 변경하므로 항상 새 배열을 돌려준다
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { ResCard } from '@/api/generated/model/resCard';
|
||||
import type { NegotiationCard } from '@/types';
|
||||
import type { BulkFailure } from '@/lib/excel';
|
||||
import { mapCardData, toCardStatusCode } from '../types';
|
||||
import { serializeToText } from '../editor';
|
||||
import { serializeToMarker } from '../editor';
|
||||
|
||||
// 카드 폼이 넘기는 입력값(편집/생성 공통).
|
||||
// 스크립트는 Slate JSON(editorScript)을 정본으로 받고, 평문 script 는 저장 시 직렬화로 파생한다.
|
||||
@@ -43,8 +43,8 @@ function toReq(input: CardInput): ReqCreateCard {
|
||||
usage_type: input.usageType,
|
||||
name: input.title,
|
||||
number: input.code,
|
||||
script: serializeToText(input.editorScript), // 평문 미리보기({변수} 토큰 포함)
|
||||
edit_script: input.editorScript, // Slate JSON 원본
|
||||
script: serializeToMarker(input.editorScript), // 마커 문자열(굵게·색 인코딩 + {변수} 토큰)
|
||||
edit_script: input.editorScript, // Slate JSON 원본(재편집 전용)
|
||||
status: toCardStatusCode(input.status),
|
||||
condition: input.isWildcard ? input.triggerCondition : undefined,
|
||||
memo: input.isWildcard ? input.memo : undefined,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Typography } from '@/components/ui/typography';
|
||||
import { StatusPill, sessionStatusTone } from './StatusPill';
|
||||
import { type Product, type Partner, sessionStatusLabel } from '../../types';
|
||||
import { maskPrices } from '@/lib/utils';
|
||||
import { renderEmphasis } from '@/lib/emphasis';
|
||||
|
||||
export function ChatTab({
|
||||
serverSessions,
|
||||
@@ -158,7 +159,7 @@ function BotBubble({
|
||||
)}
|
||||
{m.script && (
|
||||
<Typography as="p" variant="small" className="text-xs whitespace-pre-line leading-relaxed text-inherit">
|
||||
{maskPrices(m.script)}
|
||||
{renderEmphasis(maskPrices(m.script))}
|
||||
</Typography>
|
||||
)}
|
||||
<UsedCardBox
|
||||
|
||||
Reference in new issue
Block a user