797b20979d
承运商 HTML 按收货市下发;textarea 回车在 C 端转成换行。含门店去掉分享按钮与小程序企微客服。 Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
758 B
TypeScript
23 lines
758 B
TypeScript
import { RichText, Text } from '@tarojs/components';
|
||
import { deliveryHintHtmlToRichNodes } from '@dukang/shared-types';
|
||
import { DEFAULT_LOCAL_DELIVERY_HINT } from '../lib/local-delivery';
|
||
|
||
type DeliveryHintHtmlProps = {
|
||
html?: string | null;
|
||
className?: string;
|
||
};
|
||
|
||
/** 承运商配送提示:HTML 用 RichText;textarea 里的换行转成 br */
|
||
export default function DeliveryHintHtml({
|
||
html,
|
||
className = '',
|
||
}: DeliveryHintHtmlProps) {
|
||
const raw = (html || '').trim() || DEFAULT_LOCAL_DELIVERY_HINT;
|
||
const nodes = deliveryHintHtmlToRichNodes(raw);
|
||
const looksHtml = /<[a-z][\s\S]*>/i.test(nodes);
|
||
if (!looksHtml) {
|
||
return <Text className={className}>{nodes}</Text>;
|
||
}
|
||
return <RichText className={className} nodes={nodes} />;
|
||
}
|