Skip to content

Commit cf8b0d5

Browse files
committed
fix(ava,ava-react): ntv text phrase support start space of line
1 parent 0103292 commit cf8b0d5

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

packages/ava-react/src/NarrativeTextVis/styled/paragraph.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { TextParagraphSpec } from '@antv/ava';
66
import type { ThemeStylesProps } from '../types';
77

88
export const P = styled.p<ThemeStylesProps & Pick<TextParagraphSpec, 'indents'>>`
9+
white-space: pre-wrap; // 默认 pre 显示,可以显示空格和转义字符
910
font-family: PingFangSC, sans-serif;
1011
color: ${({ theme }) => getThemeColor('colorBase', theme)};
1112
font-size: ${({ size }) => getFontSize(size)};

packages/ava/src/ntv/schema/phrase.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type TextPhraseSpec = CommonProps & {
2222
/**
2323
* escape character 支持转义字符
2424
*/
25+
// @deprecated 通过 white-space: pre; 可以让普通文本也具有转义字符大部分效果,之后版本可以考虑去掉
2526
export type EscapePhraseSpec = CommonProps & {
2627
type: 'escape';
2728
value: string;

playground/src/DevPlayground/NTV/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,15 @@ const App = () => {
348348
phrases: [
349349
{
350350
type: 'text',
351-
value: '在 text 中的转义字符字符 \r\n 无效,后面是 escape 类型短语,换行:',
351+
value: '通过 escape 类型短语换行:',
352352
},
353353
{
354354
type: 'escape',
355355
value: '\n',
356356
},
357357
{
358358
type: 'text',
359-
value: '回车',
359+
value: '回车',
360360
},
361361
{
362362
type: 'escape',

site/examples/ntv/basic/demo/extra-phrases.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ const spec: NarrativeTextSpec = {
1717
phrases: [
1818
{
1919
type: 'text',
20-
value: '在 text 中的转义字符字符 \r\n 无效,后面是 escape 类型短语,换行:',
20+
value: '通过 escape 类型短语换行:',
2121
},
2222
{
2323
type: 'escape',
2424
value: '\n',
2525
},
2626
{
2727
type: 'text',
28-
value: '回车',
28+
value: '回车',
2929
},
3030
{
3131
type: 'escape',

0 commit comments

Comments
 (0)